Testing
September 29, 2020 ยท View on GitHub
Note: Build the toolkit prior testing, run ant in repository root directory
Note: Some "distributed" tests require consistent region be configured: Configuring a checkpoint data store
Note: Python 2.7 is no longer supported with v1.14 and later.
Note: Python 3.6 is required
See end of document for tests run to verify a release.
test/java
Some of the JUnit tests include Python application API and decorator operator tests (e.g. test packages with python, splpy).
Ant targets:
unittest.quick- Runsunittest.mainandunittest.standaloneunittest.main- Runs Java application api tests usingEMBEDDED_TESTERcontextunittest.standalone- Runs Java application api tests usingSTANDALONE_TESTERcontextunittest.distributed- Runs Java application api tests usingDISTRIBUTED_TESTERcontext. Streams instance must be started prior the test.unittest.streaminganalytics- Runs Java application api tests using theSTREAMING_ANALYTICS_SERVICEcontext. Streaming Analytics service must be started prior the test.unittest.streaminganalytics.remote- Runs Java application api tests using theSTREAMING_ANALYTICS_SERVICEcontext and performs builds remotely. Streaming Analytics service must be started prior the test.unittest.restapi- Runs the Java rest tests using theDISTRIBUTEDcontext (requiresSTREAMS_REST_URLenvironment variable) and theSTREAMING_ANALYTICS_SERVICEcontext (requiresSTREAMING_ANALYTICS_SERVICE_NAMEandVCAP_SERVICESenvironment variables). Streaming Analytics service must be started prior the test.
Changing Streams install or toolkit release
By default the tests run against:
- Streams release at $STREAMS_INSTALL
- including compiling the underlying SPL applications
- running or submitting the bundles
- Toolkit at
streamsx.topology/com.ibm.streamsx.topology
The version of Streams used to compile the applications can be
set by using the topology.install.compile ant property.
cd test/java
ant unittest.distributed -Dtopology.install.compile=/opt/ibm/InfoSphere_Streams/4.3.0.0
The release of the toolkit used can be specified using topology.toolkit.release ant property.
cd test/java
ant unittest.distributed -Dtopology.toolkit.release=$HOME/testtk/com.ibm.streamsx.topology
Running selected Java test classes
The tests can be specified using topology.test.base.pattern ant property.
Run using EMBEDDED_TESTER context:
cd test/java
ant unittest.main -Dtopology.test.base.pattern='**/SimpleEmbeddedTest.java'
Run using STANDALONE_TESTER context:
cd test/java
ant unittest.standalone -Dtopology.test.base.pattern='**/FileStreamsTest.java'
Run using DISTRIBUTED_TESTER context:
cd test/java
ant unittest.distributed -Dtopology.test.base.pattern='**/PublishSubscribeTest.java'
test/python
Ant targets:
test- Runs Python tests calling the targetstest.application.apiandtest.translationtest.application.api- Runs Python topology API tests (all unittests intest/python/topology)test.distributed- Runs some TestDistributed* tests using Streams instancetest.sas- Runs some TestSas* tests using Streaming Analytics Servicetest.translation- Runs translation tests (globalization support)
Most testing is performed using Python unittest.
test/python/topology- Python topology tests (application API).- Any test starting with
test2uses the testing capability supported by the toolkit. - Most
test2tests have three classes running the same test in standalone, distributed and streaming analytics service. Typically the base class is the standalone tests, then subclasses exist for distributed and streaming analytics. test2standalone tests are skipped if environment variableSTREAMS_INSTALLis not set.test2distributed tests are skipped if any of the environment variablesSTREAMS_INSTALL,STREAMS_DOMAIN_IDorSTREAMS_INSTANCE_IDis not set is not set.test2streaming analytics tests are skipped if environment variableVCAP_SERVICESis not set.
- Any test starting with
test/rest- Python Streams REST API tests.
These tests can be run directly using Python, e.g.
cd test/python/topology
# Run all test2 tests
python3 -u -m unittest test2*.py
# Run all tests in test2_spl.py
python3 -u -m unittest test2_spl
# Run a single class from a test file
# e.g. run only distributed tests for test2_spl
python3 -u -m unittest test2_spl.TestDistributedSPL
# Run a single test
python3 -u -m unittest test2_spl.TestDistributedSPL.test_SPLBeaconFilter
Naming pattern for Python test classes:
- TestXyz - Tests Xyz using standalone or a test that does not require a Streams application (e.g. api testing)
- TestDistributedXyz - Tests Xyz using distributed
- TestSasXyz - Tests Xyz using Streaming Analytics service
Running selected Python test
Test is performed with streamsx in the repository.
cd test/python
ant test.single -Dtopology.unittest.name='test2_pkg.TestPackages.test_TopologySymlinkFile'
Running Python distributed test
Test is performed with streamsx in the repository.
cd test/python
ant test.distributed
Python test2_scikit.py requires scikit-learn installed:
pip install scikit-learn
cd test/python/topology
python3 -u -m unittest test2_scikit.TestScikit.test_scikit_learn
Quick test set for a release
Tests assume setup is correct for running distributed.
Java
Embedded and standalone tests only:
cd test/java
ant unittest.quick
Python
Distributed tests only (Streams instance must be started prio the test):
cd test/python
ant test.distributed
Perform quick tests on release package
To create a release package and perform a quick test (python rest test, distributed only) on this package, run the following:
cd test/release
ant
Perform Java Topology quick test with release from Maven Central
To perform a quick test (download topology.jar from Maven and build bundle from Java Topology app), run the following and set the TOPOLOGY_VERSION to the version to be downloaded from Maven central:
export TOPOLOGY_VERSION=<tested version, for example 1.16.3>
cd test/release
ant mvntest
Full test set for a release
Full set of tests assumes setup is correct for running distributed and Streaming Analytics
test/java
Run these ant targets in test/java
unittest.quickunittest.distributedunittest.restapi
test/spl
Run basic pub-sub in SPL (distributed and Streaming Analytics):
cd test/spl/tests
python3 -u -m unittest discover -v
test/python
Python 3.6
Run python3 -u -m unittest discover -v in each of these directories:
test/python/topologytest/python/spl/teststest/python/scriptstest/python/rest