Skip to content

Commit 962de1d

Browse files
rohanKanojiamanusa
authored andcommitted
fix (kubernetes-itests) : Add Kubernetes 1.25.0 to E2E test suite matrix
Run integration tests on Kubernetes 1.25.0 as well Signed-off-by: Rohan Kumar <[email protected]>
1 parent 711482c commit 962de1d

File tree

6 files changed

+135
-66
lines changed

6 files changed

+135
-66
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
strategy:
6565
fail-fast: false
6666
matrix:
67-
kubernetes: [v1.24.0,v1.23.3, v1.22.6, v1.20.15, v1.19.16, v1.12.10]
67+
kubernetes: [v1.25.0, v1.24.0, v1.23.3, v1.22.6, v1.20.15, v1.19.16, v1.12.10]
6868
steps:
6969
- name: Checkout
7070
uses: actions/checkout@v3

kubernetes-itests/src/test/java/io/fabric8/kubernetes/CronJobIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.fabric8.kubernetes;
1818

1919
import io.fabric8.junit.jupiter.api.LoadKubernetesManifests;
20+
import io.fabric8.junit.jupiter.api.RequireK8sSupport;
2021
import io.fabric8.kubernetes.api.model.batch.v1beta1.CronJob;
2122
import io.fabric8.kubernetes.api.model.batch.v1beta1.CronJobBuilder;
2223
import io.fabric8.kubernetes.api.model.batch.v1beta1.CronJobList;
@@ -29,6 +30,7 @@
2930
import static org.junit.jupiter.api.Assertions.assertTrue;
3031

