Search in sources :

Example 1 with NexmarkConfiguration

use of org.apache.beam.sdk.nexmark.NexmarkConfiguration in project beam by apache.

the class BoundedSideInputJoinTest method queryMatchesModelStreamingDirect.

@Test
@Category(NeedsRunner.class)
public void queryMatchesModelStreamingDirect() throws Exception {
    NexmarkConfiguration config = NexmarkConfiguration.DEFAULT.copy();
    config.sideInputType = NexmarkUtils.SideInputType.DIRECT;
    config.numEventGenerators = 1;
    config.numEvents = 5000;
    config.sideInputRowCount = 10;
    config.sideInputNumShards = 3;
    queryMatchesModel("BoundedSideInputJoinTestStreaming", config, new BoundedSideInputJoin(config), new BoundedSideInputJoinModel(config), true);
}
Also used : NexmarkConfiguration(org.apache.beam.sdk.nexmark.NexmarkConfiguration) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 2 with NexmarkConfiguration

use of org.apache.beam.sdk.nexmark.NexmarkConfiguration in project beam by apache.

the class BoundedSideInputJoinTest method inputOutputSameEvents.

/**
 * A smoke test that the count of input bids and outputs are the same, to help diagnose flakiness
 * in more complex tests.
 */
@Test
@Category(NeedsRunner.class)
public void inputOutputSameEvents() throws Exception {
    NexmarkConfiguration config = NexmarkConfiguration.DEFAULT.copy();
    config.sideInputType = NexmarkUtils.SideInputType.DIRECT;
    config.numEventGenerators = 1;
    config.numEvents = 5000;
    config.sideInputRowCount = 10;
    config.sideInputNumShards = 3;
    PCollection<KV<Long, String>> sideInput = NexmarkUtils.prepareSideInput(p, config);
    try {
        PCollection<Event> input = p.apply(NexmarkUtils.batchEventsSource(config));
        PCollection<Bid> justBids = input.apply(NexmarkQueryUtil.JUST_BIDS);
        PCollection<Long> bidCount = justBids.apply("Count Bids", Count.globally());
        NexmarkQueryTransform<Bid> query = new BoundedSideInputJoin(config);
        query.setSideInput(sideInput);
        PCollection<TimestampedValue<Bid>> output = (PCollection<TimestampedValue<Bid>>) input.apply(new NexmarkQuery(config, query));
        PCollection<Long> outputCount = output.apply("Count outputs", Count.globally());
        PAssert.that(PCollectionList.of(bidCount).and(outputCount).apply(Flatten.pCollections())).satisfies(counts -> {
            assertThat(Iterables.size(counts), equalTo(2));
            assertThat(Iterables.get(counts, 0), greaterThan(0L));
            assertThat(Iterables.get(counts, 0), equalTo(Iterables.get(counts, 1)));
            return null;
        });
        p.run();
    } finally {
        NexmarkUtils.cleanUpSideInput(config);
    }
}
Also used : KV(org.apache.beam.sdk.values.KV) PCollection(org.apache.beam.sdk.values.PCollection) TimestampedValue(org.apache.beam.sdk.values.TimestampedValue) NexmarkConfiguration(org.apache.beam.sdk.nexmark.NexmarkConfiguration) Event(org.apache.beam.sdk.nexmark.model.Event) Bid(org.apache.beam.sdk.nexmark.model.Bid) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 3 with NexmarkConfiguration

use of org.apache.beam.sdk.nexmark.NexmarkConfiguration in project beam by apache.

the class BoundedSideInputJoinTest method queryMatchesModelBatchCsv.

@Test
@Category(NeedsRunner.class)
public void queryMatchesModelBatchCsv() throws Exception {
    NexmarkConfiguration config = NexmarkConfiguration.DEFAULT.copy();
    config.sideInputType = NexmarkUtils.SideInputType.CSV;
    config.numEventGenerators = 1;
    config.numEvents = 5000;
    config.sideInputRowCount = 10;
    config.sideInputNumShards = 3;
    queryMatchesModel("BoundedSideInputJoinTestBatch", config, new BoundedSideInputJoin(config), new BoundedSideInputJoinModel(config), false);
}
Also used : NexmarkConfiguration(org.apache.beam.sdk.nexmark.NexmarkConfiguration) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 4 with NexmarkConfiguration

use of org.apache.beam.sdk.nexmark.NexmarkConfiguration in project beam by apache.

the class SessionSideInputJoinTest method queryMatchesModelBatchDirect.

@Test
@Category(NeedsRunner.class)
public void queryMatchesModelBatchDirect() throws Exception {
    NexmarkConfiguration config = NexmarkConfiguration.DEFAULT.copy();
    config.sideInputType = NexmarkUtils.SideInputType.DIRECT;
    config.numEventGenerators = 1;
    config.numEvents = 5000;
    config.sideInputRowCount = 10;
    config.sideInputNumShards = 3;
    queryMatchesModel("SessionSideInputJoinTestBatch", config, new SessionSideInputJoin(config), new SessionSideInputJoinModel(config), false);
}
Also used : NexmarkConfiguration(org.apache.beam.sdk.nexmark.NexmarkConfiguration) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 5 with NexmarkConfiguration

use of org.apache.beam.sdk.nexmark.NexmarkConfiguration in project beam by apache.

the class BoundedSideInputJoinTest method queryMatchesModelStreamingCsv.

@Test
@Category(NeedsRunner.class)
public void queryMatchesModelStreamingCsv() throws Exception {
    NexmarkConfiguration config = NexmarkConfiguration.DEFAULT.copy();
    config.sideInputType = NexmarkUtils.SideInputType.CSV;
    config.numEventGenerators = 1;
    config.numEvents = 5000;
    config.sideInputRowCount = 10;
    config.sideInputNumShards = 3;
    queryMatchesModel("BoundedSideInputJoinTestStreaming", config, new BoundedSideInputJoin(config), new BoundedSideInputJoinModel(config), true);
}
Also used : NexmarkConfiguration(org.apache.beam.sdk.nexmark.NexmarkConfiguration) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Aggregations

NexmarkConfiguration (org.apache.beam.sdk.nexmark.NexmarkConfiguration)10 Test (org.junit.Test)10 Category (org.junit.experimental.categories.Category)10 Bid (org.apache.beam.sdk.nexmark.model.Bid)2 Event (org.apache.beam.sdk.nexmark.model.Event)2 KV (org.apache.beam.sdk.values.KV)2 PCollection (org.apache.beam.sdk.values.PCollection)2 TimestampedValue (org.apache.beam.sdk.values.TimestampedValue)2 GlobalWindows (org.apache.beam.sdk.transforms.windowing.GlobalWindows)1