How to use the locust.exception.StopLocust function in locust

To help you get started, we’ve selected a few locust examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github redhat-developer / che-functional-tests / che-start-workspace / osioperf.py View on Github external
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
github redhat-developer / rh-che / load-tests / simple.py View on Github external
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")
github Blazemeter / taurus / bzt / resources / locustio-taurus-wrapper.py View on Github external
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')
github Blazemeter / taurus / bzt / resources / locustio-taurus-wrapper.py View on Github external
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')
github nickboucart / realbrowserlocusts / realbrowserlocusts / core.py View on Github external
: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