use of org.apache.pulsar.common.policies.data.ClusterData in project incubator-pulsar by apache.
the class AuthenticatedProducerConsumerTest method testAuthenticationFilterNegative.
/**
* Verifies: on 500 server error, broker invalidates session and client receives 500 correctly.
*
* @throws Exception
*/
@Test
public void testAuthenticationFilterNegative() throws Exception {
log.info("-- Starting {} test --", methodName);
Map<String, String> authParams = new HashMap<>();
authParams.put("tlsCertFile", TLS_CLIENT_CERT_FILE_PATH);
authParams.put("tlsKeyFile", TLS_CLIENT_KEY_FILE_PATH);
Authentication authTls = new AuthenticationTls();
authTls.configure(authParams);
internalSetup(authTls);
final String cluster = "use";
final ClusterData clusterData = new ClusterData(brokerUrl.toString(), brokerUrlTls.toString(), "pulsar://localhost:" + BROKER_PORT, "pulsar+ssl://localhost:" + BROKER_PORT_TLS);
// this will cause NPE and it should throw 500
doReturn(null).when(pulsar).getGlobalZkCache();
try {
admin.clusters().createCluster(cluster, clusterData);
} catch (PulsarAdminException e) {
Assert.assertTrue(e.getCause() instanceof InternalServerErrorException);
}
log.info("-- Exiting {} test --", methodName);
}
use of org.apache.pulsar.common.policies.data.ClusterData in project incubator-pulsar by apache.
the class BrokerServiceLookupTest method testPartitionedMetadataWithDeprecatedVersion.
@Test
public void testPartitionedMetadataWithDeprecatedVersion() throws Exception {
final String cluster = "use2";
final String property = "my-property2";
final String namespace = "my-ns";
final String topicName = "my-partitioned";
final int totalPartitions = 10;
final TopicName dest = TopicName.get("persistent", property, cluster, namespace, topicName);
admin.clusters().createCluster(cluster, new ClusterData("http://127.0.0.1:" + BROKER_WEBSERVICE_PORT, null, null, null));
admin.properties().createProperty(property, new PropertyAdmin(Lists.newArrayList("appid1", "appid2"), Sets.newHashSet(cluster)));
admin.namespaces().createNamespace(property + "/" + cluster + "/" + namespace);
admin.persistentTopics().createPartitionedTopic(dest.toString(), totalPartitions);
stopBroker();
conf.setClientLibraryVersionCheckEnabled(true);
startBroker();
URI brokerServiceUrl = new URI(pulsar.getWebServiceAddress());
URL url = brokerServiceUrl.toURL();
String path = String.format("admin/%s/partitions", dest.getLookupName());
AsyncHttpClient httpClient = getHttpClient("Pulsar-Java-1.20");
PartitionedTopicMetadata metadata = getPartitionedMetadata(httpClient, url, path);
assertEquals(metadata.partitions, totalPartitions);
httpClient.close();
httpClient = getHttpClient("Pulsar-CPP-v1.21");
metadata = getPartitionedMetadata(httpClient, url, path);
assertEquals(metadata.partitions, totalPartitions);
httpClient.close();
httpClient = getHttpClient("Pulsar-CPP-v1.21-SNAPSHOT");
metadata = getPartitionedMetadata(httpClient, url, path);
assertEquals(metadata.partitions, totalPartitions);
httpClient.close();
httpClient = getHttpClient("");
try {
metadata = getPartitionedMetadata(httpClient, url, path);
fail("should have failed due to invalid version");
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof PulsarClientException);
}
httpClient.close();
httpClient = getHttpClient("Pulsar-CPP-v1.20-SNAPSHOT");
try {
metadata = getPartitionedMetadata(httpClient, url, path);
fail("should have failed due to invalid version");
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof PulsarClientException);
}
httpClient.close();
httpClient = getHttpClient("Pulsar-CPP-v1.20");
try {
metadata = getPartitionedMetadata(httpClient, url, path);
fail("should have failed due to invalid version");
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof PulsarClientException);
}
httpClient.close();
}
use of org.apache.pulsar.common.policies.data.ClusterData in project incubator-pulsar by apache.
the class BrokerTestBase method baseSetup.
public void baseSetup() throws Exception {
super.internalSetup();
admin.clusters().createCluster("use", new ClusterData(brokerUrl.toString()));
admin.properties().createProperty("prop", new PropertyAdmin(Lists.newArrayList("appid1"), Sets.newHashSet("use")));
admin.namespaces().createNamespace("prop/use/ns-abc");
}
use of org.apache.pulsar.common.policies.data.ClusterData in project incubator-pulsar by apache.
the class CompactedTopicTest method setup.
@BeforeMethod
@Override
public void setup() throws Exception {
super.internalSetup();
admin.clusters().createCluster("use", new ClusterData("http://127.0.0.1:" + BROKER_WEBSERVICE_PORT));
admin.properties().createProperty("my-property", new PropertyAdmin(Lists.newArrayList("appid1", "appid2"), Sets.newHashSet("use")));
admin.namespaces().createNamespace("my-property/use/my-ns");
}
use of org.apache.pulsar.common.policies.data.ClusterData in project incubator-pulsar by apache.
the class CompactionTest method setup.
@BeforeMethod
@Override
public void setup() throws Exception {
super.internalSetup();
admin.clusters().createCluster("use", new ClusterData("http://127.0.0.1:" + BROKER_WEBSERVICE_PORT));
admin.properties().createProperty("my-property", new PropertyAdmin(Lists.newArrayList("appid1", "appid2"), Sets.newHashSet("use")));
admin.namespaces().createNamespace("my-property/use/my-ns");
compactionScheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder().setNameFormat("compaction-%d").setDaemon(true).build());
bk = pulsar.getBookKeeperClientFactory().create(this.conf, null);
}
Aggregations