use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl in project devspaces-images by redhat-developer.
the class KubernetesInternalRuntimeTest method shouldReturnFalseIfAllPodsExistOnRuntimeConsistencyChecking.
@Test
public void shouldReturnFalseIfAllPodsExistOnRuntimeConsistencyChecking() throws Exception {
// given
KubernetesMachineImpl machine1 = new KubernetesMachineImpl(WORKSPACE_ID, "machine1", "pod1", "container 1", null, emptyMap(), emptyMap());
KubernetesMachineImpl machine2 = new KubernetesMachineImpl(WORKSPACE_ID, "machine2", "pod1", "container 2", null, emptyMap(), emptyMap());
KubernetesMachineImpl machine3 = new KubernetesMachineImpl(WORKSPACE_ID, "machine3", "pod2", "container 1", null, emptyMap(), emptyMap());
machinesCache.put(IDENTITY, machine1);
machinesCache.put(IDENTITY, machine2);
machinesCache.put(IDENTITY, machine3);
doReturn(Optional.empty()).when(deployments).get(anyString());
// when
boolean isConsistent = internalRuntime.isConsistent();
// then
assertFalse(isConsistent);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl in project devspaces-images by redhat-developer.
the class KubernetesInternalRuntimeTest method shouldReturnTrueIfAllPodsExistOnRuntimeConsistencyChecking.
@Test
public void shouldReturnTrueIfAllPodsExistOnRuntimeConsistencyChecking() throws Exception {
// given
KubernetesMachineImpl machine1 = new KubernetesMachineImpl(WORKSPACE_ID, "machine1", "pod1", "container 1", null, emptyMap(), emptyMap());
KubernetesMachineImpl machine2 = new KubernetesMachineImpl(WORKSPACE_ID, "machine2", "pod1", "container 2", null, emptyMap(), emptyMap());
KubernetesMachineImpl machine3 = new KubernetesMachineImpl(WORKSPACE_ID, "machine3", "pod2", "container 1", null, emptyMap(), emptyMap());
machinesCache.put(IDENTITY, machine1);
machinesCache.put(IDENTITY, machine2);
machinesCache.put(IDENTITY, machine3);
doReturn(Optional.of(mock(Pod.class))).when(deployments).get(anyString());
// when
boolean isConsistent = internalRuntime.isConsistent();
// then
assertTrue(isConsistent);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl in project devspaces-images by redhat-developer.
the class KubernetesMachinesCacheTest method shouldUpdateMachineStatus.
@Test
public void shouldUpdateMachineStatus() throws Exception {
// given
RuntimeIdentity runtimeId = runtimeStates[0].getRuntimeId();
KubernetesMachineImpl machine = machines[0];
String machineName = machine.getName();
// when
machineCache.updateMachineStatus(runtimeId, machineName, MachineStatus.RUNNING);
// then
Optional<KubernetesMachineImpl> machineOpt = machineCache.getMachines(runtimeId).entrySet().stream().filter(e -> e.getKey().equals(machineName)).map(Map.Entry::getValue).findAny();
assertTrue(machineOpt.isPresent());
assertEquals(machineOpt.get().getStatus(), MachineStatus.RUNNING);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl in project devspaces-images by redhat-developer.
the class KubernetesMachinesCacheTest method shouldThrowExceptionIfMachineIsAlreadyInCacheOnTryToPutMachine.
@Test(expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "Machine is already in cache")
public void shouldThrowExceptionIfMachineIsAlreadyInCacheOnTryToPutMachine() throws Exception {
// given
KubernetesMachineImpl machine = createMachine(workspaces[1].getId(), machines[0].getName(), MachineStatus.RUNNING, ImmutableMap.of("myServer", createServer(ServerStatus.RUNNING)));
// when
machineCache.put(runtimeStates[1].getRuntimeId(), machine);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl in project devspaces-images by redhat-developer.
the class KubernetesMachinesCacheTest method shouldThrowExceptionWhenServerWasNotFoundOnStatusUpdating.
@Test(expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "Server with name 'non-existing' was not found")
public void shouldThrowExceptionWhenServerWasNotFoundOnStatusUpdating() throws Exception {
// given
RuntimeIdentity runtimeId = runtimeStates[0].getRuntimeId();
KubernetesMachineImpl machine = machines[0];
// when
machineCache.updateServerStatus(runtimeId, machine.getName(), "non-existing", ServerStatus.RUNNING);
}
Aggregations