From 44e3d942b2d6598494056fcd0ce37c48d09dfe8d Mon Sep 17 00:00:00 2001 From: David Kornel Date: Tue, 12 Mar 2024 13:25:40 +0100 Subject: [PATCH 1/4] Write readme file for test-frame with usage and examples Signed-off-by: David Kornel --- .github/workflows/build.yaml | 2 ++ README.md | 69 ++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 README.md diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a8fcb41..2c9714d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,8 @@ name: Build on: + push: + branches: [ main ] pull_request: branches: [ main ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..0a9ae4b --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# 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 +[KubeResoruceManager](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 `KubeResoruceManager` is automatically deleted in case of test end or test failed. +So kubernetes environment is clean before and after every test run and user do not need to handle it. +Working with kubernetes resources using `KubeResoruceManager` also provides proper waiting for resource readiness. + +### Fabric8 kubernetes client and cmd client +Instance of `KubeResoruceManager` contains accessible fabric8 kubernetes client and kubernetes cmd client. +These clients are initialized and connected to the test cluster based on configuration provided by env file, env variables or kubeconfig. + +### Test visual separation +For better reading test logs 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 + + io.skodjob + test-frame-common + +``` +2. Use annotations for working with `KubeResoruceManager` or other provided functionality +```java +//... +@ResourceManager +@TestVisualSeparator +class Test { + //... +} +//... +``` +3. Work with `KubeResoruceManager` 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) \ No newline at end of file From 97499159195614eda187a82fab528e412c6a9506 Mon Sep 17 00:00:00 2001 From: David Kornel Date: Tue, 12 Mar 2024 14:52:17 +0100 Subject: [PATCH 2/4] Address comments Signed-off-by: David Kornel --- README.md | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0a9ae4b..4860d5a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # TEST-FRAME -Library for easy testing of kubernetes deployments and operators using fabric8 api. +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) @@ -8,11 +8,11 @@ Library for easy testing of kubernetes deployments and operators using fabric8 a ## Provided functionality ### Kubernetes resource manager [KubeResoruceManager](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 `KubeResoruceManager` is automatically deleted in case of test end or test failed. -So kubernetes environment is clean before and after every test run and user do not need to handle it. -Working with kubernetes resources using `KubeResoruceManager` also provides proper waiting for resource readiness. +Every Kubernetes resource created by `KubeResoruceManager` is automatically deleted after at the end of the test - no matter if 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 `KubeResoruceManager` also provides proper wait for resource readiness. -### Fabric8 kubernetes client and cmd client +### Fabric8 Kubernetes client and CMD client Instance of `KubeResoruceManager` contains accessible fabric8 kubernetes client and kubernetes cmd client. These clients are initialized and connected to the test cluster based on configuration provided by env file, env variables or kubeconfig. @@ -22,8 +22,6 @@ For better reading test logs library provides ASCII vial separation of tests and ### Utils `TestFrame` contains also tweaks and utils for better working with kubernetes cluster. - - ## Usage 1. Include dependency to your maven test project ```xml @@ -60,10 +58,9 @@ class 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 +* **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) \ No newline at end of file +* **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) From 1c5ca71b77d9f6191317a068d22a206df0b69ed0 Mon Sep 17 00:00:00 2001 From: David Kornel Date: Tue, 12 Mar 2024 14:59:11 +0100 Subject: [PATCH 3/4] Address comments v2 Signed-off-by: David Kornel --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4860d5a..7626f84 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,16 @@ Library for easy testing of Kubernetes deployments and operators using Fabric8 A ## Provided functionality ### Kubernetes resource manager [KubeResoruceManager](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 `KubeResoruceManager` is automatically deleted after at the end of the test - no matter if the test passed or failed. +Every Kubernetes resource created by `KubeResoruceManager` 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 `KubeResoruceManager` also provides proper wait for resource readiness. ### Fabric8 Kubernetes client and CMD client Instance of `KubeResoruceManager` contains accessible fabric8 kubernetes client and kubernetes cmd client. -These clients are initialized and connected to the test cluster based on configuration provided by env file, env variables or kubeconfig. +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 reading test logs library provides ASCII vial separation of tests and test classes. +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. From 91837c561029c81d75c6723236a712a7e9217728 Mon Sep 17 00:00:00 2001 From: David Kornel Date: Tue, 12 Mar 2024 15:07:22 +0100 Subject: [PATCH 4/4] Address comments v3 Signed-off-by: David Kornel --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7626f84..b2c3ff3 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,13 @@ Library for easy testing of Kubernetes deployments and operators using Fabric8 A ## Provided functionality ### Kubernetes resource manager -[KubeResoruceManager](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 `KubeResoruceManager` is automatically deleted at the end of the test, whether the test passed or failed. +[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 `KubeResoruceManager` also provides proper wait for resource readiness. +Working with Kubernetes resources using `KubeResourceManager` also provides proper wait for resource readiness. ### Fabric8 Kubernetes client and CMD client -Instance of `KubeResoruceManager` contains accessible fabric8 kubernetes client and kubernetes 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 @@ -30,7 +30,7 @@ For better clarity regarding the test logs, `TestFrame` library provides ASCII v test-frame-common ``` -2. Use annotations for working with `KubeResoruceManager` or other provided functionality +2. Use annotations for working with `KubeResourceManager` or other provided functionality ```java //... @ResourceManager @@ -40,7 +40,7 @@ class Test { } //... ``` -3. Work with `KubeResoruceManager` and clients +3. Work with `KubeResourceManager` and clients ```java //... @ResourceManager