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.
In my test I need to scale down (0) some pods (like postgresql or other) to test the behavior of my application when infrastructure is in failure.
Currently, the scale method use the applicationName used to deploy an application in the OpenShiftAssistant.
So I have tried to inject multiple OpenShiftAssistant in my test (using @ArquillianResource) and deploy for each OpenShiftAssistant the application and next call on the desired one the scale method. However it doesn't worked because the same object is injected. So the applicationName used by the scale method refer to the last application launched.
A workaround is to define this method in test:
public void scale(final int replicas, final String applicationName) {
final OpenShiftClient client = openShiftAssistant.getClient();
final String namespace = client.getNamespace();
client
.deploymentConfigs()
.inNamespace(namespace)
.withName(applicationName)
.scale(replicas);
// ideally, we'd look at deployment config's status.availableReplicas field,
// but that's only available since OpenShift 3.5
await().atMost(5, TimeUnit.MINUTES)
.until(() -> {
final List<Pod> pods = client
.pods()
.inNamespace(namespace)
.withLabel("deploymentconfig", applicationName)
.list()
.getItems();
try {
return pods.size() == replicas && pods.stream()
.allMatch(Readiness::isPodReady);
} catch (final IllegalStateException e) {
// the 'Ready' condition can be missing sometimes, in which case Readiness.isPodReady throws an exception
// here, we'll swallow that exception in hope that the 'Ready' condition will appear later
return false;
}
});
}
So I guess, the better way would be to add in OpenShiftAssistant and KubernetesAssistant this kind of method:
public void scale(final int replicas, final String applicationName) {
...
}
Regards,
Damien
The text was updated successfully, but these errors were encountered:
In my test I need to scale down (0) some pods (like postgresql or other) to test the behavior of my application when infrastructure is in failure.
Currently, the scale method use the applicationName used to deploy an application in the OpenShiftAssistant.
So I have tried to inject multiple OpenShiftAssistant in my test (using @ArquillianResource) and deploy for each OpenShiftAssistant the application and next call on the desired one the scale method. However it doesn't worked because the same object is injected. So the applicationName used by the scale method refer to the last application launched.
A workaround is to define this method in test:
So I guess, the better way would be to add in OpenShiftAssistant and KubernetesAssistant this kind of method:
Regards,
Damien
The text was updated successfully, but these errors were encountered: