本文整理汇总了Java中org.openqa.grid.internal.ProxySet类的典型用法代码示例。如果您正苦于以下问题:Java ProxySet类的具体用法?Java ProxySet怎么用?Java ProxySet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProxySet类属于org.openqa.grid.internal包,在下文中一共展示了ProxySet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNumInProgressTests
import org.openqa.grid.internal.ProxySet; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public int getNumInProgressTests(ProxySet proxySet, AutomationRunRequest runRequest) {
int inProgressTests = 0;
for(RemoteProxy proxy : proxySet) {
for(TestSlot testSlot : proxy.getTestSlots() ) {
TestSession session = testSlot.getSession();
if(session != null) {
if(runRequest.matchesCapabilities(session.getRequestedCapabilities())) {
inProgressTests++;
}
}
}
}
return inProgressTests;
}
示例2: isNodeCurrentlyEmpty
import org.openqa.grid.internal.ProxySet; //导入依赖的package包/类
/**
* Returns true if the specified node is empty and has no runs on it, and false otherwise
* @param instanceToFind
* @return
*/
public boolean isNodeCurrentlyEmpty(String instanceToFind) {
ProxySet proxySet = getProxySet();
for(RemoteProxy proxy : proxySet){
List<TestSlot> slots = proxy.getTestSlots();
Object instanceId = proxy.getConfig().get(AutomationConstants.INSTANCE_ID);
// If the instance id's do not match, this means this is not the node we are looking for
// and we should continue on to the next one
if(!instanceToFind.equals(instanceId)) {
continue;
}
// Now that we found the matching node, iterate over all its test slots to see if any sessions are running
for (TestSlot testSlot : slots) {
// If we find a running session, this means the node is occupied, so we should return false
if(testSlot.getSession() != null) {
return false;
}
}
// If we reached this point, this means we found our target node AND it had no sessions, meaning the node was empty
return true;
}
// If we didn't find a matching node, we're going to say the nodes is empty so we can terminate it
log.warn("No matching node was found in the proxy set. Instance id: " + instanceToFind);
return true;
}
示例3: testRequestNodeExpiredState
import org.openqa.grid.internal.ProxySet; //导入依赖的package包/类
@Test
// Tests that a node in the Expired state is not considered as a free resource
public void testRequestNodeExpiredState() 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.EXPIRED);
AutomationContext.getContext().addNode(node);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> config = new HashMap<String, Object>();
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("Thread count should be correct due to an expired node", 0, freeThreads);
}
示例4: testRequestNodeTerminatedNoInstanceId
import org.openqa.grid.internal.ProxySet; //导入依赖的package包/类
@Test
// Tests that a node in the Terminated state without an instance id is still considered a valid resource
public void testRequestNodeTerminatedNoInstanceId() 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.setCapabilityMatcher(new AutomationCapabilityMatcher());
proxy.setMaxNumberOfConcurrentTestSessions(5);
Map<String,Object> config = new HashMap<>();
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("Node should be available since instance id was not on the node", 1, freeThreads);
}
示例5: 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);
}
示例6: testRequestNonMatchingBrowsers
import org.openqa.grid.internal.ProxySet; //导入依赖的package包/类
@Test
// Test that non-matching browsers do not contribute to the free node count
public void testRequestNonMatchingBrowsers() 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,"doesntMatch");
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 OS", 0, freeThreads);
}
示例7: testRequestAllTestSlotsIncluded
import org.openqa.grid.internal.ProxySet; //导入依赖的package包/类
@Test
// Makes sure that all matching slots will be included to match
public void testRequestAllTestSlotsIncluded() 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(10);
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",10,freeThreads);
}
示例8: testRequestAllTestSlotsIncludedGreaterNodeLimit
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 less than
// the slot number
public void testRequestAllTestSlotsIncludedGreaterNodeLimit() 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(15);
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",10,freeThreads);
}
示例9: 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);
}
示例10: testRequestNewRunNotStarted
import org.openqa.grid.internal.ProxySet; //导入依赖的package包/类
@Test
// Test to make sure an in progress counts against the free node count
public void testRequestNewRunNotStarted() 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";
AutomationContext.getContext().addRun(new AutomationRunRequest(runId,10,"firefox"));
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("No nodes should be free since existing run hasn't started",0,freeThreads);
}
示例11: testActiveSession
import org.openqa.grid.internal.ProxySet; //导入依赖的package包/类
@Test
// Tests that a run with slots does not get removed
public void testActiveSession() {
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);
testSlot.getNewSession(config);
testSlots.add(testSlot);
proxySet.add(proxy);
context.cleanUpRunRequests(proxySet);
Assert.assertTrue("Run request should still exist as there were active sessions", context.hasRun(request.getUuid()));
}
示例12: 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()));
}
示例13: 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);
}
示例14: testNodesFreeWithUuid
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 testNodesFreeWithUuid() {
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,"testUuid");
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);
}
示例15: testNewRunIsCounted
import org.openqa.grid.internal.ProxySet; //导入依赖的package包/类
@Test
// Tests that a new run is counted instead of tests in progress
public void testNewRunIsCounted() {
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");
runContext.addRun(request);
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(0,freeThreads);
}