use of org.apache.pulsar.tests.integration.docker.ContainerExecException in project pulsar by apache.
the class TenantTest method testCreateExistTenantCmd.
@Test
public void testCreateExistTenantCmd() {
ContainerExecException ex = expectThrows(ContainerExecException.class, () -> pulsarCluster.runAdminCommandOnAnyBroker("tenants", "create", "public"));
assertTrue(ex.getResult().getStderr().contains("Tenant already exist"));
}
use of org.apache.pulsar.tests.integration.docker.ContainerExecException in project pulsar by apache.
the class PulsarFunctionsTest method checkPublisherCleanup.
private void checkPublisherCleanup(String topic) throws Exception {
try {
ContainerExecResult result = pulsarCluster.getAnyBroker().execCmd(PulsarCluster.ADMIN_SCRIPT, "topics", "stats", topic);
TopicStats topicStats = ObjectMapperFactory.getThreadLocal().readValue(result.getStdout(), TopicStats.class);
assertEquals(topicStats.getPublishers().size(), 0);
} catch (ContainerExecException e) {
fail("Command should have exited with non-zero");
}
}
use of org.apache.pulsar.tests.integration.docker.ContainerExecException in project pulsar by apache.
the class TestPulsarSQLBase method waitPulsarSQLReady.
public void waitPulsarSQLReady() throws Exception {
// wait until presto worker started
ContainerExecResult result;
do {
try {
result = execQuery("show catalogs;");
assertThat(result.getExitCode()).isEqualTo(0);
assertThat(result.getStdout()).contains("pulsar", "system");
break;
} catch (ContainerExecException cee) {
if (cee.getResult().getStderr().contains("Presto server is still initializing")) {
Thread.sleep(10000);
} else {
throw cee;
}
}
} while (true);
// check presto follow workers start finish.
if (pulsarCluster.getSqlFollowWorkerContainers() != null && pulsarCluster.getSqlFollowWorkerContainers().size() > 0) {
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder().url("http://" + pulsarCluster.getPrestoWorkerContainer().getUrl() + "/v1/node").build();
do {
try (Response response = okHttpClient.newCall(request).execute()) {
Assert.assertNotNull(response.body());
String nodeJsonStr = response.body().string();
Assert.assertTrue(nodeJsonStr.length() > 0);
log.info("presto node info: {}", nodeJsonStr);
if (nodeJsonStr.contains("uri")) {
log.info("presto node exist.");
break;
}
Thread.sleep(1000);
}
} while (true);
}
}
use of org.apache.pulsar.tests.integration.docker.ContainerExecException in project pulsar by apache.
the class CLITest method testGetTopicListCommand.
@Test
public void testGetTopicListCommand() throws Exception {
ContainerExecResult result;
final String namespaceLocalName = "list-topics-" + randomName(8);
result = pulsarCluster.createNamespace(namespaceLocalName);
final String namespace = "public/" + namespaceLocalName;
assertEquals(0, result.getExitCode());
PulsarClient client = PulsarClient.builder().serviceUrl(pulsarCluster.getPlainTextServiceUrl()).build();
final String persistentTopicName = TopicName.get("persistent", NamespaceName.get(namespace), "get_topics_mode_" + UUID.randomUUID().toString()).toString();
final String nonPersistentTopicName = TopicName.get("non-persistent", NamespaceName.get(namespace), "get_topics_mode_" + UUID.randomUUID().toString()).toString();
Producer<byte[]> producer1 = client.newProducer().topic(persistentTopicName).create();
Producer<byte[]> producer2 = client.newProducer().topic(nonPersistentTopicName).create();
BrokerContainer container = pulsarCluster.getAnyBroker();
result = container.execCmd(PulsarCluster.ADMIN_SCRIPT, "topics", "list", namespace);
assertTrue(result.getStdout().contains(persistentTopicName));
assertTrue(result.getStdout().contains(nonPersistentTopicName));
result = container.execCmd(PulsarCluster.ADMIN_SCRIPT, "topics", "list", "--topic-domain", "persistent", namespace);
assertTrue(result.getStdout().contains(persistentTopicName));
assertFalse(result.getStdout().contains(nonPersistentTopicName));
result = container.execCmd(PulsarCluster.ADMIN_SCRIPT, "topics", "list", "--topic-domain", "non_persistent", namespace);
assertFalse(result.getStdout().contains(persistentTopicName));
assertTrue(result.getStdout().contains(nonPersistentTopicName));
try {
container.execCmd(PulsarCluster.ADMIN_SCRIPT, "topics", "list", "--topic-domain", "none", namespace);
fail();
} catch (ContainerExecException ignore) {
}
producer1.close();
producer2.close();
}
use of org.apache.pulsar.tests.integration.docker.ContainerExecException in project pulsar by apache.
the class CLITest method testPropertiesCLI.
@Test
public void testPropertiesCLI() throws Exception {
final BrokerContainer container = pulsarCluster.getAnyBroker();
final String namespace = "public/default";
ContainerExecResult result = container.execCmd(PulsarCluster.ADMIN_SCRIPT, "namespaces", "set-property", "-k", "a", "-v", "a", namespace);
assertTrue(result.getStdout().isEmpty());
result = container.execCmd(PulsarCluster.ADMIN_SCRIPT, "namespaces", "get-property", "-k", "a", namespace);
assertTrue(result.getStdout().contains("a"));
result = container.execCmd(PulsarCluster.ADMIN_SCRIPT, "namespaces", "remove-property", "-k", "a", namespace);
assertTrue(result.getStdout().contains("a"));
result = container.execCmd(PulsarCluster.ADMIN_SCRIPT, "namespaces", "remove-property", "-k", "a", namespace);
assertTrue(result.getStdout().contains("null"));
result = container.execCmd(PulsarCluster.ADMIN_SCRIPT, "namespaces", "set-properties", "-p", "a=a,b=b,c=c", namespace);
assertTrue(result.getStdout().isEmpty());
result = container.execCmd(PulsarCluster.ADMIN_SCRIPT, "namespaces", "get-properties", namespace);
assertFalse(result.getStdout().isEmpty());
result = container.execCmd(PulsarCluster.ADMIN_SCRIPT, "namespaces", "clear-properties", namespace);
assertTrue(result.getStdout().isEmpty());
try {
container.execCmd(PulsarCluster.ADMIN_SCRIPT, "bookies", "set-bookie-rack", "-b", "localhost:8082", "-r", "");
fail("Command should have exited with non-zero");
} catch (ContainerExecException e) {
assertEquals(e.getResult().getStderr(), "rack name is invalid, it should not be null, empty or '/'\n\n");
}
try {
container.execCmd(PulsarCluster.ADMIN_SCRIPT, "namespaces", "set-schema-autoupdate-strategy", namespace);
} catch (ContainerExecException e) {
assertEquals(e.getResult().getStderr(), "Either --compatibility or --disabled must be specified\n\n");
}
}
Aggregations