Search in sources :

Example 1 with GridHubConfiguration

use of org.openqa.grid.internal.utils.configuration.GridHubConfiguration in project zalenium by zalando.

the class SauceLabsRemoteProxyTest method setUp.

@Before
public void setUp() {
    try {
        ObjectName objectName = new ObjectName("org.seleniumhq.grid:type=Hub");
        ManagementFactory.getPlatformMBeanServer().getObjectInstance(objectName);
        new JMXHelper().unregister(objectName);
    } catch (MalformedObjectNameException | InstanceNotFoundException e) {
    // Might be that the object does not exist, it is ok. Nothing to do, this is just a cleanup task.
    }
    registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
    // Creating the configuration and the registration request of the proxy (node)
    RegistrationRequest request = TestUtils.getRegistrationRequestForTesting(30001, SauceLabsRemoteProxy.class.getCanonicalName());
    CommonProxyUtilities commonProxyUtilities = mock(CommonProxyUtilities.class);
    when(commonProxyUtilities.readJSONFromUrl(anyString(), anyString(), anyString())).thenReturn(null);
    SauceLabsRemoteProxy.setCommonProxyUtilities(commonProxyUtilities);
    sauceLabsProxy = SauceLabsRemoteProxy.getNewInstance(request, registry);
    // we need to register a DockerSeleniumStarter proxy to have a proper functioning SauceLabsProxy
    request = TestUtils.getRegistrationRequestForTesting(30000, DockerSeleniumStarterRemoteProxy.class.getCanonicalName());
    DockerSeleniumStarterRemoteProxy dsStarterProxy = DockerSeleniumStarterRemoteProxy.getNewInstance(request, registry);
    // We add both nodes to the registry
    registry.add(sauceLabsProxy);
    registry.add(dsStarterProxy);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) CommonProxyUtilities(de.zalando.ep.zalenium.util.CommonProxyUtilities) Hub(org.openqa.grid.web.Hub) JMXHelper(org.openqa.selenium.remote.server.jmx.JMXHelper) InstanceNotFoundException(javax.management.InstanceNotFoundException) GridHubConfiguration(org.openqa.grid.internal.utils.configuration.GridHubConfiguration) RegistrationRequest(org.openqa.grid.common.RegistrationRequest) ObjectName(javax.management.ObjectName) Before(org.junit.Before)

Example 2 with GridHubConfiguration

use of org.openqa.grid.internal.utils.configuration.GridHubConfiguration in project zalenium by zalando.

the class TestingBotRemoteProxyTest method setUp.

@SuppressWarnings("ConstantConditions")
@Before
public void setUp() throws IOException {
    try {
        ObjectName objectName = new ObjectName("org.seleniumhq.grid:type=Hub");
        ManagementFactory.getPlatformMBeanServer().getObjectInstance(objectName);
        new JMXHelper().unregister(objectName);
    } catch (MalformedObjectNameException | InstanceNotFoundException e) {
    // Might be that the object does not exist, it is ok. Nothing to do, this is just a cleanup task.
    }
    registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
    // Creating the configuration and the registration request of the proxy (node)
    RegistrationRequest request = TestUtils.getRegistrationRequestForTesting(30002, TestingBotRemoteProxy.class.getCanonicalName());
    JsonElement informationSample = TestUtils.getTestInformationSample("testingbot_testinformation.json");
    String userInfoUrl = "https://api.testingbot.com/v1/user";
    Environment env = new Environment();
    CommonProxyUtilities commonProxyUtilities = mock(CommonProxyUtilities.class);
    when(commonProxyUtilities.readJSONFromUrl(userInfoUrl, env.getStringEnvVariable("TESTINGBOT_KEY", ""), env.getStringEnvVariable("TESTINGBOT_SECRET", ""))).thenReturn(null);
    String mockTestInfoUrl = "https://api.testingbot.com/v1/tests/2cf5d115-ca6f-4bc4-bc06-a4fca00836ce";
    when(commonProxyUtilities.readJSONFromUrl(mockTestInfoUrl, env.getStringEnvVariable("TESTINGBOT_KEY", ""), env.getStringEnvVariable("TESTINGBOT_SECRET", ""))).thenReturn(informationSample);
    TestingBotRemoteProxy.setCommonProxyUtilities(commonProxyUtilities);
    testingBotProxy = TestingBotRemoteProxy.getNewInstance(request, registry);
    // we need to register a DockerSeleniumStarter proxy to have a proper functioning testingBotProxy
    request = TestUtils.getRegistrationRequestForTesting(30000, DockerSeleniumStarterRemoteProxy.class.getCanonicalName());
    DockerSeleniumStarterRemoteProxy dsStarterProxy = DockerSeleniumStarterRemoteProxy.getNewInstance(request, registry);
    // Temporal folder for dashboard files
    TestUtils.ensureRequiredInputFilesExist(temporaryFolder);
    // We add both nodes to the registry
    registry.add(testingBotProxy);
    registry.add(dsStarterProxy);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) CommonProxyUtilities(de.zalando.ep.zalenium.util.CommonProxyUtilities) JMXHelper(org.openqa.selenium.remote.server.jmx.JMXHelper) InstanceNotFoundException(javax.management.InstanceNotFoundException) RegistrationRequest(org.openqa.grid.common.RegistrationRequest) ObjectName(javax.management.ObjectName) Hub(org.openqa.grid.web.Hub) JsonElement(com.google.gson.JsonElement) Environment(de.zalando.ep.zalenium.util.Environment) GridHubConfiguration(org.openqa.grid.internal.utils.configuration.GridHubConfiguration) Before(org.junit.Before)