3132
@LoadKubernetesManifests("/cronjob-it.yml")
33+
@RequireK8sSupport(CronJob.class)
3234
class CronJobIT {
3335

3436
KubernetesClient client;
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/**
2+
* Copyright (C) 2015 Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.fabric8.kubernetes;
17+
18+
import io.fabric8.junit.jupiter.api.LoadKubernetesManifests;
19+
import io.fabric8.junit.jupiter.api.RequireK8sSupport;
20+
import io.fabric8.kubernetes.api.model.IntOrString;
21+
import io.fabric8.kubernetes.api.model.Pod;
22+
import io.fabric8.kubernetes.api.model.PodBuilder;
23+
import io.fabric8.kubernetes.api.model.policy.v1beta1.PodDisruptionBudget;
24+
import io.fabric8.kubernetes.api.model.policy.v1beta1.PodDisruptionBudgetBuilder;
25+
import io.fabric8.kubernetes.api.model.policy.v1beta1.PodDisruptionBudgetSpecBuilder;
26+
import io.fabric8.kubernetes.client.KubernetesClient;
27+
import io.fabric8.kubernetes.client.readiness.Readiness;
28+
import org.junit.jupiter.api.Test;
29+
30+
import java.util.concurrent.TimeUnit;
31+
32+
import static org.awaitility.Awaitility.await;
33+
import static org.junit.jupiter.api.Assertions.assertFalse;
34+
import static org.junit.jupiter.api.Assertions.assertNotNull;
35+
import static org.junit.jupiter.api.Assertions.assertTrue;
36+
37+
@LoadKubernetesManifests("/pod-evict-it.yml")
38+
@RequireK8sSupport(PodDisruptionBudget.class)
39+
class PodEvictIT {
40+
private static final int POD_READY_WAIT_IN_SECONDS = 60;
41+
42+
KubernetesClient client;
43+
44+
@Test
45+
void evict() {
46+
Pod pod1 = client.pods().withName("pod-standard").get();
47+
String pdbScope = pod1.getMetadata().getLabels().get("pdb-scope");
48+
assertNotNull("pdb-scope label is null. is pod1 misconfigured?", pdbScope);
49+
50+
PodDisruptionBudget pdb = new PodDisruptionBudgetBuilder()
51+
.withNewMetadata()
52+
.withName("test-pdb")
53+
.endMetadata()
54+
.withSpec(
55+
new PodDisruptionBudgetSpecBuilder()
56+
.withMinAvailable(new IntOrString(1))
57+
.withNewSelector()
58+
.addToMatchLabels("pdb-scope", pdbScope)
59+
.endSelector()
60+
.build())
61+
.build();
62+
63+
Pod pod2 = new PodBuilder()
64+
.withNewMetadata()
65+
.withName("pod2")
66+
.addToLabels("pdb-scope", pdbScope)
67+
.endMetadata()
68+
.withSpec(pod1.getSpec())
69+
.build();
70+
71+
Pod pod3 = new PodBuilder()
72+
.withNewMetadata()
73+
.withName("pod3")
74+
.addToLabels("pdb-scope", pdbScope)
75+
.endMetadata()
76+
.withSpec(pod1.getSpec())
77+
.build();
78+
79+
client.pods().resource(pod1).waitUntilReady(POD_READY_WAIT_IN_SECONDS, TimeUnit.SECONDS);
80+
81+
client.pods().resource(pod2).createOrReplace();
82+
client.pods().resource(pod2).waitUntilReady(POD_READY_WAIT_IN_SECONDS, TimeUnit.SECONDS);
83+
84+
client.resource(pdb).createOrReplace();
85+
86+
// the server needs to process the pdb before the eviction can proceed, so we'll need to wait here
87+
await().atMost(5, TimeUnit.MINUTES)
88+
.until(() -> client.pods().withName(pod2.getMetadata().getName()).evict());
89+
90+
// cant evict because only one left
91+
assertFalse(client.pods().resource(pod1).evict());
92+
// ensure it really is still up
93+
assertTrue(Readiness.getInstance().isReady(client.pods().resource(pod1).fromServer().get()));
94+
95+
// create another pod to satisfy PDB
96+
client.pods().resource(pod3).createOrReplace();
97+
client.pods().resource(pod3).waitUntilReady(POD_READY_WAIT_IN_SECONDS, TimeUnit.SECONDS);
98+
99+
// can now evict
100+
assertTrue(client.pods().resource(pod3).evict());
101+
}
102+
}

kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodIT.java

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,15 @@
1818

1919
import io.fabric8.junit.jupiter.api.LoadKubernetesManifests;
2020
import io.fabric8.kubernetes.api.model.HasMetadata;
21-
import io.fabric8.kubernetes.api.model.IntOrString;
2221
import io.fabric8.kubernetes.api.model.Namespace;
2322
import io.fabric8.kubernetes.api.model.Pod;
2423
import io.fabric8.kubernetes.api.model.PodBuilder;
2524
import io.fabric8.kubernetes.api.model.PodList;
2625
import io.fabric8.kubernetes.api.model.Status;
27-
import io.fabric8.kubernetes.api.model.policy.v1beta1.PodDisruptionBudget;
28-
import io.fabric8.kubernetes.api.model.policy.v1beta1.PodDisruptionBudgetBuilder;
29-
import io.fabric8.kubernetes.api.model.policy.v1beta1.PodDisruptionBudgetSpecBuilder;
3026
import io.fabric8.kubernetes.client.KubernetesClient;
3127
import io.fabric8.kubernetes.client.dsl.ExecListener;
3228
import io.fabric8.kubernetes.client.dsl.ExecWatch;
3329
import io.fabric8.kubernetes.client.dsl.PodResource;
34-
import io.fabric8.kubernetes.client.readiness.Readiness;
3530
import io.fabric8.kubernetes.client.utils.InputStreamPumper;
3631
import org.awaitility.Awaitility;
3732
import org.junit.jupiter.api.Test;
@@ -57,7 +52,6 @@
5752
import java.util.stream.Collectors;
5853

5954
import static org.assertj.core.api.Assertions.assertThat;
60-
import static org.awaitility.Awaitility.await;
6155
import static org.junit.jupiter.api.Assertions.assertEquals;
6256
import static org.junit.jupiter.api.Assertions.assertFalse;
6357
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -106,65 +100,6 @@ void delete() {
106100
assertTrue(client.pods().withName("pod-delete").delete().size() == 1);
107101
}
108102

109-
@Test
110-
void evict() {
111-
Pod pod1 = client.pods().withName("pod-standard").get();
112-
String pdbScope = pod1.getMetadata().getLabels().get("pdb-scope");
113-
assertNotNull("pdb-scope label is null. is pod1 misconfigured?", pdbScope);
114-
115-
PodDisruptionBudget pdb = new PodDisruptionBudgetBuilder()
116-
.withNewMetadata()
117-
.withName("test-pdb")
118-
.endMetadata()
119-
.withSpec(
120-
new PodDisruptionBudgetSpecBuilder()
121-
.withMinAvailable(new IntOrString(1))
122-
.withNewSelector()
123-
.addToMatchLabels("pdb-scope", pdbScope)
124-
.endSelector()
125-
.build())
126-
.build();
127-
128-
Pod pod2 = new PodBuilder()
129-
.withNewMetadata()
130-
.withName("pod2")
131-
.addToLabels("pdb-scope", pdbScope)
132-
.endMetadata()
133-
.withSpec(pod1.getSpec())
134-
.build();
135-
136-
Pod pod3 = new PodBuilder()
137-
.withNewMetadata()
138-
.withName("pod3")
139-
.addToLabels("pdb-scope", pdbScope)
140-
.endMetadata()
141-
.withSpec(pod1.getSpec())
142-
.build();
143-
144-
client.pods().resource(pod1).waitUntilReady(POD_READY_WAIT_IN_SECONDS, TimeUnit.SECONDS);
145-
146-
client.pods().resource(pod2).createOrReplace();
147-
client.pods().resource(pod2).waitUntilReady(POD_READY_WAIT_IN_SECONDS, TimeUnit.SECONDS);
148-
149-
client.resource(pdb).createOrReplace();
150-
151-
// the server needs to process the pdb before the eviction can proceed, so we'll need to wait here
152-
await().atMost(5, TimeUnit.MINUTES)
153-
.until(() -> client.pods().withName(pod2.getMetadata().getName()).evict());
154-
155-
// cant evict because only one left
156-
assertFalse(client.pods().resource(pod1).evict());
157-
// ensure it really is still up
158-
assertTrue(Readiness.getInstance().isReady(client.pods().resource(pod1).fromServer().get()));
159-
160-
// create another pod to satisfy PDB
161-
client.pods().resource(pod3).createOrReplace();
162-
client.pods().resource(pod3).waitUntilReady(POD_READY_WAIT_IN_SECONDS, TimeUnit.SECONDS);
163-
164-
// can now evict
165-
assertTrue(client.pods().resource(pod3).evict());
166-
}
167-
168103
@Test
169104
void log() {
170105
client.pods().withName("pod-standard").waitUntilReady(POD_READY_WAIT_IN_SECONDS, TimeUnit.SECONDS);

kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodSecurityPolicyIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.fabric8.kubernetes;
1818

1919
import io.fabric8.junit.jupiter.api.LoadKubernetesManifests;
20+
import io.fabric8.junit.jupiter.api.RequireK8sSupport;
2021
import io.fabric8.kubernetes.api.model.policy.v1beta1.PodSecurityPolicy;
2122
import io.fabric8.kubernetes.api.model.policy.v1beta1.PodSecurityPolicyBuilder;
2223
import io.fabric8.kubernetes.api.model.policy.v1beta1.PodSecurityPolicyList;
@@ -32,6 +33,7 @@
3233
import static org.junit.jupiter.api.Assertions.assertTrue;
3334

3435
@LoadKubernetesManifests("/podsecuritypolicy-it.yml")
36+
@RequireK8sSupport(PodSecurityPolicy.class)
3537
class PodSecurityPolicyIT {
3638

3739
KubernetesClient client;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# Copyright (C) 2015 Red Hat, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
---
18+
apiVersion: v1
19+
kind: Pod
20+
metadata:
21+
name: pod-standard
22+
labels:
23+
pdb-scope: get
24+
spec:
25+
containers:
26+
- name: busybox
27+
image: busybox
28+
command: ["sleep", "36000"]

0 commit comments

Comments
 (0)