use of org.eclipse.che.api.workspace.shared.dto.event.MachineStatusEvent in project che-server by eclipse-che.
the class KubernetesInternalRuntimeTest method stopsWaitingAllMachineStartWhenOneMachineStartFailed.
@Test(expectedExceptions = InfrastructureException.class)
public void stopsWaitingAllMachineStartWhenOneMachineStartFailed() throws Exception {
final Container container1 = mockContainer(CONTAINER_NAME_1, EXPOSED_PORT_1);
final Container container2 = mockContainer(CONTAINER_NAME_2, EXPOSED_PORT_2, INTERNAL_PORT);
final ImmutableMap<String, Pod> allPods = ImmutableMap.of(WORKSPACE_POD_NAME, mockPod(ImmutableList.of(container1, container2)));
when(k8sEnv.getPodsCopy()).thenReturn(allPods);
internalRuntime = spy(internalRuntime);
doThrow(IllegalStateException.class).when(internalRuntime).waitRunningAsync(any(), argThat(m -> m.getName().equals(M1_NAME)));
try {
internalRuntime.start(emptyMap());
} catch (Exception rethrow) {
verify(deployments).deploy(any(Pod.class));
verify(ingresses).create(any());
verify(services).create(any());
verify(eventService, atLeastOnce()).publish(any());
final List<MachineStatusEvent> events = captureEvents();
assertTrue(events.contains(newEvent(M1_NAME, STARTING)));
throw rethrow;
}
}
use of org.eclipse.che.api.workspace.shared.dto.event.MachineStatusEvent in project devspaces-images by redhat-developer.
the class OpenShiftInternalRuntimeTest method verifyEventsOrder.
private void verifyEventsOrder(MachineStatusEvent... expectedEvents) {
final Iterator<MachineStatusEvent> actualEvents = captureEvents().iterator();
for (MachineStatusEvent expected : expectedEvents) {
if (!actualEvents.hasNext()) {
fail("It is expected to receive machine status events");
}
final MachineStatusEvent actual = actualEvents.next();
assertEquals(actual, expected);
}
if (actualEvents.hasNext()) {
fail("No more events expected");
}
}
use of org.eclipse.che.api.workspace.shared.dto.event.MachineStatusEvent in project devspaces-images by redhat-developer.
the class KubernetesInternalRuntimeTest method stopsWaitingAllMachineStartWhenOneMachineStartFailed.
@Test(expectedExceptions = InfrastructureException.class)
public void stopsWaitingAllMachineStartWhenOneMachineStartFailed() throws Exception {
final Container container1 = mockContainer(CONTAINER_NAME_1, EXPOSED_PORT_1);
final Container container2 = mockContainer(CONTAINER_NAME_2, EXPOSED_PORT_2, INTERNAL_PORT);
final ImmutableMap<String, Pod> allPods = ImmutableMap.of(WORKSPACE_POD_NAME, mockPod(ImmutableList.of(container1, container2)));
when(k8sEnv.getPodsCopy()).thenReturn(allPods);
internalRuntime = spy(internalRuntime);
doThrow(IllegalStateException.class).when(internalRuntime).waitRunningAsync(any(), argThat(m -> m.getName().equals(M1_NAME)));
try {
internalRuntime.start(emptyMap());
} catch (Exception rethrow) {
verify(deployments).deploy(any(Pod.class));
verify(ingresses).create(any());
verify(services).create(any());
verify(eventService, atLeastOnce()).publish(any());
final List<MachineStatusEvent> events = captureEvents();
assertTrue(events.contains(newEvent(M1_NAME, STARTING)));
throw rethrow;
}
}
use of org.eclipse.che.api.workspace.shared.dto.event.MachineStatusEvent in project che-server by eclipse-che.
the class KubernetesInternalRuntimeTest method verifyOrderedEventsChains.
private void verifyOrderedEventsChains(MachineStatusEvent[]... eventsArrays) {
Map<String, LinkedList<MachineStatusEvent>> machine2Events = new HashMap<>();
List<MachineStatusEvent> machineStatusEvents = captureEvents();
for (MachineStatusEvent event : machineStatusEvents) {
final String machineName = event.getMachineName();
machine2Events.computeIfPresent(machineName, (mName, events) -> {
events.add(event);
return events;
});
machine2Events.computeIfAbsent(machineName, mName -> {
final LinkedList<MachineStatusEvent> events = new LinkedList<>();
events.add(event);
return events;
});
}
for (MachineStatusEvent[] expected : eventsArrays) {
final MachineStatusEvent machineStatusEvent = expected[0];
final MachineStatusEvent[] actual = machine2Events.remove(machineStatusEvent.getMachineName()).toArray(new MachineStatusEvent[expected.length]);
assertEquals(actual, expected);
}
assertTrue(machine2Events.isEmpty(), "No more events expected");
}
use of org.eclipse.che.api.workspace.shared.dto.event.MachineStatusEvent in project che-server by eclipse-che.
the class OpenShiftInternalRuntimeTest method verifyEventsOrder.
private void verifyEventsOrder(MachineStatusEvent... expectedEvents) {
final Iterator<MachineStatusEvent> actualEvents = captureEvents().iterator();
for (MachineStatusEvent expected : expectedEvents) {
if (!actualEvents.hasNext()) {
fail("It is expected to receive machine status events");
}
final MachineStatusEvent actual = actualEvents.next();
assertEquals(actual, expected);
}
if (actualEvents.hasNext()) {
fail("No more events expected");
}
}
Aggregations