Skip to content

Commit ddafb6d

Browse files
shawkinsmanusa
authored andcommitted
fix #4924: speeding up the pod exec tests
1 parent 9ce04a6 commit ddafb6d

File tree

1 file changed

+11
-6
lines changed
  • kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock

1 file changed

+11
-6
lines changed

kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodExecTest.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package io.fabric8.kubernetes.client.mock;
1717

1818
import io.fabric8.kubernetes.api.model.PodBuilder;
19+
import io.fabric8.kubernetes.api.model.PodStatus;
20+
import io.fabric8.kubernetes.api.model.PodStatusBuilder;
1921
import io.fabric8.kubernetes.api.model.Status;
2022
import io.fabric8.kubernetes.api.model.StatusBuilder;
2123
import io.fabric8.kubernetes.client.KubernetesClient;
@@ -41,6 +43,9 @@
4143
@EnableKubernetesMockClient(crud = true)
4244
class PodExecTest {
4345

46+
private static PodStatus READY = new PodStatusBuilder().addNewCondition().withType("Ready").withStatus("True").endCondition()
47+
.build();
48+
4449
private KubernetesMockServer server;
4550
private KubernetesClient client;
4651

@@ -52,7 +57,7 @@ void setUp() {
5257
@Test
5358
@DisplayName("With no containers, should throw exception")
5459
void withNoContainers() {
55-
client.pods().resource(new PodBuilder().withNewMetadata().withName("no-containers").endMetadata().build())
60+
client.pods().resource(new PodBuilder().withNewMetadata().withName("no-containers").endMetadata().withStatus(READY).build())
5661
.createOrReplace();
5762
final PodResource pr = client.pods().withName("no-containers");
5863
assertThatThrownBy(() -> pr.exec("sh", "-c", "echo Greetings Professor Falken"))
@@ -68,7 +73,7 @@ void withSingleContainer() throws Exception {
6873
.addNewContainer()
6974
.withName("the-single-container")
7075
.endContainer()
71-
.endSpec()
76+
.endSpec().withStatus(READY)
7277
.build())
7378
.createOrReplace();
7479
server.expect()
@@ -92,7 +97,7 @@ void withSingleContainerAndInContainer() {
9297
.addNewContainer()
9398
.withName("the-single-container")
9499
.endContainer()
95-
.endSpec()
100+
.endSpec().withStatus(READY)
96101
.build())
97102
.createOrReplace();
98103
final ContainerResource cr = client.pods().withName("single-container").inContainer("non-existent");
@@ -108,7 +113,7 @@ void execNoStreams() throws Exception {
108113
.addNewContainer()
109114
.withName("the-first-container")
110115
.endContainer()
111-
.endSpec()
116+
.endSpec().withStatus(READY)
112117
.build())
113118
.createOrReplace();
114119
PodResource op = client.pods().withName("name");
@@ -126,7 +131,7 @@ void withMultipleContainers() throws Exception {
126131
.addNewContainer()
127132
.withName("the-second-container")
128133
.endContainer()
129-
.endSpec()
134+
.endSpec().withStatus(READY)
130135
.build())
131136
.createOrReplace();
132137
server.expect()
@@ -153,7 +158,7 @@ void withMultipleContainersAndInContainer() throws Exception {
153158
.addNewContainer()
154159
.withName("the-second-container")
155160
.endContainer()
156-
.endSpec()
161+
.endSpec().withStatus(READY)
157162
.build())
158163
.createOrReplace();
159164
server.expect()

0 commit comments

Comments
 (0)