Search in sources :

Example 1 with EcoParser

use of com.twitter.heron.eco.parser.EcoParser in project incubator-heron by apache.

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

Example 2 with EcoParser

use of com.twitter.heron.eco.parser.EcoParser in project incubator-heron by apache.

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(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 3 with EcoParser

use of com.twitter.heron.eco.parser.EcoParser in project incubator-heron by apache.

the class ConfigBuilderTest method testBuildConfig_IncorrectMBResourceFormat_ExceptionThrow.

@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_IncorrectMBResourceFormat_ExceptionThrow() throws Exception {
    Config config = null;
    try {
        EcoParser ecoParser = new EcoParser();
        InputStream inputStream = new ByteArrayInputStream(INCORRECT_MB_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(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 4 with EcoParser

use of com.twitter.heron.eco.parser.EcoParser in project incubator-heron by apache.

the class ConfigBuilderTest method testBuildConfig_IncorrectByteResourceFormat_ExceptionThrow.

@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_IncorrectByteResourceFormat_ExceptionThrow() throws Exception {
    Config config = null;
    try {
        EcoParser ecoParser = new EcoParser();
        InputStream inputStream = new ByteArrayInputStream(INCORRECT_BYTES_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(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 5 with EcoParser

use of com.twitter.heron.eco.parser.EcoParser in project incubator-heron by apache.

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

Aggregations

EcoParser (com.twitter.heron.eco.parser.EcoParser)9 FileInputStream (java.io.FileInputStream)9 Config (com.twitter.heron.api.Config)8 EcoTopologyDefinition (com.twitter.heron.eco.definition.EcoTopologyDefinition)8 ByteArrayInputStream (java.io.ByteArrayInputStream)8 InputStream (java.io.InputStream)8 Test (org.junit.Test)8 BoltBuilder (com.twitter.heron.eco.builder.BoltBuilder)1 ComponentBuilder (com.twitter.heron.eco.builder.ComponentBuilder)1 ConfigBuilder (com.twitter.heron.eco.builder.ConfigBuilder)1 EcoBuilder (com.twitter.heron.eco.builder.EcoBuilder)1 SpoutBuilder (com.twitter.heron.eco.builder.SpoutBuilder)1 StreamBuilder (com.twitter.heron.eco.builder.StreamBuilder)1 EcoSubmitter (com.twitter.heron.eco.submit.EcoSubmitter)1 File (java.io.File)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 DefaultParser (org.apache.commons.cli.DefaultParser)1 Options (org.apache.commons.cli.Options)1 ParseException (org.apache.commons.cli.ParseException)1