Configuration file

gkostov edited this page Jan 10, 2013 · 26 revisions

It needs to be in JSON format and can be named anything though ending the name with .conf.json is usually most informative. Every option has a default value that the server can use and can be omitted so the file needs to only specify those which need to be customized.

Accepted configuration options

  • server
    • protocol String (default: 'http') - if set to "https" the server will run using TLS/SSL [not inplemented yet]
    • host String / null (default: 'localhost') - the host to bind the server to. If set to null the server will listen on all available adapters.
    • port Number (default: 80) - the port to bind to.
    • SocketIO
      • logLevel Number (default: 0) - the logging level that Socket.IO will use.
    • browserDriverUrl String (default:'localhost/BrowserDriver.html') - the location of the BrowserDriver.html file if using browsers as slaves ( for where to put the file check the slaves page )
    • otherUrlMappings Object (default:{}) - mappings for other paths on the server in the form "relative_fs_path_to_the_config_file":"url_on_the_server". For example:
{
    "html":"/manager/tests/html", // maps the "html" folder in the same folder as the configuration file to the "/manager/tests/html" url
    "html/img":"/manager/tests/images" // and the "img" folder inside "html" to "/manager/tests/images"
}
  • slaves Array (default:[]) - a list of slaves which the server will manage. Each item in the array is an object like:
{
    "name":"Chrome.16", // the name to identify the slave. can be any string
    "app":"chromium-browser", // the shell command which starts the slave
    "args":[], // additional arguments to send to the application. the browserDriverUrl with additional url parameters will be appended to this list
}
// or if we'll be using a forked node.js process then like
{
    "name":"Node.js",
    "fork":"%CLIENT_ROOT%/node.js/node-slave.js", // specifies the JS file to use for the forked process
    "args":[], // additional arguments to send
}
  • slaveModules Array (default:[{...}]) - a list of module configurations to load on the slaves. By default it loads the TestManager, configured with the QUnit adaptor:
"slaveModules":[{
    "fileName":"/modules/testManager",
    "adaptor":"/lib/adaptors/qunit"
}]
  • modules Array (default:[{...}]) - a list of module configurations to load on the server. By default it loads the TestManager, configured with the QUnit adaptor:
"modules":[{
    name:'TestManager',
    requirePath:'./testManager',
    adaptor:'../client/lib/adaptors/qunit',
    testsPath:'tests', // path to be searched for *.js files which should have the tests. must be relative to the config file path
    userLibsPath:'lib', // must be relative to the config file path
    testsUrl:'/manager/tests/sources',  // where to map "testsPath" on the web server
    userLibsUrl:'/manager/tests/lib',   // where to map "userLibsPath" on the web server
    autoRunTests:[] // a list of tests to run automatically on startup. Each item in the array is a string in the form `'filename.js'.'moduleName'.'testName'`
}]
  • interactiveMode Boolean (default:false) - when false the server will load tests from autoRunTests and run them in all slaves launching those specified in autoRunSlaves.
  • autoRunSlaves Array (default:[]) - a list of slaves (as configured in slaves to launch automatically if interactiveMode is false.
  • timeout Number (default:0) - timeout in seconds to wait before shutting down the server. This may be useful when running tests automatically to terminate the server if some tests may take too long to complete or just hang.

Example configuration

The package includes an example in the "examples/sampleTestSuite" folder. This is a test suite which contains all needed resources. The configuration file is named testing.conf.json and here are the options that it sets:

{
    "server":{
        "port":8090

The above option directs the server to bind to port 8090. Since the "host" option is not specified the server will default to "localhost" so the BrowserDriver.html that can be used will be available at

        "browserDriverUrl":"http://localhost:8090/BrowserDriver.html",

The tests need some HTML pages to be loaded and those are located in "public_html" so the folder is mapped as

        "otherUrlMappings":{
            "public_html":"/public_html"
        }
    },

and it will be accessible as http://localhost:8090/public_html .

jQueryUI tests need to be executed in two browsers which will be named "Firefox" and "Chrome" so two entries are added for them to the "slaves" list:

    "slaves":[{
        "name":"Firefox",
        "app":"firefox", // in Ubuntu Firefox is started with this command
        "args":[]  // no other options are needed
    },{
        "name":"Chrome",
        "app":"chromium-browser", // in Ubuntu Chrome is started with this command
        "args":[]  // no other options are needed
    },

and non-UI tests shall run in a node.js instance so we also have:

    {
        "name":"Node.js",
        "fork":"%CLIENT_ROOT%/node.js/node-slave.js",   // this will let a forked node.js process be used as a slave 
        "args":[]
    }],

And finally the server is told to start in interactive mode which means it will not do anything on start up and will just wait for commands from the manager application:

    "interactiveMode":true
}