Search in sources :

Example 6 with ServerPropertiesImpl

use of org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl in project che by eclipse.

the class ServerEvaluationStrategyTest method shouldPreferMachineConfOverDockerLabels.

@Test
public void shouldPreferMachineConfOverDockerLabels() throws Exception {
    // given
    prepareStrategyAndContainerInfoMocks();
    labels.put(String.format(SERVER_CONF_LABEL_REF_KEY, "8080/tcp"), "myserv1label");
    labels.put(String.format(SERVER_CONF_LABEL_PROTOCOL_KEY, "8080/tcp"), "https");
    labels.put(String.format(SERVER_CONF_LABEL_REF_KEY, "9090/udp"), "myserv2label");
    labels.put(String.format(SERVER_CONF_LABEL_PROTOCOL_KEY, "9090/udp"), "dhcp");
    labels.put(String.format(SERVER_CONF_LABEL_PATH_KEY, "9090/udp"), "/path");
    serverConfs.put("8080/tcp", new ServerConfImpl("myserv1conf", "8080/tcp", "http", null));
    final HashMap<String, ServerImpl> expectedServers = new HashMap<>();
    expectedServers.put("8080/tcp", new ServerImpl("myserv1conf", "http", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100", new ServerPropertiesImpl(null, DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100")));
    expectedServers.put("9090/udp", new ServerImpl("myserv2label", "dhcp", DEFAULT_HOSTNAME + ":32101", "dhcp://" + DEFAULT_HOSTNAME + ":32101/path", new ServerPropertiesImpl("/path", DEFAULT_HOSTNAME + ":32101", "dhcp://" + DEFAULT_HOSTNAME + ":32101/path")));
    // when
    final Map<String, ServerImpl> servers = strategy.getServers(containerInfo, DEFAULT_HOSTNAME, serverConfs);
    // then
    assertEquals(servers, expectedServers);
}
Also used : ServerImpl(org.eclipse.che.api.machine.server.model.impl.ServerImpl) HashMap(java.util.HashMap) ServerPropertiesImpl(org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl) ServerConfImpl(org.eclipse.che.api.machine.server.model.impl.ServerConfImpl) Test(org.testng.annotations.Test)

Example 7 with ServerPropertiesImpl

use of org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl in project che by eclipse.

the class ServerEvaluationStrategyTest method shouldAddPathCorrectlyWithoutLeadingSlash.

@Test
public void shouldAddPathCorrectlyWithoutLeadingSlash() throws Exception {
    // given
    prepareStrategyAndContainerInfoMocks();
    serverConfs.put("8080", new ServerConfImpl("myserv1", "8080", "http", "some"));
    serverConfs.put("9090/udp", new ServerConfImpl("myserv1-tftp", "9090/udp", "tftp", "some/path"));
    final HashMap<String, ServerImpl> expectedServers = new HashMap<>();
    expectedServers.put("8080/tcp", new ServerImpl("myserv1", "http", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100/some", new ServerPropertiesImpl("some", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100/some")));
    expectedServers.put("9090/udp", new ServerImpl("myserv1-tftp", "tftp", DEFAULT_HOSTNAME + ":32101", "tftp://" + DEFAULT_HOSTNAME + ":32101/some/path", new ServerPropertiesImpl("some/path", DEFAULT_HOSTNAME + ":32101", "tftp://" + DEFAULT_HOSTNAME + ":32101/some/path")));
    // when
    final Map<String, ServerImpl> servers = strategy.getServers(containerInfo, DEFAULT_HOSTNAME, serverConfs);
    // then
    assertEquals(servers, expectedServers);
}
Also used : ServerImpl(org.eclipse.che.api.machine.server.model.impl.ServerImpl) HashMap(java.util.HashMap) ServerPropertiesImpl(org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl) ServerConfImpl(org.eclipse.che.api.machine.server.model.impl.ServerConfImpl) Test(org.testng.annotations.Test)

Example 8 with ServerPropertiesImpl

use of org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl in project che by eclipse.

the class ServerEvaluationStrategyTest method shouldAddRefUrlPathToServerFromLabels.

@Test
public void shouldAddRefUrlPathToServerFromLabels() throws Exception {
    // given
    Map<String, List<PortBinding>> ports = prepareStrategyAndContainerInfoMocks();
    Map<String, String> labels = new HashMap<>();
    when(containerConfig.getLabels()).thenReturn(labels);
    ports.put("8080/tcp", Collections.singletonList(new PortBinding().withHostIp(ALL_IP_ADDRESS).withHostPort("32100")));
    ports.put("9090/udp", Collections.singletonList(new PortBinding().withHostIp(ALL_IP_ADDRESS).withHostPort("32101")));
    labels.put(String.format(SERVER_CONF_LABEL_REF_KEY, "8080/tcp"), "myserv1");
    labels.put(String.format(SERVER_CONF_LABEL_PROTOCOL_KEY, "8080/tcp"), "http");
    labels.put(String.format(SERVER_CONF_LABEL_PATH_KEY, "8080/tcp"), "/some/path");
    labels.put(String.format(SERVER_CONF_LABEL_PROTOCOL_KEY, "9090/udp"), "dhcp");
    labels.put(String.format(SERVER_CONF_LABEL_PATH_KEY, "9090/udp"), "some/path");
    final HashMap<String, ServerImpl> expectedServers = new HashMap<>();
    expectedServers.put("8080/tcp", new ServerImpl("myserv1", "http", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100/some/path", new ServerPropertiesImpl("/some/path", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100/some/path")));
    expectedServers.put("9090/udp", new ServerImpl("Server-9090-udp", "dhcp", DEFAULT_HOSTNAME + ":32101", "dhcp://" + DEFAULT_HOSTNAME + ":32101/some/path", new ServerPropertiesImpl("some/path", DEFAULT_HOSTNAME + ":32101", "dhcp://" + DEFAULT_HOSTNAME + ":32101/some/path")));
    // when
    final Map<String, ServerImpl> servers = strategy.getServers(containerInfo, DEFAULT_HOSTNAME, serverConfs);
    // then
    assertEquals(servers, expectedServers);
}
Also used : PortBinding(org.eclipse.che.plugin.docker.client.json.PortBinding) ServerImpl(org.eclipse.che.api.machine.server.model.impl.ServerImpl) HashMap(java.util.HashMap) List(java.util.List) ServerPropertiesImpl(org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl) Test(org.testng.annotations.Test)

