Search in sources :

Example 1 with StubbedExecutor

use of org.apache.beam.runners.dataflow.worker.util.common.worker.StubbedExecutor in project beam by apache.

the class DataflowWorkProgressUpdaterTest method initMocksAndWorkflowServiceAndWorkerAndWork.

@Before
public void initMocksAndWorkflowServiceAndWorkerAndWork() {
    MockitoAnnotations.initMocks(this);
    startTime = 0L;
    clock = new FixedClock(startTime);
    executor = new StubbedExecutor(clock);
    options = PipelineOptionsFactory.create().as(DataflowPipelineOptions.class);
    options.setHotKeyLoggingEnabled(true);
    WorkItem workItem = new WorkItem();
    workItem.setProjectId(PROJECT_ID);
    workItem.setJobId(JOB_ID);
    workItem.setId(WORK_ID);
    workItem.setLeaseExpireTime(toCloudTime(new Instant(clock.currentTimeMillis() + 1000)));
    workItem.setReportStatusInterval(toCloudDuration(Duration.millis(300)));
    workItem.setInitialReportIndex(1L);
    when(workItemStatusClient.getExecutionContext()).thenReturn(context);
    when(context.getKey()).thenReturn(HOT_KEY);
    progressUpdater = new DataflowWorkProgressUpdater(workItemStatusClient, workItem, worker, executor.getExecutor(), clock, hotKeyLogger, options) {

        // Shorten reporting interval boundaries for faster testing.
        @Override
        protected long getMinReportingInterval() {
            return 100;
        }

        @Override
        protected long getLeaseRenewalLatencyMargin() {
            return 150;
        }
    };
}
Also used : StubbedExecutor(org.apache.beam.runners.dataflow.worker.util.common.worker.StubbedExecutor) DataflowPipelineOptions(org.apache.beam.runners.dataflow.options.DataflowPipelineOptions) Instant(org.joda.time.Instant) FixedClock(com.google.api.client.testing.http.FixedClock) WorkItem(com.google.api.services.dataflow.model.WorkItem) Before(org.junit.Before)

Aggregations

FixedClock (com.google.api.client.testing.http.FixedClock)1 WorkItem (com.google.api.services.dataflow.model.WorkItem)1 DataflowPipelineOptions (org.apache.beam.runners.dataflow.options.DataflowPipelineOptions)1 StubbedExecutor (org.apache.beam.runners.dataflow.worker.util.common.worker.StubbedExecutor)1 Instant (org.joda.time.Instant)1 Before (org.junit.Before)1