Skip to content

RequestAge script skeleton

Marko Topolnik edited this page Aug 9, 2017 · 2 revisions

RequestAge test scripts are written in embedded JavaScript with custom functionality added on top of the Mozilla Rhino engine. There are three callback functions which form the backbone of a script's interaction with the testing runtime:

function conf(b) { ... }

function init() { ... }

function test() { ... }

The most important function is test(), the only one which is repeatedly called during the testing session.

conf(b)

conf(b) is called first; its main purpose is to configure the AsyncHttpClient by calling methods on the supplied configuration builder b. The builder object is a wrapper around the Java class com.ning.http.client.AsyncHttpClientConfig.Builder, with just one convenience method added: proxy(), which accepts a simple string in the form of host:port, as opposed to the native setProxyServer, which requires the construction of a ProxyServer instance.

init()

This function is called after the HTTP client is ready. Its purpose is to set up the environment common to all executions of the test() method. It may execute any introductory HTTP requests which are not a part of the stress testing scenario, but whose results are needed as prerequisites to the main requests. The requests are made synchronously.

test()

This function is called repeatedly, at the rate selected by the throttle slider. It will be executed on a thread pool so it must be thread-safe. The global scope is frozen at this point and any assignment to global variables will fail. The user is responsible to ensure that any objects used by this function are thread-safe. The HTTP requests are made asynchronously, so if the code asks to execute two or more requests in sequence, all requests will be sent to the server immediately, without waiting for response. Responses must be handled via callback functions.

Clone this wiki locally