Package org.citrusframework.sharding
Class ShardingConfiguration
java.lang.Object
org.citrusframework.sharding.ShardingConfiguration
A configuration class for sharded test loading and execution withing the citrus framework. It uses environment
variables and system properties to configure the sharding behavior.
This class is part of the Citrus framework, designed to streamline the process of sharding test cases for efficient and scalable testing.
Configuration Example:
To configure the sharding behavior, set the following environment variables or system properties:
- Total number of shards:
- Environment Variable:
CITRUS_SHARDING_TOTAL - System Property:
citrus.sharding.total - Description: Specifies the total number of shards into which the test cases will be divided.
- Environment Variable:
- Shard number:
- Environment Variable:
CITRUS_SHARDING_NUMBER - System Property:
citrus.sharding.number - Description: Indicates the specific shard number of the current test loader. This should be a value between 0 and the total number of shards minus one.
- Environment Variable:
- Shard seed:
- Environment Variable:
CITRUS_SHARDING_SEED - System Property:
citrus.sharding.seed - Description: Specifies a seed value used for shuffling test cases within a shard. Providing a consistent seed value ensures the same shuffling order across different executions.
- Environment Variable:
Example Usage:
To configure a system with 4 total shards and assign this instance to shard number 1 (second shard, since numbering starts at 0), set the environment variables or system properties as follows:
-
Set
CITRUS_SHARDING_TOTALorcitrus.sharding.totalto 4. -
Set
CITRUS_SHARDING_NUMBERorcitrus.sharding.numberto 1. -
Optionally, set a seed for shuffling test cases using
CITRUS_SHARDING_SEEDorcitrus.sharding.seed. The total number of shards will be used as see by default.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionDefault sharding configuration which initializes the sharding with system properties and environment variables.ShardingConfiguration(int totalNumberOfShards, int shardNumber) Create a new sharding configuration with explicit total number of shards and shard number.protectedShardingConfiguration(int totalNumberOfShards, int shardNumber, SystemProvider systemProvider) Constructor that sets the total number of shards, shard number, and allows for injecting a customSystemProvider.protectedShardingConfiguration(SystemProvider systemProvider) Constructor that allows for injecting a customSystemProvider. -
Method Summary
-
Field Details
-
TOTAL_SHARD_NUMBER_PROPERTY_NAME
- See Also:
-
TOTAL_SHARD_NUMBER_ENV_VAR_NAME
-
SHARD_NUMBER_PROPERTY_NAME
- See Also:
-
SHARD_NUMBER_ENV_VAR_NAME
-
SHARD_SEED_PROPERTY_NAME
- See Also:
-
SHARD_SEED_ENV_VAR_NAME
-
-
Constructor Details
-
ShardingConfiguration
public ShardingConfiguration()Default sharding configuration which initializes the sharding with system properties and environment variables. -
ShardingConfiguration
Constructor that allows for injecting a customSystemProvider. This is primarily intended for testing purposes, enabling the mocking and overriding of system environment and properties.- Parameters:
systemProvider- a provider for system environment variables and properties.
-
ShardingConfiguration
public ShardingConfiguration(int totalNumberOfShards, int shardNumber) Create a new sharding configuration with explicit total number of shards and shard number.- Parameters:
totalNumberOfShards- the total number of shards to be used.shardNumber- the specific shard number for this loader, zero-based.
-
ShardingConfiguration
protected ShardingConfiguration(int totalNumberOfShards, int shardNumber, SystemProvider systemProvider) Constructor that sets the total number of shards, shard number, and allows for injecting a customSystemProvider. Primarily used for testing purposes.- Parameters:
totalNumberOfShards- the total number of shards.shardNumber- the shard number for this loader, zero-based.systemProvider- a provider for system environment variables and properties.
-
-
Method Details
-
getTotalNumberOfShards
public int getTotalNumberOfShards() -
getShardNumber
public int getShardNumber() -
getSeed
public int getSeed()
-