Level: INTERMEDIATE
Here at Apama we are very strong believers in automated testing - we rely on it every day and put lots of effort into it for the production of the Apama products.
We also strongly believe that customer and community solutions based on Apama should have that same opportunity.
Thankfully, due to the conceptual model of Apama makes automated testing of solutions and sub-modules of solutions very logical. Remember, we’ve already said that we have deterministic shared-nothing autonomous agents (monitors), and talked about events-in and events-out. This means that we can quite simply inject an EPL module (defining the patterns and business logic to be tested) into a correlator, attach a receiver to capture emitted events, and then send in predefined events. Of course, we’d also capture all logging output. Now, you could battle through this with any kind of scripting technology, but we recognized a long time ago that this was a strong pattern and decided to provide a test framework to make all of that much easier and more repeatable.
" PySys " is a wonderful free Open Source project from the community, written in Python, for the purpose of generic System testing, and which is easily extensible. As we said, PySys is completely generic/neutral - it is not related to Apama technology in any way.
- PySys GitHub project: GitHub - pysys-test/pysys-test: PySys System Test Framework
- PySys Documentation: Welcome to PySys! — PySys v2.1 documentation
The key point however is the extensibility of PySys, and for Apama we provide PySys extensions/helpers that specialize its capabilities to make testing Apama solutions even easier. So, instead of using PySys to launch a generic OS process that happens to be a correlator, instead, with our extensions, you ask PySys to simply launch a correlator.
The following article is a little old now but gives you the general idea to get you started:
(Note that the article refers to PySys 1.x and PySys 2.0 was recently released in August 2021, but many of the concepts still apply. One big difference is a simplification in test creation/definition in the newer version - changelog.)
The 10.11 version of Apama shipped in October 2021, and now includes this new PySys v2.0, and our example tests that also ship with the product have also been updated.
- Documentation (v10.11) for Testing Apama Applications using PySys
- API docs (v10.11) for Apama Helper Classes for PySys
A set of sample PySys testcases for Apama can be found in the samples/pysys
directory of your Apama installation.
Lastly, we should also briefly mention our code coverage analysis tooling. This means that when your CI/CD pipelines that are driving PySys test suites to exercise your EPL solutions are executed, you can get automated coverage reports simply by passing one extra flag when starting PySys. The tool can create reports in HTML, CSV, and a popular XML format that is common for coverage tools for other languages and can be read by various 3rd-party utilities.
- Documentation (v10.11) for Generating code coverage information about EPL files (softwareag.com)
This is Day #9 of a short series of brief tips, tricks, hints, and reminders of information relating to the Apama Streaming Analytics platform, both from Software AG as well as from the community.
This series of articles will be published Monday-Friday only, with the occasional weekend bonus.