Testing Apama Applications Using PySys
Developing a comprehensive suite of automated tests is an essential aspect of building reliable applications in any language. So that you can easily create tests for your Apama applications, Apama distributes an open-source automated system-testing framework called PySys.
PySys is an easy-to-use cross-platform framework for writing and orchestrating tests in which a test case consists of a simple Python file that specifies the required logic for starting processes, waiting for the expected events and log messages, and validating the results.
PySys provides a comprehensive library of utility methods to make writing these tests really easy, and has powerful features such as concurrent test-case execution, automatic cleanup of processes and files, collection of code-coverage information, memory monitoring, and reporting of performance statistics. It also provides a pluggable framework for recording test results with built-in support for the widely used Apache Ant JUnit XML output format that is supported by most continuous integration servers.
Apama includes PySys itself, as well as some helper classes for starting Apama processes such as the correlator from PySys. Apama also provides a template that we recommend using to create your project configuration file.
To get started with PySys, proceed as follows:
2. Go to the directory containing your application, create a subdirectory for the tests and change to it.
3. Use the following command to create a default pysysproject.xml configuration file in this directory, using the Apama template:
pysys makeproject --template=apama
4. Create your first test:
pysys make MyApplication_001
5. Edit the MyApplication_001/pysystest.py file, specifying a title describing what the test will do, and optionally starting to implement the execute and validate logic for your new test.
6. Run your first test:
pysys run
A set of sample PySys testcases for Apama can be found in the samples/pysys directory of your Apama installation.
Reference documentation for PySys and the Apama helper classes for PySys can be found in the
API Reference for Python. This is located in the
doc/pydoc directory of your Apama installation.
See
Using EPL code coverage with PySys tests for information on how to enable EPL code coverage reporting for PySys.