use of org.apache.pulsar.common.policies.data.TenantInfoImpl in project pulsar by apache.
the class NamespacesTest method testValidateAdminAccessOnTenant.
@Test
public void testValidateAdminAccessOnTenant() throws Exception {
try {
final String tenant = "prop";
pulsar.getConfiguration().setAuthenticationEnabled(true);
pulsar.getConfiguration().setAuthorizationEnabled(true);
pulsar.getPulsarResources().getTenantResources().createTenant(tenant, new TenantInfoImpl(Sets.newHashSet(namespaces.clientAppId()), Sets.newHashSet("use")));
namespaces.validateTenantOperation(tenant, null);
} finally {
pulsar.getConfiguration().setAuthenticationEnabled(false);
pulsar.getConfiguration().setAuthorizationEnabled(false);
}
}
use of org.apache.pulsar.common.policies.data.TenantInfoImpl in project pulsar by apache.
the class AdminApiSchemaAutoUpdateTest method setup.
@BeforeMethod
@Override
public void setup() throws Exception {
super.internalSetup();
// Setup namespaces
admin.clusters().createCluster("test", ClusterData.builder().serviceUrl(pulsar.getWebServiceAddress()).build());
TenantInfoImpl tenantInfo = new TenantInfoImpl(Sets.newHashSet("role1", "role2"), Sets.newHashSet("test"));
admin.tenants().createTenant("prop-xyz", tenantInfo);
admin.namespaces().createNamespace("prop-xyz/ns1", Sets.newHashSet("test"));
admin.namespaces().createNamespace("prop-xyz/test/ns1");
admin.namespaces().createNamespace("prop-xyz/ns2", Sets.newHashSet("test"));
admin.namespaces().createNamespace("prop-xyz/test/ns2");
}
use of org.apache.pulsar.common.policies.data.TenantInfoImpl in project pulsar by apache.
the class AdminApiSchemaTest method setup.
@BeforeMethod
@Override
public void setup() throws Exception {
super.internalSetup();
// Setup namespaces
admin.clusters().createCluster(cluster, ClusterData.builder().serviceUrl(pulsar.getWebServiceAddress()).build());
TenantInfoImpl tenantInfo = new TenantInfoImpl(Sets.newHashSet("role1", "role2"), Sets.newHashSet("test"));
admin.tenants().createTenant("schematest", tenantInfo);
admin.namespaces().createNamespace("schematest/test", Sets.newHashSet("test"));
admin.namespaces().createNamespace("schematest/" + cluster + "/test", Sets.newHashSet("test"));
admin.namespaces().createNamespace(schemaCompatibilityNamespace, Sets.newHashSet("test"));
}
use of org.apache.pulsar.common.policies.data.TenantInfoImpl in project pulsar by apache.
the class PersistentTopicsTest method testPeekWithSubscriptionNameNotExist.
@Test
public void testPeekWithSubscriptionNameNotExist() throws Exception {
TenantInfoImpl tenantInfo = new TenantInfoImpl(Sets.newHashSet("role1", "role2"), Sets.newHashSet("test"));
admin.tenants().createTenant("tenant-xyz", tenantInfo);
admin.namespaces().createNamespace("tenant-xyz/ns-abc", Sets.newHashSet("test"));
RetentionPolicies retention = new RetentionPolicies(10, 10);
admin.namespaces().setRetention("tenant-xyz/ns-abc", retention);
final String topic = "persistent://tenant-xyz/ns-abc/topic-testPeekWithSubscriptionNameNotExist";
final String subscriptionName = "sub";
((TopicsImpl) admin.topics()).createPartitionedTopicAsync(topic, 3, true, null).get();
final String partitionedTopic = topic + "-partition-0";
Producer<String> producer = pulsarClient.newProducer(Schema.STRING).enableBatching(false).topic(topic).create();
for (int i = 0; i < 10; ++i) {
producer.send("test" + i);
}
List<Message<byte[]>> messages = admin.topics().peekMessages(partitionedTopic, subscriptionName, 3);
Assert.assertEquals(messages.size(), 3);
producer.close();
}
use of org.apache.pulsar.common.policies.data.TenantInfoImpl in project pulsar by apache.
the class PersistentTopicsTest method testExamineMessageMetadata.
@Test
public void testExamineMessageMetadata() throws Exception {
TenantInfoImpl tenantInfo = new TenantInfoImpl(Sets.newHashSet("role1", "role2"), Sets.newHashSet("test"));
admin.tenants().createTenant("tenant-xyz", tenantInfo);
admin.namespaces().createNamespace("tenant-xyz/ns-abc", Sets.newHashSet("test"));
final String topicName = "persistent://tenant-xyz/ns-abc/topic-testExamineMessageMetadata";
admin.topics().createPartitionedTopic(topicName, 2);
@Cleanup Producer<String> producer = pulsarClient.newProducer(Schema.STRING).producerName("testExamineMessageMetadataProducer").compressionType(CompressionType.LZ4).topic(topicName + "-partition-0").create();
producer.newMessage().keyBytes("partition123".getBytes()).orderingKey(new byte[] { 0 }).replicationClusters(Lists.newArrayList("a", "b")).sequenceId(112233).value("data").send();
MessageImpl<byte[]> message = (MessageImpl<byte[]>) admin.topics().examineMessage(topicName + "-partition-0", "earliest", 1);
// test long
Assert.assertEquals(112233, message.getSequenceId());
// test byte[]
Assert.assertEquals(new byte[] { 0 }, message.getOrderingKey());
// test bool and byte[]
Assert.assertEquals("partition123".getBytes(), message.getKeyBytes());
Assert.assertTrue(message.hasBase64EncodedKey());
// test arrays
Assert.assertEquals(Lists.newArrayList("a", "b"), message.getReplicateTo());
// test string
Assert.assertEquals(producer.getProducerName(), message.getProducerName());
// test enum
Assert.assertEquals(CompressionType.LZ4.ordinal(), message.getMessageBuilder().getCompression().ordinal());
Assert.assertEquals("data", new String(message.getData()));
}
Aggregations