Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove references to removed WithOpenShiftTestServer functionality #45443

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions docs/src/main/asciidoc/kubernetes-client.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -474,49 +474,43 @@ public class OpenShiftClientProducer {
}
----

Mock support is also provided in a similar fashion:
Mock support is also provided in a similar fashion by using the `@WithKubernetesTestServer` explained in the previous section:

[source, java]
----
@QuarkusTestResource(OpenShiftMockServerTestResource.class)
@WithKubernetesTestServer
@QuarkusTest
public class OpenShiftClientTest {

@MockServer
private OpenShiftMockServer mockServer;
...
----

Or by using the `@WithOpenShiftTestServer` similar to the `@WithKubernetesTestServer` explained in the
previous section:

[source, java]
----
@WithOpenShiftTestServer
@QuarkusTest
public class OpenShiftClientTest {
@KubernetesTestServer
KubernetesServer mockServer;
@Inject
OpenShiftClient client;

@OpenShiftTestServer
private OpenShiftServer mockOpenShiftServer;
...
@Test
public void testInteractionWithAPIServer() {
RestAssured.when().get("/route/test").then()
.body("size()", is(2));
}
}
----

To use this feature, you have to add a dependency on `quarkus-test-openshift-client`:
To use this feature, you have to add a dependency on `quarkus-test-kubernetes-client`:

[source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"]
.pom.xml
----
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-openshift-client</artifactId>
<artifactId>quarkus-test-kubernetes-client</artifactId>
<scope>test</scope>
</dependency>
----

[source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"]
.build.gradle
----
testImplementation("io.quarkus:quarkus-test-openshift-client")
testImplementation("io.quarkus:quarkus-test-kubernetes-client")
----

== Configuration Reference
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.quarkus.it.openshift.client;

import static org.assertj.core.api.Assertions.assertThat;

import jakarta.inject.Inject;

import org.junit.jupiter.api.Test;

import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.dsl.NonDeletingOperation;
import io.fabric8.kubernetes.client.server.mock.KubernetesServer;
import io.fabric8.openshift.api.model.RouteBuilder;
import io.fabric8.openshift.client.OpenShiftClient;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.kubernetes.client.KubernetesTestServer;
import io.quarkus.test.kubernetes.client.WithKubernetesTestServer;

@WithKubernetesTestServer
@QuarkusTest
public class KubernetesTestServerTest {

@KubernetesTestServer
KubernetesServer mockServer;
@Inject
KubernetesClient kubernetesClient;
@Inject
OpenShiftClient openShiftClient;

@Test
public void clientsInjectedWithValidConfiguration() {
assertThat(kubernetesClient)
.isSameAs(openShiftClient)
.extracting(c -> c.getConfiguration().getMasterUrl())
.isEqualTo(mockServer.getKubernetesMockServer().url("/"));
}

@Test
public void openShiftClientInjectionWorks() throws InterruptedException {
openShiftClient.routes().resource(
new RouteBuilder()
.withNewMetadata().withName("the-route").endMetadata()
.withNewSpec().withHost("example.com").endSpec()
.build())
.createOr(NonDeletingOperation::update);
assertThat(mockServer.getLastRequest().getPath())
.isEqualTo("/apis/route.openshift.io/v1/namespaces/test/routes");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@
import org.junit.jupiter.api.Test;

import io.fabric8.kubernetes.api.model.PodListBuilder;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import io.fabric8.kubernetes.client.server.mock.KubernetesServer;
import io.fabric8.openshift.api.model.Route;
import io.fabric8.openshift.api.model.RouteBuilder;
import io.fabric8.openshift.client.NamespacedOpenShiftClient;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.kubernetes.client.KubernetesMockServerTestResource;
import io.quarkus.test.kubernetes.client.MockServer;
import io.quarkus.test.kubernetes.client.KubernetesTestServer;
import io.quarkus.test.kubernetes.client.WithKubernetesTestServer;
import io.restassured.RestAssured;

@QuarkusTestResource(KubernetesMockServerTestResource.class)
@WithKubernetesTestServer
@QuarkusTest
public class OpenShiftClientTest {

@MockServer
private KubernetesMockServer mockServer;
@KubernetesTestServer
KubernetesServer mockServer;

@Test
void createRoute() {
Expand All @@ -36,9 +35,10 @@ void createRoute() {
.andReturn(200, expectedRoute)
.once();

NamespacedOpenShiftClient openShiftClient = mockServer.createClient().adapt(NamespacedOpenShiftClient.class);
NamespacedOpenShiftClient openShiftClient = mockServer.getClient().adapt(NamespacedOpenShiftClient.class);
openShiftClient.routes()
.create(new RouteBuilder().withNewMetadata().withName("myroute").withNamespace("test").endMetadata().build());
.resource(new RouteBuilder().withNewMetadata().withName("myroute").withNamespace("test").endMetadata().build())
.create();
Route route = openShiftClient.routes().inNamespace("test").withName("myroute").get();
Assertions.assertNotNull(route);
}
Expand Down
Loading