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

Reworks CheckWsAgentAfterStopProcessTest test #6445

Merged
merged 5 commits into from
Sep 27, 2017
Merged
Show file tree
Hide file tree
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 @@ -10,17 +10,22 @@
*/
package org.eclipse.che.selenium.miscellaneous;

import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOAD_PAGE_TIMEOUT_SEC;
import static org.eclipse.che.api.core.model.workspace.WorkspaceStatus.RUNNING;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.REDRAW_UI_ELEMENTS_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.WIDGET_TIMEOUT_SEC;

import com.google.inject.Inject;
import java.net.URL;
import java.nio.file.Paths;
import org.eclipse.che.commons.lang.NameGenerator;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.client.TestCommandServiceClient;
import org.eclipse.che.selenium.core.client.TestProjectServiceClient;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.constant.TestCommandsConstants;
import org.eclipse.che.selenium.core.constant.TestWorkspaceConstants;
import org.eclipse.che.selenium.core.project.ProjectTemplates;
import org.eclipse.che.selenium.core.user.DefaultTestUser;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.pageobject.Events;
import org.eclipse.che.selenium.pageobject.Ide;
Expand All @@ -37,19 +42,22 @@
*
* @author Musienko Maxim
*/
public class CheckWsAgentAfterStopProcessTest {
private static final String PROJECT_NAME = CheckWsAgentAfterStopProcessTest.class.getSimpleName();
public class CheckRestoringWorkspaceAfterStoppingWsAgentProcess {
private static final String PROJECT_NAME = NameGenerator.generate("project", 4);
private static final String nameCommandForKillWsAgent = "killWsAgent";
private static final String killPIDWSAgentCommand =
"kill -9 $(ps ax | grep java | grep ws-agent | grep conf | grep -v grep | awk '{print $1}')";

@Inject private TestWorkspace workspace;
@Inject private DefaultTestUser defaultTestUser;
@Inject private Ide ide;
@Inject private ProjectExplorer projectExplorer;
@Inject private Events events;
@Inject private ToastLoader toastLoader;
@Inject private TestCommandServiceClient testCommandServiceClient;
@Inject private TestProjectServiceClient testProjectServiceClient;
@Inject private TestWorkspaceServiceClient testWorkspaceServiceClient;
@Inject private SeleniumWebDriver seleniumWebDriver;

@BeforeClass
public void setUp() throws Exception {
Expand All @@ -58,7 +66,7 @@ public void setUp() throws Exception {
workspace.getId(),
Paths.get(resource.toURI()),
PROJECT_NAME,
ProjectTemplates.MAVEN_SPRING.toString());
ProjectTemplates.MAVEN_SPRING);
testCommandServiceClient.createCommand(
killPIDWSAgentCommand,
nameCommandForKillWsAgent,
Expand All @@ -67,21 +75,26 @@ public void setUp() throws Exception {
ide.open(workspace);
}

@Test
public void checkDialogAfterKillingProcess() throws Exception {
@Test(priority = 0)
public void checkRestoreWsAgentByApi() throws Exception {
String expectedMessageOInDialog =
"Workspace agent is no longer responding. To fix the problem, restart the workspace.";
projectExplorer.waitItem(PROJECT_NAME);
toastLoader.waitAppeareanceAndClosing();
projectExplorer.invokeCommandWithContextMenu(
ProjectExplorer.CommandsGoal.COMMON, PROJECT_NAME, nameCommandForKillWsAgent);
new WebDriverWait(ide.driver(), LOAD_PAGE_TIMEOUT_SEC * 3)
new WebDriverWait(seleniumWebDriver, WIDGET_TIMEOUT_SEC)
.until(
ExpectedConditions.visibilityOfElementLocated(
By.xpath("//span[text()='" + expectedMessageOInDialog + "']")));
new WebDriverWait(ide.driver(), REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(ExpectedConditions.visibilityOfElementLocated(By.id("ask-dialog-first")))
.click();
testWorkspaceServiceClient.waitStatus(workspace.getName(), defaultTestUser.getName(), RUNNING);
}

@Test(priority = 1)
public void checkRestoreIdeItems() {
projectExplorer.waitItem(PROJECT_NAME);
events.clickProjectEventsTab();
events.waitExpectedMessage(TestWorkspaceConstants.RUNNING_WORKSPACE_MESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@
<exclude name="checkMacrosFeature"/>
</methods>
</class>
<class name="org.eclipse.che.selenium.miscellaneous.CheckWsAgentAfterStopProcessTest">
<class name="org.eclipse.che.selenium.miscellaneous.CheckRestoringWorkspaceAfterStoppingWsAgentProcess">
<methods>
<!-- unstable -->
<exclude name="checkDialogAfterKillingProcess"/>
Expand Down