REST Tester Lua Service
Introduction
The RestTestLuaService is a service for initiating Lua scripts running within the LogicApp.
The RestTestLuaService receives messages from one or more instances of the RestServerApp which is configured to receive REST/HTTP(S) Requests from an external client.
The RestTestLuaService communicates with the RestServerApp using the REST-S-… messages.
The RestTestLuaService differs from the standard RestLuaService in three important factors:
Firstly: The REST Test request is asynchronous, there is one REST query to start a test run, and REST query to poll for completion. Compare with RestLuaService where the REST request waits synchronously for the Lua script to determine the final result.
Secondly: The REST request supplies the Lua content as the body of the POST request.
Compare to RestLuaService which supplies only the script name, and it is the job of
the service to find the Lua from disk or via SQL query.
Thirdly: A single REST request can cause the execution of multiple Lua instances within a test run. Compare with RestLuaService where a one REST request/response maps to exactly one Lua instance.
Configuring RestTestLuaService
The RestTestLuaService is configured within a LogicApp.
<?xml version="1.0" encoding="utf-8"?>
<n2svcd>
...
<applications>
...
<application name="Logic" module="LogicApp">
<include>
<lib>../apps/logic/lib</lib>
</include>
<parameters>
...
</parameters>
<config>
<services>
<service module="RestServerApp::RestTestLuaService" libs="../apps/rest_s/lib"/>
</services>
<agents>
...
</agents>
</config>
</application>
...
</application>
...
</n2svcd>
In addition to the Common LogicApp Service Configuration, note the following specific attribute notes, and service-specific attributes.
Under normal installation, the following service
attributes apply:
Parameter Name | Type | XML Type | Description |
---|---|---|---|
module
|
String | Attribute |
[Required] The module name containing the Lua Service code: RestServerApp::RestTestLuaService
|
libs
|
String | Attribute |
Location of the module for RestTestLuaService.(Default: ../apps/rest_s/lib )
|
Script Selection (REST Request)
Script selection is not applicable. The REST request supplies the complete Lua script.
Script Global Variables
Scripts run with this service have access to the Common LUA Service Global Variables.
In addition, the following globals will be set where applicable:
Variable | Type | Description |
---|---|---|
TEST_NAME
|
String |
The test name is optionally supplied by the client requesting the test to run. When tests are executed using lua_test this will contain the script filename (excluding path and suffix).
|
TEST_PATH
|
String |
The test path is optionally supplied by the client requesting the test to run. When tests are executed using lua_test this will contain the script path (if known).
|
MULTI
|
Integer |
This global is present with value = 1 when n2svcd is run in multi-process mode.
|
SKIP_MATCH
|
Boolean |
This global is present with value = false for the first instance in a test run.This global is present with value = true for the second and subsequent instances in a test run.
|
Script Entry Parameters (REST Request)
A test script running within the REST TEST Lua Service has access first to the standard REST Server Script Entry Parameters.
In addition, a script running via the lua_test command line, and/or via the IN Tester GUI using the StartRun REST API method may be provided with a “variables” table which will be provided via the second chunk argument.
I.e. the Lua service method will have the following two arguments:
local args, variables = ...
Script Return Parameters (REST Response)
The script return parameters are ignored.
The RestLuaService response method is not available.
REST Request Paths
The behavior of the RestTestLuaService is determined by the trailing path in the URI, being
the part from the last /
in the URI.
Refer to the separate documentation for each of the supported paths.
The RestTestLuaService API
A test script running under the REST TEST Lua Service will typically use the LogicApp Lua Agents to perform testing, e.g. initiating TCAP transactions for MAP/INAP, creating SIP Transactions, Diameter client, REST client requests, etc.
In addition, the following API methods are specific to Test Run scripts via the REST Test Service API.
local rts = require "n2.n2svcd.rest_test_service"
The following REST Test Service helper methods are provided: