Skip to content

Implement test for covering rollout update CHE with Recreate strategy#10091

Merged
dmytro-ndp merged 25 commits intomasterfrom
9646
Jun 19, 2018
Merged

Implement test for covering rollout update CHE with Recreate strategy#10091
dmytro-ndp merged 25 commits intomasterfrom
9646

Conversation

@musienko-maxim
Copy link
Copy Markdown
Contributor

@musienko-maxim musienko-maxim commented Jun 18, 2018

What does this PR do?

  • This Pr implement next scenario:
  • Create a workspace
  • Send REST request under admin for suspending WS-master
  • Check that suspend passed properly (validate PREPARING_TO_SHUTDOWN, READY_TO_SHUTDOWN statuses and unavailability the user workspace through UI )
  • Perform rollout update and wait for RUNNING status of master
  • Check that deployment version has been incremented properly
  • Check availability the workspace for user through UI

What issues does this PR fix or reference?

#9646

@benoitf benoitf added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. kind/task Internal things, technical debt, and to-do tasks to be performed. labels Jun 18, 2018

private int cheDeploymentBeforeRollout;

private enum WsMasterStauses {
Copy link
Copy Markdown
Contributor

@dmytro-ndp dmytro-ndp Jun 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stauses > Status

String restUrlForSuspendingWorkspaces =
cheTestApiEndpointUrlProvider.get().toString() + "system/stop";
int timeLimitInSecForRecreateingUpdate = 600;
int delayBetweenRequest = 6;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request > Requests

import org.testng.annotations.Test;

@Test(groups = {TestGroup.OSIO, TestGroup.MULTIUSER})
public class RecreateUpdate {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RecreateUpdate > RecreateUpdateStrategyTest

import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

@Test(groups = {TestGroup.OSIO, TestGroup.MULTIUSER})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, check on grammar errors carefully.

waitProjectExplorer(EXPECTED_MESS_IN_CONSOLE_SEC);
}

public void waitProjectExplorerIsNotPresent(int timeout) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about "waitProjectExplorerDisappearance()"?

public void checkRecreateUpdateStrategy() throws Exception {
String ocClientRolloutCommand = "rollout latest che";
String restUrlForSuspendingWorkspaces =
cheTestApiEndpointUrlProvider.get().toString() + "system/stop";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like useful common enum and maybe it should be stored separately or in related page object.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Contributor

@dmytro-ndp dmytro-ndp Jun 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

@Ohrimenko1988 Ohrimenko1988 Jun 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Contributor

@dmytro-ndp dmytro-ndp Jun 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));
}

@dmytro-ndp
Copy link
Copy Markdown
Contributor

ci-test

@codenvy-ci
Copy link
Copy Markdown

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:10091
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

timeLimitForReadyToShutdownStatus, delayBetweenRequestes, READY_TO_SHUTDOWN);
}

public String getCurrentState() throws Exception {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we return type of WorkspaceMasterStatus here, it can avoid redundant calling of status.toString() method.

Dmytro Nochevnov added 2 commits June 19, 2018 14:48
Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
@dmytro-ndp dmytro-ndp merged commit 70bcc8b into master Jun 19, 2018
@dmytro-ndp dmytro-ndp deleted the 9646 branch June 19, 2018 12:16
@dmytro-ndp dmytro-ndp removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Jun 19, 2018
@dmytro-ndp dmytro-ndp added this to the 6.7.0 milestone Jun 19, 2018
hbhargav pushed a commit to hbhargav/che that referenced this pull request Dec 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/task Internal things, technical debt, and to-do tasks to be performed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants