aws-solutions/distributed-load-testing-on-aws

How to Update and Run Now An Existing Test Through API endpoints?

Closed this issue · 4 comments

Reading the documentation API it don't have an endpoint to update an existing Test or an option to run it now, if I understand correctly I can only create and schedule it.

For example, if I want to update the number of tasks, I could use the endpoint to update it or run it now:

response = requests.request(
    'PUT',
    'https://<foo>.execute-api.us-east-2.amazonaws.com/prod/scenarios/<bar>',
    data={
        'taskCount': 5
    },
    headers=dict(request.headers),
    timeout=10
)

Or just run it now:

response = requests.request(
    'GET',
    'https://<foo>.execute-api.us-east-2.amazonaws.com/prod/scenarios/<bar>',
    data={
        'action': 'run'
    },
    headers=dict(request.headers),
    timeout=10
)

The 'GET' operation on '/scenarios/' endpoint cancel the Test, I don't know, really confusing this approach.

My intention is to use this AWS solution to integrate with our CICD Pipeline to run the load tests and fail depending of the results.

You can use POST api but specify testId in the payload and it works as update.
Example of a sample payload

{
    "testId": "fhjOdqegK5",
    "testName": "dasda",
    "testDescription": "ada",
    "testTaskConfigs": [
        {
            "concurrency": "1",
            "taskCount": "1",
            "region": "us-west-2"
        }
    ],
    "testScenario": {
        "execution": [
            {
                "ramp-up": "0m",
                "hold-for": "1m",
                "scenario": "dasda"
            }
        ],
        "scenarios": {
            "dasda": {
                "requests": [
                    {
                        "url": "http://localhost:3000/create",
                        "method": "GET",
                        "body": {},
                        "headers": {}
                    }
                ]
            }
        }
    },
    "showLive": false,
    "testType": "simple",
    "fileType": "",
    "regionalTaskDetails": {
        "us-west-2": {
            "vCPULimit": 4000,
            "vCPUsPerTask": 2,
            "vCPUsInUse": 0,
            "dltTaskLimit": 2000,
            "dltAvailableTasks": 2000
        }
    }
}

@danilo-lopes I changed the title and the label so when others have the same question they could find it here easily

With this example payload I was able to update or run the Load Test immediately:

{
        'testId': dictionary['testId'],
        'testName': dictionary['testName'],
        'testDescription': dictionary['testDescription'],
        'showLive': dictionary['showLive'],
        'testType': dictionary['testType'],
        'fileType': dictionary['fileType'],
        'testTaskConfigs': [
            {
                'region': dictionary['testTaskConfigs'][0]['region'],
                'taskCount': None,
                'concurrency': None,
            }
        ],
        'testScenario': {
            'execution': [
                {
                    'ramp-up': None,
                    'hold-for': None,
                    'scenario': f'{project_id}.jmx',
                    'taskCount': None,
                    'concurrency': None
                }
            ]
        },
        'regionalTaskDetails': {
            dictionary['testTaskConfigs'][0]['region']: {
                'vCPULimit': 4000,
                'vCPUsPerTask': 2,
                'vCPUsInUse': 0,
                'dltTaskLimit': 2000,
                'dltAvailableTasks': 2000
            }
        },
    }

I think these are the basic necessary fields the API is waiting.

I think we can close this