Search in sources :

Example 6 with RegistrationRequest

use of org.openqa.grid.common.RegistrationRequest in project zalenium by zalando.

the class TestUtils method getNewBasicRemoteProxy.

public static DockerSeleniumRemoteProxy getNewBasicRemoteProxy(String browser, String url, GridRegistry registry) throws MalformedURLException {
    GridNodeConfiguration config = new GridNodeConfiguration();
    URL u = new URL(url);
    config.host = u.getHost();
    config.port = u.getPort();
    config.role = "webdriver";
    RegistrationRequest req = RegistrationRequest.build(config);
    req.getConfiguration().capabilities.clear();
    DesiredCapabilities capability = new DesiredCapabilities();
    capability.setBrowserName(browser);
    req.getConfiguration().capabilities.add(capability);
    return createProxy(registry, req);
}
Also used : DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) GridNodeConfiguration(org.openqa.grid.internal.utils.configuration.GridNodeConfiguration) RegistrationRequest(org.openqa.grid.common.RegistrationRequest) URL(java.net.URL)

Example 7 with RegistrationRequest

use of org.openqa.grid.common.RegistrationRequest 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)

Example 8 with RegistrationRequest

use of org.openqa.grid.common.RegistrationRequest in project carina by qaprosoft.

the class ProxyInfo method process.

protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException {
    List<RegistrationRequest> proxies = new ArrayList<>();
    Iterator<RemoteProxy> itr = this.getRegistry().getAllProxies().iterator();
    while (itr.hasNext()) {
        RemoteProxy proxy = itr.next();
        proxies.add(proxy.getOriginalRegistrationRequest());
    }
    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    try {
        mapper.writeValue(response.getWriter(), proxies);
        response.setStatus(HttpStatus.SC_OK);
    } catch (Exception e) {
        response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
    } finally {
        response.getWriter().close();
    }
}
Also used : RemoteProxy(org.openqa.grid.internal.RemoteProxy) ArrayList(java.util.ArrayList) RegistrationRequest(org.openqa.grid.common.RegistrationRequest) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 9 with RegistrationRequest

use of org.openqa.grid.common.RegistrationRequest 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 10 with RegistrationRequest

use of org.openqa.grid.common.RegistrationRequest in project zalenium by zalando.

the class SauceLabsRemoteProxyTest method nodeHasCapabilitiesEvenWhenUrlCallFails.

@SuppressWarnings("ConstantConditions")
@Test
public void nodeHasCapabilitiesEvenWhenUrlCallFails() {
    try {
        CommonProxyUtilities commonProxyUtilities = mock(CommonProxyUtilities.class);
        when(commonProxyUtilities.readJSONFromUrl(anyString(), anyString(), anyString())).thenReturn(null);
        SauceLabsRemoteProxy.setCommonProxyUtilities(commonProxyUtilities);
        RegistrationRequest request = TestUtils.getRegistrationRequestForTesting(30001, SauceLabsRemoteProxy.class.getCanonicalName());
        request = SauceLabsRemoteProxy.updateSLCapabilities(request, "");
        // Now the capabilities should be filled even if the url was not fetched
        Assert.assertFalse(request.getConfiguration().capabilities.isEmpty());
    } finally {
        SauceLabsRemoteProxy.restoreCommonProxyUtilities();
    }
}
Also used : CommonProxyUtilities(de.zalando.ep.zalenium.util.CommonProxyUtilities) RegistrationRequest(org.openqa.grid.common.RegistrationRequest) Test(org.junit.Test)

Aggregations

RegistrationRequest (org.openqa.grid.common.RegistrationRequest)14 ObjectName (javax.management.ObjectName)10 JMXHelper (org.openqa.selenium.remote.server.jmx.JMXHelper)10 GridHubConfiguration (org.openqa.grid.internal.utils.configuration.GridHubConfiguration)9 Hub (org.openqa.grid.web.Hub)9 InstanceNotFoundException (javax.management.InstanceNotFoundException)8 MalformedObjectNameException (javax.management.MalformedObjectNameException)8 CommonProxyUtilities (de.zalando.ep.zalenium.util.CommonProxyUtilities)7 Before (org.junit.Before)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 Test (org.junit.Test)5 DockerSeleniumRemoteProxy (de.zalando.ep.zalenium.proxy.DockerSeleniumRemoteProxy)4 DockerContainerMock (de.zalando.ep.zalenium.util.DockerContainerMock)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 ExternalSessionKey (org.openqa.grid.internal.ExternalSessionKey)3 TestSession (org.openqa.grid.internal.TestSession)3 Environment (de.zalando.ep.zalenium.util.Environment)2 GridRegistry (org.openqa.grid.internal.GridRegistry)2 WebDriverRequest (org.openqa.grid.web.servlet.handler.WebDriverRequest)2 JsonElement (com.google.gson.JsonElement)1