Example 3 with GridHubConfiguration

use of org.openqa.grid.internal.utils.configuration.GridHubConfiguration in project zalenium by zalando.

the class ZaleniumRegistryTest method proxyIsAdded.

@Test
public void proxyIsAdded() throws Exception {
    GridRegistry registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
    DockerSeleniumRemoteProxy p1 = TestUtils.getNewBasicRemoteProxy("app1", "http://machine1:4444/", registry);
    DockerSeleniumRemoteProxy p2 = TestUtils.getNewBasicRemoteProxy("app1", "http://machine2:4444/", registry);
    DockerSeleniumRemoteProxy p3 = TestUtils.getNewBasicRemoteProxy("app1", "http://machine3:4444/", registry);
    DockerSeleniumRemoteProxy p4 = TestUtils.getNewBasicRemoteProxy("app1", "http://machine4:4444/", registry);
    try {
        registry.add(p1);
        registry.add(p2);
        registry.add(p3);
        registry.add(p4);
        assertTrue(registry.getAllProxies().size() == 4);
    } finally {
        registry.stop();
    }
}
Also used : Hub(org.openqa.grid.web.Hub) DockerSeleniumRemoteProxy(de.zalando.ep.zalenium.proxy.DockerSeleniumRemoteProxy) GridHubConfiguration(org.openqa.grid.internal.utils.configuration.GridHubConfiguration) GridRegistry(org.openqa.grid.internal.GridRegistry) Test(org.junit.Test)

Example 4 with GridHubConfiguration

use of org.openqa.grid.internal.utils.configuration.GridHubConfiguration in project zalenium by zalando.

the class ZaleniumRegistryTest method sessionIsProcessed.

@Test
public void sessionIsProcessed() {
    Map<String, Object> requestedCapability = new HashMap<>();
    requestedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
    requestedCapability.put(CapabilityType.PLATFORM_NAME, Platform.LINUX);
    GridRegistry registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
    RegistrationRequest req = TestUtils.getRegistrationRequestForTesting(40000, DockerSeleniumRemoteProxy.class.getCanonicalName());
    req.getConfiguration().capabilities.clear();
    req.getConfiguration().capabilities.addAll(TestUtils.getDockerSeleniumCapabilitiesForTesting());
    DockerSeleniumRemoteProxy p1 = new DockerSeleniumRemoteProxy(req, registry);
    try {
        registry.add(p1);
        RequestHandler newSessionRequest = TestUtils.createNewSessionHandler(registry, requestedCapability);
        newSessionRequest.process();
        TestSession session = newSessionRequest.getSession();
        session.setExternalKey(new ExternalSessionKey(UUID.randomUUID().toString()));
        registry.terminate(session, SessionTerminationReason.CLIENT_STOPPED_SESSION);
        Callable<Boolean> callable = () -> registry.getActiveSessions().size() == 0;
        await().pollInterval(Duration.FIVE_HUNDRED_MILLISECONDS).atMost(Duration.TWO_SECONDS).until(callable);
    } finally {
        registry.stop();
    }
}
Also used : ExternalSessionKey(org.openqa.grid.internal.ExternalSessionKey) HashMap(java.util.HashMap) DockerSeleniumRemoteProxy(de.zalando.ep.zalenium.proxy.DockerSeleniumRemoteProxy) RegistrationRequest(org.openqa.grid.common.RegistrationRequest) GridRegistry(org.openqa.grid.internal.GridRegistry) Hub(org.openqa.grid.web.Hub) RequestHandler(org.openqa.grid.web.servlet.handler.RequestHandler) TestSession(org.openqa.grid.internal.TestSession) GridHubConfiguration(org.openqa.grid.internal.utils.configuration.GridHubConfiguration) Test(org.junit.Test)

