You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 10, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+54-17Lines changed: 54 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,32 +1,34 @@
1
1
# jenvtest
2
2
3
-
jenvtest makes it easy to implement integration tests with Kubernetes API Server in Java.
3
+
jenvtest makes it easy to implement integration tests with Kubernetes API Server in Java.
4
4
Inspired by [envtest](https://book.kubebuilder.io/reference/envtest.html) in go.
5
5
6
-
It runs the API Server binaries directly (without nodes and other components). Thus, only etcd and Kubernetes API Server.
6
+
It runs the API Server binaries directly (without nodes and other components). Thus, only etcd and Kubernetes API
7
+
Server.
7
8
Linux, Windows, Mac is supported.
8
9
9
10
Project is in early phases, heading towards mvp release.
10
11
11
-
## Usage
12
+
## Usage
12
13
13
14
Include dependency:
14
15
15
16
```xml
16
17
<dependency>
17
-
<groupId>io.javaoperatorsdk</groupId>
18
-
<artifactId>jenvtest</artifactId>
19
-
<version>[version]</version>
20
-
<scope>test</scope>
18
+
<groupId>io.javaoperatorsdk</groupId>
19
+
<artifactId>jenvtest</artifactId>
20
+
<version>[version]</version>
21
+
<scope>test</scope>
21
22
</dependency>
22
23
```
23
24
24
25
### In Unit Tests
25
26
26
-
See sample unit test [here](https://github.com/java-operator-sdk/jenvtest/blob/main/samples/src/test/java/io/javaoperatorsdk/jenvtest/JUnitExtensionTest.java#L10-L10)
27
+
See sample unit
28
+
test [here](https://github.com/java-operator-sdk/jenvtest/blob/main/samples/src/test/java/io/javaoperatorsdk/jenvtest/JUnitExtensionTest.java#L10-L10)
27
29
28
30
```java
29
-
31
+
30
32
@EnableKubeAPIServer// Start/Stop Kube API Server in the background
31
33
classJUnitExtensionTest {
32
34
@@ -46,7 +48,7 @@ class JUnitExtensionTest {
46
48
.withName("test1")
47
49
.withNamespace("default")
48
50
.build())
49
-
.withData(Map.of("key","data"))
51
+
.withData(Map.of("key","data"))
50
52
.build();
51
53
}
52
54
@@ -55,26 +57,61 @@ class JUnitExtensionTest {
55
57
56
58
### API
57
59
58
-
The underlying API can be used directly. See [KubeApiServer](https://github.com/java-operator-sdk/jenvtest/blob/main/core/src/main/java/io/javaoperatorsdk/jenvtest/KubeAPIServer.java#L47-L47)
60
+
The underlying API can be used directly.
61
+
See [KubeApiServer](https://github.com/java-operator-sdk/jenvtest/blob/main/core/src/main/java/io/javaoperatorsdk/jenvtest/KubeAPIServer.java#L47-L47)
62
+
63
+
See
64
+
it's [usage in a test](https://github.com/java-operator-sdk/jenvtest/blob/main/samples/src/test/java/io/javaoperatorsdk/jenvtest/KubeApiServerTest.java#L12-L35).
In general using additional standard frameworks to implement webhookhooks is adviced, like [kubernetes-webooks-framework](https://github.com/java-operator-sdk/kubernetes-webooks-framework)
70
-
with Quarkus or Spring. However, we demonstrate how it works in [this test](https://github.com/java-operator-sdk/jenvtest/blob/main/samples/src/test/java/io/javaoperatorsdk/jenvtest/KubernetesMutationHookHandlingTest.java#L53-L53)
104
+
In general using additional standard frameworks to implement webhookhooks is adviced,
105
+
like [kubernetes-webooks-framework](https://github.com/java-operator-sdk/kubernetes-webooks-framework)
106
+
with Quarkus or Spring. However, we demonstrate how it works
107
+
in [this test](https://github.com/java-operator-sdk/jenvtest/blob/main/samples/src/test/java/io/javaoperatorsdk/jenvtest/KubernetesMutationHookHandlingTest.java#L53-L53)
71
108
72
109
### How does it work
73
110
74
111
In the background Kubernetes and etcd (and kubectl) binaries are downloaded if not found locally.
75
112
76
113
All the certificates for the Kube API Server and for the client is generated. The client config file
77
-
(`~/kube/config`) file is updated, to any client can be used to talk to the API Server.
114
+
(`~/kube/config`) file is updated, to any client can be used to talk to the API Server.
0 commit comments