Class AzureEngine

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

    public class AzureEngine
    extends BaseRemoteEngine<AzureClient,​AzureTestPlanStats>
    A DslJmeterEngine which allows running DslTestPlan in Azure Load Testing.

    To use this engine you need:

    • To create a test resource and resource group in Azure Load Testing. First defined test resource for the subscription, is used by default.
    • Register an application in Azure with proper permissions for Azure Load Testing with an associated secret. Check here for more details.
    Since:
    1.10
    • Constructor Detail

      • AzureEngine

        public AzureEngine​(String credentials)
        Builds a new AzureEngine from a given string containing tenant id, client id and client secrets separated by colons.

        This is just a handy way to specify credentials in a string (eg: environment variable) and easily create an Azure Engine. For a more explicit way you may use AzureEngine(String, String, String).

        Parameters:
        credentials - contains tenant id, client id and client secrets separated by colons. Eg: myTenantId:myClientId:mySecret.

        Check the Azure guide for instructions on how to register an application with proper access.

        Tip: there is no need to specify a redirect uri.

        The tenantId can easily be retrieved getting subscription info in Azure Portal.

      • AzureEngine

        public AzureEngine​(String tenantId,
                           String clientId,
                           String clientSecret)
        This is a more explicit way to create AzureEngine than AzureEngine(String).

        This is usually preferred when you already have each credential value separated, as is more explicit and doesn't require encoding into a string.

        Parameters:
        tenantId - is the tenant id for your subscription. This can easily be retrieved getting subscription info in Azure Portal
        clientId - this is the id associated to the test that needs to run in Azure. You should use one application for each JMeter DSL project that uses Azure Load Testing. This can be retrieved when register an application following steps detailed in this Azure guide.
        clientSecret - this is a client secret generated for the test to be run in Azure.
    • Method Detail

      • subscriptionId

        public AzureEngine subscriptionId​(String subscriptionId)
        Allows specifying the Azure subscription ID to run the tests on.

        By default, AzureEngine will use any subscription associated to the given tenant. In most of the scenarios, when you only use one subscription, this behavior is good. But, when you have multiple subscriptions, it is necessary to specify which subscription from the available ones you want to use. This method is for those scenarios.

        Parameters:
        subscriptionId - specifies the Azure subscription identifier to use while running tests. When not specified, any subscription associated to the tenant will be used.
        Returns:
        the engine for further configuration or usage.
      • resourceGroupName

        public AzureEngine resourceGroupName​(String resourceGroupName)
        Specifies the name the resource group where tests will be created or updated.

        You can use Azure resource groups to group different test resources (projects, systems under test) shared by members of a team.

        If a resource group exists with the given name, then that group will be used. Otherwise, a new one will be created. You can use location(String) to specify the location where the resource group will be created (by default, the first available one will be used, eg: eastus).

        Parameters:
        resourceGroupName - specifies the name of the resource group to use. If no name is specified, then the test resource name (testResourceName(String)) plus "-rg" suffix is used. Eg: jmeter-java-dsl-rg.
        Returns:
        the engine for further configuration or usage.
      • location

        public AzureEngine location​(String location)
        Specifies the location where to create new resource groups.
        Parameters:
        location - the Azure location to use when creating new resource groups. If none is specified, then the first available location will be used (eg: eastus).
        Returns:
        the engine for further configuration or usage.
        See Also:
        resourceGroupName(String)
      • testResourceName

        public AzureEngine testResourceName​(String testResourceName)
        Specifies the name of the test resource where tests will be created or updated.

        You can use Azure test resources to group different tests resources belonging to the same project or system under test.

        If a test resource exists with the given name, then that test resources will be used. Otherwise, a new one will be created.

        Parameters:
        testResourceName - specifies the name of the test resource. If no name is specified, then the test name (testName(String)) is used.
        Returns:
        the engine for further configuration or usage.
      • testName

        public AzureEngine testName​(String testName)
        Specifies the name of the test to be created or updated.

        If a test with the given name exists, then the test is updated. Otherwise, a new one is created.

        Parameters:
        testName - specifies the name of the test to create or update. If no name is specified, then jmeter-java-dsl is used by default.
        Returns:
        the engine for further configuration or usage.
      • testRunName

        public AzureEngine testRunName​(String testRunName)
        Allows to specify the name for the individual test run.

        This is helpful, for example, if you want to add info to correlate to other entities like CI/CD job id, product version, git tag, etc.

        Parameters:
        testRunName - specifies the name to be used in the test run. By default, TestRun_<YYYY-MM-DD_HH:MM:SS> is used.
        Returns:
        the engine for further configuration or usage.
        Since:
        1.18
      • testTimeout

        public AzureEngine testTimeout​(Duration duration)
        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:
        duration - 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.
      • engines

        public AzureEngine engines​(int count)
        Specifies the number of JMeter engine instances where the test plan should run.

        This value directly impact the generated load. For example: if your test plan defines to use a thread group with 100 users, then using 3 engines will result in 300 parallel users. Azure Load Testing simply runs the test plan in as many engines specified by this value.

        Parameters:
        count - specifies the number of JMeter engine instances to run the test plan on. When not specified it just runs the test plan in 1 engine.
        Returns:
        the engine for further configuration or usage.
      • assets

        public AzureEngine assets​(File... files)
        Allows specifying asset files that need to be uploaded to Azure Load Testing 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.18
      • splitCsvsBetweenEngines

        public AzureEngine splitCsvsBetweenEngines​(boolean enabled)
        Allow to enable/disable splitting provided CSV files between test engines.

        Enabling the split allows to use a separate set of records in each engine.

        Parameters:
        enabled - specifies to split or not CSV files between engines. By default, it is set to false.
        Returns:
        the engine for further configuration or usage.
        Since:
        1.18
      • monitoredResources

        public AzureEngine monitoredResources​(String... resourceIds)
        Allows registering application components to monitor and collect statistics alongside the test collected statistics.

        This is useful to get a full view of test execution results and analyze how the test affects the service under test components.

        Parameters:
        resourceIds - specifies the Azure resources ids of each of the application components to collect metrics from. To get the ids you can navigate in Azure portal to the resource and copy part of the URL from the browser. For example a resource id for a container app looks like
        /subscriptions/my-subscription-id/resourceGroups/my-resource-group/providers/Microsoft.App/containerapps/my-papp
        .
        Returns:
        the engine for further configuration or usage.
        Since:
        1.18
      • buildTree

        protected org.apache.jorphan.collections.HashTree buildTree​(us.abstracta.jmeter.javadsl.core.DslTestPlan testPlan,
                                                                    us.abstracta.jmeter.javadsl.core.BuildTreeContext context)
        Overrides:
        buildTree in class BaseRemoteEngine<AzureClient,​AzureTestPlanStats>