Search in sources :

Example 71 with Config

use of com.twitter.heron.api.Config in project incubator-heron by apache.

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(com.twitter.heron.api.Config) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) Test(org.junit.Test)

Example 72 with Config

use of com.twitter.heron.api.Config in project incubator-heron by apache.

the class ConfigBuilderTest method testBuildConfig_MBAllocationTooSmall_ExceptionThrown.

@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_MBAllocationTooSmall_ExceptionThrown() throws Exception {
    Config config = null;
    try {
        EcoParser ecoParser = new EcoParser();
        InputStream inputStream = new ByteArrayInputStream(INCORRECT_RAM_MEGABYTES.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(com.twitter.heron.api.Config) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EcoParser(com.twitter.heron.eco.parser.EcoParser) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 73 with Config

use of com.twitter.heron.api.Config in project incubator-heron by apache.

the class EcoBuilderTest method testBuild_CustomConfigMap_ReturnsCorrectConfigs.

@Test
public void testBuild_CustomConfigMap_ReturnsCorrectConfigs() throws Exception {
    configMap.put(Config.TOPOLOGY_DEBUG, false);
    final String environment = "dev";
    final int spouts = 3;
    configMap.put(Config.TOPOLOGY_ENVIRONMENT, environment);
    configMap.put(Config.TOPOLOGY_MAX_SPOUT_PENDING, spouts);
    Config config = new Config();
    when(mockConfigBuilder.buildConfig(eq(ecoTopologyDefinition))).thenReturn(config);
    assertThat(subject.buildConfig(ecoTopologyDefinition), sameInstance(config));
    verify(mockConfigBuilder).buildConfig(same(ecoTopologyDefinition));
}
Also used : Config(com.twitter.heron.api.Config) Test(org.junit.Test)

Example 74 with Config

use of com.twitter.heron.api.Config in project incubator-heron by apache.

the class EcoBuilderTest method testBuildTopologyBuilder_BuildsAsExpected.

@Test
public void testBuildTopologyBuilder_BuildsAsExpected() throws IllegalAccessException, ClassNotFoundException, InstantiationException, NoSuchFieldException, InvocationTargetException {
    Config config = new Config();
    EcoExecutionContext context = new EcoExecutionContext(ecoTopologyDefinition, config);
    ObjectBuilder objectBuilder = new ObjectBuilder();
    subject.buildTopologyBuilder(context, objectBuilder);
    verify(mockSpoutBuilder).buildSpouts(same(context), any(TopologyBuilder.class), same(objectBuilder));
    verify(mockBoltBuilder).buildBolts(same(context), same(objectBuilder));
    verify(mockStreamBuilder).buildStreams(same(context), any(TopologyBuilder.class), same(objectBuilder));
    verify(mockComponentBuilder).buildComponents(same(context), same(objectBuilder));
}
Also used : TopologyBuilder(org.apache.storm.topology.TopologyBuilder) Config(com.twitter.heron.api.Config) EcoExecutionContext(com.twitter.heron.eco.definition.EcoExecutionContext) Test(org.junit.Test)

Example 75 with Config

use of com.twitter.heron.api.Config in project incubator-heron by apache.

the class EcoBuilderTest method testBuild_EmptyConfigMap_ReturnsDefaultConfigs.

@Test
public void testBuild_EmptyConfigMap_ReturnsDefaultConfigs() throws Exception {
    Config config = new Config();
    when(mockConfigBuilder.buildConfig(eq(ecoTopologyDefinition))).thenReturn(config);
    Config returnedConfig = subject.buildConfig(ecoTopologyDefinition);
    verify(mockConfigBuilder).buildConfig(same(ecoTopologyDefinition));
    assertThat(returnedConfig.get(Config.TOPOLOGY_DEBUG), is(nullValue()));
    assertThat(config, sameInstance(returnedConfig));
}
Also used : Config(com.twitter.heron.api.Config) Test(org.junit.Test)

Aggregations

Config (com.twitter.heron.api.Config)80 Test (org.junit.Test)39 TopologyBuilder (com.twitter.heron.api.topology.TopologyBuilder)25 HashMap (java.util.HashMap)22 Fields (com.twitter.heron.api.tuple.Fields)14 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)12 EcoTopologyDefinition (com.twitter.heron.eco.definition.EcoTopologyDefinition)12 TreeMap (java.util.TreeMap)12 ByteAmount (com.twitter.heron.common.basics.ByteAmount)9 FileInputStream (java.io.FileInputStream)9 EcoParser (com.twitter.heron.eco.parser.EcoParser)8 ByteArrayInputStream (java.io.ByteArrayInputStream)8 InputStream (java.io.InputStream)8 Map (java.util.Map)6 TopologyArgParser (com.github.ashvina.common.TopologyArgParser)5 TopologyContext (com.twitter.heron.api.topology.TopologyContext)5 Tuple (com.twitter.heron.api.tuple.Tuple)5 TestTopologyBuilder (com.twitter.heron.integration_test.core.TestTopologyBuilder)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4