Share via


Create a load test in an Azure Load Testing resource

A test specifies the test script, and configuration settings for running a load test. You can create one or more tests in an Azure Load Testing resource.

The configuration of a load test consists of:

In Azure Load Testing, the load test creation and the file uploads are decoupled, i.e., they are separate API operations. The section shows the steps involved in creating a load test.

  1. Obtain the endpoint or data plane URI for the Azure Load Testing resource as mentioned here.

  2. Create a new test

    PATCH https://{Endpoint}/tests/{testId}?api-version=2022-11-01
    

    For a client making a request with this signature, the Load Test Administration - Create Or Update Test operation will be executed.

    A successful response for a request made using this signature will be similar to the following:

    {
      "description": "sample description",
      "displayName": "Performance_LoadTest",
      "loadTestConfiguration": {
        "engineInstances": 6,
        "splitAllCSVs": true
      },
      "passFailCriteria": {
        "passFailMetrics": {
          "fefd759d-7fe8-4f83-8b6d-aeebe0f491fe": {
            "clientMetric": "response_time_ms",
            "aggregate": "percentage",
            "condition": ">",
            "value": 20,
            "action": "continue"
          }
        }
      },
      "secrets": {
        "secret1": {
          "value": "https://samplevault.vault.azure.net/secrets/samplesecret/f113f91fd4c44a368049849c164db827",
          "type": "AKV_SECRET_URI"
        }
      },
      "environmentVariables": {
        "envvar1": "sampletext"
      },
      "subnetId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/Microsoft.Network/virtualNetworks/samplenetworkresource/subnets/AAAAA0A0A0",
      "keyvaultReferenceIdentityType": "UserAssigned",
      "keyvaultReferenceIdentityId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/sampleprovider/sampleresourcetype/sampleresourcename"
    }
    

    This updates the test details like test name, description, secrets, environment variables, number of engines and pass/fail criteria.

  3. Upload files to the test created

    PUT https://{Endpoint}/tests/{testId}/files/{fileName}?api-version=2022-11-01
    

    or

    PUT https://{Endpoint}/tests/{testId}/files/{fileName}?fileType={fileType}&api-version=2022-11-01
    

    For a client making a request with this signature, the Load Test Administration - Upload Test File operation will be executed.

    Note

    Each PUT call supports only 1 file to be uploaded. If multiple files are uploaded in the same call, all files apart from the first are discarded. Depending upon the requirement, the you might need to make multiple calls, one for each, i.e. JMX script, ZIP file, CSV file, user.properties, etc.

    The uploaded JMX file is validated if it adheres to XML norms and if it is a valid JMeter script. The validationStatus field shows the status of the validation. If JMeter is able to accept the JMX script without any errors, it is considered “VALIDATION_SUCCESS” and the file is successfully associated with the load test. All subsequent test runs will use this file.

    A successful response for a request made using this signature will be similar to the following:

        {
      "url": "https://dummyurl.com/testscriptresource",
      "fileName": "sample.jmx",
      "fileType": "ADDITIONAL_ARTIFACTS",
      "expireDateTime": "2021-12-05T16:43:46.072Z",
      "validationStatus": "VALIDATION_SUCCESS"
    }
    
  4. Configure App Components on the test for monitoring server side metrics using the following steps.

    PATCH https://{Endpoint}/tests/{testId}/app-components?api-version=2022-11-01
    

    For a client making a request with this signature, the Load Test Administration - Create Or Update App Components operation will be executed. The request body should contain either a testId or a testRunId.

    A successful response for a request made using this signature will be similar to the following:

        {
      "testId": "12345678-1234-1234-1234-123456789012",
      "components": {
        "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource": {
          "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource",
          "resourceType": "microsoft.insights/components",
          "resourceName": "appcomponentresource",
          "displayName": "Performance_LoadTest_Insights",
          "resourceGroup": "samplerg",
          "subscriptionId": "00000000-0000-0000-0000-000000000000",
          "kind": "web"
        }
      },
      "createdDateTime": "2021-12-05T16:43:46.072Z",
      "createdBy": "user@contoso.com",
      "lastModifiedDateTime": "2021-12-05T16:43:46.072Z",
      "lastModifiedBy": "user@contoso.com"
    }