Search in sources :

Example 11 with SourceConfig

use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.

the class TestCmdSources method testCmdSourceConfigFileMissingJar.

@Test(expectedExceptions = ParameterException.class, expectedExceptionsMessageRegExp = "Source archive not specified")
public void testCmdSourceConfigFileMissingJar() throws Exception {
    SourceConfig testSourceConfig = getSourceConfig();
    testSourceConfig.setArchive(null);
    SourceConfig expectedSourceConfig = getSourceConfig();
    expectedSourceConfig.setArchive(null);
    testCmdSourceConfigFile(testSourceConfig, expectedSourceConfig);
}
Also used : BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Test(org.testng.annotations.Test)

Example 12 with SourceConfig

use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.

the class TestCmdSources method testCliCorrect.

@Test
public void testCliCorrect() throws Exception {
    SourceConfig sourceConfig = getSourceConfig();
    testCmdSourceCliMissingArgs(TENANT, NAMESPACE, NAME, TOPIC_NAME, SERDE_CLASS_NAME, PROCESSING_GUARANTEES, PARALLELISM, JAR_FILE_PATH, CPU, RAM, DISK, SINK_CONFIG_STRING, sourceConfig);
}
Also used : BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Test(org.testng.annotations.Test)

Example 13 with SourceConfig

use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.

the class TestCmdSources method testCliOverwriteConfigFile.

@Test
public void testCliOverwriteConfigFile() throws Exception {
    SourceConfig testSourceConfig = new SourceConfig();
    testSourceConfig.setTenant(TENANT + "-prime");
    testSourceConfig.setNamespace(NAMESPACE + "-prime");
    testSourceConfig.setName(NAME + "-prime");
    testSourceConfig.setTopicName(TOPIC_NAME + "-prime");
    testSourceConfig.setSerdeClassName(SERDE_CLASS_NAME + "-prime");
    testSourceConfig.setProcessingGuarantees(FunctionConfig.ProcessingGuarantees.EFFECTIVELY_ONCE);
    testSourceConfig.setParallelism(PARALLELISM + 1);
    testSourceConfig.setArchive(JAR_FILE_PATH + "-prime");
    testSourceConfig.setResources(new Resources(CPU + 1, RAM + 1, DISK + 1));
    testSourceConfig.setConfigs(createSource.parseConfigs("{\"created_at-prime\":\"Mon Jul 02 00:33:15 +0000 2018\", \"otherProperties\":{\"property1.value\":\"value1\",\"property2.value\":\"value2\"}}"));
    SourceConfig expectedSourceConfig = getSourceConfig();
    File file = Files.createTempFile("", "").toFile();
    new YAMLMapper().writeValue(file, testSourceConfig);
    Assert.assertEquals(testSourceConfig, CmdUtils.loadConfig(file.getAbsolutePath(), SourceConfig.class));
    testMixCliAndConfigFile(TENANT, NAMESPACE, NAME, TOPIC_NAME, SERDE_CLASS_NAME, PROCESSING_GUARANTEES, PARALLELISM, JAR_FILE_PATH, CPU, RAM, DISK, SINK_CONFIG_STRING, file.getAbsolutePath(), expectedSourceConfig);
}
Also used : YAMLMapper(com.fasterxml.jackson.dataformat.yaml.YAMLMapper) BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Resources(org.apache.pulsar.common.functions.Resources) File(java.io.File) Test(org.testng.annotations.Test)

Example 14 with SourceConfig

use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.

the class TestCmdSources method testBatchSourceConfigCorrect.

@Test
public void testBatchSourceConfigCorrect() throws Exception {
    SourceConfig testSourceConfig = getSourceConfig();
    testSourceConfig.setBatchSourceConfig(getBatchSourceConfig());
    SourceConfig expectedSourceConfig = getSourceConfig();
    expectedSourceConfig.setBatchSourceConfig(getBatchSourceConfig());
    testCmdSourceConfigFile(testSourceConfig, expectedSourceConfig);
}
Also used : BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Test(org.testng.annotations.Test)

Example 15 with SourceConfig

use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.

the class TestCmdSources method testCmdSourceConfigFileMissingProcessingGuarantees.

@Test
public void testCmdSourceConfigFileMissingProcessingGuarantees() throws Exception {
    SourceConfig testSourceConfig = getSourceConfig();
    testSourceConfig.setProcessingGuarantees(null);
    SourceConfig expectedSourceConfig = getSourceConfig();
    expectedSourceConfig.setProcessingGuarantees(null);
    testCmdSourceConfigFile(testSourceConfig, expectedSourceConfig);
}
Also used : BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Test(org.testng.annotations.Test)

Aggregations

SourceConfig (org.apache.pulsar.common.io.SourceConfig)192 BatchSourceConfig (org.apache.pulsar.common.io.BatchSourceConfig)141 Test (org.testng.annotations.Test)129 Gson (com.google.gson.Gson)42 HashMap (java.util.HashMap)30 File (java.io.File)27 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)27 Function (org.apache.pulsar.functions.proto.Function)24 IOException (java.io.IOException)21 Response (javax.ws.rs.core.Response)18 List (java.util.List)15 Map (java.util.Map)15 RestException (org.apache.pulsar.common.util.RestException)15 IdentityFunction (org.apache.pulsar.functions.api.utils.IdentityFunction)15 FunctionMetaDataManager (org.apache.pulsar.functions.worker.FunctionMetaDataManager)15 Lists (com.google.common.collect.Lists)12 FileInputStream (java.io.FileInputStream)12 InputStream (java.io.InputStream)12 Files (java.nio.file.Files)12 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)12