Library for easy testing of Kubernetes deployments and operators using Fabric8 API.
KubeResourceManager provides management of resources created during test phases.
Every Kubernetes resource created by KubeResourceManager
is automatically deleted at the end of the test, whether the test passed or failed.
So the Kubernetes environment is clean before and after every test run and user do not need to handle it.
Working with Kubernetes resources using KubeResourceManager
also provides proper wait for resource readiness.
Instance of KubeResourceManager
contains accessible fabric8 kubernetes client and kubernetes cmd client.
These clients are initialized and connected to the test cluster based on the configuration provided by the env file, env variables, or kubeconfig.
For better clarity regarding the test logs, TestFrame
library provides ASCII vial separation of tests and test classes.
The MetricsCollector
is designed to facilitate the collection of metrics from Kubernetes pods.
It integrates seamlessly with Kubernetes environments to gather and process metrics data efficiently.
For more detailed documentation, see the MetricsCollector README.
LogCollector
is utility for collecting logs from the Pods (and their containers), descriptions of Pods, and YAML
descriptions of resources specified by users, collected from the desired Namespaces.
To Log Collector's README contains detailed documentation about this component,
together with the usage and installation.
TestFrame
contains also tweaks and utils for better working with kubernetes cluster.
<dependency>
<groupId>io.skodjob</groupId>
<artifactId>test-frame-common</artifactId>
</dependency>
//...
@ResourceManager
@TestVisualSeparator
class Test {
//...
}
//...
//...
@ResourceManager(cleanResources = false)
@TestVisualSeparator
class Test {
//...
}
//...
//...
@ResourceManager
class Test {
@Test
void testMethod() {
KubeResourceManager.getInstance().createResourceWithWait(
new NamespaceBuilder().withNewMetadata().withName("test").endMetadata().build());
assertNotNull(KubeResourceManager.getKubeCmdClient().get("namespace", "test"));
}
}
//...
KubeResourceManager.getInstance().setResourceTypes(
new NamespaceType(),
new JobType(),
new NetworkPolicyType()
);
Examples are stored in test-frame-test-examples module.
- ENV_FILE - path to YAML file with env variables values
- KUBE_TOKEN - token of Kube access (use instead of username/password)
- KUBE_URL - URL of the cluster (API URL)
- CLIENT_TYPE - Switch between
kubectl
oroc
cmd client
- opendatahub.io operator test suite - odh-e2e
- strimzi.io Strimzi Kafka operator - e2e
- strimzi.io Kafka access operator - e2e
- debezium.io Debezium Operator - e2e
- streamshub Streams E2E - e2e