-
Notifications
You must be signed in to change notification settings - Fork 4
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
Service integration #7
base: master
Are you sure you want to change the base?
Service integration #7
Conversation
-PodWaitLogStrategy timeout strikes even if no logs lines are received -Pods are also removed even if waitStrategy runs into timeout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @LarsAndereggIMS,
Thanks a lot for your contribution 💯 !
Could you describe me your use case and what you are trying to achieve by adding the possibility to create a service in the tests ? Until now my approach was to create a service automatically for each pod referenced in a test and I would like to see how it complements with your suggested approach.
I didn't yet manage to test your modifications but gave you an early review on some area we likely would want to improve. Please feel free to tell me if you have some time to look into this or else I could manage to work a bit on this in next week end.
Additionally to those comments you may want to check why the build failed (https://github.com/JeanBaptisteWATENBERG/junit5-kubernetes/runs/2169846205#step:6:71) and add some test to cover the service feature. Also adding a sample in the readme to document it would be great.
Thank you,
Jean-Baptiste
if (retrievedService.getStatus() == null) { | ||
throw new RuntimeException("Can't get ip of a non running object."); | ||
} | ||
//Anhand der Umgebungsvariable entscheiden, ob der Test im Cluster oder lokal ausgeführt wird |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//Anhand der Umgebungsvariable entscheiden, ob der Test im Cluster oder lokal ausgeführt wird | |
//Use the environment variable to decide whether to run the test in the cluster or locally |
private static CoreV1Api initiateCoreV1Api() { | ||
CoreV1Api coreV1Api; | ||
try { | ||
ApiClient client = Config.defaultClient(); | ||
if (DEBUG != null && DEBUG.equalsIgnoreCase("true")) { | ||
client.setDebugging(true); | ||
} | ||
// infinite timeout | ||
OkHttpClient.Builder builder = client.getHttpClient().newBuilder() | ||
.readTimeout(0, TimeUnit.SECONDS); | ||
|
||
if (DISABLE_HTTP2 != null && DISABLE_HTTP2.equalsIgnoreCase("true")) { | ||
builder.protocols(Collections.singletonList(Protocol.HTTP_1_1)); | ||
} | ||
|
||
client.setVerifyingSsl(false); | ||
|
||
OkHttpClient httpClient = builder.build(); | ||
client.setHttpClient(httpClient); | ||
Configuration.setDefaultApiClient(client); | ||
|
||
coreV1Api = new CoreV1Api(client); | ||
|
||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
return coreV1Api; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to factorize this client initiation in kubernetesGenericObject
to avoid duplicating it from Pod.java
.
if(System.getenv("KUBERNETES_PORT") != null) { | ||
return retrievedService.getSpec().getClusterIP(); | ||
}else{ | ||
return retrievedService.getSpec().getExternalIPs().get(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In some clusters a service may not have any externalIps
and under those circumstances I think we should raise an exception with an explicit message.
} | ||
|
||
if (!serviceSuccessfullyStarted) { | ||
throw new RuntimeException("Failed to run pod " + this + " before timeout " + this.getTimeout()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new RuntimeException("Failed to run pod " + this + " before timeout " + this.getTimeout()); | |
throw new RuntimeException("Failed to run service " + this + " before timeout " + this.getTimeout()); |
protected static RuntimeException logAndThrowApiException(ApiException e) { | ||
LOGGER.severe("Kubernetes API replied with " + e.getCode() + " status code and body " + e.getResponseBody()); | ||
System.out.println("Kubernetes API replied with " + e.getCode() + " status code and body " + e.getResponseBody()); | ||
return new RuntimeException(e.getResponseBody(), e); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we should factorize this as well in the abstract class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for your quick response! Hopefully this week I will find some time to look closer at your Points.
I needed to create a more specific service for the pods. Instead of extending the service config over a pod, I thougth making an explictit service would be clearer.
Best regards
Lars
-integration of kubernetes Service
-PodWaitLogStrategy timeout strikes even if no logs lines are received
-Pods are also removed even if waitStrategy runs into timeout