Generate a test matrix based on containers
Like Travis CI it is a known pattern to perform integration tests using a matrix of dependent service versions in order to validate them with our software.
The matrix is defined as an array of array so that each element of each inner array will be made available with all the element of each other inner array avoiding repetition. Here a simple yaml example in order to clarify the structure and its behaviour:
matrix: [
- postgres:9.4, postgres:9.5
], [
- postgres:11, postgres:12
]
Will produce following test executions:
- postgres:9.4, postgres:11
- postgres:9.4, postgres:12
- postgres:9.5, postgres:11
- postgres:9.5, postgres:12
This could be achieved by introducing a new annotation @DockerMatrixExtension
that allows to declare an array of array of @DockerContainer
and specify its alias for each inner array. Follow previous example:
@DockerMatrixExtension({
@DockerMatrixContainer(alias = "postgres-source", containers = {
@DockerContainer(image = postgres:9.4),
@DockerContainer(image = postgres:9.5)
}),
@DockerMatrixContainer(alias = "postgres-target", containers = {
@DockerContainer(image = postgres:11),
@DockerContainer(image = postgres:12)
})
})
public class MatrixIT {
...
}