UnrecoverablePodEventListener implements PodEventHandler { @Override public void handle(PodEvent event) { if (isWorkspaceEvent(event) && (isFailedContainer(event) || isUnrecoverable(event))) { unrecoverableEventHandler.accept(event); } } UnrecoverablePodEventListener(
      Set<String> unrecoverableEvents,
      Set<String> pods,
      Consumer<PodEvent> unrecoverableEventHandler); @Override void handle(PodEvent event);  }
@Test public void testHandleUnrecoverableEventByReason() throws Exception { String unrecoverableEventReason = "Failed Mount"; PodEvent unrecoverableEvent = mockContainerEvent( WORKSPACE_POD_NAME, unrecoverableEventReason, "Failed to mount volume 'claim-che-workspace'", EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead()); unrecoverableEventListener.handle(unrecoverableEvent); verify(unrecoverableEventConsumer).accept(unrecoverableEvent); }
@Test public void testHandleUnrecoverableEventByMessage() throws Exception { String unrecoverableEventMessage = "Failed to pull image eclipse/che-server:nightly-centos"; PodEvent unrecoverableEvent = mockContainerEvent( WORKSPACE_POD_NAME, "Pulling", unrecoverableEventMessage, EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead()); unrecoverableEventListener.handle(unrecoverableEvent); verify(unrecoverableEventConsumer).accept(unrecoverableEvent); }
@Test public void testDoNotHandleUnrecoverableEventFromNonWorkspacePod() throws Exception { final String unrecoverableEventMessage = "Failed to pull image eclipse/che-server:nightly-centos"; final PodEvent unrecoverableEvent = mockContainerEvent( "NonWorkspacePod", "Pulling", unrecoverableEventMessage, EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead()); unrecoverableEventListener.handle(unrecoverableEvent); verify(unrecoverableEventConsumer, never()).accept(any()); }
@Test public void testHandleRegularEvent() throws Exception { final PodEvent regularEvent = mockContainerEvent( WORKSPACE_POD_NAME, "Pulling", "pulling image", EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead()); unrecoverableEventListener.handle(regularEvent); verify(unrecoverableEventConsumer, never()).accept(any()); }
@Test public void testFailedContainersInWorkspacePodAlwaysHandled() { PodEvent ev = mockContainerEvent( WORKSPACE_POD_NAME, "Failed", "bah", EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead()); unrecoverableEventListener.handle(ev); verify(unrecoverableEventConsumer).accept(any()); }