Search in sources :

Example 1 with ProcessRuntime

use of org.apache.pulsar.functions.runtime.ProcessRuntime in project incubator-pulsar by apache.

the class ProcessRuntimeTest method testJavaConstructor.

@Test
public void testJavaConstructor() {
    InstanceConfig config = createJavaInstanceConfig(FunctionConfig.Runtime.JAVA);
    ProcessRuntime container = factory.createContainer(config, userJarFile);
    List<String> args = container.getProcessArgs();
    assertEquals(args.size(), 41);
    args.remove(args.size() - 1);
    String expectedArgs = "java -cp " + javaInstanceJarFile + " -Dlog4j.configurationFile=java_instance_log4j2.yml " + "-Dpulsar.log.dir=" + logDirectory + " -Dpulsar.log.file=" + config.getFunctionConfig().getName() + " org.apache.pulsar.functions.runtime.JavaInstanceMain" + " --jar " + userJarFile + " --instance_id " + config.getInstanceId() + " --function_id " + config.getFunctionId() + " --function_version " + config.getFunctionVersion() + " --tenant " + config.getFunctionConfig().getTenant() + " --namespace " + config.getFunctionConfig().getNamespace() + " --name " + config.getFunctionConfig().getName() + " --function_classname " + config.getFunctionConfig().getClassName() + " --log_topic " + config.getFunctionConfig().getLogTopic() + " --input_topics " + TEST_NAME + "-input1," + TEST_NAME + "-input2" + " --auto_ack false" + " --output_topic " + config.getFunctionConfig().getOutput() + " --output_serde_classname " + config.getFunctionConfig().getOutputSerdeClassName() + " --processing_guarantees ATLEAST_ONCE" + " --pulsar_serviceurl " + pulsarServiceUrl + " --max_buffered_tuples 1024 --port";
    assertEquals(expectedArgs, String.join(" ", args));
}
Also used : ProcessRuntime(org.apache.pulsar.functions.runtime.ProcessRuntime) InstanceConfig(org.apache.pulsar.functions.instance.InstanceConfig) Test(org.testng.annotations.Test)

Example 2 with ProcessRuntime

use of org.apache.pulsar.functions.runtime.ProcessRuntime in project incubator-pulsar by apache.

the class ProcessRuntimeTest method testPythonConstructor.

@Test
public void testPythonConstructor() {
    InstanceConfig config = createJavaInstanceConfig(FunctionConfig.Runtime.PYTHON);
    ProcessRuntime container = factory.createContainer(config, userJarFile);
    List<String> args = container.getProcessArgs();
    assertEquals(args.size(), 40);
    args.remove(args.size() - 1);
    String expectedArgs = "python " + pythonInstanceFile + " --py " + userJarFile + " --logging_directory " + logDirectory + " --logging_file " + config.getFunctionConfig().getName() + " --instance_id " + config.getInstanceId() + " --function_id " + config.getFunctionId() + " --function_version " + config.getFunctionVersion() + " --tenant " + config.getFunctionConfig().getTenant() + " --namespace " + config.getFunctionConfig().getNamespace() + " --name " + config.getFunctionConfig().getName() + " --function_classname " + config.getFunctionConfig().getClassName() + " --log_topic " + config.getFunctionConfig().getLogTopic() + " --input_topics " + TEST_NAME + "-input1," + TEST_NAME + "-input2" + " --auto_ack false" + " --output_topic " + config.getFunctionConfig().getOutput() + " --output_serde_classname " + config.getFunctionConfig().getOutputSerdeClassName() + " --processing_guarantees ATLEAST_ONCE" + " --pulsar_serviceurl " + pulsarServiceUrl + " --max_buffered_tuples 1024 --port";
    assertEquals(expectedArgs, String.join(" ", args));
}
Also used : ProcessRuntime(org.apache.pulsar.functions.runtime.ProcessRuntime) InstanceConfig(org.apache.pulsar.functions.instance.InstanceConfig) Test(org.testng.annotations.Test)

Aggregations

InstanceConfig (org.apache.pulsar.functions.instance.InstanceConfig)2 ProcessRuntime (org.apache.pulsar.functions.runtime.ProcessRuntime)2 Test (org.testng.annotations.Test)2