6.2. Integrated Test Script Runner

The integrated "Test Script Runner" (TSR) was created to automate test sequences on one or more RCE standalone installations. These installations are automatically set up using an RCE feature called "Instance Management" (IM), which is still under development, and therefore not fully documented yet. However, the instructions below should be sufficient to configure this feature as needed for the TSR.

As of RCE 9.0.0, the Test Script Runner is included in the standard application release, as well as the standard Eclipse checkout. Therefore, very little configuration is required to use it.

6.2.1. Configuration

The only configuration that is required for using the TSR is adding an Instance Management configuration to the RCE instance that will execute the test scripts. This defines the root directory where work files and directories of managed RCE test installations will be stored. Locate the profile directory that is being launched and edit its configuration.json file. In this file, add this configuration block on the root JSON level, and adjust the settings as necessary:

"instanceManagement": {
  "dataRootDirectory": "C:\\MyWorkdir\\rce-im-dat",
  "installationsRootDirectory": "C:\\MyWorkdir\\rce-im-inst"
}

There are additional Instance Management configuration parameters available. These are, however not usually needed for using the TSR.

Note

It is strongly recommended to use a short full filesystem path as the dataRootDirectory and the installationsRootDirectory, as RCE installations will be placed inside of it, and long filesystem paths are known to cause problems with these. The maximum lenght will be determined, documented, and maybe also automatically checked in the future.

6.2.2. Test Definitions

We use the language Gherkin, a structured natural language, to define our tests and execute them using Cucumber. In the nomenclature of Gherkin, a single test is called a scenario, while multiple scenarios make up a feature. The tests are defined in *.feature files in the directory /de.rcenvironment.supplemental.testscriptrunner.scripts/resources/scripts.

Note

If you would like to edit .feature-files directly from Eclipse, we recommend using the Cucumber Eclipse Plugin, which can be found in the Eclipse Marketplace.

We show one test (or scenario) below:

@Start01
@DefaultTestSuite
Scenario: Concurrent headless instance starting and stopping

  Given instances "Node1, Node2, Node3, Node4, Node5" using the default build
  When  starting all instances concurrently
  Then  instances "Node1, Node2, Node3, Node4, Node5" should be running
  
  When  stopping all instances concurrently
  Then  the log output of all instances should indicate a clean shutdown with no warnings or errors

Each test has one or more test IDs denoted by the annotation-like tags above the indivual test scenarios, e.g. @Start01 or @DefaultTestSuite. These IDs serve to later refer to that test for execution. The same ID may also be assigned to multiple tests. Thus, the test script runner can, e.g., be asked to execute all tests with a test ID of DefaultTestSuite. The values of the test IDs can be chosen almost arbitrarily. The only reserved IDs are @Disabled and @disabled, which prevent the test from being executed at all.

In order to execute a test written in Gherkin, Cucumber requires an implementation of each individual line in the test. Each line is called a test step, while the code implementing the desired behavior is called a test step definition. In RCE, the test step definitions are location in the bundle de.rcenvironment.supplemental.testscriptrunner in the package de.rcenvironment.extras.testscriptrunner.definitions.impl. Please refer to those implementations for the canonical overview over available test steps. In the following, we list some of the more commonly used test steps. We denote placeholders using angular brackets.

Given running instance <instance id> using the default build

Starts an instance of RCE without a GUI. The instance id is used to refer to this instance in later test steps.

When executing workflow <workflow id> on node <instance id>

Executes the given workflow on the given instance and waits for the termination of that workflow. The workflow id must correspond to the basename of a workflow file in the directory de.rcenvironment.supplemental.testscriptrunner.scripts/resources/scripts/workflows, i.e., the file name without the suffix .wf.

Then that workflow run should be identical to <golden master id>

Can only be used after using the test step "When executing workflow <workflow id> on node <instance id>". Asserts that the workflow execution is identical to that stored in the directory de.rcenvironment.supplemental.testscriptrunner.scripts/resources/scripts/golden_masters. The golden master id must correspond to the basename of a file in that directory, i.e., to the file name without the suffix .json. You can export a workflow execution to serve as a golden master via the command tc export_wf_run in a running RCE instance.

6.2.3. Executing Tests

The TSR is invoked by a single RCE console command (run-test), with an alias for readability (run-tests). The general syntax is:

run-test[s] [--format pretty|json] <comma-separated list of test ids>|--all <build id>

By default, the result of the test is printed in human-readable format. If you would like output in the JSON-format instead, you may use the option --format, which requires either pretty or json as its only parameter.

There are three typical scenarios for calling this command:

  • from within an RCE instance launched from Eclipse during development, usually using the GUI workflow console

  • from within a standalone RCE instance, also usually using the GUI workflow console

  • as a CLI batch run (rce --batch "...") using a standalone instance.

The RCE installation to be tested is defined by the <build id> parameter in the above command. One important aspect to understand is that this installation is generally independent of the installation being used to execute the TSR command. The latter is, in a sense, only the "host" of test scripts. There are three ways of specifying the build to test:

  1. A build download id, which corresponds to a certain part of the standard download URL, for example snapshots/trunk or releases/9.0.0. The structure should be self-explanatory. (The major release tree to use for snapshot builds is one of the optional Instance Management settings mentioned above; the default is to use the current major version, ie 9.x.)

  2. A path to an unpacked local standalone (product) build, which can, for example, result from a local build run or from unpacking a downloaded product zip file. The syntax for this is local:<local installation path>. This directory can be either writable or read-only. For example, it is also possible to test a (read-only) .deb or .rpm package installation this way.

    Note that this path must point to an already-unpacked RCE build, unlike the first approach, which downloads zipped release packages and unpacks them automatically.

  3. As it is a frequent use case when testing standalone builds to execute the test command the installation itself, there is a convenient shortcut for this. By specifying :self as the build id, the test scripts are executed on the installation of the instance used to run the test command.

    Note that due to technical limitations, however, this shortcut is not possible when launching RCE from Eclipse, as the test scripts require a standard product build to execute.

Recall that each test has one or more test ids, denoted by annotation-like tags. These test ids can be specified in the command run-test[s] with or without the @ character. "--all" executes all available test scenarios.

6.2.4. Examples

  • run-test Test02,Test04 snapshots/trunk - runs two specific tests on the latest snapshot build

  • run-test --format pretty Test02,Test04 snapshots/trunk - equivalent to the command above

  • run-test --format json Test02,Test04 snapshots/trunk - runs two specific tests on the latest snapshot build and outputs the result in JSON format

  • run-test DefaultTestSuite :self - runs the default collection of tests on the current installation

  • run-test --all local:/tmp/local-rce-build - runs all available tests on a local build

  • rce --batch "run-test DefaultTestSuite :self" - the full command line for the standard self-test of an installation