examplecampaign.js

Example Campaign

This is a node module that exports one single object containing the campaign configuration.

The testFunction is a function that accepts one single argument. It defines a single test iteration that is executed by each firtual user. function testFunction (doneCallback) { ... }

The single iteration is considered finished when function calls doneCallback Different iterations share the same scope. The scope contains 3 variables:

  • context (initialized to null)
  • window (the window object)
  • camut (an object containing camut specific options

Also note that this is by default scoped to the window object

Declare the testFunction

function testFunction (doneCallback) {

It is possible to perform initialization tasks by checking scoped variables like context

  if (!context) {
    context = {};
    context.i = 0;
  }

The test function can report statistics directly to the OpenTSDB server using 'camut.tsdb' function directly.

  camut.tsdb ('test.dadeb', context.i++, {
    reqtype: 'valore'
  });

Functions writing to standard output are supported and their output will be logged on the drone. Note that this also means that logging too much data can slow down operations and use a lot of disk space.

  console.log ('ciao');

Once all iteration tasks are completed the function calls doneCallback()

  setTimeout (doneCallback, 1000);
}

The exported object

module.exports = {

Each campaign must have a unique user-assigned id.

  id: "dev_Example",

The user can embed any serializable custom structure of attributes and objects.

  customAttribute: "attribute",

Deployment defines the type of service the deployer engine is going to use to deploy drones for this campaign. Dummy is a simple deployer that only deploys one single drone on the same machine where the server is running. It's used only for test purposes before conducting a real campaign on the cloud.

The only real cloud deployer only supported is 'ec2'.

  deployment: "ec2", /* "dummy" */

AvailabilityZone defines the availability zone where drone instances will be deployed. It's also possible to specify a list of values, i.e.

AvailabilityZone: ['eu-west-1', 'us-east-2']

In this case a number of instances specified by 'drone' parameter will be deployed for each AvailabilityZone

  AvailabilityZone: 'eu-west-1',

simulateBrowser activates browser emulation for each virtual user. This means that window object will contain all attributes a normal browser window object would do. It also includes jquery-1.6.0 automatically. Please note that each virtual browser will use up to 2Mb of ram, meaning this option is not suitable for campaigns simulating many virtual users (high value of parallelism parameter)

  simulateBrowser: false,

monitorProgress specifies that the progress status for each drone will be reported and visualized in the kue web interface

  monitorProgress: true,

duration is the maximum duration of the campaign (seconds). If iterations are not finished in time the campaign will be terminated anyway

  duration: 10, /* 10 seconds */
  

testIterations is the number of iterations that each virtual user will have to complete before finish his job.

  testIterations: 100,

parallelism represents how many virtual users will be simulated for each drone instance.

  parallelism: 10,

drones is the number of drones to be deployed for the campaign for each availability zone

  drones: 2,

rampUpTime is defined as the time the system will take to reach the total number of virtual users (milliseconds). The total number of virtual users is currently equal to

n_users = parallelism * drones * [number of AvailabilityZones]

Users will start one by one separated by

rampUpTime / n_users
  rampUpTime: 5000,

thinkingTime is the time that separates each virtual user test iteration (milliseconds)

  thinkingTime: 1000,

measureTTFB tells if Time To First Byte time should be measured

  measureTTFB: false,

testFunction attribute must contain the serialized version of the test function aforementioned

  testFunction: testFunction.toString ()
};