use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class CheEnvironmentValidatorTest method shouldNotFailIfExtraMachineDoesNotHaveExtendedMachineEntry.
@Test
public void shouldNotFailIfExtraMachineDoesNotHaveExtendedMachineEntry() throws Exception {
// given
CheServicesEnvironmentImpl cheServicesEnv = createServicesEnv();
cheServicesEnv.getServices().put("extra", createCheService("_extra", 1000000L, null, null, null));
when(environmentParser.parse(any(Environment.class))).thenReturn(cheServicesEnv);
// when
environmentValidator.validate("env", environment);
}
use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class EnvironmentParserTest method createCheServicesEnv.
private static CheServicesEnvironmentImpl createCheServicesEnv(Map<String, String> labels, List<String> expose) {
CheServiceImpl cheService = new CheServiceImpl().withLabels(labels).withExpose(expose).withImage(DEFAULT_DOCKER_IMAGE);
Map<String, CheServiceImpl> cheComposeEnvs = new HashMap<>();
cheComposeEnvs.put(DEFAULT_MACHINE_NAME, cheService);
return new CheServicesEnvironmentImpl().withServices(cheComposeEnvs);
}
use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class EnvironmentParserTest method shouldAddPortsAndLabelsFromExtendedMachineServers.
@Test(dataProvider = "environmentWithServersProvider")
public void shouldAddPortsAndLabelsFromExtendedMachineServers(EnvironmentImpl environment, CheServicesEnvironmentImpl expectedEnv, CheServicesEnvironmentImpl parsedCheEnv) throws Exception {
when(envParser.parse(any(Environment.class))).thenReturn(parsedCheEnv);
// when
CheServicesEnvironmentImpl cheServicesEnvironment = parser.parse(environment);
// then
// prevent failures because of reordered entries of expose field
assertEquals(cheServicesEnvironment.getServices().size(), expectedEnv.getServices().size());
cheServicesEnvironment.getServices().entrySet().forEach(entry -> {
CheServiceImpl actual = entry.getValue();
CheServiceImpl expected = expectedEnv.getServices().get(entry.getKey());
assertNotNull(expected);
assertEqualsNoOrder(actual.getExpose().toArray(), expected.getExpose().toArray(), format("Expose fields differ. Actual:%s. Expected:%s", actual.getExpose(), expected.getExpose()));
expected.setExpose(null);
actual.setExpose(null);
});
assertEquals(cheServicesEnvironment, expectedEnv);
}
use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl 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.environment.server.model.CheServicesEnvironmentImpl 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);
}
Aggregations