Skyramp Test

Performance Testing

Performance Testing

Introduction

With Skyramp’s tester_start_v1 function’s loadtest_config options, it is easy to change any test to a performance test.

loadtest_config Options

  1. target_rps: desired requests per second to be generated.

  2. at_once: number of concurrent requests to be made.

  3. rampup_interval: interval after which to increase current rps.

  4. rampup_duration: time over which to scale to target_rps starting from 0 rps.

  5. stop_on_failure: boolean to control whether the test continues in the event of a failure or stops.

  6. duration: how long to run the test.

  7. count: set number of requests to generate before stopping.

Example

#Define scenarios
def add_artists_functional_scenario():
    scenario = skyramp.Scenario(
        "artists_functional_scenario",
        ignore=False,
        vars_={"token":"_token"}
    )
    # Endpoint /v1/artists and Method POST
    scenario.add_request_v1(
        request=artists_POST_request,
        step_name="artists_functional_scenario-0",
        vars_override={},
        description="Endpoint /v1/artists and Method POST"
    )
    # Assert of scenario step artists_functional_scenario-0 - Endpoint /v1/artists and Method POST
    scenario.add_assert_v1(
        assert_value="requests.artists_POST.code",
        assert_expected_value="201", 
        assert_step_name="artists_functional_scenario-1",
        description="Assert of scenario step artists_functional_scenario-0 - Endpoint /v1/artists and Method POST"
    )
    return scenario
    
def get_test_scenarios():
    scenario = skyramp.Scenario(
        "artists_full_scenario",
        ignore=True,
        vars_={"token":"globalVars.token"},
        headers={"X-API-Key":"vars.token"}
    )
    artists_functional_scenario = add_artists_functional_scenario()
    scenario.add_scenario_v1(
        artists_functional_scenario,
        step_name="artists_full_scenario-0" ,
        description="functional scenario of /v1/artists" ,
        vars_override={"token":"vars.token"}
    )
    return scenario
    
def execute_tests(
    address="localhost:35142",
    override_code_path=None,
    global_vars={"token":"defaultValue"},
    **kwargs
):
    docker_client = skyramp.DockerClient()
    scenarios = get_test_scenarios()
    status = docker_client.tester_start_v1(
        scenario=scenarios,
        test_name="artists test",
        address=address,
        blocked=True,
        global_vars=global_vars,
        override_code_path=override_code_path, 
        skip_verify=kwargs.get("skip_verify", False),
        blobs=kwargs.get("blobs", {}), 
        loadtest_config=skyramp.LoadTestConfig(
        target_rps=1000,
        at_once=2,
        duration=10s,
        rampup_interval=1s,
        rampup_duration=5s,
        stop_on_failure=True)
    )
    return status

In this example:

  • We specify that we want to scale to 1000 requests per second hitting /artists to create new artists.

  • With two requests hitting the endpoint concurrently.

  • The test will last 10 seconds. Alternatively, we could have specified a maximum number of requests to be generated and send before stopping the test via count.

  • Starting from 0 requests per second every second the worker will increase the rate by 200 requests per second to ramp up to 1000 requests per second within 5 seconds.

  • If a request fails at any point we will stop the test.

© 2024 Skyramp, Inc. All rights reserved.

© 2024 Skyramp, Inc. All rights reserved.

© 2024 Skyramp, Inc. All rights reserved.