Templates

The templating logic is based on the same JSON Editor that has full semantic and syntax check so that it’s as easy as possible to define a template case through the Dashboard page.

This means that besides the saving and uploading data from your local system, you also have the possibility of:

  • saving your work remotely as a template

  • loading your work from a template

Templates can be used by any editor to launch tests.

Permissions

Member role vs API call

List templates

Add template

Get template details

Remove template

Reader

True

False

True

False

Editor

True

True

True

True

Admin

True

True

True

True

Owner

True

True

True

True

Template properties

Template properties are exactly the same as the Test Properties mentioned in the Tests page.

List templates

Web

In order to view the templates on our platform, all you have to do is browse to the Templates page.

API call

The API call is:

curl -s \
    -d '{"team_id":"my-team"}' \
    -H "X-Api-Key: my_api_key" \
    -X POST \
    https://api.rungutan.com/v1/api/templates/list | jq . -r

{
  "Tests": [
    {
        "template_id": "my_template_id",
        "domain_name": "my-team.com",
        "threads_per_region": 2,
        "num_clients": 30,
        "hatch_rate": 30,
        "created_date": "2020-03-26T09:08:15Z",
        "run_time": "30s",
        "member_email": "[email protected]",
        "test_region": "ap-southeast-1,ap-southeast-2"
    },
    {
        "template_id": "my_template_id_2",
        "domain_name": "my-team.com",
        "threads_per_region": 5,
        "num_clients": 60,
        "hatch_rate": 20,
        "created_date": "2020-03-29T10:12:34Z",
        "run_time": "60s",
        "member_email": "[email protected]",
        "test_region": "us-east-1,us-east-2"
    }
}

You can also filter based on template_id to generate the summary for only that specific template_id:

curl -s \
    -d '{"team_id":"my-team", "template_id": "my_template_id"}' \
    -H "X-Api-Key: my_api_key" \
    -X POST \
    https://api.rungutan.com/v1/api/templates/list | jq . -r

{
  "Templates": [
    {
        "template_id": "my_template_id",
        "domain_name": "my-team.com",
        "threads_per_region": 2,
        "num_clients": 30,
        "hatch_rate": 30,
        "created_date": "2020-03-26T09:08:15Z",
        "run_time": "30s",
        "member_email": "[email protected]",
        "test_region": "ap-southeast-1,ap-southeast-2"
    }
}

CLI

List all templates:

$ rungutan templates list
{
    "Tests": [
        {
            "template_id": "ad837abd-15d4-47ce-a344-01a3323bdd09",
            "test_name": "test name",
            "domain_name": "rungutan.com",
            "threads_per_region": 1,
            "num_clients": 30,
            "hatch_rate": 30,
            "created_date": "2020-05-19T12:04:42Z",
            "run_time": 30,
            "member_email": "[email protected]",
            "test_region": "us-east-1"
        },
        {
            "test_id": "15fa78b9-097b-401a-bedb-a70ddc4726ed",
            "test_name": "Sample worklfow test",
            "domain_name": "rungutan.com",
            "threads_per_region": 1,
            "num_clients": 30,
            "hatch_rate": 30,
            "created_date": "2020-05-19T11:56:19Z",
            "run_time": 30,
            "member_email": "[email protected]",
            "test_region": "us-east-1"
        }
    ]
}

Filter based on template_id:

$ rungutan templates list --template_id ad837abd-15d4-47ce-a344-01a3323bdd09
{
    "Templates": [
        {
            "test_id": "ad837abd-15d4-47ce-a344-01a3323bdd09",
            "test_name": "test name",
            "domain_name": "rungutan.com",
            "threads_per_region": 1,
            "num_clients": 30,
            "hatch_rate": 30,
            "created_date": "2020-05-19T12:04:42Z",
            "run_time": 30,
            "member_email": "[email protected]",
            "test_region": "us-east-1"
        }
    ]
}

Add template

Web

In order to save a new template, all you have to do is browse to the Dashboard page and click on the SAVE as template button.

API call

The API call is:

curl -s \
    -d '{
        "team_id": "my-team",
        "num_clients": 30,
        "hatch_rate": 30,
        "run_time": 30,
        "threads_per_region": 1,
        "domain_name": "my-team.com",
        "protocol": "https",
        "min_wait": 1000,
        "max_wait": 1000,
        "test_region": [
            "us-east-1"
        ],
        "workflow": [
            {
                "path": "/",
                "method": "GET",
                "data": "",
                "headers": {}
            }
        ]}' \
    -H "X-Api-Key: my_api_key" \
    -X POST \
    https://api.rungutan.com/v1/api/templates/add | jq . -r

{
    "template_id": "some_template_id",
    "message": "Successfully created new template"
}

CLI

Start the test in the background:

$ rungutan templates add --test_file test_file.json
{
    "test_id": "fff6580d-999b-4ce5-8e1b-b14eb66f42be",
    "test_name": "test from cli",
    "message": "Successfully created new template"
}

Get template details

Web

In order to get the details of a template, all you have to do is browse to the Dashboard page and click on the LOAD from template button for the respective test.

API call

The API call is:

curl -s \
    -d '{
        "template_id": "some_template_id",
        "team_id": "my-team"
        }' \
    -H "X-Api-Key: my_api_key" \
    -X POST \
    https://api.rungutan.com/v1/api/templates/get | jq . -r

{
    "TestData": {
        "num_clients": 30,
        "hatch_rate": 30,
        "run_time": 30,
        "threads_per_region": 1,
        "workflow": [
            {
                "path": "/",
                "method": "GET",
                "data": "",
                "headers": {}
            }
        ],
        "domain_name": "my-team.com",
        "protocol": "https",
        "test_region": [
            "us-east-1"
        ],
        "min_wait": 1000,
        "max_wait": 1000
      }
}

CLI

This is how you run the CLI:

$ rungutan templates get --template_id 61c8bc4b-e1b1-4fb5-bb24-d860bf79e460
{
    "TestData": {
        "num_clients": 1,
        "hatch_rate": 1,
        "run_time": 5,
        "threads_per_region": 1,
        "workflow": [
            {
                "path": "/",
                "method": "GET",
                "data": "",
                "headers": {}
            }
        ],
        "domain_name": "rungutan.com",
        "protocol": "https",
        "test_region": [
            "us-east-1"
        ],
        "min_wait": 1000,
        "max_wait": 1000
    }
}

And this is how you get the TestData and save it to a file for later use:

$ rungutan templates get --template_id 61c8bc4b-e1b1-4fb5-bb24-d860bf79e460 | jq -r .TestData > file.json
$ cat file.json
{
  "num_clients": 1,
  "hatch_rate": 1,
  "run_time": 5,
  "threads_per_region": 1,
  "workflow": [
    {
      "path": "/",
      "method": "GET",
      "data": "",
      "headers": {}
    }
  ],
  "domain_name": "rungutan.com",
  "protocol": "https",
  "test_region": [
    "us-east-1"
  ],
  "min_wait": 1000,
  "max_wait": 1000
}

Remove template

Web

In order to remove a template, all you have to do is browse to the Templates page and click remove domain button.

API call

The API call is:

curl -s \
    -d '{
        "template_id": "some_template_id",
        "team_id": "my-team"
        }' \
    -H "X-Api-Key: my_api_key" \
    -X POST \
    https://api.rungutan.com/v1/api/templates/remove | jq . -r

{
    "message": "Successfully deleted template"
}

CLI

Remove the template using the CLI:

$ rungutan templates remove --template_id fff6580d-999b-4ce5-8e1b-b14eb66f42be
{
    "message": "Successfully deleted template"
}