KubernetesMockServer not serving some URL

10/8/2019

I am trying to test an application in Quarkus which uses CustomResourcesDefinitions, to so I'm trying to setup the mockServer, on the @BeforeEach annotated method I have added 2 URLs to the mock one for retrieving the list of CRDs and other for retrieving a secret in a given namespace:

final Secret s1 = new Secret("v1",data,"Secret",metadata,null,"opaque");
final CustomResourceDefinitionList crdl = new CustomResourceDefinitionList("apiextensions.k8s.io/v1beta1",null,"CustomResourceDefinitionList",null);
mockServer.expect().get().withPath("/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions").andReturn(200, crdl).always();
mockServer.expect().get().withPath("/api/v1/namespaces/projectname/secrets/tokenname").andReturn(200, s1).always();

But when running the tests, while it is able to get the secret it is always failing to get the CRD list:

2019-10-08 12:14:52,456 INFO [okh.moc.MockWebServer] (MockWebServer /127.0.0.1:65227) MockWebServer[65217] received request: GET /apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions HTTP/1.1 and responded: HTTP/1.1 404 Client Error

Taking a look to source code of KubernetesMockServer seems like it will request only accept request when the start with "/api" or "/apis/extensions" (getRootPaths method). Perhaps can be this the reason?

-- alphamikevictor
fabric8
kubernetes
kubernetes-custom-resources
quarkus
unit-testing

0 Answers