List of usage examples for org.openqa.selenium Platform LINUX
Platform LINUX
To view the source code for org.openqa.selenium Platform LINUX.
Click Source Link
From source file:com.rmn.qa.AutomationRunRequestTest.java
License:Open Source License
@Test // Tests that a platform of 'ANY' matches another otherwise non-matching OS public void testOsMatchesAnyCapability() { String uuid = "testUuid"; String browser = "firefox"; String browserVersion = "25"; Platform os = Platform.ANY;/*from w w w . jav a 2 s.c o m*/ Map<String, Object> capabilities = new HashMap<>(); capabilities.put(CapabilityType.BROWSER_NAME, browser); capabilities.put(CapabilityType.VERSION, browserVersion); capabilities.put(CapabilityType.PLATFORM, os.toString()); AutomationRunRequest first = new AutomationRunRequest(uuid, null, browser, browserVersion, Platform.LINUX); Assert.assertTrue("Requests should be equal", first.matchesCapabilities(capabilities)); }
From source file:com.rmn.qa.aws.VmManagerTest.java
License:Open Source License
@Test // Test that the correct node config file is generated for a linux os public void testGetNodeConfigLinux() { MockManageVm manageEC2 = new MockManageVm(null, null, null); String uuid = "uuid", hostName = "hostName", browser = "chrome"; Platform os = Platform.LINUX; int maxSessions = 5; String nodeConfig = manageEC2.getNodeConfig(uuid, hostName, browser, os, maxSessions); Assert.assertTrue("Max sessions should have been passed in", nodeConfig.contains(String.valueOf(maxSessions))); Assert.assertTrue("UUID should have been passed in", nodeConfig.contains(uuid)); Assert.assertTrue("Browser should have been passed in", nodeConfig.contains(browser)); Assert.assertTrue("OS should have been passed in", nodeConfig.contains(os.toString())); Assert.assertTrue("Host name should have been passed in", nodeConfig.contains(hostName)); Assert.assertTrue("IE thread count should have been passed in", nodeConfig.contains(String.valueOf(AwsVmManager.CHROME_THREAD_COUNT))); }
From source file:com.rmn.qa.aws.VmManagerTest.java
License:Open Source License
@Test // Tests that if no fallback subnets are specified, the correct exception is thrown public void testSubnetNoFallBack() throws NodesCouldNotBeStartedException { MockAmazonEc2Client client = new MockAmazonEc2Client(null); AmazonServiceException exception = new AmazonServiceException("message"); exception.setErrorCode("InsufficientInstanceCapacity"); client.setThrowDescribeInstancesError(exception); RunInstancesResult runInstancesResult = new RunInstancesResult(); Reservation reservation = new Reservation(); reservation.setInstances(Arrays.asList(new Instance())); runInstancesResult.setReservation(reservation); client.setRunInstances(runInstancesResult); Properties properties = new Properties(); String region = "east", uuid = "uuid", browser = "chrome"; Platform os = Platform.LINUX; Integer threadCount = 5, maxSessions = 5; MockManageVm manageEC2 = new MockManageVm(client, properties, region); String userData = "userData"; String securityGroup = "securityGroup", subnetId = "subnetId", keyName = "keyName", windowsImage = "windowsImage"; properties.setProperty(region + "_security_group", securityGroup); properties.setProperty(region + "_subnet_id", subnetId); properties.setProperty(region + "_key_name", keyName); properties.setProperty(region + "_windows_node_ami", windowsImage); manageEC2.setUserData(userData);/*from w w w . j a v a2 s.c om*/ try { manageEC2.launchNodes(uuid, os, browser, null, threadCount, maxSessions); } catch (NodesCouldNotBeStartedException e) { Assert.assertTrue("Failure message should be correct", e.getMessage() .contains("Sufficient resources were not available in any of the availability zones")); return; } Assert.fail("Call should fail due to insufficient resources"); }
From source file:com.rmn.qa.aws.VmManagerTest.java
License:Open Source License
@Test // Test that if a fallback subnet is specified, that the request for new nodes will fallback successfully and nodes will be spun up public void testSubnetFallsBackSuccessfully() throws NodesCouldNotBeStartedException { MockAmazonEc2Client client = new MockAmazonEc2Client(null); AmazonServiceException exception = new AmazonServiceException("message"); exception.setErrorCode("InsufficientInstanceCapacity"); client.setThrowDescribeInstancesError(exception); RunInstancesResult runInstancesResult = new RunInstancesResult(); Reservation reservation = new Reservation(); reservation.setInstances(Arrays.asList(new Instance())); runInstancesResult.setReservation(reservation); client.setRunInstances(runInstancesResult); Properties properties = new Properties(); String region = "east", uuid = "uuid", browser = "chrome"; Platform os = Platform.LINUX; Integer threadCount = 5, maxSessions = 5; MockManageVm manageEC2 = new MockManageVm(client, properties, region); String userData = "userData"; String securityGroup = "securityGroup", subnetId = "subnetId", keyName = "keyName", windowsImage = "windowsImage", fallBackSubnet = "fallback"; properties.setProperty(region + "_security_group", securityGroup); properties.setProperty(region + "_subnet_id", subnetId); properties.setProperty(region + "_subnet_fallback_id_1", fallBackSubnet); properties.setProperty(region + "_key_name", keyName); properties.setProperty(region + "_windows_node_ami", windowsImage); manageEC2.setUserData(userData);/*from w w w .ja v a 2 s . c om*/ List<Instance> instances = manageEC2.launchNodes(uuid, os, browser, null, threadCount, maxSessions); System.out.print(""); }
From source file:com.rmn.qa.aws.VmManagerTest.java
License:Open Source License
@Test // Tests that if the client fails for an error other than insufficient capacity, subnet fallback logic is not performed public void testSubnetFallBackUnknownError() throws NodesCouldNotBeStartedException { MockAmazonEc2Client client = new MockAmazonEc2Client(null); AmazonServiceException exception = new AmazonServiceException("message"); client.setThrowDescribeInstancesError(exception); RunInstancesResult runInstancesResult = new RunInstancesResult(); Reservation reservation = new Reservation(); reservation.setInstances(Arrays.asList(new Instance())); runInstancesResult.setReservation(reservation); client.setRunInstances(runInstancesResult); Properties properties = new Properties(); String region = "east", uuid = "uuid", browser = "chrome"; Platform os = Platform.LINUX; Integer threadCount = 5, maxSessions = 5; MockManageVm manageEC2 = new MockManageVm(client, properties, region); String userData = "userData"; String securityGroup = "securityGroup", subnetId = "subnetId", keyName = "keyName", windowsImage = "windowsImage"; properties.setProperty(region + "_security_group", securityGroup); properties.setProperty(region + "_subnet_id", subnetId); properties.setProperty(region + "_key_name", keyName); properties.setProperty(region + "_windows_node_ami", windowsImage); manageEC2.setUserData(userData);/*from w w w .j a v a2s . c o m*/ try { manageEC2.launchNodes(uuid, os, browser, null, threadCount, maxSessions); } catch (AmazonServiceException e) { Assert.assertEquals("Exception should be the same", exception, e); return; } Assert.fail("Call should fail due to other AWS error"); }
From source file:com.rmn.qa.aws.VmManagerTest.java
License:Open Source License
@Test // Tests that the built in guard against an infinite loop in the fallback recursive logic has a working safeguard public void testSubnetInfiniteLoop() throws NodesCouldNotBeStartedException { MockAmazonEc2Client client = new MockAmazonEc2Client(null); client.setThrowExceptionsInRunInstancesIndefinitely(); AmazonServiceException exception = new AmazonServiceException("message"); exception.setErrorCode("InsufficientInstanceCapacity"); client.setThrowDescribeInstancesError(exception); RunInstancesResult runInstancesResult = new RunInstancesResult(); Reservation reservation = new Reservation(); reservation.setInstances(Arrays.asList(new Instance())); runInstancesResult.setReservation(reservation); client.setRunInstances(runInstancesResult); Properties properties = new Properties(); String region = "east", uuid = "uuid", browser = "chrome"; Platform os = Platform.LINUX; Integer threadCount = 5, maxSessions = 5; MockManageVm manageEC2 = new MockManageVm(client, properties, region); String userData = "userData"; String securityGroup = "securityGroup", subnetId = "subnetId", keyName = "keyName", windowsImage = "windowsImage"; properties.setProperty(region + "_security_group", securityGroup); properties.setProperty(region + "_subnet_id", subnetId); properties.setProperty(region + "_subnet_fallback_id_1", "foo"); properties.setProperty(region + "_subnet_fallback_id_2", "foo"); properties.setProperty(region + "_subnet_fallback_id_3", "foo"); properties.setProperty(region + "_subnet_fallback_id_4", "foo"); properties.setProperty(region + "_subnet_fallback_id_5", "foo"); properties.setProperty(region + "_subnet_fallback_id_6", "foo"); properties.setProperty(region + "_key_name", keyName); properties.setProperty(region + "_windows_node_ami", windowsImage); manageEC2.setUserData(userData);// w w w . j a v a 2 s .c om try { manageEC2.launchNodes(uuid, os, browser, null, threadCount, maxSessions); } catch (NodesCouldNotBeStartedException e) { Assert.assertTrue("Failure message should be correct", e.getMessage() .contains("Sufficient resources were not available in any of the availability zones")); return; } Assert.fail("Call should fail due to insufficient resources"); }
From source file:com.rmn.qa.servlet.AutomationTestRunServletTest.java
License:Open Source License
@Test // Tests a request can be fulfilled when chrome nodes have to be spun up public void testRequestCanFulfillSpinUpNodesChrome() throws IOException, ServletException { MockVmManager manageEc2 = new MockVmManager(); MockRequestMatcher matcher = new MockRequestMatcher(); matcher.setThreadsToReturn(0);/*from ww w . java 2s. c om*/ MockAutomationTestRunServlet servlet = new MockAutomationTestRunServlet(null, false, manageEc2, matcher); MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter("uuid", "testUuid"); request.setParameter("browser", "chrome"); request.setParameter("os", Platform.LINUX.toString()); request.setParameter("threadCount", "7"); String nodeId = "nodeId"; // Add a node that is not running to make sure its not included in the available calculation AutomationDynamicNode node = new AutomationDynamicNode("testUuid", nodeId, null, null, new Date(), 50); AutomationContext.getContext().addNode(node); ProxySet proxySet = new ProxySet(false); MockRemoteProxy proxy = new MockRemoteProxy(); proxy.setMaxNumberOfConcurrentTestSessions(50); proxy.setCapabilityMatcher(new AutomationCapabilityMatcher()); Map<String, Object> config = new HashMap<String, Object>(); config.put(AutomationConstants.INSTANCE_ID, nodeId); proxy.setConfig(config); Map<String, Object> capabilities = new HashMap<String, Object>(); capabilities.put(CapabilityType.BROWSER_NAME, "chrome"); TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver, null, capabilities); proxy.setMultipleTestSlots(testSlot, 10); proxySet.add(proxy); servlet.setProxySet(proxySet); AutomationContext.getContext().setTotalNodeCount(50); MockHttpServletResponse response = new MockHttpServletResponse(); servlet.doGet(request, response); Assert.assertEquals("Hub should be able to fulfill request", HttpServletResponse.SC_CREATED, response.getStatusCode()); }
From source file:com.rmn.qa.task.AutomationOrphanedNodeRegistryTaskTest.java
License:Open Source License
@Test // Test that a node not in the context gets picked up and registered by the task public void testRegisterNewNode() { MockAutomationOrphanedNodeRegistryTask task = new MockAutomationOrphanedNodeRegistryTask(null); ProxySet proxySet = new ProxySet(false); MockRemoteProxy proxy = new MockRemoteProxy(); proxySet.add(proxy);// w ww .j a v a 2s. c o m Map<String, Object> config = new HashMap<>(); String instanceId = "instanceId"; String uuid = "testUuid"; int threadCount = 10; String browser = "firefox"; Platform os = Platform.LINUX; config.put(AutomationConstants.INSTANCE_ID, instanceId); config.put(AutomationConstants.UUID, uuid); config.put(AutomationConstants.CONFIG_MAX_SESSION, threadCount); config.put(AutomationConstants.CONFIG_BROWSER, browser); config.put(AutomationConstants.CONFIG_OS, os.toString()); config.put(AutomationConstants.CONFIG_CREATED_DATE, AwsVmManager.NODE_DATE_FORMAT.format(new Date())); proxy.setConfig(config); proxy.setCapabilityMatcher(new AutomationCapabilityMatcher()); task.setProxySet(proxySet); Assert.assertNull("Node should not be registered before the task runs", AutomationContext.getContext().getNode(instanceId)); task.run(); AutomationDynamicNode existingNode = AutomationContext.getContext().getNode(instanceId); Assert.assertNotNull("Node should exist after the task has run", existingNode); Assert.assertEquals("UUID should match", uuid, existingNode.getUuid()); Assert.assertEquals("Browser should match", browser, existingNode.getBrowser()); Assert.assertEquals("Thread count should match", threadCount, existingNode.getNodeCapacity()); Assert.assertEquals("OS should match", os, existingNode.getPlatform()); }
From source file:com.rmn.qa.task.AutomationOrphanedNodeRegistryTaskTest.java
License:Open Source License
@Test // Test if a node already exists in the context that the task does not override that node public void testNodeAlreadyExists() { MockAutomationOrphanedNodeRegistryTask task = new MockAutomationOrphanedNodeRegistryTask(null); ProxySet proxySet = new ProxySet(false); MockRemoteProxy proxy = new MockRemoteProxy(); proxySet.add(proxy);/*from w w w . j av a2 s . com*/ Map<String, Object> config = new HashMap<>(); String instanceId = "instanceId"; String uuid = "testUuid"; int threadCount = 10; String browser = "firefox"; Platform os = Platform.LINUX; config.put(AutomationConstants.INSTANCE_ID, instanceId); config.put(AutomationConstants.UUID, "fake"); config.put(AutomationConstants.CONFIG_MAX_SESSION, 1); config.put(AutomationConstants.CONFIG_BROWSER, "fake"); config.put(AutomationConstants.CONFIG_OS, "fake"); config.put(AutomationConstants.CONFIG_CREATED_DATE, AwsVmManager.NODE_DATE_FORMAT.format(new Date())); proxy.setConfig(config); proxy.setCapabilityMatcher(new AutomationCapabilityMatcher()); task.setProxySet(proxySet); AutomationDynamicNode existingNode = new AutomationDynamicNode(uuid, instanceId, browser, os, new Date(), threadCount); AutomationContext.getContext().addNode(existingNode); Assert.assertNotNull("Node should be registered before the task runs", AutomationContext.getContext().getNode(instanceId)); task.run(); AutomationDynamicNode newNode = AutomationContext.getContext().getNode(instanceId); Assert.assertNotNull("Node should still exist after the task has run", newNode); Assert.assertEquals("UUID should match the previously existing node", uuid, newNode.getUuid()); Assert.assertEquals("Browser should match the previously existing node", browser, newNode.getBrowser()); Assert.assertEquals("Thread count should match the previously existing node", threadCount, newNode.getNodeCapacity()); Assert.assertEquals("OS should match the previously existing node", os, newNode.getPlatform()); }
From source file:com.rmn.qa.task.AutomationRunCleanupTaskTest.java
License:Open Source License
@Test // Tests that an old run not in progress is no longer registered public void testCleanup() { AutomationRunRequest oldRequest = new AutomationRunRequest("uuid", 10, "firefox", "10", Platform.LINUX, AutomationUtils.modifyDate(new Date(), -1, Calendar.HOUR)); AutomationRunContext context = AutomationContext.getContext(); context.addRun(oldRequest);//from ww w.j a v a2 s .c o m Assert.assertTrue("Run should exist", context.hasRun(oldRequest.getUuid())); ProxySet proxySet = new ProxySet(false); proxySet.add(new MockRemoteProxy()); context.cleanUpRunRequests(proxySet); MockAutomationRunCleanupTask task = new MockAutomationRunCleanupTask(null); task.setProxySet(proxySet); task.run(); Assert.assertFalse("Run request should no longer exist as it should have been removed", context.hasRun(oldRequest.getUuid())); }