Skip to content

Commit

Permalink
fix #4924: speeding up the pod exec tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins authored and manusa committed Mar 8, 2023
1 parent 523e775 commit aae3080
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package io.fabric8.kubernetes.client.mock;

import io.fabric8.kubernetes.api.model.PodBuilder;
import io.fabric8.kubernetes.api.model.PodStatus;
import io.fabric8.kubernetes.api.model.PodStatusBuilder;
import io.fabric8.kubernetes.api.model.Status;
import io.fabric8.kubernetes.api.model.StatusBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
Expand All @@ -41,6 +43,9 @@
@EnableKubernetesMockClient(crud = true)
class PodExecTest {

private static PodStatus READY = new PodStatusBuilder().addNewCondition().withType("Ready").withStatus("True").endCondition()
.build();

private KubernetesMockServer server;
private KubernetesClient client;

Expand All @@ -52,7 +57,7 @@ void setUp() {
@Test
@DisplayName("With no containers, should throw exception")
void withNoContainers() {
client.pods().resource(new PodBuilder().withNewMetadata().withName("no-containers").endMetadata().build())
client.pods().resource(new PodBuilder().withNewMetadata().withName("no-containers").endMetadata().withStatus(READY).build())
.createOrReplace();
final PodResource pr = client.pods().withName("no-containers");
assertThatThrownBy(() -> pr.exec("sh", "-c", "echo Greetings Professor Falken"))
Expand All @@ -68,7 +73,7 @@ void withSingleContainer() throws Exception {
.addNewContainer()
.withName("the-single-container")
.endContainer()
.endSpec()
.endSpec().withStatus(READY)
.build())
.createOrReplace();
server.expect()
Expand All @@ -92,7 +97,7 @@ void withSingleContainerAndInContainer() {
.addNewContainer()
.withName("the-single-container")
.endContainer()
.endSpec()
.endSpec().withStatus(READY)
.build())
.createOrReplace();
final ContainerResource cr = client.pods().withName("single-container").inContainer("non-existent");
Expand All @@ -108,7 +113,7 @@ void execNoStreams() throws Exception {
.addNewContainer()
.withName("the-first-container")
.endContainer()
.endSpec()
.endSpec().withStatus(READY)
.build())
.createOrReplace();
PodResource op = client.pods().withName("name");
Expand All @@ -126,7 +131,7 @@ void withMultipleContainers() throws Exception {
.addNewContainer()
.withName("the-second-container")
.endContainer()
.endSpec()
.endSpec().withStatus(READY)
.build())
.createOrReplace();
server.expect()
Expand All @@ -153,7 +158,7 @@ void withMultipleContainersAndInContainer() throws Exception {
.addNewContainer()
.withName("the-second-container")
.endContainer()
.endSpec()
.endSpec().withStatus(READY)
.build())
.createOrReplace();
server.expect()
Expand Down

0 comments on commit aae3080

Please sign in to comment.