DRAFT
This page summarizes points to consider when adding or revisiting tests for some feature or functionality. Tests should be omitted only if there are certain reasons for not implementing tests of some kind.
The framework provides an ability to write a test-case once and run it in multiple Ignite and Cache configurations.
Test class has to extend IgniteConfigVariationsAbstractTest
or IgniteCacheConfigVariationsAbstractTest
.
TestSuite has to be built using ConfigVariationsTestSuiteBuilder
.
As an example see IgniteCacheBasicConfigVariationsFullApiTestSuite
.
Examples:
The following code will test SomeFunctionalityTest
with basic set of IgniteConfiguration
variations (BinaryMarshaller
/ OptimizedMarshaller
and enabled / disabled per class loading), will be used Ignite cluster with 3 nodes, the second started node is client (client with idx=1
), each test-method will be run with testedGrid=0
and testedGrid=1
(see testedGrid()
method) .
TestSuite suite = new ConfigVariationsTestSuiteBuilder( "Basic Ignite Configuration Variations Some Functionality Test Suite", SomeFunctionalityTest.class) .gridsCount(3) .testedNodesCount(2).withClients() .build();
The following code will test SomeCacheFunctionalityTest
with basic set of IgniteConfiguration
variations (see above) and basic set of CacheConfiguration
variations (different cache modes, atomicity modes and memory modes), Ignite cluster with 5 nodes will be used, the second started node is client (with nodeIdx=1
) and the third started node is client with near-only cache (with nodeIdx=2
), each test-method will be run with testedGrid=0,1 and 2
(see testedGrid() and
methods) .jcache()
TestSuite suite = new ConfigVariationsTestSuiteBuilder( "Basic Cache Configuration Variations Some Cache Functionality Test Suite", SomeCacheFunctionalityTest.class) .withBasicCacheParams() .gridsCount(5).backups(1) .testedNodesCount(3).withClients() .build();
IgniteConfigVariationsAbstractTest has methods key(int i)
and value(int i)
. To run a test scenario in all supported by the framework data modes (Serializable
, Externaliazable
, plane, mixed and etc. objects), it's enough to write test scenario using these methods to generate different keys and values and to place test scenario inside runInAllDataModes(TestRunnable runnable)
method.
For example, the following code test cache's put-get scenario in all supported by the framework data modes:
public void testPutGet() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { IgniteCache cache = jcache(); Object key = key(1); Object val = value(1); cache.put(key, val); assertEquals(val, cache.get(key)); } }); }
The main idea of Configuration Variations framework is a using of a matrix of possible variants of configuration properties.
Lets imagine there's a need to look over all possible variations of IgniteConfiguration
where marshaller property can be BinaryMarshaller
/ OptimizedMarshaller
and perClassLoadingEnabled
can be true
/ false.
So, there's the following matrix:
IgniteConfiguration Property | Variant 1 | Variant 2 |
---|---|---|
marshaller | BinaryMarshaller |
|
peerClassLoadingEnabled | true | false |
The framework has VariationsIterator
which will produce the following 4 variation vectors for the matrix above:
BinaryMarshaller
and perClassLoadingEnabled
flag to true.
OptimizedMarshaller
and perClassLoadingEnabled
flag to true.
BinaryMarshaller
and perClassLoadingEnabled
flag to false
.OptimizedMarshaller
and perClassLoadingEnabled
flag to false
.The following methods should be used to provide custom matrixes:
ConfigVariationsTestSuiteBuilder.igniteParams(ConfigParameter<IgniteConfiguration>[][] igniteParams)
ConfigVariationsTestSuiteBuilder.cacheParams(ConfigParameter<CacheConfiguration>[][] cacheParams)
ConfigVariations
- contains ready to use configuration parameters matrixes.
Parameters
- contains util methods to build parameters matrixes.
ConfigVariationsTestSuiteBuilder
also provides possibility to filter Ignite and Cache configurations. See withIgniteConfigFilters(IgnitePredicate<IgniteConfiguration>... filters) and withCacheConfigFilters(IgnitePredicate<CacheConfiguration>... filters) methods.
There is a plane to have Full API test coverage of Ignite functionality. See: - IGNITE-2521Getting issue details... STATUS .
The purpose of this ticket is to make sure that all ignite operations should work for any configuration properties combination.