use of org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent in project devspaces-images by redhat-developer.
the class UnrecoverablePodEventListenerTest method testHandleRegularEvent.
@Test
public void testHandleRegularEvent() throws Exception {
// given
final PodEvent regularEvent = mockContainerEvent(WORKSPACE_POD_NAME, "Pulling", "pulling image", EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead());
// when
unrecoverableEventListener.handle(regularEvent);
// then
verify(unrecoverableEventConsumer, never()).accept(any());
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent in project devspaces-images by redhat-developer.
the class UnrecoverablePodEventListenerTest method testDoNotHandleUnrecoverableEventFromNonWorkspacePod.
@Test
public void testDoNotHandleUnrecoverableEventFromNonWorkspacePod() throws Exception {
// given
final String unrecoverableEventMessage = "Failed to pull image eclipse/che-server:nightly-centos";
final PodEvent unrecoverableEvent = mockContainerEvent("NonWorkspacePod", "Pulling", unrecoverableEventMessage, EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead());
// when
unrecoverableEventListener.handle(unrecoverableEvent);
// then
verify(unrecoverableEventConsumer, never()).accept(any());
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent in project devspaces-images by redhat-developer.
the class UnrecoverablePodEventListenerTest method mockContainerEvent.
/**
* Mock a container event, as though it was triggered by the OpenShift API. As workspace Pods are
* created indirectly through deployments, they are given generated names with the provided name
* as a root. <br>
* Use this method in a test to ensure that tested code manages this fact correctly. For example,
* code such as unrecoverable events handling cannot directly look at an event's pod name and
* compare it to the internal representation, and so must confirm the event is relevant in some
* other way.
*/
private static PodEvent mockContainerEvent(String podName, String reason, String message, String creationTimestamp, String lastTimestamp) {
final PodEvent event = mock(PodEvent.class);
when(event.getPodName()).thenReturn(podName + POD_NAME_RANDOM_SUFFIX);
lenient().when(event.getContainerName()).thenReturn(CONTAINER_NAME_1);
lenient().when(event.getReason()).thenReturn(reason);
lenient().when(event.getMessage()).thenReturn(message);
lenient().when(event.getCreationTimeStamp()).thenReturn(creationTimestamp);
lenient().when(event.getLastTimestamp()).thenReturn(lastTimestamp);
return event;
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent in project devspaces-images by redhat-developer.
the class UnrecoverablePodEventListenerTest method testHandleUnrecoverableEventByReason.
@Test
public void testHandleUnrecoverableEventByReason() throws Exception {
// given
String unrecoverableEventReason = "Failed Mount";
PodEvent unrecoverableEvent = mockContainerEvent(WORKSPACE_POD_NAME, unrecoverableEventReason, "Failed to mount volume 'claim-che-workspace'", EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead());
// when
unrecoverableEventListener.handle(unrecoverableEvent);
// then
verify(unrecoverableEventConsumer).accept(unrecoverableEvent);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent in project devspaces-images by redhat-developer.
the class UnrecoverablePodEventListenerTest method testHandleUnrecoverableEventByMessage.
@Test
public void testHandleUnrecoverableEventByMessage() throws Exception {
// given
String unrecoverableEventMessage = "Failed to pull image eclipse/che-server:nightly-centos";
PodEvent unrecoverableEvent = mockContainerEvent(WORKSPACE_POD_NAME, "Pulling", unrecoverableEventMessage, EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead());
// when
unrecoverableEventListener.handle(unrecoverableEvent);
// then
verify(unrecoverableEventConsumer).accept(unrecoverableEvent);
}
Aggregations