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"));
}
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);
}
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);
}
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);
}
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);
}
Aggregations