Search in sources :

Example 26 with PodEvent

use of org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent in project che-server by eclipse-che.

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());
}
Also used : PodEvent(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent) Test(org.testng.annotations.Test)

Example 27 with PodEvent

use of org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent in project che-server by eclipse-che.

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);
}
Also used : PodEvent(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent) Test(org.testng.annotations.Test)

Example 28 with PodEvent

use of org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent in project che-server by eclipse-che.

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());
}
Also used : PodEvent(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent) Test(org.testng.annotations.Test)

Example 29 with PodEvent

use of org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent in project che-server by eclipse-che.

the class UnrecoverablePodEventListenerTest method testFailedContainersInWorkspacePodAlwaysHandled.

@Test
public void testFailedContainersInWorkspacePodAlwaysHandled() {
    // given
    PodEvent ev = mockContainerEvent(WORKSPACE_POD_NAME, "Failed", "bah", EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead());
    // when
    unrecoverableEventListener.handle(ev);
    // then
    verify(unrecoverableEventConsumer).accept(any());
}
Also used : PodEvent(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent) Test(org.testng.annotations.Test)

Example 30 with PodEvent

use of org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent in project devspaces-images by redhat-developer.

the class KubernetesInternalRuntimeTest method testRepublishContainerOutputAsMachineLogEvents.

@Test
public void testRepublishContainerOutputAsMachineLogEvents() throws Exception {
    final MachineLogsPublisher logsPublisher = new MachineLogsPublisher(eventPublisher, machinesCache, IDENTITY);
    final PodEvent out1 = mockContainerEventWithoutRandomName(WORKSPACE_POD_NAME, "Pulling", "pulling image", EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead());
    final PodEvent out2 = mockContainerEventWithoutRandomName(WORKSPACE_POD_NAME, "Pulled", "image pulled", EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead());
    final ArgumentCaptor<RuntimeLogEvent> captor = ArgumentCaptor.forClass(RuntimeLogEvent.class);
    internalRuntime.doStartMachine(serverResolver);
    logsPublisher.handle(out1);
    logsPublisher.handle(out2);
    verify(eventService, atLeastOnce()).publish(captor.capture());
    final ImmutableList<RuntimeLogEvent> machineLogs = ImmutableList.of(asRuntimeLogEvent(out1), asRuntimeLogEvent(out2));
    assertTrue(captor.getAllValues().containsAll(machineLogs));
}
Also used : RuntimeLogEvent(org.eclipse.che.api.workspace.shared.dto.event.RuntimeLogEvent) PodEvent(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent) Test(org.testng.annotations.Test)

Aggregations

PodEvent (org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent)40 Test (org.testng.annotations.Test)32 Event (io.fabric8.kubernetes.api.model.Event)8 Date (java.util.Date)8 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)6 Calendar (java.util.Calendar)6 LocalObjectReference (io.fabric8.kubernetes.api.model.LocalObjectReference)2 ObjectReference (io.fabric8.kubernetes.api.model.ObjectReference)2 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)2 Watcher (io.fabric8.kubernetes.client.Watcher)2 WatcherException (io.fabric8.kubernetes.client.WatcherException)2 Field (java.lang.reflect.Field)2 ParseException (java.text.ParseException)2 Matcher (java.util.regex.Matcher)2 RuntimeLogEvent (org.eclipse.che.api.workspace.shared.dto.event.RuntimeLogEvent)2 KubernetesInfrastructureException (org.eclipse.che.workspace.infrastructure.kubernetes.KubernetesInfrastructureException)2 LogWatcher (org.eclipse.che.workspace.infrastructure.kubernetes.namespace.log.LogWatcher)2