[Selenium] Adapt selenium test from hotupdate.recreate package (#14777)

7.20.x
Sergey Skorik 2019-10-04 16:59:35 +03:00 committed by GitHub
parent 6889118aa2
commit 597cde950d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 54 additions and 30 deletions

View File

@ -11,60 +11,80 @@
*/
package org.eclipse.che.selenium.hotupdate.recreate;
import static org.eclipse.che.commons.lang.NameGenerator.generate;
import static org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage.Template.CONSOLE_JAVA_SIMPLE;
import com.google.inject.Inject;
import java.io.IOException;
import java.util.Collections;
import org.eclipse.che.api.system.shared.SystemStatus;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.TestGroup;
import org.eclipse.che.selenium.core.client.CheTestSystemClient;
import org.eclipse.che.selenium.core.executor.OpenShiftCliCommandExecutor;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.executor.hotupdate.HotUpdateUtil;
import org.eclipse.che.selenium.core.requestfactory.CheTestAdminHttpJsonRequestFactory;
import org.eclipse.che.selenium.core.utils.process.ProcessAgent;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.pageobject.CheTerminal;
import org.eclipse.che.selenium.pageobject.Ide;
import org.eclipse.che.selenium.pageobject.Menu;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.core.user.DefaultTestUser;
import org.eclipse.che.selenium.pageobject.dashboard.CreateWorkspaceHelper;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Devfile;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces.Status;
import org.eclipse.che.selenium.pageobject.theia.TheiaIde;
import org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test(groups = {TestGroup.OPENSHIFT, TestGroup.K8S, TestGroup.MULTIUSER})
public class RecreateUpdateStrategyTest {
@Inject CheTestAdminHttpJsonRequestFactory testUserHttpJsonRequestFactory;
@Inject CheTestSystemClient cheTestSystemClient;
@Inject ProjectExplorer projectExplorer;
@Inject OpenShiftCliCommandExecutor openShiftCliCommandExecutor;
@Inject private ProcessAgent processAgent;
@Inject private TestWorkspace workspace;
@Inject private Ide ide;
@Inject private SeleniumWebDriver seleniumWebDriver;
@Inject private CheTerminal terminal;
@Inject private Menu menu;
private static final String WORKSPACE_NAME =
generate(RecreateUpdateStrategyTest.class.getSimpleName(), 5);
@Inject private CheTestSystemClient cheTestSystemClient;
@Inject private HotUpdateUtil hotUpdateUtil;
@Inject private Dashboard dashboard;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private CreateWorkspaceHelper createWorkspaceHelper;
@Inject private TheiaIde theiaIde;
@Inject private TheiaProjectTree theiaProjectTree;
@Inject private DefaultTestUser defaultTestUser;
@Inject private Workspaces workspaces;
private int cheDeploymentBeforeRollout;
@BeforeClass
public void setUp() throws IOException {
public void setUp() throws Exception {
cheDeploymentBeforeRollout = hotUpdateUtil.getMasterPodRevision();
dashboard.open();
createWorkspaceHelper.createAndStartWorkspaceFromStack(
Devfile.JAVA_MAVEN, WORKSPACE_NAME, Collections.emptyList(), null);
}
@AfterClass
public void tearDown() throws Exception {
workspaceServiceClient.delete(WORKSPACE_NAME, defaultTestUser.getName());
}
@Test
public void checkRecreateUpdateStrategy() throws Exception {
int requestAttempts = 100;
int requestTimeoutInSec = 6;
// open a user workspace and send request for preparing to shutdown
ide.open(workspace);
theiaIde.waitOpenedWorkspaceIsReadyToUse();
theiaProjectTree.waitFilesTab();
theiaProjectTree.clickOnFilesTab();
theiaProjectTree.waitProjectAreaOpened();
theiaProjectTree.waitItem(CONSOLE_JAVA_SIMPLE);
theiaIde.waitAllNotificationsClosed();
cheTestSystemClient.stop();
// reopen the workspace and make sure that this one is not available after suspending system
ide.open(workspace);
projectExplorer.waitProjectExplorerDisappearance(requestTimeoutInSec);
terminal.waitTerminalIsNotPresent(requestTimeoutInSec);
// open the Dashboard and make sure that workspace is not available after suspending system
dashboard.open();
dashboard.waitDashboardToolbarTitle();
dashboard.selectWorkspacesItemOnDashboard();
Assert.assertFalse(dashboard.isWorkspacePresentedInRecentList(WORKSPACE_NAME));
// performs rollout
hotUpdateUtil.executeMasterPodUpdateCommand();
@ -74,8 +94,12 @@ public class RecreateUpdateStrategyTest {
// After rollout updating - deployment should be increased on 1
hotUpdateUtil.waitMasterPodRevision(cheDeploymentBeforeRollout + 1);
// make sure that CHE ide is available after updating again
ide.open(workspace);
ide.waitOpenedWorkspaceIsReadyToUse();
// make sure that workspace exists in workspaces list after updating again
dashboard.open();
dashboard.waitDashboardToolbarTitle();
dashboard.selectWorkspacesItemOnDashboard();
dashboard.waitToolbarTitleName("Workspaces");
workspaces.waitWorkspaceIsPresent(WORKSPACE_NAME);
workspaces.waitWorkspaceStatus(WORKSPACE_NAME, Status.RUNNING);
}
}