Search in sources :

Example 1 with ExecutionContext

use of org.apache.storm.flux.model.ExecutionContext in project storm by apache.

the class TCKTest method testTCK.

@Test
public void testTCK() throws Exception {
    TopologyDef topologyDef = FluxParser.parseResource("/configs/tck.yaml", false, true, null, false);
    Config conf = FluxBuilder.buildConfig(topologyDef);
    ExecutionContext context = new ExecutionContext(topologyDef, conf);
    StormTopology topology = FluxBuilder.buildTopology(context);
    assertNotNull(topology);
    topology.validate();
}
Also used : TopologyDef(org.apache.storm.flux.model.TopologyDef) ExecutionContext(org.apache.storm.flux.model.ExecutionContext) Config(org.apache.storm.Config) StormTopology(org.apache.storm.generated.StormTopology) Test(org.junit.Test)

Example 2 with ExecutionContext

use of org.apache.storm.flux.model.ExecutionContext in project storm by apache.

the class TCKTest method testHdfs.

@Test
public void testHdfs() throws Exception {
    TopologyDef topologyDef = FluxParser.parseResource("/configs/hdfs_test.yaml", false, true, null, false);
    Config conf = FluxBuilder.buildConfig(topologyDef);
    ExecutionContext context = new ExecutionContext(topologyDef, conf);
    StormTopology topology = FluxBuilder.buildTopology(context);
    assertNotNull(topology);
    topology.validate();
}
Also used : TopologyDef(org.apache.storm.flux.model.TopologyDef) ExecutionContext(org.apache.storm.flux.model.ExecutionContext) Config(org.apache.storm.Config) StormTopology(org.apache.storm.generated.StormTopology) Test(org.junit.Test)

Example 3 with ExecutionContext

use of org.apache.storm.flux.model.ExecutionContext in project storm by apache.

the class TCKTest method testTopologySourceWithGetMethodName.

@Test
public void testTopologySourceWithGetMethodName() throws Exception {
    TopologyDef topologyDef = FluxParser.parseResource("/configs/existing-topology-reflection.yaml", false, true, null, false);
    assertTrue(topologyDef.validate());
    Config conf = FluxBuilder.buildConfig(topologyDef);
    ExecutionContext context = new ExecutionContext(topologyDef, conf);
    StormTopology topology = FluxBuilder.buildTopology(context);
    assertNotNull(topology);
    topology.validate();
}
Also used : TopologyDef(org.apache.storm.flux.model.TopologyDef) ExecutionContext(org.apache.storm.flux.model.ExecutionContext) Config(org.apache.storm.Config) StormTopology(org.apache.storm.generated.StormTopology) Test(org.junit.Test)

Example 4 with ExecutionContext

use of org.apache.storm.flux.model.ExecutionContext in project storm by apache.

the class TCKTest method testVariableSubstitution.

@Test
public void testVariableSubstitution() throws Exception {
    Properties properties = FluxParser.parseProperties("/configs/test.properties", true);
    TopologyDef topologyDef = FluxParser.parseResource("/configs/substitution-test.yaml", false, true, properties, true);
    assertTrue(topologyDef.validate());
    Config conf = FluxBuilder.buildConfig(topologyDef);
    ExecutionContext context = new ExecutionContext(topologyDef, conf);
    StormTopology topology = FluxBuilder.buildTopology(context);
    assertNotNull(topology);
    topology.validate();
    // test basic substitution
    assertEquals("Property not replaced.", "substitution-topology", context.getTopologyDef().getName());
    // test environment variable substitution
    // $PATH should be defined on most systems
    String envPath = System.getenv().get("PATH");
    assertEquals("ENV variable not replaced.", envPath, context.getTopologyDef().getConfig().get("test.env.value"));
    // Test substitution where the target type is List
    assertThat("List property is not replaced by the expected value", Collections.singletonList("A string list"), is(context.getTopologyDef().getConfig().get("list.property.target")));
    // Test substitution where the target type is a List element
    assertThat("List element property is not replaced by the expected value", "A string list", is(context.getTopologyDef().getConfig().get("list.element.property.target")));
}
Also used : TopologyDef(org.apache.storm.flux.model.TopologyDef) ExecutionContext(org.apache.storm.flux.model.ExecutionContext) Config(org.apache.storm.Config) StormTopology(org.apache.storm.generated.StormTopology) Properties(java.util.Properties) Test(org.junit.Test)

Example 5 with ExecutionContext

use of org.apache.storm.flux.model.ExecutionContext in project storm by apache.

the class TCKTest method testTopologyWithInvalidStaticFactoryArgument.

@Test
public void testTopologyWithInvalidStaticFactoryArgument() throws Exception {
    // STORM-3087.
    TopologyDef topologyDef = FluxParser.parseResource("/configs/bad_static_factory_test.yaml", false, true, null, false);
    Config conf = FluxBuilder.buildConfig(topologyDef);
    ExecutionContext context = new ExecutionContext(topologyDef, conf);
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("Couldn't find a suitable static method");
    FluxBuilder.buildTopology(context);
}
Also used : TopologyDef(org.apache.storm.flux.model.TopologyDef) ExecutionContext(org.apache.storm.flux.model.ExecutionContext) Config(org.apache.storm.Config) Test(org.junit.Test)

Aggregations

Config (org.apache.storm.Config)22 ExecutionContext (org.apache.storm.flux.model.ExecutionContext)22 TopologyDef (org.apache.storm.flux.model.TopologyDef)22 Test (org.junit.Test)20 StormTopology (org.apache.storm.generated.StormTopology)19 Properties (java.util.Properties)2 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 UnableToStartException (org.apache.metron.integration.UnableToStartException)1 TestBolt (org.apache.storm.flux.test.TestBolt)1 SubmitOptions (org.apache.storm.generated.SubmitOptions)1 TException (org.apache.storm.thrift.TException)1 TProtocolException (org.apache.storm.thrift.protocol.TProtocolException)1