Apama Helper Classes for PySys

So that you can easily create tests for your Apama applications, Apama distributes a copy of the open-source “PySys” system testing framework.

We also provide some additional classes that use the functionality provided by PySys to make it easy to work with Apama correlators, IAF adapters, Ant builds, Apama project directories and (Linux-only) Docker containers.

Getting Started

When creating a PySys test project for use with Apama we recommend using apama.basetest.ApamaBaseTest as the base for all your test classes, and configuring your project to use the apama.runner.ApamaRunner (or your own subclass of it). If you use the apama project template this will be automatically configured for you:

mkdir tests
cd tests
pysys makeproject --template=apama

Now create your first testcase:

pysys make MyApplication_001

This will create a MyApplication_001 subdirectory with a pysystest.xml file holding metadata about the test such as its title, and a run.py where you can add the logic to execute your test, and to validate that the results are as expected.

Edit the generated run.py and use the apama.correlator.CorrelatorHelper Apama class to start the correlator and inject your application into it.

For validate, you will want to make use of standard PySys methods such as waitForGrep and assertGrep to validate the expected the correlator log messages, and apama.plugins.ApamaPlugin.extractEventLoggerOutput() if you need to check the events sent by your application. You can read more about the available PySys methods in the pysys.basetest documentation.

A set of sample PySys testcases for Apama can be found in the samples/pysys directory of your Apama installation.

To run your test, use pysys run:

pysys run 1

When using the Apama extensions you can automatically generate an HTML code coverage report for your EPL application using the -Xeplcoverage option; for more information see apama.runner.ApamaRunner.