Skip to content

Commit 6a2a60a

Browse files
authored
Merge pull request #1190 from yue9944882/informer-e2e
E2E Test: BDD testing (groovy+spock) for informer utilities
2 parents 5dd0819 + 413bbd4 commit 6a2a60a

File tree

5 files changed

+187
-6
lines changed

5 files changed

+187
-6
lines changed

.github/workflows/maven.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,20 @@ jobs:
3737
graalvm-version: '19.3.0.java8'
3838
- name: Build with Maven
3939
run: mvn -q test -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
40+
e2e:
41+
runs-on: ubuntu-latest
42+
name: End-to-End Test Against Real Cluster
43+
steps:
44+
- uses: actions/checkout@v2
45+
- name: Create k8s Kind Cluster
46+
uses: helm/[email protected]
47+
- name: Run E2E with Maven
48+
run: |
49+
mvn clean install \
50+
-q \
51+
-Dmaven.test.skip=true
52+
cd e2e
53+
mvn test \
54+
-B \
55+
-De2e.skip=false \
56+
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn

e2e/pom.xml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>io.kubernetes</groupId>
7+
<artifactId>e2e-tests</artifactId>
8+
<packaging>bundle</packaging>
9+
<name>client-java-e2e-tests</name>
10+
<url>https://github.com/kubernetes-client/java</url>
11+
12+
<parent>
13+
<artifactId>client-java-parent</artifactId>
14+
<groupId>io.kubernetes</groupId>
15+
<version>10.0.0-SNAPSHOT</version>
16+
<relativePath>../pom.xml</relativePath>
17+
</parent>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>io.kubernetes</groupId>
22+
<artifactId>client-java</artifactId>
23+
<version>${project.version}</version>
24+
</dependency>
25+
<dependency>
26+
<groupId>io.kubernetes</groupId>
27+
<artifactId>client-java-extended</artifactId>
28+
<version>${project.version}</version>
29+
</dependency>
30+
31+
<dependency>
32+
<groupId>org.spockframework</groupId>
33+
<artifactId>spock-core</artifactId>
34+
<version>1.1-groovy-2.4-rc-2</version>
35+
<scope>test</scope>
36+
</dependency>
37+
</dependencies>
38+
39+
<build>
40+
<plugins>
41+
<plugin>
42+
<groupId>org.apache.felix</groupId>
43+
<artifactId>maven-bundle-plugin</artifactId>
44+
<extensions>true</extensions>
45+
</plugin>
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-surefire-plugin</artifactId>
49+
<configuration>
50+
<skipTests>${e2e.skip}</skipTests>
51+
</configuration>
52+
</plugin>
53+
<plugin>
54+
<groupId>org.codehaus.gmavenplus</groupId>
55+
<artifactId>gmavenplus-plugin</artifactId>
56+
<configuration>
57+
<testSources>
58+
<testSource>
59+
<directory>${project.basedir}/src/test/groovy</directory>
60+
<includes>
61+
<include>**/*.groovy</include>
62+
</includes>
63+
</testSource>
64+
</testSources>
65+
</configuration>
66+
<executions>
67+
<execution>
68+
<!-- Without joint compilation - no dependencies between Java and Groovy (inheritance)-->
69+
<goals>
70+
<goal>testCompile</goal>
71+
</goals>
72+
</execution>
73+
</executions>
74+
<dependencies>
75+
<dependency>
76+
<groupId>org.codehaus.groovy</groupId>
77+
<artifactId>groovy-all</artifactId>
78+
<version>2.4.6</version>
79+
</dependency>
80+
</dependencies>
81+
</plugin>
82+
</plugins>
83+
</build>
84+
85+
</project>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package io.kubernetes.client.e2e.informer
14+
15+
import io.kubernetes.client.informer.SharedInformerFactory
16+
import io.kubernetes.client.informer.cache.Lister
17+
import io.kubernetes.client.openapi.models.V1Namespace
18+
import io.kubernetes.client.openapi.models.V1NamespaceList
19+
import io.kubernetes.client.util.ClientBuilder
20+
import io.kubernetes.client.util.generic.GenericKubernetesApi
21+
import spock.lang.Specification
22+
import spock.util.concurrent.PollingConditions
23+
24+
class NamespaceInformerTest extends Specification {
25+
26+
def "list-watching namespaces should work" () {
27+
given:
28+
def conditions = new PollingConditions();
29+
def apiClient = ClientBuilder.defaultClient();
30+
def api = new GenericKubernetesApi(
31+
V1Namespace.class,
32+
V1NamespaceList.class,
33+
"",
34+
"v1",
35+
"namespaces",
36+
apiClient)
37+
def informerFactory = new SharedInformerFactory();
38+
def nsInformer = informerFactory.sharedIndexInformerFor(
39+
api,
40+
V1Namespace.class,
41+
0)
42+
def nsLister = new Lister(nsInformer.getIndexer());
43+
when:
44+
informerFactory.startAllRegisteredInformers();
45+
then:
46+
conditions.eventually {
47+
nsInformer.hasSynced()
48+
nsLister.list().size() > 0
49+
}
50+
}
51+
52+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package io.kubernetes.client.e2e.kubectl
14+
15+
import spock.lang.Specification
16+
17+
class KubectlLabelTest extends Specification {
18+
}

pom.xml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<module>extended</module>
1717
<module>spring</module>
1818
<module>client-java-contrib/cert-manager</module>
19+
<module>e2e</module>
1920
</modules>
2021

2122
<scm>
@@ -51,6 +52,8 @@
5152
<spring.version>5.2.8.RELEASE</spring.version>
5253
<prometheus.client.version>0.9.0</prometheus.client.version>
5354

55+
<e2e.skip>true</e2e.skip>
56+
5457
<gpg.keyname>48540ECBBF00A28EACCF04E720FD12AFB0C9EBA9</gpg.keyname>
5558
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
5659
</properties>
@@ -289,6 +292,11 @@
289292
<artifactId>maven-deploy-plugin</artifactId>
290293
<version>2.8.2</version>
291294
</plugin>
295+
<plugin>
296+
<groupId>org.codehaus.gmavenplus</groupId>
297+
<artifactId>gmavenplus-plugin</artifactId>
298+
<version>1.5</version>
299+
</plugin>
292300
</plugins>
293301
</pluginManagement>
294302
<plugins>
@@ -334,10 +342,11 @@
334342
<java>
335343
<removeUnusedImports /> <!-- self-explanatory -->
336344
<googleJavaFormat />
337-
<licenseHeader>
338-
<content>
345+
</java>
346+
<licenseHeader>
347+
<content>
339348
/*
340-
Copyright 2020 The Kubernetes Authors.
349+
Copyright $YEAR The Kubernetes Authors.
341350
Licensed under the Apache License, Version 2.0 (the "License");
342351
you may not use this file except in compliance with the License.
343352
You may obtain a copy of the License at
@@ -348,9 +357,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
348357
See the License for the specific language governing permissions and
349358
limitations under the License.
350359
*/
351-
</content>
352-
</licenseHeader>
353-
</java>
360+
</content>
361+
<delimiter>package </delimiter>
362+
</licenseHeader>
354363
</configuration>
355364
</plugin>
356365
</plugins>

0 commit comments

Comments
 (0)