Search in sources :

Example 6 with SinkConfig

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

the class TestCmdSinks method testInvalidJar.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Sink Archive file /tmp/foo.jar" + " does not exist")
public void testInvalidJar() throws Exception {
    SinkConfig sinkConfig = getSinkConfig();
    String fakeJar = "/tmp/foo.jar";
    sinkConfig.setArchive(fakeJar);
    testCmdSinkCliMissingArgs(TENANT, NAMESPACE, NAME, INPUTS, TOPIC_PATTERN, CUSTOM_SERDE_INPUT_STRING, PROCESSING_GUARANTEES, PARALLELISM, fakeJar, CPU, RAM, DISK, SINK_CONFIG_STRING, sinkConfig);
}
Also used : SinkConfig(org.apache.pulsar.common.io.SinkConfig) Test(org.testng.annotations.Test)

Example 7 with SinkConfig

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

the class TestCmdSinks method testMissingCustomSerdeInput.

@Test
public void testMissingCustomSerdeInput() throws Exception {
    SinkConfig sinkConfig = getSinkConfig();
    sinkConfig.setTopicToSerdeClassName(null);
    sinkConfig.setTopicToSchemaType(null);
    testCmdSinkCliMissingArgs(TENANT, NAMESPACE, NAME, INPUTS, TOPIC_PATTERN, null, PROCESSING_GUARANTEES, PARALLELISM, JAR_FILE_PATH, CPU, RAM, DISK, SINK_CONFIG_STRING, sinkConfig);
}
Also used : SinkConfig(org.apache.pulsar.common.io.SinkConfig) Test(org.testng.annotations.Test)

Example 8 with SinkConfig

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

the class TestCmdSinks method testCmdSinkConfigFile.

private void testCmdSinkConfigFile(SinkConfig testSinkConfig, SinkConfig expectedSinkConfig) throws Exception {
    File file = Files.createTempFile("", "").toFile();
    new YAMLMapper().writeValue(file, testSinkConfig);
    Assert.assertEquals(testSinkConfig, CmdUtils.loadConfig(file.getAbsolutePath(), SinkConfig.class));
    // test create sink
    createSink.sinkConfigFile = file.getAbsolutePath();
    createSink.processArguments();
    createSink.runCmd();
    // test update sink
    updateSink.sinkConfigFile = file.getAbsolutePath();
    updateSink.processArguments();
    updateSink.runCmd();
    // test local runner
    localSinkRunner.sinkConfigFile = file.getAbsolutePath();
    localSinkRunner.processArguments();
    localSinkRunner.runCmd();
    verify(createSink).validateSinkConfigs(eq(expectedSinkConfig));
    verify(updateSink).validateSinkConfigs(eq(expectedSinkConfig));
    verify(localSinkRunner).validateSinkConfigs(eq(expectedSinkConfig));
}
Also used : SinkConfig(org.apache.pulsar.common.io.SinkConfig) YAMLMapper(com.fasterxml.jackson.dataformat.yaml.YAMLMapper) File(java.io.File)

Example 9 with SinkConfig

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

the class TestCmdSinks method testParseConfigs.

@Test
public void testParseConfigs() throws Exception {
    SinkConfig testSinkConfig = getSinkConfig();
    Map<String, Object> config = testSinkConfig.getConfigs();
    Assert.assertEquals(config.get("int"), 1000);
    Assert.assertEquals(config.get("int_string"), "1000");
    Assert.assertEquals(config.get("float"), 1000.0);
    Assert.assertEquals(config.get("float_string"), "1000.0");
    Assert.assertEquals(config.get("created_at"), "Mon Jul 02 00:33:15 +0000 2018");
}
Also used : SinkConfig(org.apache.pulsar.common.io.SinkConfig) Test(org.testng.annotations.Test)

Example 10 with SinkConfig

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

the class TestCmdSinks method testMissingConfig.

@Test
public void testMissingConfig() throws Exception {
    SinkConfig sinkConfig = getSinkConfig();
    sinkConfig.setConfigs(null);
    testCmdSinkCliMissingArgs(TENANT, NAMESPACE, NAME, INPUTS, TOPIC_PATTERN, CUSTOM_SERDE_INPUT_STRING, PROCESSING_GUARANTEES, PARALLELISM, JAR_FILE_PATH, CPU, RAM, DISK, null, sinkConfig);
}
Also used : SinkConfig(org.apache.pulsar.common.io.SinkConfig) Test(org.testng.annotations.Test)

Aggregations

SinkConfig (org.apache.pulsar.common.io.SinkConfig)223 Test (org.testng.annotations.Test)165 Gson (com.google.gson.Gson)42 HashMap (java.util.HashMap)33 Function (org.apache.pulsar.functions.proto.Function)27 File (java.io.File)24 ConsumerConfig (org.apache.pulsar.common.functions.ConsumerConfig)24 IdentityFunction (org.apache.pulsar.functions.api.utils.IdentityFunction)24 NarClassLoader (org.apache.pulsar.common.nar.NarClassLoader)21 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)19 IOException (java.io.IOException)18 Resources (org.apache.pulsar.common.functions.Resources)15 FileInputStream (java.io.FileInputStream)12 WebTarget (javax.ws.rs.client.WebTarget)12 ObjectMapperFactory (org.apache.pulsar.common.util.ObjectMapperFactory)12 TopicStats (org.apache.pulsar.common.policies.data.TopicStats)10 List (java.util.List)9 Map (java.util.Map)9 CompletableFuture (java.util.concurrent.CompletableFuture)9 Cleanup (lombok.Cleanup)9