From 7f2c142834cf4ec243bea1d5d80cf6ca60b1f949 Mon Sep 17 00:00:00 2001 From: Skorik Sergey Date: Fri, 4 Oct 2019 15:25:45 +0300 Subject: [PATCH] adapt RecreateUpdateStrategyTest test to work with Che7 workspaces --- .../recreate/RecreateUpdateStrategyTest.java | 84 ++++++++++++------- 1 file changed, 54 insertions(+), 30 deletions(-) diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/recreate/RecreateUpdateStrategyTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/recreate/RecreateUpdateStrategyTest.java index cb8f7b08cb6..2e677cd2d8c 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/recreate/RecreateUpdateStrategyTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/recreate/RecreateUpdateStrategyTest.java @@ -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 void checkRecreateUpdateStrategy() throws Exception { // 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); } }