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
+42-19Lines changed: 42 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,33 +25,28 @@ Include dependency:
25
25
### In Unit Tests
26
26
27
27
See sample unit
28
-
test [here](https://github.com/java-operator-sdk/jenvtest/blob/6fadd8cb07ea0a61410175abf1f6ec495bf6a20f/samples/src/test/java/io/javaoperatorsdk/jenvtest/JUnitExtensionOnClassTest.java)
28
+
test [here](https://github.com/java-operator-sdk/jenvtest/blob/main/core/src/test/java/io/javaoperatorsdk/jenvtest/sample/JUnitExtensionSimpleCaseTest.java)
29
29
30
30
```java
31
31
32
-
@EnableKubeAPIServer// Start/Stop Kube API Server in the background
33
-
classJUnitExtensionTest {
32
+
@EnableKubeAPIServer
33
+
classJUnitExtensionSimpleCaseTest {
34
+
35
+
// Use @KubeConfig annotation to inject kube config yaml to init any client
36
+
@KubeConfig
37
+
staticString kubeConfigYaml;
34
38
35
39
@Test
36
-
voidtestCommunication() {
37
-
// use a Kubernetes client to communicate with the server
var cm = client.resource(TestUtils.testConfigMap()).get();
44
47
45
-
privateConfigMapconfigMap() {
46
-
returnnewConfigMapBuilder()
47
-
.withMetadata(newObjectMetaBuilder()
48
-
.withName("test1")
49
-
.withNamespace("default")
50
-
.build())
51
-
.withData(Map.of("key", "data"))
52
-
.build();
48
+
Assertions.assertThat(cm).isNotNull();
53
49
}
54
-
55
50
}
56
51
```
57
52
@@ -94,6 +89,34 @@ class KubeApiServerTest {
94
89
}
95
90
```
96
91
92
+
### Fabric8 Kubernetes Client Support
93
+
94
+
There is a dedicated support for [Fabric8 Kubernetes Client](https://github.com/fabric8io/kubernetes-client).
95
+
96
+
Using dependency:
97
+
98
+
```xml
99
+
<dependency>
100
+
<groupId>io.javaoperatorsdk</groupId>
101
+
<artifactId>jenvtest-fabric8-client</artifactId>
102
+
<version>[version]</version>
103
+
<scope>test</scope>
104
+
</dependency>
105
+
```
106
+
107
+
The client can be directly injected to the test. See sample test [here](/home/csviri/Workspace/jenvtest/fabric8/src/test/java/io/javaoperatorsdk/jenvtest/junit/JUnitFabric8ClientInjectionTest.java).
108
+
109
+
```java
110
+
111
+
@EnableKubeAPIServer
112
+
classJUnitFabric8ClientInjectionTest {
113
+
114
+
staticKubernetesClient client;
115
+
116
+
// emitted code
117
+
}
118
+
```
119
+
97
120
### Testing Mutation and Validation Webhooks
98
121
99
122
An additional benefits os running K8S API Server this way, is that it makes easy to test
0 commit comments