Search in sources :

Example 1 with TestSlot

use of org.openqa.grid.internal.TestSlot in project zalenium by zalando.

the class CloudTestingRemoteProxy method terminateIdleSessions.

/*
        Method to check for test inactivity, and terminate idle sessions
     */
@VisibleForTesting
public void terminateIdleSessions() {
    for (TestSlot testSlot : getTestSlots()) {
        if (testSlot.getSession() != null && (testSlot.getSession().getInactivityTime() >= (getMaxTestIdleTime() * 1000L))) {
            long executionTime = (System.currentTimeMillis() - testSlot.getLastSessionStart()) / 1000;
            getGa().testEvent(getProxyClassName(), testSlot.getSession().getRequestedCapabilities().toString(), executionTime);
            addTestToDashboard(testSlot.getSession().getExternalKey().getKey(), false);
            getRegistry().forceRelease(testSlot, SessionTerminationReason.ORPHAN);
            logger.info(getProxyName() + " Releasing slot and terminating session due to inactivity.");
        }
    }
}
Also used : TestSlot(org.openqa.grid.internal.TestSlot) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with TestSlot

use of org.openqa.grid.internal.TestSlot in project zalenium by zalando.

the class CloudProxyHtmlRenderer method getPlatform.

/**
 * 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();
}
Also used : Platform(org.openqa.selenium.Platform) TestSlot(org.openqa.grid.internal.TestSlot)

Example 3 with TestSlot

use of org.openqa.grid.internal.TestSlot in project zalenium by zalando.

the class CloudProxyHtmlRenderer method tabBrowsers.

// content of the browsers tab
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();
}
Also used : HashMap(java.util.HashMap) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) TestSlot(org.openqa.grid.internal.TestSlot)

Example 4 with TestSlot

use of org.openqa.grid.internal.TestSlot in project zalenium by zalando.

the class LiveNodeHtmlRenderer method tabBrowsers.

// content of the browsers tab
private String tabBrowsers() {
    StringBuilder browserSection = new StringBuilder();
    for (TestSlot testSlot : proxy.getTestSlots()) {
        DesiredCapabilities desiredCapabilities = new DesiredCapabilities(testSlot.getCapabilities());
        String icon = getConsoleIconPath(desiredCapabilities);
        String version = desiredCapabilities.getVersion();
        TestSession session = testSlot.getSession();
        String slotClass = "";
        String slotTitle;
        if (session != null) {
            slotClass = "busy";
            slotTitle = session.get("lastCommand") == null ? "" : session.get("lastCommand").toString();
        } else {
            slotTitle = testSlot.getCapabilities().toString();
        }
        Map<String, String> browserValues = new HashMap<>();
        browserValues.put("{{browserVersion}}", Optional.ofNullable(version).orElse("N/A"));
        browserValues.put("{{slotIcon}}", Optional.ofNullable(icon).orElse("N/A"));
        browserValues.put("{{slotClass}}", slotClass);
        browserValues.put("{{slotTitle}}", slotTitle);
        browserSection.append(templateRenderer.renderSection("{{tabBrowsers}}", browserValues));
    }
    return browserSection.toString();
}
Also used : HashMap(java.util.HashMap) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) TestSession(org.openqa.grid.internal.TestSession) TestSlot(org.openqa.grid.internal.TestSlot)

Example 5 with TestSlot

use of org.openqa.grid.internal.TestSlot in project zalenium by zalando.

the class DockerSeleniumCapabilityMatcher method getChromeAndFirefoxVersions.

private void getChromeAndFirefoxVersions(DefaultRemoteProxy proxy) {
    if (!browserVersionsFetched.getAndSet(true)) {
        for (TestSlot testSlot : proxy.getTestSlots()) {
            String browser = testSlot.getCapabilities().get(CapabilityType.BROWSER_NAME).toString();
            String browserVersion = testSlot.getCapabilities().get(CapabilityType.VERSION).toString();
            if (BrowserType.CHROME.equalsIgnoreCase(browser)) {
                chromeVersion = browserVersion;
            } else if (BrowserType.FIREFOX.equalsIgnoreCase(browser)) {
                firefoxVersion = browserVersion;
            }
        }
    }
}
Also used : TestSlot(org.openqa.grid.internal.TestSlot)

Aggregations

TestSlot (org.openqa.grid.internal.TestSlot)6 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 HashMap (java.util.HashMap)2 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)2 TestSession (org.openqa.grid.internal.TestSession)1 Platform (org.openqa.selenium.Platform)1