use of co.cask.cdap.test.FlowManager in project cdap by caskdata.
the class TestFrameworkTestRun method testGenerator.
@Category(SlowTests.class)
@Test
public void testGenerator() throws InterruptedException, IOException, TimeoutException {
ApplicationManager applicationManager = deployApplication(testSpace, GenSinkApp2.class);
FlowManager flowManager = applicationManager.getFlowManager("GenSinkFlow").start();
// Check the flowlet metrics
RuntimeMetrics genMetrics = flowManager.getFlowletMetrics("GenFlowlet");
RuntimeMetrics sinkMetrics = flowManager.getFlowletMetrics("SinkFlowlet");
RuntimeMetrics batchSinkMetrics = flowManager.getFlowletMetrics("BatchSinkFlowlet");
// Generator generators 99 events + 99 batched events
sinkMetrics.waitFor("system.process.events.in", 198, 5, TimeUnit.SECONDS);
sinkMetrics.waitForProcessed(198, 5, TimeUnit.SECONDS);
Assert.assertEquals(0L, sinkMetrics.getException());
// Batch sink only get the 99 batch events
batchSinkMetrics.waitFor("system.process.events.in", 99, 5, TimeUnit.SECONDS);
batchSinkMetrics.waitForProcessed(99, 5, TimeUnit.SECONDS);
Assert.assertEquals(0L, batchSinkMetrics.getException());
Assert.assertEquals(1L, genMetrics.getException());
}
use of co.cask.cdap.test.FlowManager in project cdap by caskdata.
the class AdminAppTestRun method testAdminFlow.
@Test
public void testAdminFlow() throws Exception {
// start the worker and wait for it to finish
FlowManager flowManager = appManager.getFlowManager(AdminApp.FLOW_NAME).start();
try {
flowManager.waitForRun(ProgramRunStatus.RUNNING, 5, TimeUnit.MINUTES);
// send some events to the stream
StreamManager streamManager = getStreamManager("events");
streamManager.send("aa ab bc aa bc");
streamManager.send("xx xy aa ab aa");
// wait for flow to process them
flowManager.getFlowletMetrics("counter").waitForProcessed(10, 30, TimeUnit.SECONDS);
// validate that the flow created tables for a, b, and x, and that the counts are correct
DataSetManager<KeyValueTable> aManager = getDataset("counters_a");
Assert.assertNotNull(aManager.get());
Assert.assertEquals(4L, Bytes.toLong(aManager.get().read("aa")));
Assert.assertEquals(2L, Bytes.toLong(aManager.get().read("ab")));
DataSetManager<KeyValueTable> bManager = getDataset("counters_b");
Assert.assertNotNull(bManager.get());
Assert.assertEquals(2L, Bytes.toLong(bManager.get().read("bc")));
DataSetManager<KeyValueTable> xManager = getDataset("counters_x");
Assert.assertNotNull(xManager.get());
Assert.assertEquals(1L, Bytes.toLong(xManager.get().read("xx")));
Assert.assertEquals(1L, Bytes.toLong(xManager.get().read("xy")));
} finally {
flowManager.stop();
}
flowManager.waitForRun(ProgramRunStatus.KILLED, 30, TimeUnit.SECONDS);
// flowlet destroy() deletes all the tables - validate
Assert.assertNull(getDataset("counters_a").get());
Assert.assertNull(getDataset("counters_b").get());
Assert.assertNull(getDataset("counters_x").get());
}
use of co.cask.cdap.test.FlowManager in project cdap by caskdata.
the class FlowStreamIntegrationTestRun method testStreamBatch.
@Test
public void testStreamBatch() throws Exception {
ApplicationManager applicationManager = deployApplication(TestFlowStreamIntegrationApp.class);
StreamManager s1 = getStreamManager("s1");
for (int i = 0; i < 50; i++) {
s1.send(String.valueOf(i));
}
FlowManager flowManager = applicationManager.getFlowManager("StreamTestFlow");
submitAndVerifyFlowProgram(flowManager);
}
use of co.cask.cdap.test.FlowManager in project cdap by caskdata.
the class FlowStreamIntegrationTestRun method testStreamFromOtherNamespaceBatch.
@Test
public void testStreamFromOtherNamespaceBatch() throws Exception {
NamespaceId streamSpace = new NamespaceId("streamSpace");
getNamespaceAdmin().create(new NamespaceMeta.Builder().setName(streamSpace).build());
// Deploy an app to add a stream in streamSpace
deployApplication(streamSpace, TestFlowStreamIntegrationAcrossNSApp.class);
ApplicationManager applicationManager = deployApplication(TestFlowStreamIntegrationAcrossNSApp.class);
StreamManager s1 = getStreamManager(streamSpace.stream("s1"));
StreamManager s1Default = getStreamManager("s1");
// Send to both stream
for (int i = 0; i < 50; i++) {
s1.send(String.valueOf(i));
s1Default.send(String.valueOf(i));
}
FlowManager flowManager = applicationManager.getFlowManager("StreamAcrossNSTestFlow");
submitAndVerifyFlowProgram(flowManager);
}
Aggregations