Search in sources :

Example 1 with TestingKafkaBolt

use of org.openkilda.wfm.topology.TestingKafkaBolt in project open-kilda by telstra.

the class OpenTSDBTopologyTest method shouldSendDatapointRequestsTwice.

@Ignore
@Test
public void shouldSendDatapointRequestsTwice() throws Exception {
    Datapoint datapoint1 = new Datapoint("metric", timestamp, Collections.emptyMap(), 123);
    String jsonDatapoint1 = MAPPER.writeValueAsString(datapoint1);
    Datapoint datapoint2 = new Datapoint("metric", timestamp, Collections.emptyMap(), 456);
    String jsonDatapoint2 = MAPPER.writeValueAsString(datapoint2);
    MockedSources sources = new MockedSources();
    sources.addMockData(Topic.OTSDB + "-spout", new Values(jsonDatapoint1), new Values(jsonDatapoint2));
    completeTopologyParam.setMockedSources(sources);
    Testing.withTrackedCluster(clusterParam, (cluster) -> {
        OpenTSDBTopology topology = new TestingTargetTopology(new TestingKafkaBolt());
        StormTopology stormTopology = topology.createTopology();
        Testing.completeTopology(cluster, stormTopology, completeTopologyParam);
    });
    // verify that request is sent to OpenTSDB server once
    mockServer.verify(HttpRequest.request(), VerificationTimes.exactly(2));
}
Also used : Datapoint(org.openkilda.messaging.info.Datapoint) MockedSources(org.apache.storm.testing.MockedSources) StormTopology(org.apache.storm.generated.StormTopology) Values(org.apache.storm.tuple.Values) TestingKafkaBolt(org.openkilda.wfm.topology.TestingKafkaBolt) Ignore(org.junit.Ignore) StableAbstractStormTest(org.openkilda.wfm.StableAbstractStormTest) Test(org.junit.Test)

Example 2 with TestingKafkaBolt

use of org.openkilda.wfm.topology.TestingKafkaBolt in project open-kilda by telstra.

the class OpenTSDBTopologyTest method shouldSendDatapointRequestsOnlyOnce.

@Ignore
@Test
public void shouldSendDatapointRequestsOnlyOnce() throws Exception {
    Datapoint datapoint = new Datapoint("metric", timestamp, Collections.emptyMap(), 123);
    String jsonDatapoint = MAPPER.writeValueAsString(datapoint);
    MockedSources sources = new MockedSources();
    sources.addMockData(Topic.OTSDB + "-spout", new Values(jsonDatapoint), new Values(jsonDatapoint));
    completeTopologyParam.setMockedSources(sources);
    Testing.withTrackedCluster(clusterParam, (cluster) -> {
        OpenTSDBTopology topology = new TestingTargetTopology(new TestingKafkaBolt());
        StormTopology stormTopology = topology.createTopology();
        Testing.completeTopology(cluster, stormTopology, completeTopologyParam);
    });
    // verify that request is sent to OpenTSDB server once
    mockServer.verify(HttpRequest.request(), VerificationTimes.exactly(1));
}
Also used : Datapoint(org.openkilda.messaging.info.Datapoint) MockedSources(org.apache.storm.testing.MockedSources) StormTopology(org.apache.storm.generated.StormTopology) Values(org.apache.storm.tuple.Values) TestingKafkaBolt(org.openkilda.wfm.topology.TestingKafkaBolt) Ignore(org.junit.Ignore) StableAbstractStormTest(org.openkilda.wfm.StableAbstractStormTest) Test(org.junit.Test)

Example 3 with TestingKafkaBolt

use of org.openkilda.wfm.topology.TestingKafkaBolt in project open-kilda by telstra.

the class OpenTSDBTopologyTest method shouldSuccessfulSendDatapoint.

@Ignore
@Test
public void shouldSuccessfulSendDatapoint() throws Exception {
    Datapoint datapoint = new Datapoint("metric", timestamp, Collections.emptyMap(), 123);
    MockedSources sources = new MockedSources();
    // TODO: rather than use Topic.OTSDB, grab it from the TopologyConfig object (which does
    // not exist at this point in the code.
    sources.addMockData(Topic.OTSDB + "-spout", new Values(MAPPER.writeValueAsString(datapoint)));
    completeTopologyParam.setMockedSources(sources);
    Testing.withTrackedCluster(clusterParam, (cluster) -> {
        OpenTSDBTopology topology = new TestingTargetTopology(new TestingKafkaBolt());
        StormTopology stormTopology = topology.createTopology();
        Map result = Testing.completeTopology(cluster, stormTopology, completeTopologyParam);
    });
    // verify that request is sent to OpenTSDB server
    mockServer.verify(HttpRequest.request(), VerificationTimes.exactly(1));
}
Also used : Datapoint(org.openkilda.messaging.info.Datapoint) MockedSources(org.apache.storm.testing.MockedSources) StormTopology(org.apache.storm.generated.StormTopology) Values(org.apache.storm.tuple.Values) TestingKafkaBolt(org.openkilda.wfm.topology.TestingKafkaBolt) Map(java.util.Map) Ignore(org.junit.Ignore) StableAbstractStormTest(org.openkilda.wfm.StableAbstractStormTest) Test(org.junit.Test)

Aggregations

StormTopology (org.apache.storm.generated.StormTopology)3 MockedSources (org.apache.storm.testing.MockedSources)3 Values (org.apache.storm.tuple.Values)3 Ignore (org.junit.Ignore)3 Test (org.junit.Test)3 Datapoint (org.openkilda.messaging.info.Datapoint)3 StableAbstractStormTest (org.openkilda.wfm.StableAbstractStormTest)3 TestingKafkaBolt (org.openkilda.wfm.topology.TestingKafkaBolt)3 Map (java.util.Map)1