Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
print("\n["+self.clusterName+"] Running workspace start test "+str(self.cycles + 1)+" of "+str(self.cyclesMax)+"\n")
self.log("Checking if there are some removing pods before creating and running new workspace.")
self.waitUntilDeletingIsDone()
self.id = self.createWorkspace()
self.wait()
self._reset_timer()
self.startWorkspace()
self.wait()
self.waitForWorkspaceToStart()
self._reset_timer()
self.stopWorkspaceSelf()
self.waitForWorkspaceToStopSelf()
self.wait()
self.deleteWorkspaceSelf()
if (self.cycles == (self.cyclesMax - 1)):
raise StopLocust("Tests finished, unable to set Locust to run set number of times (https://github.com/locustio/locust/pull/656), issuing hard-stop.")
self.cycles += 1
def on_start(self):
print("Opening websocket connection from user [" + self.uuid + "].")
try:
self.locust.client.connect(self.uuid, self.uri)
except:
raise StopLocust("Failed to connect to master")
def __check_limits(self):
if self.locust_start_time is None:
self.locust_start_time = time.time()
# Only raise an exception if the actual test is running
if self.locust_stop_time is None:
if time.time() - self.locust_start_time >= self.locust_duration:
raise StopLocust('Duration limit reached')
if self.num_requests <= 0:
raise StopLocust('Request limit reached')
def __check_limits(self):
if self.locust_start_time is None:
self.locust_start_time = time.time()
# Only raise an exception if the actual test is running
if self.locust_stop_time is None:
if time.time() - self.locust_start_time >= self.locust_duration:
raise StopLocust('Duration limit reached')
if self.num_requests <= 0:
raise StopLocust('Request limit reached')
:param func: callable to be timed and logged
:return result: Result of the provided function if doesn't raise exception
"""
try:
start_time = time.time()
result = func(*args, **kwargs)
except Exception as event_exception:
total_time = int((time.time() - start_time) * 1000)
events.request_failure.fire(
request_type=request_type,
name=name,
response_time=total_time,
response_length=0,
exception=event_exception
)
raise StopLocust()
else:
total_time = int((time.time() - start_time) * 1000)
events.request_success.fire(
request_type=request_type,
name=name,
response_time=total_time,
response_length=0
)
return result