Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
}