1111import logging
1212
1313import locust_plugins
14- from common .deploy_auth import MonitoringBasicAuth
14+ from common .deploy_auth import MonitoringBasicAuth , OsparcAuth
1515from locust import events , task
1616from locust .contrib .fasthttp import FastHttpUser
1717
2626_endpoint_holder = {"endpoint" : "/" }
2727
2828
29- def add_endpoint_argument (parser ):
29+ def add_endpoint_argument (parser ) -> None :
3030 parser .add_argument (
3131 "--endpoint" ,
3232 type = str ,
@@ -42,7 +42,7 @@ def _(parser):
4242
4343
4444@events .init .add_listener
45- def _ (environment , ** _kwargs ):
45+ def _ (environment , ** _kwargs ) -> None :
4646 _endpoint_holder ["endpoint" ] = environment .parsed_options .endpoint
4747 logging .info ("Testing endpoint: %s" , _endpoint_holder ["endpoint" ])
4848
@@ -52,7 +52,25 @@ def __init__(self, *args, **kwargs):
5252 super ().__init__ (* args , ** kwargs )
5353 self .auth = MonitoringBasicAuth ().to_auth ()
5454 self .endpoint = _endpoint_holder ["endpoint" ]
55+ self .osparc_auth = OsparcAuth ()
56+ self .requires_login = False
5557
5658 @task
57- def get_endpoint (self ):
59+ def get_endpoint (self ) -> None :
5860 self .client .get (self .endpoint , auth = self .auth )
61+
62+ def _login (self ) -> None :
63+ # Implement login logic here
64+ logging .info ("Logging in user with email: %s" , self .osparc_auth )
65+
66+ def _logout (self ) -> None :
67+ # Implement logout logic here
68+ logging .info ("Logging out user with email: %s" , self .osparc_auth )
69+
70+ def on_start (self ) -> None :
71+ if self .requires_login :
72+ self ._login ()
73+
74+ def on_stop (self ) -> None :
75+ if self .requires_login :
76+ self ._logout ()
0 commit comments