Upload configuration

Upload test specification

Test specifications can be written and composed from different files. The load configuration call allows you to provision this configuration on each node.
The test specifications are parsed at this point and any error in the syntax will be noted in the response. Validation of the content is done on start_load, to ensure all required phases, scenarios and plugins are defined in the system.

POST /api/megaload/upload_config_file/:familyUUID

Input

HTTP multipart request with Content-Type : application/json

Example

-----------------------------18036622772727284871017578311
Content-Disposition: form-data; name="files[]"; filename="test.json"
Content-Type: application/json

[ {"phase" : {"id" : "phase-1",
              "arrival_rate" : 10,
              "duration" : 30000,
              "concurrent_scenarios" : 10,
              "rate" : 10,
              "scenarios" : [{"main-page" : 1}]
             }
  }
]

-----------------------------18036622772727284871017578311--

Returns

If the test specification is invalid, it returns a 409 response code with an error message explaining the reason.

Example response

Status: 200 OK
{}

Clear test specification

Clear all tests specifications in the system. If a test is running, it will not clear the specification and return and error.

POST /api/megaload/clear_config_file/:familyUUID

Example request

curl http://localhost:8080/api/megaload/clear_config_load/c719a664-83cb-4ab5-b02f-0f91f3e6f512  --data "" --header "Content-Type: application/json"

Example response

Status: 200 OK
{}

Upload additional data

Some tests may require additional information from the user. This information can be provided in the form of CSV files that must be provisioned in the system.

The name to be used in the test must be provided when the file is uploaded through Megaload-UI.

POST /api/megaload/upload_data_file/:familyUUID

Input

HTTP multipart request with Content-Type : application/octet-stream

Example

-----------------------------18036622772727284871017578311
Content-Disposition: form-data; name="files[]"; filename="users.csv"
Content-Type: octet-stream

user1,password1
user2,password2
user3,password3

-----------------------------18036622772727284871017578311--

Example response

Status: 200 OK
{}

Upload actions module

Some tests may require additional actions provided by the user. This is the case of property-based testing where they can define custom generators.

Modules defining actions can be uploaded from this interface. They are compiled in every Megaload node and compilation errors are reported. If a module with the same name exists in core Megaload, this call reports an error. If another action module with the same name was uploaded through this call, it is replaced.

POST /api/megaload/upload_actions_file/:familyUUID

Input

HTTP multipart request with Content-Type : application/octet-stream

Example

-----------------------------18036622772727284871017578311
Content-Disposition: form-data; name="files[]"; filename="ml_integer.erl"
Content-Type: application/octet-stream

-module(ml_integer).
-behaviour(loader_action).

-export([
   validation_spec/1,
   post_validation/1,
   increase/3
  ]).

-record('integer-increase', {value}).

-compile({parse_transform, exprecs}).

-export_records(['integer-increase']).

%%%===================================================================
%%% Configuration callbacks
%%%===================================================================
validation_spec('integer-increase') ->
    [{value, mandatory, integer, false}].

post_validation(_) ->
    fun(V) -> V end.

%%%===================================================================
%%% Plugin actions
%%%===================================================================
-spec increase(#'integer-increase'{}, loader_run:global_test_id(), undefined) ->
      {ok, integer(), undefined}.
increase(#'integer-increase'{value = Value}, GlobalTestId, undefined) ->
    {ok, Value + 1, undefined}.

-----------------------------18036622772727284871017578311--

Returns

If the module exists or is invalid, it returns a 409 response code with an error message explaining the reason.

Example response

Status: 200 OK
{}

Upload property module

POST /api/megaload/upload_property_file/:familyUUID

Input

HTTP multipart request with Content-Type : application/octet-stream

Example

-----------------------------18036622772727284871017578311
Content-Disposition: form-data; name="files[]"; filename="quickcheck_prop.erl"
Content-Type: application/octet-stream

-module(quickcheck_prop).

-include_lib("eqc/include/eqc.hrl").

-compile(export_all).

prop_load() ->
    ?FORALL(Users, eqc_loadtest:linear(10, 100),
        begin
            {ok, ok} = loader:update_phase(<<"phase1">>,
                                           [{<<"concurrent_scenarios">>, Users}]),
            case loader:start_load("test") of
                {ok,ok} ->
                    loader_pbt:wait_until_terminated(),
                    {ok, Requests} = loader:get_counter(
                                           <<"http_counter_totalRequests">>),
                    Requests > 1000;
                Other ->
                    false
                end
        end).

-----------------------------18036622772727284871017578311--

Returns

If the module is invalid, it returns a 409 response code with an error message explaining the reason.

Example response

Status: 200 OK
{}