Search in sources :

Example 51 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class ConfigBuilderTest method testBuildConfig_IncorrectGBResourceFormat_ExceptionThrow.

@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_IncorrectGBResourceFormat_ExceptionThrow() throws Exception {
    Config config = null;
    try {
        EcoParser ecoParser = new EcoParser();
        InputStream inputStream = new ByteArrayInputStream(INCORRECT_GB_FORMAT_YAML.getBytes());
        FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
        EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
        config = subject.buildConfig(ecoTopologyDefinition);
    } finally {
        assertNull(config);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Config(org.apache.heron.api.Config) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EcoParser(org.apache.heron.eco.parser.EcoParser) EcoTopologyDefinition(org.apache.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 52 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class ConfigBuilderTest method testBuildConfig_ConfigIsDefined_ReturnsCorrectValues.

@Test
public void testBuildConfig_ConfigIsDefined_ReturnsCorrectValues() throws Exception {
    EcoTopologyDefinition ecoTopologyDefinition = new EcoTopologyDefinition();
    Map<String, Object> topologyDefinitionConfig = new HashMap<>();
    topologyDefinitionConfig.put(Config.TOPOLOGY_COMPONENT_PARALLELISM, 2);
    topologyDefinitionConfig.put(Config.TOPOLOGY_CONTAINER_CPU_REQUESTED, 4);
    ecoTopologyDefinition.setConfig(topologyDefinitionConfig);
    Config config = subject.buildConfig(ecoTopologyDefinition);
    assertThat(config.get(Config.TOPOLOGY_COMPONENT_PARALLELISM), is(equalTo(2)));
    assertThat(config.get(Config.TOPOLOGY_CONTAINER_CPU_REQUESTED), is(equalTo(4)));
}
Also used : HashMap(java.util.HashMap) Config(org.apache.heron.api.Config) EcoTopologyDefinition(org.apache.heron.eco.definition.EcoTopologyDefinition) Test(org.junit.Test)

Example 53 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class ConfigBuilderTest method testBuildConfig_SpecifyingComponentResources_ReturnsCorrectValues.

@Test
public void testBuildConfig_SpecifyingComponentResources_ReturnsCorrectValues() throws Exception {
    EcoParser ecoParser = new EcoParser();
    InputStream inputStream = new ByteArrayInputStream(YAML_PROPERTIES.getBytes());
    FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
    EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
    Config config = subject.buildConfig(ecoTopologyDefinition);
    assertThat(config.get(Config.TOPOLOGY_COMPONENT_RAMMAP), is(equalTo("spout-1:256000000,bolt-1:256000000")));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Config(org.apache.heron.api.Config) EcoParser(org.apache.heron.eco.parser.EcoParser) EcoTopologyDefinition(org.apache.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 54 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class ConfigBuilderTest method testBuildConfig_SpecifyingComponentJVMOptions_ReturnsCorrectValues.

@Test
public void testBuildConfig_SpecifyingComponentJVMOptions_ReturnsCorrectValues() throws Exception {
    EcoParser ecoParser = new EcoParser();
    InputStream inputStream = new ByteArrayInputStream(JVM_OPTIONS_CONFIG.getBytes());
    FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
    EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
    Config config = subject.buildConfig(ecoTopologyDefinition);
    assertThat(config.get(Config.TOPOLOGY_COMPONENT_JVMOPTS), is(equalTo("{\"c3BvdXQtMSw=\":\"LVhYOk5ld1NpemU9MzAwbSwgLVhtczJnIA==\"}")));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Config(org.apache.heron.api.Config) EcoParser(org.apache.heron.eco.parser.EcoParser) EcoTopologyDefinition(org.apache.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 55 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class ConfigBuilderTest method testBuildConfig_ConfigIsNotDefined_ReturnsEmptyConfig.

@Test
public void testBuildConfig_ConfigIsNotDefined_ReturnsEmptyConfig() throws Exception {
    EcoTopologyDefinition ecoTopologyDefinition = new EcoTopologyDefinition();
    Config config = subject.buildConfig(ecoTopologyDefinition);
    assertThat(0, is(equalTo(config.size())));
}
Also used : Config(org.apache.heron.api.Config) EcoTopologyDefinition(org.apache.heron.eco.definition.EcoTopologyDefinition) Test(org.junit.Test)

Aggregations

Config (org.apache.heron.api.Config)74 Test (org.junit.Test)35 TopologyBuilder (org.apache.heron.api.topology.TopologyBuilder)21 HashMap (java.util.HashMap)16 EcoTopologyDefinition (org.apache.heron.eco.definition.EcoTopologyDefinition)10 TreeMap (java.util.TreeMap)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 FileInputStream (java.io.FileInputStream)8 InputStream (java.io.InputStream)8 Fields (org.apache.heron.api.tuple.Fields)7 EcoParser (org.apache.heron.eco.parser.EcoParser)7 Map (java.util.Map)6 TopologyAPI (org.apache.heron.api.generated.TopologyAPI)6 ByteAmount (org.apache.heron.common.basics.ByteAmount)6 Simulator (org.apache.heron.simulator.Simulator)6 LinkedList (java.util.LinkedList)5 List (java.util.List)5 TopologyContext (org.apache.heron.api.topology.TopologyContext)5 Tuple (org.apache.heron.api.tuple.Tuple)5 TestWordSpout (org.apache.heron.examples.api.spout.TestWordSpout)5