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

Add the test for checking inactive workspace #9171

Merged
merged 12 commits into from
Mar 28, 2018
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.selenium.workspaces;

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.eclipse.che.api.core.model.workspace.WorkspaceStatus.*;
import static org.eclipse.che.selenium.core.utils.WaitUtils.sleepQuietly;
import static org.testng.AssertJUnit.assertEquals;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it exactly what you want to add? Maybe "org.testng.Assert"?

import com.google.inject.Inject;
import javax.inject.Named;
import org.eclipse.che.api.core.model.workspace.Workspace;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.user.TestUser;
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.ToastLoader;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class CheckStoppingWsByTimeoutTest {

private static int TOASTLOADER_WIDGET_LATENCY_TIMEOUT_IN_MILLISEC = 20000;
@Inject private Ide ide;
@Inject private ProjectExplorer projectExplorer;
@Inject private ToastLoader toastLoader;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private TestWorkspace testWorkspace;
@Inject private TestUser testUser;

@Inject
@Named("che.workspace_agent_dev_inactive_stop_timeout_ms")
private int cheWorkspaceAgentDevInactiveStopTimeoutMilliseconds;

@Inject
@Named("che.workspace.activity_check_scheduler_period_s")
private int cheWorkspaceActivityCheckSchedulerPeriodInSeconds;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Request"

@BeforeClass
public void setUp() throws Exception {
ide.open(testWorkspace);
projectExplorer.waitProjectExplorer();
// We should invoke delay without any action for triggering workspace activity checker
sleepQuietly(getCommonTimeout(), MILLISECONDS);
}

@Test
public void checkStoppingByApi() throws Exception {
Workspace workspace =
workspaceServiceClient.getByName(
testWorkspace.getName(), testUser.getName(), testUser.getAuthToken());
assertEquals(workspace.getStatus(), STOPPED);
}

@Test
public void checkLoadToasterAfterStopping() {
toastLoader.waitStartButtonInToastLoader();
}

private int getCommonTimeout() {
return cheWorkspaceAgentDevInactiveStopTimeoutMilliseconds
+ TOASTLOADER_WIDGET_LATENCY_TIMEOUT_IN_MILLISEC
+ cheWorkspaceActivityCheckSchedulerPeriodInSeconds * 1000;
Copy link
Contributor

@dmytro-ndp dmytro-ndp Mar 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to point millisecond unit of time measurement in the method name: getCommonTimeoutInMillisec

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ tests.screenshots_dir=target/screenshots
tests.htmldumps_dir=target/htmldumps
tests.workspacelogs_dir=target/workspace-logs
tests.webdriverlogs_dir=target/webdriver-logs
che.workspace_agent_dev_inactive_stop_timeout_ms=300000
che.workspace.activity_check_scheduler_period_s=60

# Workspace default size
workspace.default_memory_gb=2
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
<class name="org.eclipse.che.selenium.workspaces.WorkingWithJavaMySqlStackTest"/>
<class name="org.eclipse.che.selenium.workspaces.WorkingWithNodeWsTest"/>
<class name="org.eclipse.che.selenium.workspaces.WorkspaceFromOfficialUbuntuImageStartTest"/>
<class name="org.eclipse.che.selenium.workspaces.CheckStoppingWsByTimeoutTest"/>
<class name="org.eclipse.che.selenium.dashboard.AccountTest"/>
</classes>
</test>
Expand Down