diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/executor/hotupdate/HotUpdateUtil.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/executor/hotupdate/HotUpdateUtil.java index 0d29d898764..b46238a5eb8 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/executor/hotupdate/HotUpdateUtil.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/executor/hotupdate/HotUpdateUtil.java @@ -36,9 +36,9 @@ public class HotUpdateUtil { private static final int DELAY_BETWEEN_ATTEMPTS_IN_MILLISECS = 5000; private static final String PODS_LIST_COMMAND = "get pods | awk 'NR > 1 {print $1}'"; private static final String COMMAND_TO_GET_REVISION_OF_CHE_DEPLOYMENT = - "get dc | grep che | awk '{print $2}'"; + "get dc che | awk 'NR==2{print $2}'"; private static final String COMMAND_TO_GET_NAME_OF_CHE_DEPLOYMENT = - "get dc | grep che | awk '{print $1}'"; + "get dc che | awk 'NR==2{print $1}'"; private static final String UPDATE_COMMAND_TEMPLATE = "rollout latest %s"; protected final OpenShiftCliCommandExecutor openShiftCliCommandExecutor; diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/workspaces/Workspaces.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/workspaces/Workspaces.java index b864f875a83..57a82aa858d 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/workspaces/Workspaces.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/workspaces/Workspaces.java @@ -12,11 +12,11 @@ package org.eclipse.che.selenium.pageobject.dashboard.workspaces; import static java.lang.String.format; +import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.APPLICATION_START_TIMEOUT_SEC; import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.ELEMENT_TIMEOUT_SEC; import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.EXPECTED_MESS_IN_CONSOLE_SEC; import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOADER_TIMEOUT_SEC; import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOAD_PAGE_TIMEOUT_SEC; -import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.PREPARING_WS_TIMEOUT_SEC; import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.REDRAW_UI_ELEMENTS_TIMEOUT_SEC; import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces.Locators.ERROR_NOTIFICATION_MESSAGE_XPATH; import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces.Locators.PROGRESS_BAR_XPATH; @@ -139,7 +139,7 @@ public String getWorkspaceStatus(String workspaceName) { public void waitWorkspaceStatus(String workspaceName, String workspaceStatus) { // we need long timeout for OCP - new WebDriverWait(seleniumWebDriver, PREPARING_WS_TIMEOUT_SEC) + new WebDriverWait(seleniumWebDriver, APPLICATION_START_TIMEOUT_SEC) .until( new ExpectedCondition() { @Override diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/rolling/RollingUpdateStrategyWithEditorTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/rolling/RollingUpdateStrategyWithEditorTest.java index 2ec17b2184c..8a4b8d43b90 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/rolling/RollingUpdateStrategyWithEditorTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/rolling/RollingUpdateStrategyWithEditorTest.java @@ -11,57 +11,66 @@ */ package org.eclipse.che.selenium.hotupdate.rolling; -import static org.eclipse.che.selenium.core.project.ProjectTemplates.MAVEN_SPRING; +import static org.eclipse.che.commons.lang.NameGenerator.generate; +import static org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage.Template.CONSOLE_JAVA_SIMPLE; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import com.google.inject.Inject; -import java.nio.file.Path; -import java.nio.file.Paths; +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.client.CheTestSystemClient; -import org.eclipse.che.selenium.core.client.TestProjectServiceClient; import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient; import org.eclipse.che.selenium.core.executor.hotupdate.HotUpdateUtil; import org.eclipse.che.selenium.core.user.DefaultTestUser; -import org.eclipse.che.selenium.core.workspace.TestWorkspace; -import org.eclipse.che.selenium.pageobject.Ide; -import org.eclipse.che.selenium.pageobject.ProjectExplorer; +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.theia.TheiaIde; +import org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** @author Ihor Okhrimenko */ public class RollingUpdateStrategyWithEditorTest { - private static final int RESTORE_IDE_AFTER_REFRESH_TIMEOUT = 10; - private static final String PROJECT_NAME = "default-spring-project"; + private static final String WORKSPACE_NAME = + generate(RollingUpdateStrategyWithEditorTest.class.getSimpleName(), 5); - @Inject private ProjectExplorer projectExplorer; - @Inject private Ide ide; - @Inject private TestWorkspace workspace; - @Inject private TestProjectServiceClient testProjectServiceClient; @Inject private CheTestSystemClient cheTestSystemClient; @Inject private TestWorkspaceServiceClient testWorkspaceServiceClient; @Inject private SeleniumWebDriver seleniumWebDriver; @Inject private DefaultTestUser defaultTestUser; @Inject private HotUpdateUtil hotUpdateUtil; + @Inject private Dashboard dashboard; + @Inject private TestWorkspaceServiceClient workspaceServiceClient; + @Inject private CreateWorkspaceHelper createWorkspaceHelper; + @Inject private TheiaIde theiaIde; + @Inject private TheiaProjectTree theiaProjectTree; @BeforeClass - public void prepare() throws Exception { - Path pathToProject = - Paths.get(getClass().getResource("/projects/default-spring-project").toURI()); + public void setUp() throws Exception { + dashboard.open(); + createWorkspaceHelper.createAndStartWorkspaceFromStack( + Devfile.JAVA_MAVEN, WORKSPACE_NAME, Collections.emptyList(), null); + } - testProjectServiceClient.importProject( - workspace.getId(), pathToProject, PROJECT_NAME, MAVEN_SPRING); + @AfterClass + public void tearDown() throws Exception { + workspaceServiceClient.delete(WORKSPACE_NAME, defaultTestUser.getName()); } @Test public void shouldUpdateMasterByRollingStrategyWithAccessibleEditorInProcess() throws Exception { - // prepare int currentRevision = hotUpdateUtil.getMasterPodRevision(); - ide.open(workspace); - projectExplorer.waitProjectExplorer(); - projectExplorer.waitItem(PROJECT_NAME); + theiaIde.waitOpenedWorkspaceIsReadyToUse(); + + theiaProjectTree.waitFilesTab(); + theiaProjectTree.clickOnFilesTab(); + theiaProjectTree.waitProjectAreaOpened(); + theiaProjectTree.waitItem(CONSOLE_JAVA_SIMPLE); + theiaIde.waitAllNotificationsClosed(); // check that master is running assertEquals(cheTestSystemClient.getStatus(), SystemStatus.RUNNING); @@ -75,17 +84,14 @@ public void shouldUpdateMasterByRollingStrategyWithAccessibleEditorInProcess() t hotUpdateUtil.waitFullMasterPodUpdate(currentRevision); // check that workspace is successfully migrated to the new master - assertTrue(testWorkspaceServiceClient.exists(workspace.getName(), defaultTestUser.getName())); + assertTrue(testWorkspaceServiceClient.exists(WORKSPACE_NAME, defaultTestUser.getName())); checkIdeAvailability(); } private void checkIdeAvailability() { hotUpdateUtil.checkMasterPodAvailabilityByPreferencesRequest(); - seleniumWebDriver.navigate().refresh(); - - projectExplorer.waitProjectExplorer(RESTORE_IDE_AFTER_REFRESH_TIMEOUT); - projectExplorer.waitItem(PROJECT_NAME); + theiaIde.waitOpenedWorkspaceIsReadyToUse(); } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/rolling/RollingUpdateStrategyWithStartedWorkspaceTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/rolling/RollingUpdateStrategyWithStartedWorkspaceTest.java index a172ee55dab..c226584f02f 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/rolling/RollingUpdateStrategyWithStartedWorkspaceTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/rolling/RollingUpdateStrategyWithStartedWorkspaceTest.java @@ -11,15 +11,25 @@ */ package org.eclipse.che.selenium.hotupdate.rolling; +import static org.eclipse.che.commons.lang.NameGenerator.generate; +import static org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage.Template.CONSOLE_JAVA_SIMPLE; import static org.testng.Assert.assertEquals; import com.google.inject.Inject; +import java.util.Collections; import org.eclipse.che.api.system.shared.SystemStatus; import org.eclipse.che.selenium.core.client.CheTestSystemClient; +import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient; import org.eclipse.che.selenium.core.executor.hotupdate.HotUpdateUtil; -import org.eclipse.che.selenium.core.workspace.TestWorkspace; +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.theia.TheiaIde; +import org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /* @@ -35,35 +45,60 @@ /** @author Katerina Kanova */ public class RollingUpdateStrategyWithStartedWorkspaceTest { + private static final String WORKSPACE_NAME = + generate(RollingUpdateStrategyWithStartedWorkspaceTest.class.getSimpleName(), 5); - @Inject private TestWorkspace workspaceForStopping; @Inject private CheTestSystemClient cheTestSystemClient; @Inject private Dashboard dashboard; @Inject private Workspaces workspaces; @Inject private HotUpdateUtil hotUpdateUtil; + @Inject private DefaultTestUser defaultTestUser; + @Inject private TestWorkspaceServiceClient workspaceServiceClient; + @Inject private CreateWorkspaceHelper createWorkspaceHelper; + @Inject private TheiaIde theiaIde; + @Inject private TheiaProjectTree theiaProjectTree; + + @BeforeClass + public void setUp() throws Exception { + 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 startStopWorkspaceFunctionsShouldBeAvailableDuringRollingUpdate() throws Exception { int currentRevision = hotUpdateUtil.getMasterPodRevision(); + theiaIde.waitOpenedWorkspaceIsReadyToUse(); + + theiaProjectTree.waitFilesTab(); + theiaProjectTree.clickOnFilesTab(); + theiaProjectTree.waitProjectAreaOpened(); + theiaProjectTree.waitItem(CONSOLE_JAVA_SIMPLE); + theiaIde.waitAllNotificationsClosed(); - // open 'Workspaces' page dashboard.open(); dashboard.waitDashboardToolbarTitle(); dashboard.selectWorkspacesItemOnDashboard(); + dashboard.waitToolbarTitleName("Workspaces"); // check existing of expected workspace and its status workspaces.waitPageLoading(); - workspaces.waitWorkspaceIsPresent(workspaceForStopping.getName()); - workspaces.waitWorkspaceStatus(workspaceForStopping.getName(), Workspaces.Status.RUNNING); + workspaces.waitWorkspaceIsPresent(WORKSPACE_NAME); + workspaces.waitWorkspaceStatus(WORKSPACE_NAME, Workspaces.Status.RUNNING); hotUpdateUtil.executeMasterPodUpdateCommand(); - // check that che is updated + // check that Che is updated hotUpdateUtil.waitMasterPodRevision(currentRevision + 1); hotUpdateUtil.waitFullMasterPodUpdate(currentRevision); assertEquals(cheTestSystemClient.getStatus(), SystemStatus.RUNNING); - workspaces.waitWorkspaceIsPresent(workspaceForStopping.getName()); - workspaces.waitWorkspaceStatus(workspaceForStopping.getName(), Workspaces.Status.RUNNING); + workspaces.waitWorkspaceIsPresent(WORKSPACE_NAME); + workspaces.waitWorkspaceStatus(WORKSPACE_NAME, Workspaces.Status.RUNNING); } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/rolling/RollingUpdateStrategyWithWorkspacesStartStopTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/rolling/RollingUpdateStrategyWithWorkspacesStartStopTest.java index 587d4e61b4a..7957b2aa4d2 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/rolling/RollingUpdateStrategyWithWorkspacesStartStopTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/hotupdate/rolling/RollingUpdateStrategyWithWorkspacesStartStopTest.java @@ -11,56 +11,93 @@ */ package org.eclipse.che.selenium.hotupdate.rolling; +import static org.eclipse.che.commons.lang.NameGenerator.generate; +import static org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage.Template.CONSOLE_JAVA_SIMPLE; import static org.testng.Assert.assertEquals; import com.google.inject.Inject; +import java.util.Collections; import org.eclipse.che.api.system.shared.SystemStatus; import org.eclipse.che.selenium.core.client.CheTestSystemClient; +import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient; import org.eclipse.che.selenium.core.executor.hotupdate.HotUpdateUtil; -import org.eclipse.che.selenium.core.workspace.InjectTestWorkspace; -import org.eclipse.che.selenium.core.workspace.TestWorkspace; +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.theia.TheiaIde; +import org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** @author Ihor Okhrimenko */ public class RollingUpdateStrategyWithWorkspacesStartStopTest { - @InjectTestWorkspace(startAfterCreation = false) - private TestWorkspace workspaceForStarting; + private static final String STARTED_WORKSPACE_NAME = + generate(RollingUpdateStrategyWithWorkspacesStartStopTest.class.getSimpleName(), 5); + private static final String STOPPED_WORKSPACE_NAME = + generate(RollingUpdateStrategyWithWorkspacesStartStopTest.class.getSimpleName(), 5); - @Inject private TestWorkspace workspaceForStopping; @Inject private CheTestSystemClient cheTestSystemClient; @Inject private Dashboard dashboard; @Inject private Workspaces workspaces; @Inject private HotUpdateUtil hotUpdateUtil; + @Inject private TestWorkspaceServiceClient workspaceServiceClient; + @Inject private CreateWorkspaceHelper createWorkspaceHelper; + @Inject private TheiaIde theiaIde; + @Inject private TheiaProjectTree theiaProjectTree; + @Inject private DefaultTestUser defaultTestUser; + + @BeforeClass + public void setUp() throws Exception { + dashboard.open(); + createWorkspaceHelper.createAndEditWorkspaceFromStack( + Devfile.JAVA_MAVEN, STARTED_WORKSPACE_NAME, Collections.emptyList(), null); + dashboard.open(); + createWorkspaceHelper.createAndStartWorkspaceFromStack( + Devfile.JAVA_MAVEN, STOPPED_WORKSPACE_NAME, Collections.emptyList(), null); + } + + @AfterClass + public void tearDown() throws Exception { + workspaceServiceClient.delete(STARTED_WORKSPACE_NAME, defaultTestUser.getName()); + workspaceServiceClient.delete(STOPPED_WORKSPACE_NAME, defaultTestUser.getName()); + } @Test public void startStopWorkspaceFunctionsShouldBeAvailableDuringRollingUpdate() throws Exception { int currentRevision = hotUpdateUtil.getMasterPodRevision(); + theiaIde.waitOpenedWorkspaceIsReadyToUse(); + + theiaProjectTree.waitFilesTab(); + theiaProjectTree.clickOnFilesTab(); + theiaProjectTree.waitProjectAreaOpened(); + theiaProjectTree.waitItem(CONSOLE_JAVA_SIMPLE); + theiaIde.waitAllNotificationsClosed(); - // open 'Workspaces' page dashboard.open(); dashboard.waitDashboardToolbarTitle(); dashboard.selectWorkspacesItemOnDashboard(); // check existing of expected workspaces and their statuses workspaces.waitPageLoading(); - workspaces.waitWorkspaceIsPresent(workspaceForStopping.getName()); - workspaces.waitWorkspaceIsPresent(workspaceForStarting.getName()); - workspaces.waitWorkspaceStatus(workspaceForStopping.getName(), Workspaces.Status.RUNNING); - workspaces.waitWorkspaceStatus(workspaceForStarting.getName(), Workspaces.Status.STOPPED); + workspaces.waitWorkspaceIsPresent(STOPPED_WORKSPACE_NAME); + workspaces.waitWorkspaceIsPresent(STARTED_WORKSPACE_NAME); + workspaces.waitWorkspaceStatus(STOPPED_WORKSPACE_NAME, Workspaces.Status.RUNNING); + workspaces.waitWorkspaceStatus(STARTED_WORKSPACE_NAME, Workspaces.Status.STOPPED); hotUpdateUtil.executeMasterPodUpdateCommand(); // execute stop-start commands for existing workspaces assertEquals(cheTestSystemClient.getStatus(), SystemStatus.RUNNING); - workspaces.clickOnWorkspaceStopStartButton(workspaceForStarting.getName()); - workspaces.clickOnWorkspaceStopStartButton(workspaceForStopping.getName()); + workspaces.clickOnWorkspaceStopStartButton(STOPPED_WORKSPACE_NAME); + workspaces.clickOnWorkspaceStopStartButton(STARTED_WORKSPACE_NAME); // wait successful results of the stop-start requests - workspaces.waitWorkspaceStatus(workspaceForStopping.getName(), Workspaces.Status.STOPPED); - workspaces.waitWorkspaceStatus(workspaceForStarting.getName(), Workspaces.Status.RUNNING); + workspaces.waitWorkspaceStatus(STOPPED_WORKSPACE_NAME, Workspaces.Status.STOPPED); + workspaces.waitWorkspaceStatus(STARTED_WORKSPACE_NAME, Workspaces.Status.RUNNING); // check that che is updated hotUpdateUtil.waitMasterPodRevision(currentRevision + 1);