Services Subsystem

When you need to perform some actions before test starts, after test starts, or in parallel with running test, you should use services subsystem in Taurus. To configure services, use services top-level section of config with list of service module configs:

Services are configured with services toplevel section. services section contains a list of services to run:

---
services:
- module: shellexec:
  post-process: ...
- module: monitoring
  server-agent:
  - address: 127.0.0.1:4444
    metrics:
    - cpu
    - disks
    - memory

Taurus provides the following services:

  • passfail allows you to set test status based on runtime criteria
  • shellexec used to execute additional shell commands when test is executed
  • monitoring allows including monitoring data in test reports
  • chrome-profiler allows to extract performance metrics from Chrome running Selenium tests

Pass/Fail Service

Pass/Fail Service is used to dynamically update test status based on some runtime criteria. For example, you can use it to automatically fail the test when response time exceeds some limit. Here's a sample:

---
services:
- module: passfail
  criteria:
  - avg-rt of IndexPage>150ms for 10s, stop as failed
  - fail of CheckoutPage>50% for 10s, stop as failed

You can learn more about Pass/Fail Service at its page.

Shell Executor Service Module

Shell executor is used to perform additional shell commands at various test execution phases. Taurus provides hooks to all Taurus test execution phases.

Sample configuration:

---
services:
- module: shellexec
  prepare:  
  - mkdir /tmp/test
  startup:
  - echo 'started' >> /tmp/test/log
  shutdown:
  - echo 'shutdown' >> /tmp/test/log 
  post-process:
  - rm /tmp/test/log
execution:
- scenario: tg1
  hold-for: 10s
scenarios:
  tg1:
    requests:
    - label: HTTP Request
      method: GET
      url: http://127.0.0.1/

Learn more about shellexec service here.

Resource Monitoring Service

It may be useful to attach monitoring data from both servers and load generators in the test report for further analysis. You can achieve that with monitoring service. Here's a quick example.

services:
- module: monitoring
  server-agent:  # collect data from remote server which has ServerAgent running
  - address: 192.168.1.3:4444
    metrics:
    - cpu
    - disks
    - memory

You can learn more about Monitoring Service at its page

Chrome Profiler Service

This service allows you to extract frontend performance stats from Chrome.

It calculates the following metrics:

  • page load metrics (time to 'load' event, time to full page load, etc)
  • network metrics (page footprint, time to first byte, number of HTTP requests, etc)
  • memory metrics (how much memory was consumed by browser, tab, JavaScript engine)
  • JavaScript CPU utilization
  • all HTTP requests that were made by browser tab
  • all AJAX requests
  • JavaScript functions that browser spent most of the time executing

Service also comes with a reporter (named chrome-metric-reporter) that will print performance metrics extracted from Chrome to terminal at the end of the test.

You can learn more about chrome-profiler service at its own page.

Unpacker

You can ask Taurus to unzip some of your files into artifacts directory before test starts (only zip format is supported). It's easy with unpacker service:

---
services:
- module: unpacker
  files:
  - c:\tmp.zip
  - /home/user/temp.zip

Alternate Provisionings and Services

If you use alternate provisionings, like BlazeMeter Cloud, you might want to specify where to run the service module - at target machine, or on your local machine. For that, use run-at option of service modules. The service will be effective only when its run-at value match to provisioning value. On the cloud images, provisioning always has value of local. Default value for run-at of services is also local.

Required Tools Installer

There is small service which helps to check for all possible tools presence on the machine. It is called install-checker service. This service, once present in config, will check for all possible tools to be installed on the computer. After that, it will shutdown Taurus without running anything else.

To invoke this service, just run Taurus like this bzt -install-tools.