Search in sources :

Example 6 with GridHubConfiguration

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

the class DockerSeleniumRemoteProxyTest method setUp.

@Before
public void setUp() {
    // Change the factory to return our version of the Container Client
    if (this.currentIsKubernetesValue.get()) {
        // This is needed in order to use a fresh version of the mock, otherwise the return values
        // are gone, and returning them always is not the normal behaviour.
        this.containerClient = KubernetesContainerMock.getMockedKubernetesContainerClient();
        ContainerFactory.setKubernetesContainerClient((KubernetesContainerClient) containerClient);
    } else {
        ContainerFactory.setContainerClientGenerator(() -> containerClient);
    }
    ContainerFactory.setIsKubernetes(this.currentIsKubernetesValue);
    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(40000, DockerSeleniumRemoteProxy.class.getCanonicalName());
    request.getConfiguration().capabilities.clear();
    request.getConfiguration().capabilities.addAll(TestUtils.getDockerSeleniumCapabilitiesForTesting());
    // Creating the proxy
    proxy = DockerSeleniumRemoteProxy.getNewInstance(request, registry);
    proxy.setContainerClient(containerClient);
}
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) ObjectName(javax.management.ObjectName) Before(org.junit.Before)

Example 7 with GridHubConfiguration

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

the class DockerSeleniumStarterRemoteProxyTest method setUp.

@Before
public void setUp() {
    // Change the factory to return our version of the Container Client
    if (this.currentIsKubernetesValue.get()) {
        // This is needed in order to use a fresh version of the mock, otherwise the return values
        // are gone, and returning them always is not the normal behaviour.
        this.containerClient = KubernetesContainerMock.getMockedKubernetesContainerClient();
        ContainerFactory.setKubernetesContainerClient((KubernetesContainerClient) containerClient);
    } else {
        ContainerFactory.setContainerClientGenerator(() -> containerClient);
    }
    ContainerFactory.setIsKubernetes(this.currentIsKubernetesValue);
    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)
    request = TestUtils.getRegistrationRequestForTesting(30000, DockerSeleniumStarterRemoteProxy.class.getCanonicalName());
    // Creating the proxy
    DockerSeleniumStarterRemoteProxy.setContainerClient(containerClient);
    DockerSeleniumStarterRemoteProxy.setSleepIntervalMultiplier(0);
    DockerSeleniumStarterRemoteProxy proxy = DockerSeleniumStarterRemoteProxy.getNewInstance(request, registry);
    timeZone = DockerSeleniumStarterRemoteProxy.getConfiguredTimeZone();
    screenSize = DockerSeleniumStarterRemoteProxy.getConfiguredScreenSize();
    // Spying on the proxy to see if methods are invoked or not
    spyProxy = spy(proxy);
}
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) ObjectName(javax.management.ObjectName) Before(org.junit.Before)

Example 8 with GridHubConfiguration

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

the class ZaleniumRegistryTest method proxyIsRemoved.