Example 5 with GridHubConfiguration

use of org.openqa.grid.internal.utils.configuration.GridHubConfiguration in project zalenium by zalando.

the class CloudTestingRemoteProxyTest method defaultValuesAreAlwaysNull.

@Test
public void defaultValuesAreAlwaysNull() {
    try {
        ObjectName objectName = new ObjectName("org.seleniumhq.grid:type=Hub");
        ManagementFactory.getPlatformMBeanServer().getObjectInstance(objectName);
        new JMXHelper().unregister(objectName);
    } catch (MalformedObjectNameException | InstanceNotFoundException e) {
    // Might be that the object does not exist, it is ok. Nothing to do, this is just a cleanup task.
    }
    GridRegistry registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
    RegistrationRequest request = TestUtils.getRegistrationRequestForTesting(30003, CloudTestingRemoteProxy.class.getCanonicalName());
    CloudTestingRemoteProxy proxy = CloudTestingRemoteProxy.getNewInstance(request, registry);
    Assert.assertNull(proxy.getAccessKeyProperty());
    Assert.assertNull(proxy.getAccessKeyValue());
    Assert.assertNotNull(proxy.getCloudTestingServiceUrl());
    Assert.assertNull(proxy.getUserNameProperty());
    Assert.assertNull(proxy.getUserNameValue());
    Assert.assertNotNull(proxy.getRemoteHost());
    Assert.assertNull(proxy.getVideoFileExtension());
    Assert.assertNull(proxy.getProxyName());
    Assert.assertNull(proxy.getProxyClassName());
    Assert.assertNull(proxy.getTestInformation("seleniumSessionId"));
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) Hub(org.openqa.grid.web.Hub) JMXHelper(org.openqa.selenium.remote.server.jmx.JMXHelper) InstanceNotFoundException(javax.management.InstanceNotFoundException) GridHubConfiguration(org.openqa.grid.internal.utils.configuration.GridHubConfiguration) RegistrationRequest(org.openqa.grid.common.RegistrationRequest) GridRegistry(org.openqa.grid.internal.GridRegistry) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

GridHubConfiguration (org.openqa.grid.internal.utils.configuration.GridHubConfiguration)13 Hub (org.openqa.grid.web.Hub)12 InstanceNotFoundException (javax.management.InstanceNotFoundException)9 MalformedObjectNameException (javax.management.MalformedObjectNameException)9 ObjectName (javax.management.ObjectName)9 RegistrationRequest (org.openqa.grid.common.RegistrationRequest)9 JMXHelper (org.openqa.selenium.remote.server.jmx.JMXHelper)9 Before (org.junit.Before)8 DockerSeleniumRemoteProxy (de.zalando.ep.zalenium.proxy.DockerSeleniumRemoteProxy)6 CommonProxyUtilities (de.zalando.ep.zalenium.util.CommonProxyUtilities)4 Test (org.junit.Test)4 GridRegistry (org.openqa.grid.internal.GridRegistry)4 DockerContainerMock (de.zalando.ep.zalenium.util.DockerContainerMock)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 HashMap (java.util.HashMap)2 JsonElement (com.google.gson.JsonElement)1 BrowserStackRemoteProxy (de.zalando.ep.zalenium.proxy.BrowserStackRemoteProxy)1 DockerSeleniumStarterRemoteProxy (de.zalando.ep.zalenium.proxy.DockerSeleniumStarterRemoteProxy)1 SauceLabsRemoteProxy (de.zalando.ep.zalenium.proxy.SauceLabsRemoteProxy)1