Search in sources :

Example 86 with InternalMachineConfig

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"));
}
Also used : InternalMachineConfig(org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig) Container(io.fabric8.kubernetes.api.model.Container) CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) HashMap(java.util.HashMap) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ArrayList(java.util.ArrayList) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 87 with InternalMachineConfig

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);
}
Also used : InternalMachineConfig(org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig) Test(org.testng.annotations.Test)

Example 88 with InternalMachineConfig

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);
}
Also used : ServicePort(io.fabric8.kubernetes.api.model.ServicePort) InternalMachineConfig(org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig) Container(io.fabric8.kubernetes.api.model.Container) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Pod(io.fabric8.kubernetes.api.model.Pod) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Service(io.fabric8.kubernetes.api.model.Service) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) Test(org.testng.annotations.Test)

Aggregations

InternalMachineConfig (org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig)88 Test (org.testng.annotations.Test)64 Container (io.fabric8.kubernetes.api.model.Container)36 ChePlugin (org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin)18 PodData (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData)16 DevfileImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl)14 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)12 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)12 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)12 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)10 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)10 Pod (io.fabric8.kubernetes.api.model.Pod)10 Secret (io.fabric8.kubernetes.api.model.Secret)10 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)10 InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)10 HashMap (java.util.HashMap)8 CheContainer (org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer)8 Traced (org.eclipse.che.commons.annotation.Traced)8 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)6 PodSpecBuilder (io.fabric8.kubernetes.api.model.PodSpecBuilder)6