use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method createInstanceFromRecipe.
private CheServiceImpl createInstanceFromRecipe() throws Exception {
CheServiceImpl service = createService();
createInstanceFromRecipe(service);
return service;
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method shouldUseLocalImageOnInstanceCreationFromSnapshot.
@Test
public void shouldUseLocalImageOnInstanceCreationFromSnapshot() throws Exception {
final String repo = MACHINE_SNAPSHOT_PREFIX + "repo";
final String tag = "latest";
provider = spy(new MachineProviderBuilder().setSnapshotUseRegistry(false).build());
CheServiceImpl machine = createService();
machine.setImage(repo + ":" + tag);
machine.setBuild(null);
provider.startService(USER_NAME, WORKSPACE_ID, ENV_NAME, MACHINE_NAME, false, NETWORK_NAME, machine, LineConsumer.DEV_NULL);
verify(dockerConnector, never()).pull(any(PullParams.class), any(ProgressMonitor.class));
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method shouldCreateContainerOnInstanceCreationFromSnapshot.
@Test
public void shouldCreateContainerOnInstanceCreationFromSnapshot() throws Exception {
// when
CheServiceImpl machine = createInstanceFromSnapshot();
// then
ArgumentCaptor<CreateContainerParams> argumentCaptor = ArgumentCaptor.forClass(CreateContainerParams.class);
verify(dockerConnector).createContainer(argumentCaptor.capture());
assertEquals(argumentCaptor.getValue().getContainerConfig().getImage(), "eclipse-che/" + machine.getContainerName());
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method shouldAddCommonsSystemVolumesOnlyOnNonDevInstanceCreationFromSnapshot.
@Test
public void shouldAddCommonsSystemVolumesOnlyOnNonDevInstanceCreationFromSnapshot() throws Exception {
String[] bindMountVolumesFromMachine = new String[] { "/my/bind/mount1:/from/host1", "/my/bind/mount2:/from/host2:ro", "/my/bind/mount3:/from/host3:ro,Z" };
String[] volumesFromMachine = new String[] { "/projects", "/something", "/something/else" };
String[] allMachinesSystemVolumes = new String[] { "/some/thing/else:/home/some/thing/else", "/other/path:/home/other/path", "/home/other/path2" };
String[] devMachinesSystemVolumes = new String[] { "/etc:/tmp/etc:ro", "/some/thing:/home/some/thing", "/some/thing2:/home/some/thing2:ro,z", "/home/some/thing3" };
String[] expectedBindMountVolumes = new String[] { "/my/bind/mount1:/from/host1", "/my/bind/mount2:/from/host2:ro", "/my/bind/mount3:/from/host3:ro,Z", "/some/thing/else:/home/some/thing/else", "/other/path:/home/other/path" };
Map<String, Volume> expectedVolumes = Stream.of("/projects", "/something", "/something/else", "/home/other/path2").collect(toMap(Function.identity(), v -> new Volume()));
provider = new MachineProviderBuilder().setDevMachineVolumes(new HashSet<>(asList(devMachinesSystemVolumes))).setAllMachineVolumes(new HashSet<>(asList(allMachinesSystemVolumes))).build();
CheServiceImpl service = createService();
service.setVolumes(Stream.concat(Stream.of(bindMountVolumesFromMachine), Stream.of(volumesFromMachine)).collect(Collectors.toList()));
createInstanceFromSnapshot(service, false);
ArgumentCaptor<CreateContainerParams> argumentCaptor = ArgumentCaptor.forClass(CreateContainerParams.class);
verify(dockerConnector).createContainer(argumentCaptor.capture());
String[] actualBindMountVolumes = argumentCaptor.getValue().getContainerConfig().getHostConfig().getBinds();
Map<String, Volume> actualVolumes = argumentCaptor.getValue().getContainerConfig().getVolumes();
assertEquals(actualVolumes, expectedVolumes);
assertEqualsNoOrder(actualBindMountVolumes, expectedBindMountVolumes);
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method shouldCallCreationDockerInstanceWithFactoryOnCreateInstanceFromRecipe.
@Test
public void shouldCallCreationDockerInstanceWithFactoryOnCreateInstanceFromRecipe() throws Exception {
CheServiceImpl service = createService();
createInstanceFromRecipe(service);
verify(dockerMachineFactory).createInstance(any(Machine.class), eq(CONTAINER_ID), eq("eclipse-che/" + service.getContainerName()), eq(dockerNode), any(LineConsumer.class));
}
Aggregations