Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write readme file for test-frame with usage and examples #31

Merged
merged 4 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
kornys marked this conversation as resolved.
Show resolved Hide resolved

## Usage
1. Include dependency to your maven test project
kornys marked this conversation as resolved.
Show resolved Hide resolved
```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.

kornys marked this conversation as resolved.
Show resolved Hide resolved
## 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)
Loading