use of com.google.api.services.dataflow.model.WorkItemStatus in project beam by apache.
the class WorkItemStatusClientTest method reportErrorAfterSetWorker.
/**
* Reporting an error after setWorker has been called should also work.
*/
@Test
public void reportErrorAfterSetWorker() throws IOException {
RuntimeException error = new RuntimeException();
error.fillInStackTrace();
when(worker.extractMetricUpdates()).thenReturn(Collections.emptyList());
statusClient.setWorker(worker, executionContext);
statusClient.reportError(error);
verify(workUnitClient).reportWorkItemStatus(statusCaptor.capture());
WorkItemStatus workStatus = statusCaptor.getValue();
assertThat(workStatus.getWorkItemId(), equalTo(Long.toString(WORK_ID)));
assertThat(workStatus.getCompleted(), equalTo(true));
assertThat(workStatus.getReportIndex(), equalTo(INITIAL_REPORT_INDEX));
assertThat(workStatus.getErrors(), hasSize(1));
Status status = workStatus.getErrors().get(0);
assertThat(status.getCode(), equalTo(2));
assertThat(status.getMessage(), containsString("WorkItemStatusClientTest"));
}
use of com.google.api.services.dataflow.model.WorkItemStatus in project beam by apache.
the class WorkItemStatusClientTest method reportOutOfMemoryErrorAfterSetWorker.
/**
* Reporting an out of memory error should log it in addition to the regular flow.
*/
@Test
public void reportOutOfMemoryErrorAfterSetWorker() throws IOException {
OutOfMemoryError error = new OutOfMemoryError();
error.fillInStackTrace();
when(worker.extractMetricUpdates()).thenReturn(Collections.emptyList());
statusClient.setWorker(worker, executionContext);
statusClient.reportError(error);
verify(workUnitClient).reportWorkItemStatus(statusCaptor.capture());
WorkItemStatus workStatus = statusCaptor.getValue();
assertThat(workStatus.getWorkItemId(), equalTo(Long.toString(WORK_ID)));
assertThat(workStatus.getCompleted(), equalTo(true));
assertThat(workStatus.getReportIndex(), equalTo(INITIAL_REPORT_INDEX));
assertThat(workStatus.getErrors(), hasSize(1));
Status status = workStatus.getErrors().get(0);
assertThat(status.getCode(), equalTo(2));
assertThat(status.getMessage(), containsString("WorkItemStatusClientTest"));
assertThat(status.getMessage(), containsString("An OutOfMemoryException occurred."));
}
use of com.google.api.services.dataflow.model.WorkItemStatus in project beam by apache.
the class WorkItemStatusClientTest method populateSplitResultNull.
@Test
public void populateSplitResultNull() throws Exception {
WorkItemStatus status = new WorkItemStatus();
statusClient.setWorker(worker, executionContext);
statusClient.populateSplitResult(status, null);
assertThat(status.getDynamicSourceSplit(), nullValue());
assertThat(status.getStopPosition(), nullValue());
}
use of com.google.api.services.dataflow.model.WorkItemStatus in project beam by apache.
the class WorkItemStatusClientTest method populateMetricUpdatesNoStateSamplerInfo.
@Test
public void populateMetricUpdatesNoStateSamplerInfo() throws Exception {
// When executionContext.getExecutionStateTracker() returns null, we get no metric updates.
WorkItemStatus status = new WorkItemStatus();
BatchModeExecutionContext executionContext = mock(BatchModeExecutionContext.class);
when(executionContext.getExecutionStateTracker()).thenReturn(null);
statusClient.setWorker(worker, executionContext);
statusClient.populateMetricUpdates(status);
assertThat(status.getMetricUpdates(), empty());
}
use of com.google.api.services.dataflow.model.WorkItemStatus in project beam by apache.
the class WorkItemStatusClientTest method reportUpdateNullSplit.
@Test
public void reportUpdateNullSplit() throws Exception {
when(worker.extractMetricUpdates()).thenReturn(Collections.emptyList());
statusClient.setWorker(worker, executionContext);
statusClient.reportUpdate(null, LEASE_DURATION);
verify(workUnitClient).reportWorkItemStatus(statusCaptor.capture());
WorkItemStatus workStatus = statusCaptor.getValue();
assertThat(workStatus.getCompleted(), equalTo(false));
}
Aggregations