use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method addToolingInitContainerWithArgs.
@Test
public void addToolingInitContainerWithArgs() throws InfrastructureException {
List<String> args = Arrays.asList("cp", "-rf", "test-file", "/some-volume/test");
lenient().when(podSpec.getInitContainers()).thenReturn(new ArrayList<>());
ChePlugin chePlugin = createChePlugin();
List<CheContainer> initContainers = singletonList(createContainer(null, args));
chePlugin.setInitContainers(initContainers);
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
verifyPodAndInitContainersNumber(1);
Container toolingInitContainer = getOnlyOneInitContainerFromPod(internalEnvironment);
verifyContainer(toolingInitContainer);
assertEquals(toolingInitContainer.getArgs(), args);
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method addsMachinesWithVolumesToAllToolingContainer.
@Test
public void addsMachinesWithVolumesToAllToolingContainer() throws Exception {
// given
ChePlugin chePluginWithNonDefaultVolume = createChePlugin();
String anotherVolumeName = VOLUME_NAME + "1";
String anotherVolumeMountPath = VOLUME_MOUNT_PATH + "/something";
List<Volume> volumes = singletonList(new Volume().name(anotherVolumeName).mountPath(anotherVolumeMountPath));
CheContainer toolingContainer = chePluginWithNonDefaultVolume.getContainers().get(0);
toolingContainer.setVolumes(volumes);
ChePlugin chePlugin = createChePlugin();
// when
applier.apply(runtimeIdentity, internalEnvironment, asList(chePlugin, chePluginWithNonDefaultVolume));
// then
Collection<InternalMachineConfig> machineConfigs = getNonUserMachines(internalEnvironment);
assertEquals(machineConfigs.size(), 2);
verify(chePluginsVolumeApplier).applyVolumes(any(PodData.class), any(Container.class), eq(chePlugin.getContainers().get(0).getVolumes()), eq(internalEnvironment));
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method addToolingContainerWithCommandAndArgs.
@Test
public void addToolingContainerWithCommandAndArgs() throws InfrastructureException {
List<String> command = singletonList("tail");
List<String> args = Arrays.asList("-f", "/dev/null");
lenient().when(podSpec.getContainers()).thenReturn(new ArrayList<>());
ChePlugin chePlugin = createChePlugin();
List<CheContainer> containers = singletonList(createContainer(command, args));
chePlugin.setContainers(containers);
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
verifyPodAndContainersNumber(1);
Container toolingContainer = getOneAndOnlyNonUserContainer(internalEnvironment);
verifyContainer(toolingContainer);
assertEquals(toolingContainer.getCommand(), command);
assertEquals(toolingContainer.getArgs(), args);
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project devspaces-images by redhat-developer.
the class K8sContainerResolverBuilderTest method shouldPassOnlyParticularContainerEndpoints.
@Test
public void shouldPassOnlyParticularContainerEndpoints() {
// given
K8sContainerResolverBuilder builder = new K8sContainerResolverBuilder();
builder.setContainer(new CheContainer().ports(asList(new CheContainerPort().exposedPort(9014), new CheContainerPort().exposedPort(4040))));
builder.setPluginEndpoints(asList(new ChePluginEndpoint().targetPort(9014), new ChePluginEndpoint().targetPort(9013), new ChePluginEndpoint().targetPort(8080), new ChePluginEndpoint().targetPort(4040)));
K8sContainerResolver resolver = builder.build();
ArrayList<ChePluginEndpoint> expected = new ArrayList<>();
expected.add(new ChePluginEndpoint().targetPort(9014));
expected.add(new ChePluginEndpoint().targetPort(4040));
// when
List<ChePluginEndpoint> actualEndpoints = resolver.getEndpoints();
// then
assertEqualsNoOrder(actualEndpoints.toArray(), expected.toArray());
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project devspaces-images by redhat-developer.
the class K8sContainerResolverTest method setUp.
@BeforeMethod
public void setUp() {
cheContainer = new CheContainer();
endpoints = new ArrayList<>();
resolver = new K8sContainerResolver("Always", cheContainer, endpoints);
}
Aggregations