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)));
}
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);
}
}
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));
}
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));
}
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));
}
Aggregations