use of org.apache.beam.sdk.testing.TestPipeline in project beam by apache.
the class BeamSetOperatorRelBaseTest method testDifferentWindows.
@Test(expected = IllegalArgumentException.class)
public void testDifferentWindows() throws Exception {
String sql = "SELECT " + " order_id, site_id, count(*) as cnt " + "FROM ORDER_DETAILS GROUP BY order_id, site_id" + ", TUMBLE(order_time, INTERVAL '1' HOUR) " + " UNION SELECT " + " order_id, site_id, count(*) as cnt " + "FROM ORDER_DETAILS GROUP BY order_id, site_id" + ", TUMBLE(order_time, INTERVAL '2' HOUR) ";
// use a real pipeline rather than the TestPipeline because we are
// testing exceptions, the pipeline will not actually run.
Pipeline pipeline1 = Pipeline.create(PipelineOptionsFactory.create());
compilePipeline(sql, pipeline1);
pipeline.run();
}
use of org.apache.beam.sdk.testing.TestPipeline in project beam by apache.
the class RampupThrottlingFnTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.openMocks(this);
DateTimeUtils.setCurrentMillisFixed(0);
TestPipeline pipeline = TestPipeline.create();
PCollectionView<Instant> startTimeView = pipeline.apply(Create.of(Instant.now())).apply(View.asSingleton());
RampupThrottlingFn<Void> rampupThrottlingFn = new RampupThrottlingFn<Void>(1, startTimeView) {
@Override
@Setup
public void setup() {
super.setup();
this.sleeper = mockSleeper;
}
};
rampupThrottlingFnTester = DoFnTester.of(rampupThrottlingFn);
rampupThrottlingFnTester.setSideInput(startTimeView, GlobalWindow.INSTANCE, Instant.now());
rampupThrottlingFnTester.setCloningBehavior(CloningBehavior.DO_NOT_CLONE);
rampupThrottlingFnTester.startBundle();
rampupThrottlingFn.throttlingMsecs = mockCounter;
}
use of org.apache.beam.sdk.testing.TestPipeline in project beam by apache.
the class TestUtils method createTestPipeline.
public static TestPipeline createTestPipeline() {
final PipelineOptions pipelineOptions = PipelineOptionsFactory.create();
pipelineOptions.as(EuphoriaOptions.class).setTranslatorProvider(new PrimitiveOutputTranslatorProvider());
final TestPipeline testPipeline = TestPipeline.fromOptions(pipelineOptions);
testPipeline.getCoderRegistry().registerCoderForClass(Object.class, KryoCoder.of(pipelineOptions));
return testPipeline;
}
use of org.apache.beam.sdk.testing.TestPipeline in project beam by apache.
the class UnionTest method testBuild_ThreeDataSet.
@Test
public void testBuild_ThreeDataSet() {
final TestPipeline pipeline = TestUtils.createTestPipeline();
final PCollection<String> first = TestUtils.createMockDataset(pipeline, TypeDescriptors.strings());
final PCollection<String> second = TestUtils.createMockDataset(pipeline, TypeDescriptors.strings());
final PCollection<String> third = TestUtils.createMockDataset(pipeline, TypeDescriptors.strings());
final PCollection<String> unioned = Union.named("Union1").of(first, second, third).output();
final Union union = (Union) TestUtils.getProducer(unioned);
assertTrue(union.getName().isPresent());
assertEquals("Union1", union.getName().get());
}
use of org.apache.beam.sdk.testing.TestPipeline in project beam by apache.
the class PCollectionTupleTest method testEquals.
@Test
public void testEquals() {
TestPipeline p = TestPipeline.create();
TupleTag<Long> longTag = new TupleTag<>();
PCollection<Long> longs = p.apply(GenerateSequence.from(0));
TupleTag<String> strTag = new TupleTag<>();
PCollection<String> strs = p.apply(Create.of("foo", "bar"));
EqualsTester tester = new EqualsTester();
// Empty tuples in the same pipeline are equal
tester.addEqualityGroup(PCollectionTuple.empty(p), PCollectionTuple.empty(p));
tester.addEqualityGroup(PCollectionTuple.of(longTag, longs).and(strTag, strs), PCollectionTuple.of(longTag, longs).and(strTag, strs));
tester.addEqualityGroup(PCollectionTuple.of(longTag, longs));
tester.addEqualityGroup(PCollectionTuple.of(strTag, strs));
TestPipeline otherPipeline = TestPipeline.create();
// Empty tuples in different pipelines are not equal
tester.addEqualityGroup(PCollectionTuple.empty(otherPipeline));
tester.testEquals();
}
Aggregations