Skip to content

Commit

Permalink
Write readme file for test-frame with usage and examples (#31)
Browse files Browse the repository at this point in the history
* Write readme file for test-frame with usage and examples


Signed-off-by: David Kornel <[email protected]>
  • Loading branch information
kornys authored Mar 12, 2024
1 parent 29270b8 commit b4573c9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

Expand Down
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# TEST-FRAME
Library for easy testing of Kubernetes deployments and operators using Fabric8 API.

[![Build](https://github.com/skodjob/test-frame/actions/workflows/build.yaml/badge.svg?branch=main)](https://github.com/skodjob/test-frame/actions/workflows/build.yaml)
[![Publish-snapshot](https://github.com/skodjob/test-frame/actions/workflows/publish-snapshot.yaml/badge.svg?branch=main)](https://github.com/skodjob/test-frame/actions/workflows/publish-snapshot.yaml)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

## Provided functionality
### Kubernetes resource manager
[KubeResourceManager](test-frame-common/src/main/java/io/skodjob/testframe/resources/KubeResourceManager.java) 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.

### Fabric8 Kubernetes client and CMD client
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.

### Test visual separation
For better clarity regarding the test logs, `TestFrame` library provides ASCII vial separation of tests and test classes.

### Utils
`TestFrame` contains also tweaks and utils for better working with kubernetes cluster.

## Usage
1. Include dependency to your maven test project
```xml
<dependency>
<groupId>io.skodjob</groupId>
<artifactId>test-frame-common</artifactId>
</dependency>
```
2. Use annotations for working with `KubeResourceManager` or other provided functionality
```java
//...
@ResourceManager
@TestVisualSeparator
class Test {
//...
}
//...
```
3. Work with `KubeResourceManager` and clients
```java
//...
@ResourceManager
class Test {
@Test
void testMethod() {
KubeResourceManager.getInstance().createResourceWithWait(
new NamespaceBuilder().withNewMetadata().withName("test").endMetadata().build());
assertNotNull(KubeResourceManager.getKubeCmdClient().get("namespace", "test"));
}
}
//...
```

## Examples
Examples are stored in [test-frame-test](test-frame-test/src/test/java/io/skodjob/testframe/test/integration) module.

## Config environment variables
* **ENV_FILE** - path to YAML file with env variables values
* **KUBE_USERNAME** - user of the cluster
* **KUBE_PASSWORD** - password of Kube user
* **KUBE_TOKEN** - token of Kube access (use instead of username/password)
* **KUBE_URL** - URL of the cluster (API URL)

0 comments on commit b4573c9

Please sign in to comment.