Implement test for covering rollout update CHE with Recreate strategy#10091
Implement test for covering rollout update CHE with Recreate strategy#10091dmytro-ndp merged 25 commits intomasterfrom
Conversation
|
|
||
| private int cheDeploymentBeforeRollout; | ||
|
|
||
| private enum WsMasterStauses { |
| String restUrlForSuspendingWorkspaces = | ||
| cheTestApiEndpointUrlProvider.get().toString() + "system/stop"; | ||
| int timeLimitInSecForRecreateingUpdate = 600; | ||
| int delayBetweenRequest = 6; |
| import org.testng.annotations.Test; | ||
|
|
||
| @Test(groups = {TestGroup.OSIO, TestGroup.MULTIUSER}) | ||
| public class RecreateUpdate { |
There was a problem hiding this comment.
RecreateUpdate > RecreateUpdateStrategyTest
| import org.testng.annotations.BeforeClass; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| @Test(groups = {TestGroup.OSIO, TestGroup.MULTIUSER}) |
There was a problem hiding this comment.
TestGroup.OSIO is for ospenshift.io specific tests, whereas this test is OpenShift specific one.
| String ocClientRolloutCommand = "rollout latest che"; | ||
| String restUrlForSuspendingWorkspaces = | ||
| cheTestApiEndpointUrlProvider.get().toString() + "system/stop"; | ||
| int timeLimitInSecForRecreateingUpdate = 600; |
There was a problem hiding this comment.
Please, check on grammar errors carefully.
| waitProjectExplorer(EXPECTED_MESS_IN_CONSOLE_SEC); | ||
| } | ||
|
|
||
| public void waitProjectExplorerIsNotPresent(int timeout) { |
There was a problem hiding this comment.
What about "waitProjectExplorerDisappearance()"?
| public void checkRecreateUpdateStrategy() throws Exception { | ||
| String ocClientRolloutCommand = "rollout latest che"; | ||
| String restUrlForSuspendingWorkspaces = | ||
| cheTestApiEndpointUrlProvider.get().toString() + "system/stop"; |
There was a problem hiding this comment.
I would suggest to extract system-specific methods to the separate class with name like org.eclipse.che.selenium.core.client.CheTestSystemClient
|
|
||
| private int cheDeploymentBeforeRollout; | ||
|
|
||
| private enum WsMasterStauses { |
There was a problem hiding this comment.
It looks like useful common enum and maybe it should be stored separately or in related page object.
There was a problem hiding this comment.
This enum describes statuses of ws-master on OpenShift . On this moment this one is used in this place. But is we will need this one for other tests, of course we should store this into separate class.
| parseInt(openShiftCliCommandExecutor.execute(COMMAND_FOR_GETTING_CURRENT_DEPLOYMENT_CHE)); | ||
| // After rollout updating - deployment should be increased on 1. So we previews version +1 | ||
| // should be equal current | ||
| assertEquals(cheDeploymentAfterRollout, cheDeploymentBeforeRollout += 1); |
There was a problem hiding this comment.
cheDeploymentBeforeRollout += 1 > cheDeploymentBeforeRollout + 1
|
|
||
| // get current response code - if system is suspended, we will get IO exception from the | ||
| // server. This mean that we have suspended status | ||
| try { |
There was a problem hiding this comment.
I would suggest to extract system-specific methods to the separate class with name like org.eclipse.che.selenium.core.client.CheTestSystemClient
| parseInt(openShiftCliCommandExecutor.execute(COMMAND_FOR_GETTING_CURRENT_DEPLOYMENT_CHE)); | ||
| // After rollout updating - deployment should be increased on 1. So we previews version +1 | ||
| // should be equal current | ||
| assertEquals(cheDeploymentAfterRollout, cheDeploymentBeforeRollout += 1); |
There was a problem hiding this comment.
I think "+=" it is redundant
this condition means: cheDeploymentBeforeRollout = cheDeploymentBeforeRollout + 1
but in my opinion in this case "cheDeploymentBeforeRollout + 1" is enough.
| // open a user workspace and send request for preparing to shutdown | ||
| ide.open(workspace); | ||
|
|
||
| testUserHttpJsonRequestFactory |
There was a problem hiding this comment.
In my opinion, incapsulating to the method looks more clear.
Something like:
private void prepareToShutdownRequest(){
String restUrlForSuspendingWorkspaces = cheTestApiEndpointUrlProvider.get().toString() + "system/stop";
testUserHttpJsonRequestFactory
.fromUrl(restUrlForSuspendingWorkspaces)
.usePostMethod()
.request();
}
| // performs rollout | ||
| openShiftCliCommandExecutor.execute(ocClientRolloutCommand); | ||
| waitOpenShiftStatus( | ||
| timeLimitInSecForRecreateingUpdate, delayBetweenRequest, WsMasterStauses.RUNNING); |
There was a problem hiding this comment.
In all occurrences of this method changes only "WsMasterStauses" argument, so you can rid of extra arguments and left only "WsMasterStauses".
| throws Exception { | ||
|
|
||
| // if the limit is not exceeded - do request and check status of the system | ||
| while (maxTimeLimitInSec > 0) { |
There was a problem hiding this comment.
It could be simplified as follow:
private void waitWorkspaceMasterStatus(int maxReadStatusAttempts, int readStatusTimeoutInSec, WsMasterStatus expectedStatus) throws Exception {
int readStatusAttempts = maxReadStatusAttempts;
while (readStatusAttempts-- > 0) {
if (getCurrentRollingStatus().equals(expectedStatus.toString())) {
return;
}
WaitUtils.sleepQuietly(readStatusTimeoutInSec);
}
throw new IOException(String.format("Workspace Master hasn't achieved status '%s' in '%' seconds.", status, maxReadStatusAttempts * readStatusTimeoutInSec));
}
Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
|
ci-test |
|
ci-test build report: |
| timeLimitForReadyToShutdownStatus, delayBetweenRequestes, READY_TO_SHUTDOWN); | ||
| } | ||
|
|
||
| public String getCurrentState() throws Exception { |
There was a problem hiding this comment.
If we return type of WorkspaceMasterStatus here, it can avoid redundant calling of status.toString() method.
Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
…eclipse-che#10091) Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
What does this PR do?
What issues does this PR fix or reference?
#9646