Search in sources :

Example 41 with Category

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();
}
Also used : Instant(org.joda.time.Instant) Duration(org.joda.time.Duration) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 42 with Category

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));
}
Also used : ArrayList(java.util.ArrayList) TestPipeline(org.apache.beam.sdk.testing.TestPipeline) Pipeline(org.apache.beam.sdk.Pipeline) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 43 with Category

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);
}
Also used : PipelineResult(org.apache.beam.sdk.PipelineResult) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 44 with Category

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);
}
Also used : PipelineResult(org.apache.beam.sdk.PipelineResult) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 45 with Category

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)));
}
Also used : PipelineResult(org.apache.beam.sdk.PipelineResult) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Aggregations

Category (org.junit.experimental.categories.Category)499 Test (org.junit.Test)496 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)148 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)121 File (java.io.File)68 VM (org.apache.geode.test.dunit.VM)65 KV (org.apache.beam.sdk.values.KV)62 Instant (org.joda.time.Instant)60 ArrayList (java.util.ArrayList)55 Matchers.containsString (org.hamcrest.Matchers.containsString)49 StringUtils.byteArrayToJsonString (org.apache.beam.sdk.util.StringUtils.byteArrayToJsonString)41 Region (org.apache.geode.cache.Region)35 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)34 Host (org.apache.geode.test.dunit.Host)34 Properties (java.util.Properties)32 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)31 Cache (org.apache.geode.cache.Cache)26 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)25 IOException (java.io.IOException)24 CacheException (org.apache.geode.cache.CacheException)24