Skip to content

Connection closed when using mock server #7086

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

Open
ruiarodrigues opened this issue May 23, 2025 · 4 comments
Open

Connection closed when using mock server #7086

ruiarodrigues opened this issue May 23, 2025 · 4 comments
Labels
component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly Waiting on feedback Issues that require feedback from User/Other community members

Comments

@ruiarodrigues
Copy link

Describe the bug

Hi!
I'm upgrade from 6.x to 7.3.1 and my tests fail with connection closed when the first request to the server is done. Everything works fine with 6.x. See the steps to reproduce the error.

Fabric8 Kubernetes Client version

7.3.1

Steps to reproduce

Run this

import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.PodBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import org.junit.jupiter.api.Test;

@EnableKubernetesMockClient
class SomeTest {

    KubernetesMockServer server;
    KubernetesClient client;

    @Test
    void myTest() {
        server.expect().get()
            .withPath("/api/v1/namespaces/my-namespace/pods/my-pod")
            .andReturn(200, new PodBuilder().build())
            .always();
        Pod pod = client.pods().inNamespace("my-namespace").withName("my-pod").get();
    }
}

Expected behavior

Tests should pass after the upograde

Runtime

Kubernetes (vanilla)

Kubernetes API Server version

1.33

Environment

macOS

Fabric8 Kubernetes Client Logs

INFO: MockWebServer[51150] starting to accept connections on localhost
May 23, 2025 3:43:37 PM io.fabric8.mockwebserver.MockWebServer info
INFO: MockWebServer[51150] done accepting connections

Connection was closed
io.fabric8.kubernetes.client.KubernetesClientException: Connection was closed
	at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.waitForResult(OperationSupport.java:509)
	at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.handleResponse(OperationSupport.java:524)
	at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.handleGet(OperationSupport.java:467)
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.handleGet(BaseOperation.java:792)
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.requireFromServer(BaseOperation.java:193)
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.get(BaseOperation.java:149)
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.get(BaseOperation.java:98)
	at fi.relex.processor2.adapter.SomeTest.myTest(SomeTest.java:38)

Additional context

I have as dependencies. Maybe something is missing?

kubernetes-client-bom = { module = "io.fabric8:kubernetes-client-bom", version = "7.3.1" }

implementation("io.fabric8:kubernetes-client")

@manusa
Copy link
Member

manusa commented May 26, 2025

Seems like the exact same issue as #6847

Unfortunately, there's no way we can reproduce this, most of our tests are based in the mock server and work just fine.

Would you be able to provide a reproducer project?

@manusa manusa added Waiting on feedback Issues that require feedback from User/Other community members component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly labels May 26, 2025
@ruiarodrigues
Copy link
Author

Hi! I will try to reproduce in a smaller project. The project is large and have ,a lot of submodules. OkHttp is being used in the project. Can this have some side effect since now vertx is used for the mock server?

@manusa
Copy link
Member

manusa commented May 29, 2025

OkHttp is being used in the project. Can this have some side effect since now vertx is used for the mock server?

It shouldn't have to be related to that.
However, this is probably the only notable difference with our main test suite, so it might be a possible cause.

@ruiarodrigues
Copy link
Author

ruiarodrigues commented May 29, 2025

I'm not able to reproduce it in a simple project until now :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly Waiting on feedback Issues that require feedback from User/Other community members
Projects
None yet
Development

No branches or pull requests

2 participants