@Test
public void proxyIsRemoved() throws Exception {
    GridRegistry registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
    DockerSeleniumRemoteProxy p1 = TestUtils.getNewBasicRemoteProxy("app1", "http://machine1:4444/", registry);
    try {
        registry.add(p1);
        assertTrue(registry.getAllProxies().size() == 1);
        registry.removeIfPresent(p1);
        assertTrue(registry.getAllProxies().size() == 0);
    } 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 9 with GridHubConfiguration

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

the class LiveNodeServletTest method setUp.

@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()));
    this.originalContainerClient = ContainerFactory.getContainerClientGenerator();
    ContainerFactory.setContainerClientGenerator(DockerContainerMock::getMockedDockerContainerClient);
    // Creating the configuration and the registration request of the proxy (node)
    RegistrationRequest registrationRequest = TestUtils.getRegistrationRequestForTesting(40000, DockerSeleniumRemoteProxy.class.getCanonicalName());
    registrationRequest.getConfiguration().capabilities.clear();
    registrationRequest.getConfiguration().capabilities.addAll(DockerSeleniumStarterRemoteProxy.getCapabilities());
    DockerSeleniumRemoteProxy proxyOne = DockerSeleniumRemoteProxy.getNewInstance(registrationRequest, registry);
    registrationRequest = TestUtils.getRegistrationRequestForTesting(40001, DockerSeleniumRemoteProxy.class.getCanonicalName());
    registrationRequest.getConfiguration().capabilities.clear();
    registrationRequest.getConfiguration().capabilities.addAll(DockerSeleniumStarterRemoteProxy.getCapabilities());
    DockerSeleniumRemoteProxy proxyTwo = DockerSeleniumRemoteProxy.getNewInstance(registrationRequest, registry);
    registry.add(proxyOne);
    registry.add(proxyTwo);
    request = mock(HttpServletRequest.class);
    response = mock(HttpServletResponse.class);
    when(request.getParameter("refresh")).thenReturn("1");
    when(request.getServerName()).thenReturn("localhost");
    when(response.getOutputStream()).thenReturn(TestUtils.getMockedServletOutputStream());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) MalformedObjectNameException(javax.management.MalformedObjectNameException) DockerContainerMock(de.zalando.ep.zalenium.util.DockerContainerMock) Hub(org.openqa.grid.web.Hub) DockerSeleniumRemoteProxy(de.zalando.ep.zalenium.proxy.DockerSeleniumRemoteProxy) JMXHelper(org.openqa.selenium.remote.server.jmx.JMXHelper) InstanceNotFoundException(javax.management.InstanceNotFoundException) HttpServletResponse(javax.servlet.http.HttpServletResponse) GridHubConfiguration(org.openqa.grid.internal.utils.configuration.GridHubConfiguration) RegistrationRequest(org.openqa.grid.common.RegistrationRequest) ObjectName(javax.management.ObjectName) Before(org.junit.Before)

Example 10 with GridHubConfiguration

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

the class VncAuthenticationServletTest method setUp.

@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()));
    this.originalContainerClient = ContainerFactory.getContainerClientGenerator();
    ContainerFactory.setContainerClientGenerator(DockerContainerMock::getMockedDockerContainerClient);
    // Creating the configuration and the registration request of the proxy (node)
    RegistrationRequest registrationRequest = TestUtils.getRegistrationRequestForTesting(40000, DockerSeleniumRemoteProxy.class.getCanonicalName());
    registrationRequest.getConfiguration().capabilities.clear();
    registrationRequest.getConfiguration().capabilities.addAll(DockerSeleniumStarterRemoteProxy.getCapabilities());
    DockerSeleniumRemoteProxy proxyOne = DockerSeleniumRemoteProxy.getNewInstance(registrationRequest, registry);
    registrationRequest = TestUtils.getRegistrationRequestForTesting(40001, DockerSeleniumRemoteProxy.class.getCanonicalName());
    registrationRequest.getConfiguration().capabilities.clear();
    registrationRequest.getConfiguration().capabilities.addAll(DockerSeleniumStarterRemoteProxy.getCapabilities());
    DockerSeleniumRemoteProxy proxyTwo = DockerSeleniumRemoteProxy.getNewInstance(registrationRequest, registry);
    registry.add(proxyOne);
    registry.add(proxyTwo);
    request = mock(HttpServletRequest.class);
    response = mock(HttpServletResponse.class);
    when(request.getParameter("refresh")).thenReturn("1");
    when(request.getServerName()).thenReturn("localhost");
    when(response.getOutputStream()).thenReturn(TestUtils.getMockedServletOutputStream());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) MalformedObjectNameException(javax.management.MalformedObjectNameException) DockerContainerMock(de.zalando.ep.zalenium.util.DockerContainerMock) Hub(org.openqa.grid.web.Hub) DockerSeleniumRemoteProxy(de.zalando.ep.zalenium.proxy.DockerSeleniumRemoteProxy) JMXHelper(org.openqa.selenium.remote.server.jmx.JMXHelper) InstanceNotFoundException(javax.management.InstanceNotFoundException) HttpServletResponse(javax.servlet.http.HttpServletResponse) GridHubConfiguration(org.openqa.grid.internal.utils.configuration.GridHubConfiguration) RegistrationRequest(org.openqa.grid.common.RegistrationRequest) ObjectName(javax.management.ObjectName) Before(org.junit.Before)

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