Example 9 with ServerPropertiesImpl

use of org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl in project che by eclipse.

the class ServerEvaluationStrategyTest method shouldAddDefaultReferenceIfReferenceIsNotSet.

@Test
public void shouldAddDefaultReferenceIfReferenceIsNotSet() throws Exception {
    // given
    prepareStrategyAndContainerInfoMocks();
    final HashMap<String, ServerImpl> expectedServers = new HashMap<>();
    expectedServers.put("8080/tcp", new ServerImpl("Server-8080-tcp", null, DEFAULT_HOSTNAME + ":32100", null, new ServerPropertiesImpl(null, DEFAULT_HOSTNAME + ":32100", null)));
    expectedServers.put("9090/udp", new ServerImpl("Server-9090-udp", null, DEFAULT_HOSTNAME + ":32101", null, new ServerPropertiesImpl(null, DEFAULT_HOSTNAME + ":32101", null)));
    // when
    final Map<String, ServerImpl> servers = strategy.getServers(containerInfo, DEFAULT_HOSTNAME, serverConfs);
    // then
    assertEquals(servers, expectedServers);
}
Also used : ServerImpl(org.eclipse.che.api.machine.server.model.impl.ServerImpl) HashMap(java.util.HashMap) ServerPropertiesImpl(org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl) Test(org.testng.annotations.Test)

Example 10 with ServerPropertiesImpl

use of org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl in project che by eclipse.

the class ServerEvaluationStrategyTest method shouldAllowToUsePortFromMachineConfigWithoutTransportProtocol.

@Test
public void shouldAllowToUsePortFromMachineConfigWithoutTransportProtocol() throws Exception {
    // given
    prepareStrategyAndContainerInfoMocks();
    serverConfs.put("8080", new ServerConfImpl("myserv1", "8080", "http", "/some"));
    serverConfs.put("9090/udp", new ServerConfImpl("myserv1-tftp", "9090/udp", "tftp", "/path"));
    final HashMap<String, ServerImpl> expectedServers = new HashMap<>();
    expectedServers.put("8080/tcp", new ServerImpl("myserv1", "http", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100/some", new ServerPropertiesImpl("/some", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100/some")));
    expectedServers.put("9090/udp", new ServerImpl("myserv1-tftp", "tftp", DEFAULT_HOSTNAME + ":32101", "tftp://" + DEFAULT_HOSTNAME + ":32101/path", new ServerPropertiesImpl("/path", DEFAULT_HOSTNAME + ":32101", "tftp://" + DEFAULT_HOSTNAME + ":32101/path")));
    // when
    final Map<String, ServerImpl> servers = strategy.getServers(containerInfo, DEFAULT_HOSTNAME, serverConfs);
    // then
    assertEquals(servers, expectedServers);
}
Also used : ServerImpl(org.eclipse.che.api.machine.server.model.impl.ServerImpl) HashMap(java.util.HashMap) ServerPropertiesImpl(org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl) ServerConfImpl(org.eclipse.che.api.machine.server.model.impl.ServerConfImpl) Test(org.testng.annotations.Test)

Aggregations

ServerImpl (org.eclipse.che.api.machine.server.model.impl.ServerImpl)11 ServerPropertiesImpl (org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl)11 HashMap (java.util.HashMap)9 Test (org.testng.annotations.Test)8 ServerConfImpl (org.eclipse.che.api.machine.server.model.impl.ServerConfImpl)5 List (java.util.List)2 Response (com.jayway.restassured.response.Response)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 ServerProperties (org.eclipse.che.api.core.model.machine.ServerProperties)1 MachineConfigImpl (org.eclipse.che.api.machine.server.model.impl.MachineConfigImpl)1 MachineImpl (org.eclipse.che.api.machine.server.model.impl.MachineImpl)1 MachineLimitsImpl (org.eclipse.che.api.machine.server.model.impl.MachineLimitsImpl)1 MachineRuntimeInfoImpl (org.eclipse.che.api.machine.server.model.impl.MachineRuntimeInfoImpl)1 MachineSourceImpl (org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl)1 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)1 ExtendedMachineImpl (org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl)1 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)1 WorkspaceRuntimeImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceRuntimeImpl)1 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)1