use of org.apache.pulsar.tests.integration.docker.ContainerExecResult in project pulsar by apache.
the class PulsarGenericObjectSinkTest method deleteSink.
private void deleteSink(String sinkName) throws Exception {
ContainerExecResult result = container.execCmd(PulsarCluster.ADMIN_SCRIPT, "sinks", "delete", "--tenant", "public", "--namespace", "default", "--name", sinkName);
assertTrue(result.getStdout().contains("successfully"));
result.assertNoStderr();
}
use of org.apache.pulsar.tests.integration.docker.ContainerExecResult in project pulsar by apache.
the class PulsarGenericObjectSinkTest method getSinkInfoSuccess.
private void getSinkInfoSuccess(String sinkName) throws Exception {
ContainerExecResult result = container.execCmd(PulsarCluster.ADMIN_SCRIPT, "sinks", "get", "--tenant", "public", "--namespace", "default", "--name", sinkName);
assertTrue(result.getStdout().contains("\"name\": \"" + sinkName + "\""));
}
use of org.apache.pulsar.tests.integration.docker.ContainerExecResult in project pulsar by apache.
the class PackagesCliTest method testPackagesOperationsWithoutUploadingPackages.
@Test(timeOut = 60000 * 5)
public void testPackagesOperationsWithoutUploadingPackages() throws Exception {
ContainerExecResult result = runPackagesCommand("list", "--type", "function", "public/default");
assertEquals(result.getExitCode(), 0);
result = runPackagesCommand("list-versions", "function://public/default/test");
assertEquals(result.getExitCode(), 0);
try {
result = runPackagesCommand("download", "function://public/default/test@v1", "--path", "test-admin");
fail("this command should be failed");
} catch (Exception e) {
// expected exception
}
}
use of org.apache.pulsar.tests.integration.docker.ContainerExecResult in project pulsar by apache.
the class SchemaUpdateStrategyTest method testAutoUpdateBackward.
private void testAutoUpdateBackward(String namespace, String topicName) throws Exception {
ContainerExecResult result = pulsarCluster.runAdminCommandOnAnyBroker("namespaces", "get-schema-autoupdate-strategy", namespace);
Assert.assertEquals(result.getStdout().trim(), "FULL");
pulsarCluster.runAdminCommandOnAnyBroker("namespaces", "set-schema-autoupdate-strategy", "--compatibility", "BACKWARD", namespace);
try (PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(pulsarCluster.getPlainTextServiceUrl()).build()) {
V1Data v1Data = new V1Data("test1", 1);
try (Producer<V1Data> p = pulsarClient.newProducer(Schema.AVRO(V1Data.class)).topic(topicName).create()) {
p.send(v1Data);
}
log.info("try with forward compat, should fail");
try (Producer<V3Data> p = pulsarClient.newProducer(Schema.AVRO(V3Data.class)).topic(topicName).create()) {
Assert.fail("Forward compat schema should be rejected");
} catch (PulsarClientException e) {
Assert.assertTrue(e.getMessage().contains("IncompatibleSchemaException"));
}
log.info("try with backward compat, should succeed");
V2Data v2Data = new V2Data("test2");
try (Producer<V2Data> p = pulsarClient.newProducer(Schema.AVRO(V2Data.class)).topic(topicName).create()) {
p.send(v2Data);
}
Schema<GenericRecord> schema = Schema.AUTO_CONSUME();
try (Consumer<GenericRecord> consumer = pulsarClient.newConsumer(schema).topic(topicName).subscriptionInitialPosition(SubscriptionInitialPosition.Earliest).subscriptionName("sub").subscribe()) {
log.info("Schema Info : {}", schema.getSchemaInfo().getSchemaDefinition());
Message<GenericRecord> msg1 = consumer.receive();
v1Data.assertEqualToRecord(msg1.getValue());
Message<GenericRecord> msg2 = consumer.receive();
v2Data.assertEqualToRecord(msg2.getValue());
}
}
}
use of org.apache.pulsar.tests.integration.docker.ContainerExecResult in project pulsar by apache.
the class SchemaUpdateStrategyTest method testAutoUpdateFull.
private void testAutoUpdateFull(String namespace, String topicName) throws Exception {
ContainerExecResult result = pulsarCluster.runAdminCommandOnAnyBroker("namespaces", "get-schema-autoupdate-strategy", namespace);
Assert.assertEquals(result.getStdout().trim(), "FULL");
try (PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(pulsarCluster.getPlainTextServiceUrl()).build()) {
V1Data v1Data = new V1Data("test1", 1);
try (Producer<V1Data> p = pulsarClient.newProducer(Schema.AVRO(V1Data.class)).topic(topicName).create()) {
p.send(v1Data);
}
log.info("try with backward compat only, should fail");
try (Producer<V2Data> p = pulsarClient.newProducer(Schema.AVRO(V2Data.class)).topic(topicName).create()) {
Assert.fail("Backward compat only schema should fail");
} catch (PulsarClientException e) {
Assert.assertTrue(e.getMessage().contains("IncompatibleSchemaException"));
}
log.info("try with forward compat only, should fail");
try (Producer<V3Data> p = pulsarClient.newProducer(Schema.AVRO(V3Data.class)).topic(topicName).create()) {
Assert.fail("Forward compat only schema should fail");
} catch (PulsarClientException e) {
Assert.assertTrue(e.getMessage().contains("IncompatibleSchemaException"));
}
log.info("try with fully compat");
V4Data v4Data = new V4Data("test2", 1, (short) 100);
try (Producer<V4Data> p = pulsarClient.newProducer(Schema.AVRO(V4Data.class)).topic(topicName).create()) {
p.send(v4Data);
}
Schema<GenericRecord> schema = Schema.AUTO_CONSUME();
try (Consumer<GenericRecord> consumer = pulsarClient.newConsumer(schema).topic(topicName).subscriptionName("sub").subscriptionInitialPosition(SubscriptionInitialPosition.Earliest).subscribe()) {
log.info("Schema Info : {}", schema.getSchemaInfo().getSchemaDefinition());
Message<GenericRecord> msg1 = consumer.receive();
v1Data.assertEqualToRecord(msg1.getValue());
Message<GenericRecord> msg2 = consumer.receive();
v4Data.assertEqualToRecord(msg2.getValue());
}
}
}
Aggregations