Search in sources :

Example 21 with FlowManager

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());
}
Also used : FlowManager(co.cask.cdap.test.FlowManager) ApplicationManager(co.cask.cdap.test.ApplicationManager) RuntimeMetrics(co.cask.cdap.api.metrics.RuntimeMetrics) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 22 with FlowManager

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());
}
Also used : FlowManager(co.cask.cdap.test.FlowManager) StreamManager(co.cask.cdap.test.StreamManager) KeyValueTable(co.cask.cdap.api.dataset.lib.KeyValueTable) Test(org.junit.Test)

Example 23 with FlowManager

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);
}
Also used : FlowManager(co.cask.cdap.test.FlowManager) ApplicationManager(co.cask.cdap.test.ApplicationManager) StreamManager(co.cask.cdap.test.StreamManager) Test(org.junit.Test)

Example 24 with 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);
}
Also used : FlowManager(co.cask.cdap.test.FlowManager) ApplicationManager(co.cask.cdap.test.ApplicationManager) NamespaceMeta(co.cask.cdap.proto.NamespaceMeta) StreamManager(co.cask.cdap.test.StreamManager) NamespaceId(co.cask.cdap.proto.id.NamespaceId) Test(org.junit.Test)

Aggregations

FlowManager (co.cask.cdap.test.FlowManager)24 ApplicationManager (co.cask.cdap.test.ApplicationManager)22 Test (org.junit.Test)22 RuntimeMetrics (co.cask.cdap.api.metrics.RuntimeMetrics)17 StreamManager (co.cask.cdap.test.StreamManager)17 ServiceManager (co.cask.cdap.test.ServiceManager)13 KeyValueTable (co.cask.cdap.api.dataset.lib.KeyValueTable)9 URL (java.net.URL)9 HttpURLConnection (java.net.HttpURLConnection)6 Category (org.junit.experimental.categories.Category)6 Gson (com.google.gson.Gson)5 MapReduceManager (co.cask.cdap.test.MapReduceManager)4 SparkManager (co.cask.cdap.test.SparkManager)4 Get (co.cask.cdap.api.dataset.table.Get)3 Table (co.cask.cdap.api.dataset.table.Table)3 Action (co.cask.cdap.proto.security.Action)2 WorkerManager (co.cask.cdap.test.WorkerManager)2 WorkflowManager (co.cask.cdap.test.WorkflowManager)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2