use of org.junit.experimental.categories.Category in project beam by apache.
the class WindowingTest method testWindowPreservation.
@Test
@Category(ValidatesRunner.class)
public void testWindowPreservation() {
PCollection<String> input1 = p.apply("Create12", Create.timestamped(TimestampedValue.of("a", new Instant(1)), TimestampedValue.of("b", new Instant(2))));
PCollection<String> input2 = p.apply("Create34", Create.timestamped(TimestampedValue.of("a", new Instant(3)), TimestampedValue.of("b", new Instant(4))));
PCollectionList<String> input = PCollectionList.of(input1).and(input2);
PCollection<String> output = input.apply(Flatten.<String>pCollections()).apply(new WindowedCount(FixedWindows.of(new Duration(5))));
PAssert.that(output).containsInAnyOrder(output("a", 2, 1, 0, 5), output("b", 2, 2, 0, 5));
p.run();
}
use of org.junit.experimental.categories.Category in project beam by apache.
the class WriteFilesTest method testCustomShardedWrite.
@Test
@Category(NeedsRunner.class)
public void testCustomShardedWrite() throws IOException {
// Flag to validate that the pipeline options are passed to the Sink
WriteOptions options = TestPipeline.testingPipelineOptions().as(WriteOptions.class);
options.setTestFlag("test_value");
Pipeline p = TestPipeline.create(options);
List<String> inputs = new ArrayList<>();
// Prepare timestamps for the elements.
List<Long> timestamps = new ArrayList<>();
for (long i = 0; i < 1000; i++) {
inputs.add(Integer.toString(3));
timestamps.add(i + 1);
}
SimpleSink sink = makeSimpleSink();
WriteFiles<String> write = WriteFiles.to(sink).withSharding(new LargestInt());
p.apply(Create.timestamped(inputs, timestamps).withCoder(StringUtf8Coder.of())).apply(IDENTITY_MAP).apply(write);
p.run();
checkFileContents(getBaseOutputFilename(), inputs, Optional.of(3));
}
use of org.junit.experimental.categories.Category in project beam by apache.
the class MetricsTest method testAllCommittedMetrics.
@Category({ ValidatesRunner.class, UsesCommittedMetrics.class, UsesCounterMetrics.class, UsesDistributionMetrics.class, UsesGaugeMetrics.class })
@Test
public void testAllCommittedMetrics() {
PipelineResult result = runPipelineWithMetrics();
MetricQueryResults metrics = queryTestMetrics(result);
assertAllMetrics(metrics, true);
}
use of org.junit.experimental.categories.Category in project beam by apache.
the class MetricsTest method testAttemptedDistributionMetrics.
@Category({ ValidatesRunner.class, UsesAttemptedMetrics.class, UsesDistributionMetrics.class })
@Test
public void testAttemptedDistributionMetrics() {
PipelineResult result = runPipelineWithMetrics();
MetricQueryResults metrics = queryTestMetrics(result);
assertDistributionMetrics(metrics, false);
}
use of org.junit.experimental.categories.Category in project beam by apache.
the class MetricsTest method testUnboundedSourceMetrics.
@Test
@Category({ ValidatesRunner.class, UsesAttemptedMetrics.class, UsesCounterMetrics.class })
public void testUnboundedSourceMetrics() {
long numElements = 1000;
// Use withMaxReadTime to force unbounded mode.
pipeline.apply(GenerateSequence.from(0).to(numElements).withMaxReadTime(Duration.standardDays(1)));
PipelineResult pipelineResult = pipeline.run();
MetricQueryResults metrics = pipelineResult.metrics().queryMetrics(MetricsFilter.builder().addNameFilter(MetricNameFilter.named(ELEMENTS_READ.namespace(), ELEMENTS_READ.name())).build());
assertThat(metrics.counters(), hasItem(attemptedMetricsResult(ELEMENTS_READ.namespace(), ELEMENTS_READ.name(), "Read(UnboundedCountingSource)", 1000L)));
}
Aggregations