Class BlazeMeterEngine

  • All Implemented Interfaces:
    us.abstracta.jmeter.javadsl.core.DslJmeterEngine

    public class BlazeMeterEngine
    extends BaseRemoteEngine<BlazeMeterClient,​BlazeMeterTestPlanStats>
    A DslJmeterEngine which allows running DslTestPlan in BlazeMeter.

    Note: the engine always returns 0 as sentBytes statistics, since there is no efficient way to get it from BlazeMeter.

    Since:
    0.2
    • Constructor Detail

      • BlazeMeterEngine

        public BlazeMeterEngine​(String authToken)
        Parameters:
        authToken - is the authentication token to be used to access BlazeMeter API.

        It follows the following format: <Key ID>:<Key Secret>.

        Check BlazeMeter API keys for instructions on how to generate them.

    • Method Detail

      • testName

        public BlazeMeterEngine testName​(String testName)
        Sets the name of the BlazeMeter test to use.

        BlazeMeterEngine will search for a test with the given name in the given project (Check projectId(long)) and if one exists, it will update it and use it to run the provided test plan. If a test with the given name does not exist, then it will create a new one to run the given test plan.

        When not specified, the test name defaults to "jmeter-java-dsl".

        Parameters:
        testName - specifies the name of the test to update or create in BlazeMeter.
        Returns:
        the engine for further configuration or usage.
      • projectId

        public BlazeMeterEngine projectId​(long projectId)
        Specifies the ID of the BlazeMeter project where to run the test.

        You can get the ID of the project by selecting a given project in BlazeMeter and getting the number right after "/projects" in the URL.

        When no project ID is specified, then the default one for the user (associated to the given authentication token) is used.

        Parameters:
        projectId - is the ID of the project to be used to run the test.
        Returns:
        the engine for further configuration or usage.
      • testTimeout

        public BlazeMeterEngine testTimeout​(Duration testTimeout)
        Specifies a timeout for the entire test execution.

        If the timeout is reached then the test run will throw a TimeoutException.

        It is strongly advised to set this timeout properly in each run, according to the expected test execution time plus some additional margin (to consider for additional delays in BlazeMeter test setup and teardown).

        This timeout exists to avoid any potential problem with BlazeMeter execution not detected by the client, and avoid keeping the test indefinitely running until is interrupted by a user. This is specially annoying when running tests in automated fashion, for example in CI/CD.

        When not specified, the default timeout will is set to 1 hour.

        Parameters:
        testTimeout - to be used as time limit for test execution. If execution takes more than this, then a TimeoutException will be thrown by the engine.
        Returns:
        the engine for further configuration or usage.
      • availableDataTimeout

        public BlazeMeterEngine availableDataTimeout​(Duration availableDataTimeout)
        Specifies a timeout for waiting for test data (metrics) to be available in BlazeMeter.

        After a test is marked as ENDED in BlazeMeter, it may take a few seconds for the associated final metrics to be available. In some cases, the test is marked as ENDED by BlazeMeter, but the data is never available. This usually happens when there is some problem running the test (for example some internal problem with BlazeMeter engine, some missing jmeter plugin, or some other jmeter error). This timeout makes sure that tests properly fail (throwing a TimeoutException) when they are marked as ENDED and no data is available after the given timeout, and avoids unnecessary wait for test execution timeout.

        Usually this timeout should not be necessary to change, but the API provides such method in case you need to tune such setting.

        When not specified, this value will default to 30 seconds.

        Parameters:
        availableDataTimeout - to wait for available data after a test ends, before throwing a TimeoutException.
        Returns:
        the engine for further configuration or usage.
      • totalUsers

        public BlazeMeterEngine totalUsers​(int totalUsers)
        Specifies the number of virtual users to use when running the test.

        This value overwrites any value specified in JMeter test plans thread groups.

        When no configuration is given for totalUsers, rampUpFor, iterations or holdFor, then configuration will be taken from the first default thread group found in the test plan. Otherwise, when no totalUsers is specified, 1 total user for will be used.

        Parameters:
        totalUsers - number of virtual users to run the test with.
        Returns:
        the engine for further configuration or usage.
      • rampUpFor

        public BlazeMeterEngine rampUpFor​(Duration rampUp)
        Sets the duration of time taken to start the specified total users.

        For example if totalUsers is set to 10, rampUp is 1 minute and holdFor is 10 minutes, it means that it will take 1 minute to start the 10 users (starting them in a linear fashion: 1 user every 6 seconds), and then continue executing the test with the 10 users for 10 additional minutes.

        This value overwrites any value specified in JMeter test plans thread groups.

        Take into consideration that BlazeMeter does not support specifying this value in units more granular than minutes, so, if you use a finer grain duration, it will be rounded up to minutes (eg: if you specify 61 seconds, this will be translated into 2 minutes).

        When no configuration is given for totalUsers, rampUpFor, iterations or holdFor, then configuration will be taken from the first default thread group found in the test plan. Otherwise, when no ramp up is specified, 0 ramp up will be used.

        Parameters:
        rampUp - duration that BlazeMeter will take to spin up all the virtual users.
        Returns:
        the engine for further configuration or usage.
      • iterations

        public BlazeMeterEngine iterations​(int iterations)
        Specifies the number of iterations each virtual user will execute.

        If both iterations and holdFor are specified, then iterations are ignored and only holdFor is taken into consideration.

        When neither iterations and holdFor are specified, then the last test run configuration is used, or the criteria specified in the JMeter test plan if no previous test run exists.

        When no configuration is given for totalUsers, rampUpFor, iterations or holdFor, then configuration will be taken from the first default thread group found in the test plan. Otherwise, when no iterations are specified, infinite iterations will be used.

        Parameters:
        iterations - for each virtual users to execute.
        Returns:
        the engine for further configuration or usage.
      • holdFor

        public BlazeMeterEngine holdFor​(Duration holdFor)
        Specifies the duration of time to keep the virtual users running, after the rampUp period.

        If both iterations and holdFor are specified, then iterations are ignored and only holdFor is taken into consideration.

        When neither iterations and holdFor are specified, then the last test run configuration is used, or the criteria specified in the JMeter test plan if no previous test run exists.

        Take into consideration that BlazeMeter does not support specifying this value in units more granular than minutes, so, if you use a finer grain duration, it will be rounded up to minutes (eg: if you specify 61 seconds, this will be translated into 2 minutes).

        When no configuration is given for totalUsers, rampUpFor, iterations or holdFor, then configuration will be taken from the first default thread group found in the test plan. Otherwise, when no hold for or iterations are specified, 10 seconds hold for will be used.

        Parameters:
        holdFor - duration to keep virtual users running after the rampUp period.
        Returns:
        the engine for further configuration or usage.
      • threadsPerEngine

        public BlazeMeterEngine threadsPerEngine​(int threadsPerEngine)
        Specifies the number of threads/virtual users to use per BlazeMeter engine (host or container).

        It is always important to use as less resources (which reduces costs) as possible to generate the required load for the test. Too few resources might lead to misguiding results, since the instances/engines running might be saturating and not properly imposing the expected load upon the system under test. Too many resources might lead to unnecessary expenses (wasted money).

        This setting, in conjunction with totalUsers, determines the number of engines BlazeMeter will use to run the test. For example, if you specify totalUsers to 500 and 100 threadsPerEngine, then 5 engines will be used to run the test.

        It is important to set this value appropriately, since different test plans may impose different load in BlazeMeter engines. This in turns ends up defining different limit of number of virtual users per engine that a test run requires to properly measure the performance of the system under test. This process is usually referred as "calibration" and you can read more about it here.

        When not specified, the value of the last test run will be used, or the default one for your BlazeMeter billing plan if no previous test run exists.

        Parameters:
        threadsPerEngine - the number of threads/virtual users to execute per BlazeMeter engine.
        Returns:
        the engine for further configuration or usage.
      • assets

        public BlazeMeterEngine assets​(File... files)
        Allows specifying asset files that need to be uploaded to BlazeMeter for proper test plan execution.

        Take into consideration that JMeter DSL will automatically upload files used by DslCsvDataSet, DslHttpSampler.bodyFile(String) and DslHttpSampler.bodyFilePart(String, String, ContentType). So, use this method for any additional files that your test plan requires and is not one used in previously mentioned scenarios.

        Parameters:
        files - specifies files to upload to BlazeMeter.
        Returns:
        the engine for further configuration or usage.
        Since:
        1.11
      • location

        public BlazeMeterEngine location​(BlazeMeterLocation location,
                                         int weight)
        Allows specifying BlazeMeter locations where the test plan will run.

        This method allows to use one of the known public locations (from BlazeMeterLocation}. If you need to use a private location use location(String, int).

        Use this method multiple times to specify several locations to generate load from multiple locations in parallel.

        E.g:

        
          testPlan(
            ...
          ).runIn(new BlazeMeterEngine(bzToken)
          // this scenario will run 50% of the users in GCP us-east1 and the rest in us-west1
              .location(BlazeMeterLocation.GCP_US_EAST_1, 0.5)
              .location(BlazeMeterLocation.GCP_US_WEST_1, 0.5)
          );
         

        When no location is specified, then the default one will be used.

        Parameters:
        location - specifies a location where to run test plans.
        weight - specifies the weight of this location over others. For instance, if you have two locations one with weight 1 and the other 2, then the first one will get 1/(2+1)=33% of totalUsers and the other will get the rest of the users. In general is easier to think in terms of percentages, for example for the same sample set 33 and 67 as weights.
        Returns:
        the engine for further configuration or usage.
        Since:
        1.11
      • location

        public BlazeMeterEngine location​(String location,
                                         int weight)
        Same as location(BlazeMeterLocation, int) but allowing to use any location id (not just public ones).
        Parameters:
        location - specifies the location id or name (eg:
        harbor-5b0323b3c648be3b4c7b23c8
        or
        My Location
        ).
        weight - specifies the weight of this location over others. For instance, if you have two locations one with weight 1 and the other 2, then the first one will get 1/(2+1)=33% of totalUsers and the other will get the rest of the users. In general is easier to think in terms of percentages, for example for the same sample set 33 and 67 as weights.
        Returns:
        the engine for further configuration or usage.
        Since:
        1.11
        See Also:
        location(BlazeMeterLocation, int)
      • useDebugRun

        public BlazeMeterEngine useDebugRun()
        Specifies that the test run will use BlazeMeter debug run feature, not consuming credits but limited up to 10 threads and 5 minutes or 100 iterations.
        Returns:
        the engine for further configuration or usage.
      • useDebugRun

        public BlazeMeterEngine useDebugRun​(boolean enable)
        Same as useDebugRun() but allowing to enable or disable the settign.

        This is helpful when the resolution is taken at runtime.

        Parameters:
        enable - specifies to enable or disable the setting. By default, it is set to false.
        Returns:
        the engine for further configuration or usage.
        Since:
        1.0
        See Also:
        useDebugRun()