use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumRemoteProxyTest method testIdleTimeoutUsesValuePassedAsCapability.
@Test
public void testIdleTimeoutUsesValuePassedAsCapability() {
Map<String, Object> requestedCapability = getCapabilitySupportedByDockerSelenium();
requestedCapability.put("zal:idleTimeout", 180L);
TestSession newSession = proxy.getNewSession(requestedCapability);
Assert.assertNotNull(newSession);
Assert.assertEquals(180L, proxy.getMaxTestIdleTimeSecs());
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumRemoteProxyTest method testIdleTimeoutUsesDefaultValueWhenCapabilityIsNotPresent.
@Test
public void testIdleTimeoutUsesDefaultValueWhenCapabilityIsNotPresent() {
Map<String, Object> requestedCapability = getCapabilitySupportedByDockerSelenium();
TestSession newSession = proxy.getNewSession(requestedCapability);
Assert.assertNotNull(newSession);
Assert.assertEquals(proxy.getMaxTestIdleTimeSecs(), DockerSeleniumRemoteProxy.DEFAULT_MAX_TEST_IDLE_TIME_SECS);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumRemoteProxyTest method videoRecordingIsStartedAndStopped.
@Test
public void videoRecordingIsStartedAndStopped() throws MalformedObjectNameException, IOException {
try {
// Create a docker-selenium container
RegistrationRequest request = TestUtils.getRegistrationRequestForTesting(30000, DockerSeleniumStarterRemoteProxy.class.getCanonicalName());
DockerSeleniumStarterRemoteProxy dsProxy = new DockerSeleniumStarterRemoteProxy(request, registry);
DockerSeleniumStarterRemoteProxy.setMaxDockerSeleniumContainers(1);
DockerSeleniumStarterRemoteProxy.setConfiguredScreenSize(DockerSeleniumStarterRemoteProxy.DEFAULT_SCREEN_SIZE);
DockerSeleniumStarterRemoteProxy.setContainerClient(containerClient);
dsProxy.getNewSession(getCapabilitySupportedByDockerSelenium());
CommonProxyUtilities commonProxyUtilities = TestUtils.mockCommonProxyUtilitiesForDashboardTesting(temporaryFolder);
TestUtils.ensureRequiredInputFilesExist(temporaryFolder);
Dashboard.setCommonProxyUtilities(commonProxyUtilities);
// Creating a spy proxy to verify the invoked methods
DockerSeleniumRemoteProxy spyProxy = spy(proxy);
// Start pulling thread
spyProxy.startPolling();
// Get a test session
TestSession newSession = spyProxy.getNewSession(getCapabilitySupportedByDockerSelenium());
newSession.setExternalKey(new ExternalSessionKey("DockerSeleniumRemoteProxy Test"));
Assert.assertNotNull(newSession);
// We start the session, in order to start recording
WebDriverRequest webDriverRequest = mock(WebDriverRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
when(webDriverRequest.getMethod()).thenReturn("POST");
when(webDriverRequest.getRequestType()).thenReturn(RequestType.START_SESSION);
spyProxy.afterCommand(newSession, webDriverRequest, response);
// Assert video recording started
String containerId = spyProxy.getContainerId();
verify(spyProxy, times(1)).videoRecording(DockerSeleniumRemoteProxy.DockerSeleniumContainerAction.START_RECORDING);
verify(spyProxy, times(1)).processContainerAction(DockerSeleniumRemoteProxy.DockerSeleniumContainerAction.START_RECORDING, containerId);
// We release the sessions, the node should be free
webDriverRequest = mock(WebDriverRequest.class);
response = mock(HttpServletResponse.class);
when(webDriverRequest.getMethod()).thenReturn("DELETE");
when(webDriverRequest.getRequestType()).thenReturn(RequestType.STOP_SESSION);
newSession.getSlot().doFinishRelease();
spyProxy.afterCommand(newSession, webDriverRequest, response);
spyProxy.afterSession(newSession);
Assert.assertFalse(spyProxy.isBusy());
verify(spyProxy, timeout(40000)).videoRecording(DockerSeleniumRemoteProxy.DockerSeleniumContainerAction.STOP_RECORDING);
verify(spyProxy, timeout(40000)).processContainerAction(DockerSeleniumRemoteProxy.DockerSeleniumContainerAction.STOP_RECORDING, containerId);
verify(spyProxy, timeout(40000)).copyVideos(containerId);
} finally {
ObjectName objectName = new ObjectName("org.seleniumhq.grid:type=RemoteProxy,node=\"http://localhost:30000\"");
new JMXHelper().unregister(objectName);
Dashboard.restoreCommonProxyUtilities();
}
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumRemoteProxyTest method sessionGetsCreatedEvenIfCapabilitiesAreNull.
@Test
public void sessionGetsCreatedEvenIfCapabilitiesAreNull() {
// Supported desired capability for the test session
Map<String, Object> requestedCapability = getCapabilitySupportedByDockerSelenium();
requestedCapability.put("name", null);
requestedCapability.put("build", null);
requestedCapability.put("version", null);
TestSession newSession = proxy.getNewSession(requestedCapability);
Assert.assertNotNull(newSession);
Assert.assertTrue(proxy.getTestBuild().isEmpty());
Assert.assertEquals(newSession.getInternalKey(), proxy.getTestName());
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumRemoteProxyTest method normalSessionCommandsDoNotStopNode.
@Test
public void normalSessionCommandsDoNotStopNode() {
// Supported desired capability for the test session
Map<String, Object> requestedCapability = getCapabilitySupportedByDockerSelenium();
// Start polling thread
proxy.startPolling();
// Get a test session
TestSession newSession = proxy.getNewSession(requestedCapability);
Assert.assertNotNull(newSession);
// The node should be busy since there is a session in it
Assert.assertTrue(proxy.isBusy());
// We release the session, the node should be free
WebDriverRequest request = mock(WebDriverRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
when(request.getMethod()).thenReturn("POST");
when(request.getRequestType()).thenReturn(RequestType.REGULAR);
proxy.afterCommand(newSession, request, response);
// The node should not tear down
Assert.assertTrue(proxy.isBusy());
Callable<Boolean> callable = () -> !proxy.isDown();
await().pollInterval(Duration.FIVE_HUNDRED_MILLISECONDS).atMost(Duration.TWO_SECONDS).until(callable);
}
Aggregations