Search in sources :

Example 11 with ExtendedMachineImpl

use of org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl in project che by eclipse.

the class AgentConfigApplierTest method shouldAddExposedPorts.

@Test
public void shouldAddExposedPorts() throws Exception {
    final ServerConf2 serverConf1 = mock(ServerConf2.class);
    final ServerConf2 serverConf2 = mock(ServerConf2.class);
    when(serverConf1.getPort()).thenReturn("1111/udp");
    when(serverConf2.getPort()).thenReturn("2222/tcp");
    when(sorter.sort(any())).thenReturn(asList(AgentKeyImpl.parse("agent1"), AgentKeyImpl.parse("agent2"), AgentKeyImpl.parse("agent3")));
    when(agent1.getServers()).thenAnswer(invocation -> singletonMap("a", serverConf1));
    when(agent2.getServers()).thenAnswer(invocation -> singletonMap("b", serverConf2));
    when(agent3.getServers()).thenReturn(emptyMap());
    CheServiceImpl service = new CheServiceImpl();
    agentConfigApplier.apply(new ExtendedMachineImpl(asList("agent1", "agent2", "agent3"), emptyMap(), emptyMap()), service);
    List<String> exposedPorts = service.getExpose();
    assertTrue(exposedPorts.contains("1111/udp"));
    assertTrue(exposedPorts.contains("2222/tcp"));
}
Also used : CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) ServerConf2(org.eclipse.che.api.core.model.workspace.ServerConf2) Test(org.testng.annotations.Test)

Example 12 with ExtendedMachineImpl

use of org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl in project che by eclipse.

the class CheEnvironmentValidatorTest method createEnv.

private static EnvironmentDto createEnv() {
    // singletonMap, asList are wrapped into modifiable collections to ease env modifying by tests
    EnvironmentImpl env = new EnvironmentImpl();
    Map<String, ExtendedMachineImpl> machines = new HashMap<>();
    Map<String, ServerConf2Impl> servers = new HashMap<>();
    servers.put("ref1", new ServerConf2Impl("8080/tcp", "proto1", singletonMap("prop1", "propValue")));
    servers.put("ref2", new ServerConf2Impl("8080/udp", "proto1", null));
    servers.put("ref3", new ServerConf2Impl("9090", "proto1", null));
    machines.put("dev-machine", new ExtendedMachineImpl(asList("org.eclipse.che.ws-agent", "someAgent"), servers, singletonMap("memoryLimitBytes", "10000")));
    machines.put("machine2", new ExtendedMachineImpl(asList("someAgent2", "someAgent3"), null, singletonMap("memoryLimitBytes", "10000")));
    env.setRecipe(new EnvironmentRecipeImpl("compose", "application/x-yaml", "content", null));
    env.setMachines(machines);
    return DtoConverter.asDto(env);
}
Also used : ServerConf2Impl(org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl) HashMap(java.util.HashMap) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) EnvironmentRecipeImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)

Example 13 with ExtendedMachineImpl

use of org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl in project che by eclipse.

the class EnvironmentParserTest method shouldOverrideMemoryLimitFromExtendedMachineInComposeEnv.

@Test
public void shouldOverrideMemoryLimitFromExtendedMachineInComposeEnv() throws Exception {
    // given
    HashMap<String, ExtendedMachineImpl> machines = new HashMap<>();
    machines.put("machine1", new ExtendedMachineImpl(emptyList(), emptyMap(), singletonMap("memoryLimitBytes", "101010")));
    machines.put("machine2", new ExtendedMachineImpl(emptyList(), emptyMap(), emptyMap()));
    EnvironmentImpl environment = new EnvironmentImpl(new EnvironmentRecipeImpl("compose", "application/x-yaml", "content", null), machines);
    CheServicesEnvironmentImpl cheEnv = new CheServicesEnvironmentImpl();
    cheEnv.getServices().put("machine1", new CheServiceImpl());
    cheEnv.getServices().put("machine2", new CheServiceImpl());
    when(envParser.parse(environment)).thenReturn(cheEnv);
    // when
    CheServicesEnvironmentImpl cheServicesEnvironment = parser.parse(environment);
    // then
    assertEquals(cheServicesEnvironment, cheEnv);
    assertEquals(cheServicesEnvironment.getServices().get("machine1").getMemLimit().longValue(), 101010L);
    assertEquals(cheServicesEnvironment.getServices().get("machine2").getMemLimit(), null);
}
Also used : HashMap(java.util.HashMap) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) EnvironmentRecipeImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl) Test(org.testng.annotations.Test)

Example 14 with ExtendedMachineImpl

use of org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl in project che by eclipse.

the class EnvironmentParserTest method getEntryForComposeEnv.

private static List<Object> getEntryForComposeEnv(Map<String, ServerConf2Impl> servers, List<String> composeExpose, Map<String, String> composeLabels, List<String> expectedExpose, Map<String, String> expectedLabels) {
    CheServicesEnvironmentImpl cheComposeEnv = createCheServicesEnv(new HashMap<>(composeLabels), new ArrayList<>(composeExpose));
    CheServicesEnvironmentImpl expectedEnv = createCheServicesEnv(expectedLabels, expectedExpose);
    EnvironmentImpl environmentConfig = createCompose1MachineEnvConfig();
    ExtendedMachineImpl extendedMachine = getMachine(environmentConfig);
    extendedMachine.setServers(new HashMap<>(servers));
    return asList(environmentConfig, expectedEnv, cheComposeEnv);
}
Also used : ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)

Example 15 with ExtendedMachineImpl

use of org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl in project che by eclipse.

the class EnvironmentParserTest method shouldThrowExceptionInCaseFailedParseMemoryLimit.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Value of attribute 'memoryLimitBytes' of machine 'machine1' is illegal")
public void shouldThrowExceptionInCaseFailedParseMemoryLimit() throws ServerException {
    HashMap<String, ExtendedMachineImpl> machines = new HashMap<>();
    machines.put("machine1", new ExtendedMachineImpl(emptyList(), emptyMap(), singletonMap("memoryLimitBytes", "here should be memory size number")));
    EnvironmentImpl environment = new EnvironmentImpl(new EnvironmentRecipeImpl("compose", "application/x-yaml", "content", null), machines);
    CheServicesEnvironmentImpl cheEnv = new CheServicesEnvironmentImpl();
    cheEnv.getServices().put("machine1", new CheServiceImpl());
    when(envParser.parse(environment)).thenReturn(cheEnv);
    // when
    parser.parse(environment);
}
Also used : HashMap(java.util.HashMap) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) EnvironmentRecipeImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl) Test(org.testng.annotations.Test)

Aggregations

ExtendedMachineImpl (org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl)21 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)16 CheServicesEnvironmentImpl (org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)10 EnvironmentRecipeImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)10 CheServiceImpl (org.eclipse.che.api.environment.server.model.CheServiceImpl)9 Test (org.testng.annotations.Test)8 ServerConf2Impl (org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl)7 HashMap (java.util.HashMap)6 ArrayList (java.util.ArrayList)3 CommandImpl (org.eclipse.che.api.machine.server.model.impl.CommandImpl)3 ProjectConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)3 SourceStorageImpl (org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl)3 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)3 ConflictException (org.eclipse.che.api.core.ConflictException)2 NotFoundException (org.eclipse.che.api.core.NotFoundException)2 ServerConf2 (org.eclipse.che.api.core.model.workspace.ServerConf2)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Arrays (java.util.Arrays)1