/** * return the platform for the proxy. It should be the same for all slots of the proxy, so checking that. * @param proxy remote proxy * @return Either the platform name, "Unknown", "mixed OS", or "not specified". */ private static String getPlatform(RemoteProxy proxy) { Platform res; if (proxy.getTestSlots().size() == 0) { return "Unknown"; } res = getPlatform(proxy.getTestSlots().get(0)); for (TestSlot slot : proxy.getTestSlots()) { Platform tmp = getPlatform(slot); if (!tmp.is(res)) { return "mixed OS"; } res = tmp; } if (res == null) { return "not specified"; } return res.toString(); }
private String tabBrowsers() { List<TestSlot> testSlots = proxy.getTestSlots(); StringBuilder slotLines = new StringBuilder(); DesiredCapabilities desiredCapabilities = new DesiredCapabilities(testSlots.get(0).getCapabilities()); String version = desiredCapabilities.getVersion(); if (version != null) { version = "v:" + version; } Map<String, String> linesValues = new HashMap<>(); linesValues.put("{{browserVersion}}", version); // the lines of icons representing the possible slots StringBuilder singleSlotsHtml = new StringBuilder(); for (TestSlot testSlot : testSlots) { singleSlotsHtml.append(getSingleSlotHtml(testSlot)); } linesValues.put("{{singleSlots}}", singleSlotsHtml.toString()); slotLines.append(templateRenderer.renderSection("{{tabBrowsers}}", linesValues)); return slotLines.toString(); }
/** * @see GridRegistry#removeIfPresent(RemoteProxy) */ public void removeIfPresent(RemoteProxy proxy) { // Find the original proxy. While the supplied one is logically equivalent, it may be a fresh object with // an empty TestSlot list, which doesn't figure into the proxy equivalence check. Since we want to free up // those test sessions, we need to operate on that original object. if (proxies.contains(proxy)) { LOG.debug(String.format("Cleaning up stale test sessions on the unregistered node %s", proxy)); final RemoteProxy p = proxies.remove(proxy); p.getTestSlots().forEach(testSlot -> forceRelease(testSlot, SessionTerminationReason.PROXY_REREGISTRATION)); p.teardown(); } }
private TestSession createNewSession(Map<String, Object> desiredCapabilities) { List<RemoteProxy> sorted = getSorted(); LOGGER.debug("Available nodes: " + sorted); // Removing the proxies with Android so they are not taken into account to create a session. List<RemoteProxy> proxiesToConsider; if (Platform.LINUX.equals(getPlatformFromCaps(desiredCapabilities))) { proxiesToConsider = sorted.stream() .filter(remoteProxy -> remoteProxy .getTestSlots().stream() .noneMatch(testSlot -> Platform.ANDROID.equals(getPlatformFromCaps(testSlot.getCapabilities())))) .collect(Collectors.toList()); } else { proxiesToConsider = sorted; } return proxiesToConsider.stream() .map(proxy -> proxy.getNewSession(desiredCapabilities)) .filter(Objects::nonNull) .findFirst().orElse(null); }
private void initUsageBySlot(RemoteProxy proxy) { // figure out usage by slot type slotUsage = new HashMap<>(); for (TestSlot slot : proxy.getTestSlots()) { String slotType = getSlotType(slot); SlotInfo info = slotUsage.get(slotType); if (info == null) { info = new SlotInfo(getMaxInstances(slot)); } if (slot.getSession() != null) { info.addUsed(); } slotUsage.put(slotType, info); } }
private void initUsageBySlot(RemoteProxy proxy) { // figure out usage by slot type slotUsage = new HashMap<>(); for (TestSlot slot : proxy.getTestSlots()) { String slotType = getSlotType(slot); SlotInfo info = slotUsage.get(slotType); if (info == null) { info = new SlotInfo(getMaxInstances(slot)); } if (slot.getSession() != null) { info.addUsed(); } slotUsage.put(slotType, info); } }
/** * 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; } }
List<TestSlot> slots = proxy.getTestSlots();
public Collection<SeleniumTestSlotGroup> call() { Map<URL, SeleniumTestSlotGroup> groups = new HashMap<URL, SeleniumTestSlotGroup>(); if (HubHolder.getHub() == null) { return Collections.emptyList(); } GridRegistry registry = HubHolder.getHub().getRegistry(); if (registry != null) { for (RemoteProxy proxy : registry.getAllProxies()) { for (TestSlot slot : proxy.getTestSlots()) { URL host = slot.getProxy().getRemoteHost(); SeleniumTestSlotGroup grp = groups.get(host); if (grp == null) { grp = new SeleniumTestSlotGroup(host); groups.put(host, grp); } grp.addTestSlot(new SeleniumTestSlot(slot)); } } } List<SeleniumTestSlotGroup> values = new ArrayList<SeleniumTestSlotGroup>(groups.values()); Collections.sort(values); return values; } });
/** * {@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; }
for (TestSlot testSlot : proxy.getTestSlots()) {
for (TestSlot slot : proxy.getTestSlots()) { TestSession session = slot.getSession();
log.info("Analyzing node..."); for (TestSlot testSlot : proxy.getTestSlots()) {
for(TestSlot testSlot : proxy.getTestSlots()) { AutomationRunRequest requestRepresentation = AutomationRunRequest.requestFromCapabilities(testSlot.getCapabilities()); existingSlots.add(requestRepresentation); for(TestSlot testSlot : proxy.getTestSlots()) {