use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumStarterRemoteProxyTest method containerIsStartedWhenNegativeResolutionIsProvidedUsingDefaults.
@Test
public void containerIsStartedWhenNegativeResolutionIsProvidedUsingDefaults() {
// Supported desired capability for the test session
Map<String, Object> supportedCapability = new HashMap<>();
supportedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
supportedCapability.put(CapabilityType.PLATFORM_NAME, Platform.ANY);
supportedCapability.put("resolution", "-1300x800");
TestSession testSession = spyProxy.getNewSession(supportedCapability);
Assert.assertNull(testSession);
verify(spyProxy, timeout(1000).times(1)).startDockerSeleniumContainer(timeZone, screenSize);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumStarterRemoteProxyTest method containerIsStartedWhenAnInvalidResolutionIsProvidedUsingDefaults.
@Test
public void containerIsStartedWhenAnInvalidResolutionIsProvidedUsingDefaults() {
// Supported desired capability for the test session
Map<String, Object> supportedCapability = new HashMap<>();
supportedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
supportedCapability.put(CapabilityType.PLATFORM_NAME, Platform.ANY);
supportedCapability.put("screenResolution", "notAValidScreenResolution");
TestSession testSession = spyProxy.getNewSession(supportedCapability);
Assert.assertNull(testSession);
verify(spyProxy, timeout(1000).times(1)).startDockerSeleniumContainer(timeZone, screenSize);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumStarterRemoteProxyTest method containerIsStartedForRequestProcessedMoreThan30Times.
@Test
public void containerIsStartedForRequestProcessedMoreThan30Times() {
Map<String, Object> requestedCapability = new HashMap<>();
requestedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.FIREFOX);
requestedCapability.put(CapabilityType.PLATFORM_NAME, Platform.LINUX);
ProcessedCapabilities processedCapabilities = new ProcessedCapabilities(requestedCapability, System.identityHashCode(requestedCapability));
processedCapabilities.setProcessedTimes(31);
DockerSeleniumStarterRemoteProxy.processedCapabilitiesList.add(processedCapabilities);
TestSession testSession = spyProxy.getNewSession(requestedCapability);
Assert.assertNull(testSession);
verify(spyProxy, timeout(1000).atLeastOnce()).startDockerSeleniumContainer(timeZone, screenSize);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class SauceLabsRemoteProxyTest method testInformationIsRetrievedWhenStoppingSession.
@Test
public void testInformationIsRetrievedWhenStoppingSession() throws IOException {
try {
// Capability which should result in a created session
Map<String, Object> requestedCapability = new HashMap<>();
requestedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
requestedCapability.put(CapabilityType.PLATFORM_NAME, Platform.MAC);
// Getting a test session in the sauce labs node
SauceLabsRemoteProxy sauceLabsSpyProxy = spy(sauceLabsProxy);
JsonElement informationSample = TestUtils.getTestInformationSample("saucelabs_testinformation.json");
CommonProxyUtilities commonProxyUtilities = mock(CommonProxyUtilities.class);
when(commonProxyUtilities.readJSONFromUrl(anyString(), anyString(), anyString())).thenReturn(informationSample);
doCallRealMethod().when(commonProxyUtilities).convertFlvFileToMP4(any(TestInformation.class));
SauceLabsRemoteProxy.setCommonProxyUtilities(commonProxyUtilities);
TestSession testSession = sauceLabsSpyProxy.getNewSession(requestedCapability);
Assert.assertNotNull(testSession);
String mockSeleniumSessionId = "72e4f8ecf04440fe965faf657864ed52";
testSession.setExternalKey(new ExternalSessionKey(mockSeleniumSessionId));
// We release the session, the node should be free
WebDriverRequest request = mock(WebDriverRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
when(request.getMethod()).thenReturn("DELETE");
when(request.getRequestType()).thenReturn(RequestType.STOP_SESSION);
testSession.getSlot().doFinishRelease();
sauceLabsSpyProxy.afterCommand(testSession, request, response);
verify(sauceLabsSpyProxy, timeout(1000 * 5)).getTestInformation(mockSeleniumSessionId);
TestInformation testInformation = sauceLabsSpyProxy.getTestInformation(mockSeleniumSessionId);
Assert.assertEquals(mockSeleniumSessionId, testInformation.getTestName());
Assert.assertThat(testInformation.getFileName(), CoreMatchers.containsString("saucelabs_72e4f8ecf04440fe965faf657864ed52_googlechrome_Windows_2008"));
Assert.assertEquals("googlechrome 56, Windows 2008", testInformation.getBrowserAndPlatform());
Assert.assertThat(testInformation.getVideoUrl(), CoreMatchers.containsString("jobs/72e4f8ecf04440fe965faf657864ed52/assets/video.flv"));
} finally {
SauceLabsRemoteProxy.restoreCommonProxyUtilities();
}
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class SauceLabsRemoteProxyTest method slotIsReleasedWhenTestIsIdle.
@Test
public void slotIsReleasedWhenTestIsIdle() throws IOException {
// Supported desired capability for the test session
Map<String, Object> requestedCapability = new HashMap<>();
requestedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.SAFARI);
requestedCapability.put(CapabilityType.PLATFORM_NAME, Platform.MAC);
SauceLabsRemoteProxy sauceLabsSpyProxy = spy(sauceLabsProxy);
// Set a short idle time
sauceLabsSpyProxy.setMaxTestIdleTime(1L);
// Start poller thread
sauceLabsSpyProxy.startPolling();
// Get a test session
TestSession newSession = sauceLabsSpyProxy.getNewSession(requestedCapability);
Assert.assertNotNull(newSession);
newSession.setExternalKey(new ExternalSessionKey("RANDOM_EXTERNAL_KEY"));
// Start the session
WebDriverRequest request = TestUtils.getMockedWebDriverRequestStartSession(BrowserType.SAFARI, Platform.MAC);
HttpServletResponse response = mock(HttpServletResponse.class);
ServletOutputStream stream = mock(ServletOutputStream.class);
when(response.getOutputStream()).thenReturn(stream);
sauceLabsSpyProxy.beforeCommand(newSession, request, response);
// The terminateIdleSessions() method should be called after a moment
verify(sauceLabsSpyProxy, timeout(2000)).terminateIdleSessions();
verify(sauceLabsSpyProxy, timeout(2000)).addTestToDashboard("RANDOM_EXTERNAL_KEY", false);
}
Aggregations