@Override public void afterCommand(TestSession session, HttpServletRequest request, HttpServletResponse response) { String currentName = Thread.currentThread().getName(); Thread.currentThread().setName(getProxyName()); if (request instanceof WebDriverRequest && "DELETE".equalsIgnoreCase(request.getMethod())) { WebDriverRequest seleniumRequest = (WebDriverRequest) request; if (seleniumRequest.getRequestType().equals(RequestType.STOP_SESSION)) { long executionTime = (System.currentTimeMillis() - session.getSlot().getLastSessionStart()) / 1000; getGa().testEvent(getProxyClassName(), session.getRequestedCapabilities().toString(), executionTime); addTestToDashboard(session.getExternalKey().getKey(), true); } } super.afterCommand(session, request, response); Thread.currentThread().setName(currentName); }
@VisibleForTesting public void terminateIdleSessions() { String currentName = Thread.currentThread().getName(); Thread.currentThread().setName(getProxyName()); 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); // If it is null, it is probable that the test never reached the cloud service. if (testSlot.getSession().getExternalKey() != null) { addTestToDashboard(testSlot.getSession().getExternalKey().getKey(), false); } getRegistry().forceRelease(testSlot, SessionTerminationReason.ORPHAN); logger.warn("Releasing slot and terminating session due to inactivity."); } } Thread.currentThread().setName(currentName); }
testName = getCapability(requestedCapability, ZaleniumCapabilityType.TEST_NAME, ""); String seleniumSessionId = newSession.getExternalKey() != null ? newSession.getExternalKey().getKey() : newSession.getInternalKey(); if (testName.isEmpty()) {
public static void declareSessionStopping(TestSession session) { stoppingSessions.put(session.getExternalKey().getKey(), new VideoFuture()); }
VideoFuture videoFuture = stoppingSessions.getIfPresent(key.getKey()); if(videoFuture != null) { videoFuture.setDone();
public URL getRemoteHostForSession(String sessionId) { for (TestSession activeSession : registry.getActiveSessions()) { if (sessionId.equals(activeSession.getExternalKey().getKey())) { return activeSession.getSlot().getProxy().getRemoteHost(); } } throw new IllegalArgumentException("Invalid sessionId. No active session is present for id:" + sessionId); }
public void refreshTimeout(String sessionId) { for (TestSession activeSession : registry.getActiveSessions()) { if ((activeSession != null) && (sessionId != null) && (activeSession.getExternalKey() != null)) { if (sessionId.equals(activeSession.getExternalKey().getKey())) { refreshTimeout(activeSession); } } } }