本文整理汇总了Java中org.openqa.grid.internal.ProxySet.add方法的典型用法代码示例。如果您正苦于以下问题:Java ProxySet.add方法的具体用法?Java ProxySet.add怎么用?Java ProxySet.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openqa.grid.internal.ProxySet
的用法示例。
在下文中一共展示了ProxySet.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRequestMatchingBrowsers
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Happy path that browsers matching shows correct free node count
public void testRequestMatchingBrowsers() throws IOException, ServletException{
String browser = "firefox";
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,browser);
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
proxy.setMultipleTestSlots(testSlot, 10);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
Assert.assertEquals("Thread count should be correct due to matching browser", 10, freeThreads);
}
示例2: testRegisterNodeWithoutInstanceId
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Test that a node without an instance id does not get registered
public void testRegisterNodeWithoutInstanceId() {
MockAutomationNodeRegistryTask task = new MockAutomationNodeRegistryTask(null);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxySet.add(proxy);
Map<String,Object> config = new HashMap<String, Object>();
String uuid="testUuid";
int threadCount = 10;
String browser = "firefox";
String os = "linux";
config.put(AutomationConstants.UUID,uuid);
config.put(AutomationConstants.CONFIG_MAX_SESSION, threadCount);
config.put(AutomationConstants.CONFIG_BROWSER, browser);
config.put(AutomationConstants.CONFIG_OS, os);
config.put(AutomationConstants.CONFIG_CREATED_DATE, AwsVmManager.NODE_DATE_FORMAT.format(new Date()));
proxy.setConfig(config);
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
task.setProxySet(proxySet);
Assert.assertEquals("Node should not be registered before the task runs",0,AutomationContext.getContext().getNodes().size());
task.run();
Assert.assertEquals("Node should still not be registered after the task runs",0,AutomationContext.getContext().getNodes().size());
}
示例3: testNoSessions
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Tests that a run with slots does not get removed
public void testNoSessions() {
String uuid = "uuid";
AutomationRunRequest request = new AutomationRunRequest(uuid,10,"firefox","10","linux",AutomationUtils.modifyDate(new Date(),-1, Calendar.HOUR));
AutomationRunContext context = AutomationContext.getContext();
context.addRun(request);
Assert.assertTrue("Run should exist", context.hasRun(request.getUuid()));
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
CapabilityMatcher matcher = new AutomationCapabilityMatcher();
proxy.setCapabilityMatcher(matcher);
proxySet.add(proxy);
Map<String,Object> config = new HashMap<>();
config.put(AutomationConstants.UUID,uuid);
proxy.setConfig(config);
List<TestSlot> testSlots = new ArrayList<>();
TestSlot testSlot = new TestSlot(proxy,null,null,config);
proxy.setTestSlots(testSlots);
testSlots.add(testSlot);
proxySet.add(proxy);
context.cleanUpRunRequests(proxySet);
Assert.assertFalse("Run request should not exist as there were no active sessions", context.hasRun(request.getUuid()));
}
示例4: testRequestAllTestSlotsIncludedLessThanNodeLimit
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Tests that the correct number of slots match even when the max session config on node is greater than
// the slot number
public void testRequestAllTestSlotsIncludedLessThanNodeLimit() throws IOException, ServletException{
String browser = "firefox";
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(5);
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,"firefox");
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
proxy.setMultipleTestSlots(testSlot, 10);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
Assert.assertEquals("There should be no matching threads since the node limit was reached",5,freeThreads);
}
示例5: testNodesFreeNoUuid
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Tests that the correct node count is returned when tests don't have a UUID
public void testNodesFreeNoUuid() {
AutomationRunContext runContext = new AutomationRunContext();
runContext.setTotalNodeCount(10);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> capabilities = new HashMap<>();
capabilities.put(CapabilityType.PLATFORM,"linux");
capabilities.put(CapabilityType.BROWSER_NAME,"chrome");
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
testSlot.getNewSession(capabilities);
proxy.setMultipleTestSlots(testSlot,5);
proxySet.add(proxy);
int freeThreads = runContext.getTotalThreadsAvailable(proxySet);
Assert.assertEquals(5,freeThreads);
}
示例6: testOldRunInProgress
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Tests that for an old run, the in progress tests are counted
public void testOldRunInProgress() {
String uuid = "testUuid";
AutomationRunContext runContext = new AutomationRunContext();
runContext.setTotalNodeCount(10);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> capabilities = new HashMap<>();
capabilities.put(CapabilityType.PLATFORM,"linux");
capabilities.put(CapabilityType.BROWSER_NAME,"chrome");
capabilities.put(AutomationConstants.UUID,uuid);
AutomationRunRequest request = new AutomationRunRequest(uuid,10,"chrome","23","linux", AutomationUtils.modifyDate(new Date(),-5,Calendar.MINUTE));
runContext.addRun(request);
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
testSlot.getNewSession(capabilities);
int inProgressTests = 5;
proxy.setMultipleTestSlots(testSlot,inProgressTests);
proxySet.add(proxy);
int freeThreads = runContext.getTotalThreadsAvailable(proxySet);
Assert.assertEquals("Free threads should reflect in progress test count",inProgressTests,freeThreads);
}
示例7: testRequestCanFulfillSpinUpNodesIe
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Tests a request can be fulfilled when IE nodes have to be spun up
public void testRequestCanFulfillSpinUpNodesIe() throws IOException, ServletException{
MockVmManager manageEc2 = new MockVmManager();
System.setProperty(AutomationConstants.IP_ADDRESS,"192.168.1.1");
MockRequestMatcher matcher = new MockRequestMatcher();
matcher.setThreadsToReturn(0);
MockAutomationTestRunServlet servlet = new MockAutomationTestRunServlet(null,false, manageEc2,matcher);
MockHttpServletRequest request = new MockHttpServletRequest();
request.setParameter("uuid","testUuid");
request.setParameter("browser","internetexplorer");
request.setParameter("threadCount","1");
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,"internetexplorer");
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());
}
示例8: testBadDateFormat
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Test that a node with a bad date does not register successfully after the task runs
public void testBadDateFormat() {
MockAutomationNodeRegistryTask task = new MockAutomationNodeRegistryTask(null);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxySet.add(proxy);
Map<String,Object> config = new HashMap<>();
String instanceId = "instanceId";
String uuid="testUuid";
int threadCount = 10;
String browser = "firefox";
String os = "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);
DateFormat badDateFormat = new SimpleDateFormat("MM HH:mm:ss");
config.put(AutomationConstants.CONFIG_CREATED_DATE, badDateFormat.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();
Assert.assertNull("Node should still not be registered after the task runs",AutomationContext.getContext().getNode(instanceId));
}
示例9: testRequestNodeTerminatedState
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Tests that a node in the Terminated state is not considered as a free resource
public void testRequestNodeTerminatedState() throws IOException, ServletException{
String browser = "firefox";
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(),10);
node.updateStatus(AutomationDynamicNode.STATUS.TERMINATED);
AutomationContext.getContext().addNode(node);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setMaxNumberOfConcurrentTestSessions(5);
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> config = new HashMap<>();
config.put(AutomationConstants.INSTANCE_ID, nodeId);
proxy.setConfig(config);
List<TestSlot> testSlots = new ArrayList<TestSlot>();
Map<String,Object> capabilities = new HashMap<String,Object>();
capabilities.put(CapabilityType.BROWSER_NAME,browser);
testSlots.add(new TestSlot(proxy, SeleniumProtocol.WebDriver, null, capabilities));
proxy.setTestSlots(testSlots);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
AutomationRequestMatcher requestMatcher = new AutomationRequestMatcher();
int freeThreads = requestMatcher.getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
Assert.assertEquals("No threads should be available since the node was set to terminated", 0, freeThreads);
}
示例10: testRequestMatchingOs
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Tests that OS matching on a node works correctly
public void testRequestMatchingOs() throws IOException, ServletException {
String browser = "firefox";
String os = "linux";
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<>();
config.put(AutomationConstants.INSTANCE_ID,nodeId);
proxy.setConfig(config);
Map<String,Object> capabilities = new HashMap<>();
capabilities.put(CapabilityType.BROWSER_NAME,"firefox");
capabilities.put(CapabilityType.PLATFORM,os);
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
proxy.setMultipleTestSlots(testSlot, 10);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(null,null,browser,null,os));
Assert.assertEquals("Thread count should be correct due to matching OS", 10, freeThreads);
}
示例11: testNewRunIE
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Tests that a new run does not get cleaned up (removed)
public void testNewRunIE() {
AutomationRunRequest oldRequest = new AutomationRunRequest("uuid",10,"internetexplorer","10","linux",AutomationUtils.modifyDate(new Date(),-7, Calendar.MINUTE));
AutomationRunContext context = AutomationContext.getContext();
context.addRun(oldRequest);
Assert.assertTrue("Run should exist", context.hasRun(oldRequest.getUuid()));
ProxySet proxySet = new ProxySet(false);
proxySet.add(new MockRemoteProxy());
context.cleanUpRunRequests(proxySet);
Assert.assertTrue("Run request should still exist as the run was new enough", context.hasRun(oldRequest.getUuid()));
}
示例12: testNewRun
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Tests that a new run does not get cleaned up (removed)
public void testNewRun() {
AutomationRunRequest oldRequest = new AutomationRunRequest("uuid",10,"firefox");
AutomationRunContext context = AutomationContext.getContext();
context.addRun(oldRequest);
Assert.assertTrue("Run should exist", context.hasRun(oldRequest.getUuid()));
ProxySet proxySet = new ProxySet(false);
proxySet.add(new MockRemoteProxy());
context.cleanUpRunRequests(proxySet);
Assert.assertTrue("Run request should still exist as the run was new enough", context.hasRun(oldRequest.getUuid()));
}
示例13: testHubNotTerminatedExistingNodes
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Tests that if the hub still has nodes registered to it, it will not terminate
public void testHubNotTerminatedExistingNodes() {
MockVmManager ec2 = new MockVmManager();
MockAutomationHubCleanupTask task = new MockAutomationHubCleanupTask(null,ec2,"dummyId");
ProxySet proxySet = new ProxySet(false);
proxySet.add(new MockRemoteProxy());
task.setProxySet(proxySet);
String createdDate = AwsVmManager.NODE_DATE_FORMAT.format(AutomationUtils.modifyDate(new Date(),-56, Calendar.MINUTE));
task.setCreatedDate(createdDate);
task.run();
Assert.assertFalse("Hub should not be terminated as nodes are still registered", ec2.isTerminated());
}
示例14: testNodeNotSetToTerminatedNotEmpty
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Tests that if a node still has tests running against it will only get set to expired and not terminated
public void testNodeNotSetToTerminatedNotEmpty() {
String nodeId = "nodeId";
MockRequestMatcher matcher = new MockRequestMatcher();
matcher.setThreadsToReturn(10);
MockAutomationNodeCleanupTask task = new MockAutomationNodeCleanupTask(null,new MockVmManager(),matcher);
ProxySet proxySet = new ProxySet(false);
task.setProxySet(proxySet);
AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,AutomationUtils.modifyDate(new Date(),-56, Calendar.MINUTE),10);
AutomationContext.getContext().addNode(node);
MockRemoteProxy proxy = new MockRemoteProxy();
proxySet.add(proxy);
Map<String,Object> config = new HashMap<String, Object>();
config.put(AutomationConstants.INSTANCE_ID,nodeId);
proxy.setConfig(config);
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> capabilities = new HashMap<String,Object>();
capabilities.put(CapabilityType.BROWSER_NAME,"firefox");
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
// Assign a session to the test slot
testSlot.getNewSession(capabilities);
proxy.setMultipleTestSlots(testSlot, 5);
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
task.run();
Assert.assertEquals("Status should change to expired first", AutomationDynamicNode.STATUS.EXPIRED,node.getStatus());
task.run();
Assert.assertEquals("Node should be expired as it was not empty", AutomationDynamicNode.STATUS.EXPIRED,node.getStatus());
}
示例15: testRequestOldRunFinished
import org.openqa.grid.internal.ProxySet; //导入方法依赖的package包/类
@Test
// Tests when a run is considered old that the threads are not considered in use
public void testRequestOldRunFinished() throws IOException, ServletException{
String browser = "firefox";
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);
String runId = "runId";
// Add an old run that will not be included in the available resource logic
AutomationContext.getContext().addRun(new AutomationRunRequest(runId, 10, "firefox", null,null,AutomationUtils.modifyDate(new Date(), -2, Calendar.MINUTE)));
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,"firefox");
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
proxy.setMultipleTestSlots(testSlot, 10);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
Assert.assertEquals("Free nodes should be correct since the run has finished at this point",10,freeThreads);
}