You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At present, submarine's tests on k8s services are mainly in submarine-k8s packages. Because k8s service is a complex service composition, it is difficult to write unit tests of many k8s related functions (like submarine-server-submitter package) in a simple way.
I think that since most of the methods in submarine-server-submitter package are processed by k8s API similar to CRUD, it should be necessary to keep/create enough test cases to test and verify these methods. I have just search some k8s client related test cases informations. In fact, I think the main problem is how to support a mock server, so that we can break away from the constraints of k8s and write test cases freely.
I think in this issue kubernetes-client/java#1842 we can get some inspiration. Most of k8s apis can simulate the return messages based on the http request, so we can refer to the methods mentioned in it to change the existing test cases.
Mock Client and Server
I've write a test case about how to test k8s client by a mock client and server (WireMockRule). The core of the whole test case is to use fake message to response the client request.
It refers to k8s java official test case
When we add a new test case, we can first confirm the response information (usually the JSON information of the resource) according to the resources we need, and then define and register the URL, RequestMethod, ResponseCode and ResponseBody into WireMockRule.
The text was updated successfully, but these errors were encountered:
At present, submarine's tests on k8s services are mainly in
submarine-k8s
packages. Because k8s service is a complex service composition, it is difficult to write unit tests of many k8s related functions (likesubmarine-server-submitter
package) in a simple way.I think that since most of the methods in
submarine-server-submitter
package are processed by k8s API similar to CRUD, it should be necessary to keep/create enough test cases to test and verify these methods. I have just search some k8s client related test cases informations. In fact, I think the main problem is how to support a mock server, so that we can break away from the constraints of k8s and write test cases freely.I think in this issue kubernetes-client/java#1842 we can get some inspiration. Most of k8s apis can simulate the return messages based on the http request, so we can refer to the methods mentioned in it to change the existing test cases.
Mock Client and Server
I've write a test case about how to test k8s client by a mock client and server (WireMockRule). The core of the whole test case is to use fake message to response the client request.
It refers to k8s java official test case
The following codes can be found in https://github.com/shangyuantech/submarine/blob/SUBMARINE-1174/submarine-server/server-submitter/submitter-k8s/src/test/java/org/apache/submarine/server/submitter/k8s/SubmitterK8sMockApiTest.java
In this case, I create a
K8sMockClient
. In this class I did some initialization of URL and WireMockRule for the client.The following codes can be found in https://github.com/shangyuantech/submarine/blob/SUBMARINE-1174/submarine-server/server-submitter/submitter-k8s/src/test/java/org/apache/submarine/server/submitter/k8s/client/K8sMockClient.java
When we add a new test case, we can first confirm the response information (usually the JSON information of the resource) according to the resources we need, and then define and register the URL, RequestMethod, ResponseCode and ResponseBody into WireMockRule.
The text was updated successfully, but these errors were encountered: