use of org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method setUp.
@BeforeMethod
public void setUp() {
internalEnvironment = spy(KubernetesEnvironment.builder().build());
internalEnvironment.setDevfile(new DevfileImpl());
applier = new KubernetesPluginsToolingApplier(TEST_IMAGE_POLICY, MEMORY_LIMIT_MB, MEMORY_REQUEST_MB, CPU_LIMIT, CPU_REQUEST, false, projectsRootEnvVariableProvider, chePluginsVolumeApplier, envVars);
Map<String, InternalMachineConfig> machines = new HashMap<>();
List<Container> containers = new ArrayList<>();
containers.add(userContainer);
machines.put(USER_MACHINE_NAME, userMachineConfig);
when(pod.getSpec()).thenReturn(podSpec);
lenient().when(podSpec.getContainers()).thenReturn(containers);
lenient().when(pod.getMetadata()).thenReturn(meta);
lenient().when(meta.getName()).thenReturn(POD_NAME);
internalEnvironment.addPod(pod);
internalEnvironment.getMachines().putAll(machines);
lenient().when(projectsRootEnvVariableProvider.get(any())).thenReturn(new Pair<>("projects_root", "/somewhere/over/the/rainbow"));
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig in project devspaces-images by redhat-developer.
the class LogsVolumeMachineProvisionerTest method testProvisionLogsVolumeToAllMachineInEnvironment.
@Test
public void testProvisionLogsVolumeToAllMachineInEnvironment() throws Exception {
logsVolumeProvisioner.provision(openShiftEnvironment, identity);
InternalMachineConfig m1 = openShiftEnvironment.getMachines().get(MACHINE_NAME_1);
InternalMachineConfig m2 = openShiftEnvironment.getMachines().get(MACHINE_NAME_2);
assertTrue(m1.getVolumes().containsKey(LOGS_VOLUME_NAME));
assertEquals(m1.getVolumes().get(LOGS_VOLUME_NAME).getPath(), WORKSPACE_LOGS_ROOT_PATH);
assertTrue(m2.getVolumes().containsKey(LOGS_VOLUME_NAME));
assertEquals(m2.getVolumes().get(LOGS_VOLUME_NAME).getPath(), WORKSPACE_LOGS_ROOT_PATH);
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig in project devspaces-images by redhat-developer.
the class JwtProxyProvisionerTest method shouldProvisionJwtProxyRelatedObjectsIntoKubernetesEnvironment.
@Test
public void shouldProvisionJwtProxyRelatedObjectsIntoKubernetesEnvironment() throws Exception {
// given
ServerConfigImpl secureServer = new ServerConfigImpl("4401/tcp", "ws", "/", emptyMap());
ServicePort port = new ServicePort();
port.setTargetPort(new IntOrString(4401));
// when
jwtProxyProvisioner.expose(k8sEnv, podWithName(), "machine", "terminal", port, "TCP", false, ImmutableMap.of("server", secureServer));
// then
InternalMachineConfig jwtProxyMachine = k8sEnv.getMachines().get(JwtProxyProvisioner.JWT_PROXY_MACHINE_NAME);
assertNotNull(jwtProxyMachine);
ConfigMap configMap = k8sEnv.getConfigMaps().get(jwtProxyProvisioner.getConfigMapName());
assertNotNull(configMap);
assertEquals(configMap.getData().get(JWT_PROXY_PUBLIC_KEY_FILE), PUBLIC_KEY_HEADER + Base64.getEncoder().encodeToString("publickey".getBytes()) + PUBLIC_KEY_FOOTER);
assertNotNull(configMap.getData().get(JWT_PROXY_CONFIG_FILE));
Pod jwtProxyPod = k8sEnv.getInjectablePodsCopy().getOrDefault("machine", emptyMap()).get("che-jwtproxy");
assertNotNull(jwtProxyPod);
assertEquals(1, jwtProxyPod.getSpec().getContainers().size());
Container jwtProxyContainer = jwtProxyPod.getSpec().getContainers().get(0);
assertEquals(jwtProxyContainer.getArgs().size(), 2);
assertEquals(jwtProxyContainer.getArgs().get(0), "-config");
assertEquals(jwtProxyContainer.getArgs().get(1), JWT_PROXY_CONFIG_FOLDER + "/" + JWT_PROXY_CONFIG_FILE);
assertEquals(jwtProxyContainer.getEnv().size(), 1);
EnvVar xdgHome = jwtProxyContainer.getEnv().get(0);
assertEquals(xdgHome.getName(), "XDG_CONFIG_HOME");
assertEquals(xdgHome.getValue(), JWT_PROXY_CONFIG_FOLDER);
Service jwtProxyService = k8sEnv.getServices().get(jwtProxyProvisioner.getServiceName());
assertNotNull(jwtProxyService);
}
Aggregations