Search in sources :

Example 16 with Schemas

use of org.apache.pulsar.client.admin.Schemas in project pulsar by yahoo.

the class PulsarAdminToolTest method topics.

@Test
public void topics() throws Exception {
    PulsarAdmin admin = Mockito.mock(PulsarAdmin.class);
    Topics mockTopics = mock(Topics.class);
    when(admin.topics()).thenReturn(mockTopics);
    Schemas mockSchemas = mock(Schemas.class);
    when(admin.schemas()).thenReturn(mockSchemas);
    Lookup mockLookup = mock(Lookup.class);
    when(admin.lookups()).thenReturn(mockLookup);
    CmdTopics cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("truncate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).truncate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("delete persistent://myprop/clust/ns1/ds1 -f"));
    verify(mockTopics).delete("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("unload persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).unload("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("permissions persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getPermissions("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("grant-permission persistent://myprop/clust/ns1/ds1 --role admin --actions produce,consume"));
    verify(mockTopics).grantPermission("persistent://myprop/clust/ns1/ds1", "admin", Sets.newHashSet(AuthAction.produce, AuthAction.consume));
    cmdTopics.run(split("revoke-permission persistent://myprop/clust/ns1/ds1 --role admin"));
    verify(mockTopics).revokePermissions("persistent://myprop/clust/ns1/ds1", "admin");
    cmdTopics.run(split("list myprop/clust/ns1"));
    verify(mockTopics).getList("myprop/clust/ns1", null, ListTopicsOptions.EMPTY);
    cmdTopics.run(split("lookup persistent://myprop/clust/ns1/ds1"));
    verify(mockLookup).lookupTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("partitioned-lookup persistent://myprop/clust/ns1/ds1"));
    verify(mockLookup).lookupPartitionedTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("partitioned-lookup persistent://myprop/clust/ns1/ds1 --sort-by-broker"));
    verify(mockLookup).lookupPartitionedTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("bundle-range persistent://myprop/clust/ns1/ds1"));
    verify(mockLookup).getBundleRange("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("subscriptions persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getSubscriptions("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("unsubscribe persistent://myprop/clust/ns1/ds1 -s sub1"));
    verify(mockTopics).deleteSubscription("persistent://myprop/clust/ns1/ds1", "sub1", false);
    cmdTopics.run(split("stats persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getStats("persistent://myprop/clust/ns1/ds1", false, false, false);
    cmdTopics.run(split("stats-internal persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getInternalStats("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("get-backlog-quotas persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getBacklogQuotaMap("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("set-backlog-quota persistent://myprop/clust/ns1/ds1 -l 10 -p producer_request_hold"));
    verify(mockTopics).setBacklogQuota("persistent://myprop/clust/ns1/ds1", BacklogQuota.builder().limitSize(10).retentionPolicy(RetentionPolicy.producer_request_hold).build(), BacklogQuota.BacklogQuotaType.destination_storage);
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("set-backlog-quota persistent://myprop/clust/ns1/ds1 -lt 5h -p consumer_backlog_eviction"));
    verify(mockTopics).setBacklogQuota("persistent://myprop/clust/ns1/ds1", BacklogQuota.builder().limitSize(-1).limitTime(5 * 60 * 60).retentionPolicy(RetentionPolicy.consumer_backlog_eviction).build(), BacklogQuota.BacklogQuotaType.destination_storage);
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("set-backlog-quota persistent://myprop/clust/ns1/ds1 -lt 1000 -p producer_request_hold -t message_age"));
    verify(mockTopics).setBacklogQuota("persistent://myprop/clust/ns1/ds1", BacklogQuota.builder().limitSize(-1).limitTime(1000).retentionPolicy(RetentionPolicy.producer_request_hold).build(), BacklogQuota.BacklogQuotaType.message_age);
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("remove-backlog-quota persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeBacklogQuota("persistent://myprop/clust/ns1/ds1", BacklogQuota.BacklogQuotaType.destination_storage);
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("remove-backlog-quota persistent://myprop/clust/ns1/ds1 -t message_age"));
    verify(mockTopics).removeBacklogQuota("persistent://myprop/clust/ns1/ds1", BacklogQuota.BacklogQuotaType.message_age);
    cmdTopics.run(split("info-internal persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getInternalInfo("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("partitioned-stats persistent://myprop/clust/ns1/ds1 --per-partition"));
    verify(mockTopics).getPartitionedStats("persistent://myprop/clust/ns1/ds1", true, false, false);
    cmdTopics.run(split("partitioned-stats-internal persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getPartitionedInternalStats("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("clear-backlog persistent://myprop/clust/ns1/ds1 -s sub1"));
    verify(mockTopics).skipAllMessages("persistent://myprop/clust/ns1/ds1", "sub1");
    cmdTopics.run(split("skip persistent://myprop/clust/ns1/ds1 -s sub1 -n 100"));
    verify(mockTopics).skipMessages("persistent://myprop/clust/ns1/ds1", "sub1", 100);
    cmdTopics.run(split("expire-messages persistent://myprop/clust/ns1/ds1 -s sub1 -t 100"));
    verify(mockTopics).expireMessages("persistent://myprop/clust/ns1/ds1", "sub1", 100);
    cmdTopics.run(split("expire-messages-all-subscriptions persistent://myprop/clust/ns1/ds1 -t 100"));
    verify(mockTopics).expireMessagesForAllSubscriptions("persistent://myprop/clust/ns1/ds1", 100);
    cmdTopics.run(split("get-subscribe-rate persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getSubscribeRate("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("set-subscribe-rate persistent://myprop/clust/ns1/ds1 -sr 2 -st 60"));
    verify(mockTopics).setSubscribeRate("persistent://myprop/clust/ns1/ds1", new SubscribeRate(2, 60));
    cmdTopics.run(split("remove-subscribe-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeSubscribeRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-replicated-subscription-status persistent://myprop/clust/ns1/ds1 -s sub1 -e"));
    verify(mockTopics).setReplicatedSubscriptionStatus("persistent://myprop/clust/ns1/ds1", "sub1", true);
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("expire-messages persistent://myprop/clust/ns1/ds1 -s sub1 -p 1:1 -e"));
    verify(mockTopics).expireMessages(eq("persistent://myprop/clust/ns1/ds1"), eq("sub1"), eq(new MessageIdImpl(1, 1, -1)), eq(true));
    cmdTopics.run(split("expire-messages-all-subscriptions persistent://myprop/clust/ns1/ds1 -t 1d"));
    verify(mockTopics).expireMessagesForAllSubscriptions("persistent://myprop/clust/ns1/ds1", 60 * 60 * 24);
    cmdTopics.run(split("create-subscription persistent://myprop/clust/ns1/ds1 -s sub1 --messageId earliest"));
    verify(mockTopics).createSubscription("persistent://myprop/clust/ns1/ds1", "sub1", MessageId.earliest, false, null);
    // jcommander is stateful, you cannot parse the same command twice
    cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("create-subscription persistent://myprop/clust/ns1/ds1 -s sub1 --messageId earliest --property a=b"));
    Map<String, String> props = new HashMap<>();
    props.put("a", "b");
    verify(mockTopics).createSubscription("persistent://myprop/clust/ns1/ds1", "sub1", MessageId.earliest, false, props);
    cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("create-subscription persistent://myprop/clust/ns1/ds1 -s sub1 --messageId earliest -r"));
    verify(mockTopics).createSubscription("persistent://myprop/clust/ns1/ds1", "sub1", MessageId.earliest, true, null);
    cmdTopics.run(split("create-partitioned-topic persistent://myprop/clust/ns1/ds1 --partitions 32"));
    verify(mockTopics).createPartitionedTopic("persistent://myprop/clust/ns1/ds1", 32, null);
    cmdTopics.run(split("create-missed-partitions persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).createMissedPartitions("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("create persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).createNonPartitionedTopic("persistent://myprop/clust/ns1/ds1", null);
    cmdTopics.run(split("list-partitioned-topics myprop/clust/ns1"));
    verify(mockTopics).getPartitionedTopicList("myprop/clust/ns1", ListTopicsOptions.EMPTY);
    cmdTopics.run(split("update-partitioned-topic persistent://myprop/clust/ns1/ds1 -p 6"));
    verify(mockTopics).updatePartitionedTopic("persistent://myprop/clust/ns1/ds1", 6, false, false);
    cmdTopics.run(split("get-partitioned-topic-metadata persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getPartitionedTopicMetadata("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("delete-partitioned-topic persistent://myprop/clust/ns1/ds1 -f"));
    verify(mockTopics).deletePartitionedTopic("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("peek-messages persistent://myprop/clust/ns1/ds1 -s sub1 -n 3"));
    verify(mockTopics).peekMessages("persistent://myprop/clust/ns1/ds1", "sub1", 3);
    MessageImpl message = mock(MessageImpl.class);
    when(message.getData()).thenReturn(new byte[] {});
    when(message.getMessageId()).thenReturn(new MessageIdImpl(1L, 1L, 1));
    when(mockTopics.examineMessage("persistent://myprop/clust/ns1/ds1", "latest", 1)).thenReturn(message);
    cmdTopics.run(split("examine-messages persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).examineMessage("persistent://myprop/clust/ns1/ds1", "latest", 1);
    cmdTopics.run(split("enable-deduplication persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).enableDeduplication("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("disable-deduplication persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).enableDeduplication("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-deduplication persistent://myprop/clust/ns1/ds1 --disable"));
    verify(mockTopics).setDeduplicationStatus("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-subscription-dispatch-rate persistent://myprop/clust/ns1/ds1 -md -1 -bd -1 -dt 2"));
    verify(mockTopics).setSubscriptionDispatchRate("persistent://myprop/clust/ns1/ds1", DispatchRate.builder().dispatchThrottlingRateInMsg(-1).dispatchThrottlingRateInByte(-1).ratePeriodInSecond(2).build());
    cmdTopics.run(split("get-subscription-dispatch-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getSubscriptionDispatchRate("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-subscription-dispatch-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeSubscriptionDispatchRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-deduplication persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeDeduplicationStatus("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-replicator-dispatch-rate persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getReplicatorDispatchRate("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("set-subscription-types-enabled persistent://myprop/clust/ns1/ds1 -t Shared,Failover"));
    verify(mockTopics).setSubscriptionTypesEnabled("persistent://myprop/clust/ns1/ds1", Sets.newHashSet(SubscriptionType.Shared, SubscriptionType.Failover));
    cmdTopics.run(split("get-subscription-types-enabled persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getSubscriptionTypesEnabled("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-subscription-types-enabled persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeSubscriptionTypesEnabled("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-replicator-dispatch-rate persistent://myprop/clust/ns1/ds1 -md 10 -bd 11 -dt 12"));
    verify(mockTopics).setReplicatorDispatchRate("persistent://myprop/clust/ns1/ds1", DispatchRate.builder().dispatchThrottlingRateInMsg(10).dispatchThrottlingRateInByte(11).ratePeriodInSecond(12).build());
    cmdTopics.run(split("remove-replicator-dispatch-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeReplicatorDispatchRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-deduplication-enabled persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getDeduplicationStatus("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-deduplication persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics, times(2)).getDeduplicationStatus("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-offload-policies persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getOffloadPolicies("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-offload-policies persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeOffloadPolicies("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-delayed-delivery persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-delayed-delivery persistent://myprop/clust/ns1/ds1 -t 10s --enable"));
    verify(mockTopics).setDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1", DelayedDeliveryPolicies.builder().tickTime(10000).active(true).build());
    cmdTopics.run(split("remove-delayed-delivery persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-offload-policies persistent://myprop/clust/ns1/ds1 -d s3 -r region -b bucket -e endpoint -m 8 -rb 9 -t 10 -orp tiered-storage-first"));
    OffloadPoliciesImpl offloadPolicies = OffloadPoliciesImpl.create("s3", "region", "bucket", "endpoint", null, null, null, null, 8, 9, 10L, null, OffloadedReadPriority.TIERED_STORAGE_FIRST);
    verify(mockTopics).setOffloadPolicies("persistent://myprop/clust/ns1/ds1", offloadPolicies);
    cmdTopics.run(split("get-max-unacked-messages-on-consumer persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("get-max-unacked-messages-per-consumer persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics, times(2)).getMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-unacked-messages-on-consumer persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-max-unacked-messages-per-consumer persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics, times(2)).removeMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-unacked-messages-on-consumer persistent://myprop/clust/ns1/ds1 -m 999"));
    verify(mockTopics).setMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", 999);
    cmdTopics.run(split("set-max-unacked-messages-per-consumer persistent://myprop/clust/ns1/ds1 -m 999"));
    verify(mockTopics, times(2)).setMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", 999);
    cmdTopics.run(split("get-max-unacked-messages-on-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("get-max-unacked-messages-per-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics, times(2)).getMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-unacked-messages-on-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-max-unacked-messages-per-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics, times(2)).removeMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-publish-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getPublishRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-publish-rate persistent://myprop/clust/ns1/ds1 -m 100 -b 10240"));
    verify(mockTopics).setPublishRate("persistent://myprop/clust/ns1/ds1", new PublishRate(100, 10240L));
    cmdTopics.run(split("remove-publish-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removePublishRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-unacked-messages-on-subscription persistent://myprop/clust/ns1/ds1 -m 99"));
    verify(mockTopics).setMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("set-max-unacked-messages-per-subscription persistent://myprop/clust/ns1/ds1 -m 99"));
    verify(mockTopics, times(2)).setMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-compaction-threshold persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getCompactionThreshold("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-compaction-threshold persistent://myprop/clust/ns1/ds1 -t 10k"));
    verify(mockTopics).setCompactionThreshold("persistent://myprop/clust/ns1/ds1", 10 * 1024);
    cmdTopics.run(split("remove-compaction-threshold persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeCompactionThreshold("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-message-size persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxMessageSize("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-max-message-size persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxMessageSize("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-consumers-per-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxConsumersPerSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-consumers-per-subscription persistent://myprop/clust/ns1/ds1 -c 5"));
    verify(mockTopics).setMaxConsumersPerSubscription("persistent://myprop/clust/ns1/ds1", 5);
    cmdTopics.run(split("remove-max-consumers-per-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxConsumersPerSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-message-size persistent://myprop/clust/ns1/ds1 -m 99"));
    verify(mockTopics).setMaxMessageSize("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-message-by-id persistent://myprop/clust/ns1/ds1 -l 10 -e 2"));
    verify(mockTopics).getMessageById("persistent://myprop/clust/ns1/ds1", 10, 2);
    cmdTopics.run(split("get-dispatch-rate persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getDispatchRate("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("remove-dispatch-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeDispatchRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-dispatch-rate persistent://myprop/clust/ns1/ds1 -md -1 -bd -1 -dt 2"));
    verify(mockTopics).setDispatchRate("persistent://myprop/clust/ns1/ds1", DispatchRate.builder().dispatchThrottlingRateInMsg(-1).dispatchThrottlingRateInByte(-1).ratePeriodInSecond(2).build());
    cmdTopics.run(split("get-max-producers persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxProducers("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-producers persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxProducers("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-producers persistent://myprop/clust/ns1/ds1 -p 99"));
    verify(mockTopics).setMaxProducers("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-max-consumers persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxConsumers("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-consumers persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxConsumers("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-consumers persistent://myprop/clust/ns1/ds1 -c 99"));
    verify(mockTopics).setMaxConsumers("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-deduplication-snapshot-interval persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getDeduplicationSnapshotInterval("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-deduplication-snapshot-interval persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeDeduplicationSnapshotInterval("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-deduplication-snapshot-interval persistent://myprop/clust/ns1/ds1 -i 99"));
    verify(mockTopics).setDeduplicationSnapshotInterval("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-inactive-topic-policies persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-inactive-topic-policies persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-inactive-topic-policies persistent://myprop/clust/ns1/ds1" + " -e -t 1s -m delete_when_no_subscriptions"));
    verify(mockTopics).setInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1", new InactiveTopicPolicies(InactiveTopicDeleteMode.delete_when_no_subscriptions, 1, true));
    cmdTopics.run(split("get-max-subscriptions persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxSubscriptionsPerTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-subscriptions persistent://myprop/clust/ns1/ds1 -m 100"));
    verify(mockTopics).setMaxSubscriptionsPerTopic("persistent://myprop/clust/ns1/ds1", 100);
    cmdTopics.run(split("remove-max-subscriptions persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxSubscriptionsPerTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-persistence persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getPersistence("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-persistence persistent://myprop/clust/ns1/ds1 -e 2 -w 1 -a 1 -r 100.0"));
    verify(mockTopics).setPersistence("persistent://myprop/clust/ns1/ds1", new PersistencePolicies(2, 1, 1, 100.0d));
    cmdTopics.run(split("remove-persistence persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removePersistence("persistent://myprop/clust/ns1/ds1");
    // range of +/- 1 second of the expected timestamp
    class TimestampMatcher implements ArgumentMatcher<Long> {

        @Override
        public boolean matches(Long timestamp) {
            long expectedTimestamp = System.currentTimeMillis() - (1 * 60 * 1000);
            if (timestamp < (expectedTimestamp + 1000) && timestamp > (expectedTimestamp - 1000)) {
                return true;
            }
            return false;
        }
    }
    cmdTopics.run(split("reset-cursor persistent://myprop/clust/ns1/ds1 -s sub1 -t 1m"));
    verify(mockTopics).resetCursor(eq("persistent://myprop/clust/ns1/ds1"), eq("sub1"), longThat(new TimestampMatcher()));
    when(mockTopics.terminateTopicAsync("persistent://myprop/clust/ns1/ds1")).thenReturn(CompletableFuture.completedFuture(new MessageIdImpl(1L, 1L, 1)));
    cmdTopics.run(split("terminate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).terminateTopicAsync("persistent://myprop/clust/ns1/ds1");
    Map<Integer, MessageId> results = new HashMap<>();
    results.put(0, new MessageIdImpl(1, 1, 0));
    when(mockTopics.terminatePartitionedTopic("persistent://myprop/clust/ns1/ds1")).thenReturn(results);
    cmdTopics.run(split("partitioned-terminate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).terminatePartitionedTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("compact persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).triggerCompaction("persistent://myprop/clust/ns1/ds1");
    when(mockTopics.compactionStatus("persistent://myprop/clust/ns1/ds1")).thenReturn(new LongRunningProcessStatus());
    cmdTopics.run(split("compaction-status persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).compactionStatus("persistent://myprop/clust/ns1/ds1");
    PersistentTopicInternalStats stats = new PersistentTopicInternalStats();
    stats.ledgers = new ArrayList<>();
    stats.ledgers.add(newLedger(0, 10, 1000));
    stats.ledgers.add(newLedger(1, 10, 2000));
    stats.ledgers.add(newLedger(2, 10, 3000));
    when(mockTopics.getInternalStats("persistent://myprop/clust/ns1/ds1", false)).thenReturn(stats);
    cmdTopics.run(split("offload persistent://myprop/clust/ns1/ds1 -s 1k"));
    verify(mockTopics).triggerOffload("persistent://myprop/clust/ns1/ds1", new MessageIdImpl(2, 0, -1));
    when(mockTopics.offloadStatus("persistent://myprop/clust/ns1/ds1")).thenReturn(new OffloadProcessStatusImpl());
    cmdTopics.run(split("offload-status persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).offloadStatus("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("last-message-id persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getLastMessageId(eq("persistent://myprop/clust/ns1/ds1"));
    cmdTopics.run(split("get-message-ttl persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMessageTTL("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-message-ttl persistent://myprop/clust/ns1/ds1 -t 10"));
    verify(mockTopics).setMessageTTL("persistent://myprop/clust/ns1/ds1", 10);
    cmdTopics.run(split("remove-message-ttl persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMessageTTL("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-replicated-subscription-status persistent://myprop/clust/ns1/ds1 -s sub1 -d"));
    verify(mockTopics).setReplicatedSubscriptionStatus("persistent://myprop/clust/ns1/ds1", "sub1", false);
    cmdTopics.run(split("get-replicated-subscription-status persistent://myprop/clust/ns1/ds1 -s sub1"));
    verify(mockTopics).getReplicatedSubscriptionStatus("persistent://myprop/clust/ns1/ds1", "sub1");
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("get-max-unacked-messages-on-subscription persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("reset-cursor persistent://myprop/clust/ns1/ds2 -s sub1 -m 1:1 -e"));
    verify(mockTopics).resetCursor(eq("persistent://myprop/clust/ns1/ds2"), eq("sub1"), eq(new MessageIdImpl(1, 1, -1)), eq(true));
    cmdTopics.run(split("get-maxProducers persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getMaxProducers("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("set-maxProducers persistent://myprop/clust/ns1/ds1 -p 3"));
    verify(mockTopics).setMaxProducers("persistent://myprop/clust/ns1/ds1", 3);
    cmdTopics.run(split("remove-maxProducers persistent://myprop/clust/ns1/ds2"));
    verify(mockTopics).removeMaxProducers("persistent://myprop/clust/ns1/ds2");
    cmdTopics.run(split("set-message-ttl persistent://myprop/clust/ns1/ds1 -t 30m"));
    verify(mockTopics).setMessageTTL("persistent://myprop/clust/ns1/ds1", 30 * 60);
    cmdTopics.run(split("get-message-ttl persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getMessageTTL("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("get-offload-policies persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getOffloadPolicies("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("get-max-unacked-messages-on-consumer persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("get-inactive-topic-policies persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("get-delayed-delivery persistent://myprop/clust/ns1/ds1 --applied"));
    verify(mockTopics).getDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("get-max-consumers persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getMaxConsumers("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("get-replication-clusters persistent://myprop/clust/ns1/ds1 --applied"));
    verify(mockTopics).getReplicationClusters("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("set-replication-clusters persistent://myprop/clust/ns1/ds1 -c test"));
    verify(mockTopics).setReplicationClusters("persistent://myprop/clust/ns1/ds1", Lists.newArrayList("test"));
    cmdTopics.run(split("remove-replication-clusters persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeReplicationClusters("persistent://myprop/clust/ns1/ds1");
}
Also used : PersistencePolicies(org.apache.pulsar.common.policies.data.PersistencePolicies) HashMap(java.util.HashMap) OffloadProcessStatusImpl(org.apache.pulsar.client.admin.internal.OffloadProcessStatusImpl) ArgumentMatcher(org.mockito.ArgumentMatcher) PersistentTopicInternalStats(org.apache.pulsar.common.policies.data.PersistentTopicInternalStats) Lookup(org.apache.pulsar.client.admin.Lookup) NonPersistentTopics(org.apache.pulsar.client.admin.NonPersistentTopics) Topics(org.apache.pulsar.client.admin.Topics) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) LongRunningProcessStatus(org.apache.pulsar.client.admin.LongRunningProcessStatus) MessageIdImpl(org.apache.pulsar.client.impl.MessageIdImpl) PublishRate(org.apache.pulsar.common.policies.data.PublishRate) Schemas(org.apache.pulsar.client.admin.Schemas) OffloadPoliciesImpl(org.apache.pulsar.common.policies.data.OffloadPoliciesImpl) SubscribeRate(org.apache.pulsar.common.policies.data.SubscribeRate) InactiveTopicPolicies(org.apache.pulsar.common.policies.data.InactiveTopicPolicies) MessageImpl(org.apache.pulsar.client.impl.MessageImpl) MessageId(org.apache.pulsar.client.api.MessageId) Test(org.testng.annotations.Test)

Example 17 with Schemas

use of org.apache.pulsar.client.admin.Schemas in project pulsar by apache.

the class PulsarAdminToolTest method schemas.

@Test
void schemas() throws Exception {
    PulsarAdmin admin = Mockito.mock(PulsarAdmin.class);
    Schemas schemas = Mockito.mock(Schemas.class);
    doReturn(schemas).when(admin).schemas();
    CmdSchemas cmdSchemas = new CmdSchemas(() -> admin);
    cmdSchemas.run(split("get -v 1 persistent://tn1/ns1/tp1"));
    verify(schemas).getSchemaInfo("persistent://tn1/ns1/tp1", 1);
    cmdSchemas = new CmdSchemas(() -> admin);
    cmdSchemas.run(split("get -a persistent://tn1/ns1/tp1"));
    verify(schemas).getAllSchemas("persistent://tn1/ns1/tp1");
    cmdSchemas = new CmdSchemas(() -> admin);
    cmdSchemas.run(split("get persistent://tn1/ns1/tp1"));
    verify(schemas).getSchemaInfoWithVersion("persistent://tn1/ns1/tp1");
    cmdSchemas = new CmdSchemas(() -> admin);
    cmdSchemas.run(split("delete persistent://tn1/ns1/tp1"));
    verify(schemas).deleteSchema("persistent://tn1/ns1/tp1");
    cmdSchemas = new CmdSchemas(() -> admin);
    String schemaFile = PulsarAdminToolTest.class.getClassLoader().getResource("test_schema_create.json").getFile();
    cmdSchemas.run(split("upload -f " + schemaFile + " persistent://tn1/ns1/tp1"));
    PostSchemaPayload input = new ObjectMapper().readValue(new File(schemaFile), PostSchemaPayload.class);
    verify(schemas).createSchema("persistent://tn1/ns1/tp1", input);
    cmdSchemas = new CmdSchemas(() -> admin);
    String jarFile = PulsarAdminToolTest.class.getClassLoader().getResource("dummyexamples.jar").getFile();
    String className = SchemaDemo.class.getName();
    cmdSchemas.run(split("extract -j " + jarFile + " -c " + className + " -t json persistent://tn1/ns1/tp1"));
    File file = new File(jarFile);
    ClassLoader cl = new URLClassLoader(new URL[] { file.toURI().toURL() });
    Class cls = cl.loadClass(className);
    SchemaDefinition<Object> schemaDefinition = SchemaDefinition.builder().withPojo(cls).withAlwaysAllowNull(true).build();
    PostSchemaPayload postSchemaPayload = new PostSchemaPayload();
    postSchemaPayload.setType("JSON");
    postSchemaPayload.setSchema(SchemaExtractor.getJsonSchemaInfo(schemaDefinition));
    postSchemaPayload.setProperties(schemaDefinition.getProperties());
    verify(schemas).createSchema("persistent://tn1/ns1/tp1", postSchemaPayload);
}
Also used : PostSchemaPayload(org.apache.pulsar.common.protocol.schema.PostSchemaPayload) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) Schemas(org.apache.pulsar.client.admin.Schemas) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.testng.annotations.Test)

Example 18 with Schemas

use of org.apache.pulsar.client.admin.Schemas in project pulsar by apache.

the class PulsarAdminToolTest method topicPolicies.

@Test
public void topicPolicies() throws Exception {
    PulsarAdmin admin = Mockito.mock(PulsarAdmin.class);
    TopicPolicies mockTopicsPolicies = mock(TopicPolicies.class);
    TopicPolicies mockGlobalTopicsPolicies = mock(TopicPolicies.class);
    when(admin.topicPolicies()).thenReturn(mockTopicsPolicies);
    when(admin.topicPolicies(false)).thenReturn(mockTopicsPolicies);
    when(admin.topicPolicies(true)).thenReturn(mockGlobalTopicsPolicies);
    Schemas mockSchemas = mock(Schemas.class);
    when(admin.schemas()).thenReturn(mockSchemas);
    Lookup mockLookup = mock(Lookup.class);
    when(admin.lookups()).thenReturn(mockLookup);
    CmdTopicPolicies cmdTopics = new CmdTopicPolicies(() -> admin);
    cmdTopics.run(split("set-subscription-types-enabled persistent://myprop/clust/ns1/ds1 -t Shared,Failover"));
    verify(mockTopicsPolicies).setSubscriptionTypesEnabled("persistent://myprop/clust/ns1/ds1", Sets.newHashSet(SubscriptionType.Shared, SubscriptionType.Failover));
    cmdTopics.run(split("get-subscription-types-enabled persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getSubscriptionTypesEnabled("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-subscription-types-enabled persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeSubscriptionTypesEnabled("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-offload-policies persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getOffloadPolicies("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-offload-policies persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeOffloadPolicies("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-offload-policies persistent://myprop/clust/ns1/ds1 -d s3 -r" + " region -b bucket -e endpoint -m 8 -rb 9 -t 10 -orp tiered-storage-first"));
    verify(mockTopicsPolicies).setOffloadPolicies("persistent://myprop/clust/ns1/ds1", OffloadPoliciesImpl.create("s3", "region", "bucket", "endpoint", null, null, null, null, 8, 9, 10L, null, OffloadedReadPriority.TIERED_STORAGE_FIRST));
    cmdTopics.run(split("get-retention persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getRetention("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-retention persistent://myprop/clust/ns1/ds1 -t 10m -s 20M"));
    verify(mockTopicsPolicies).setRetention("persistent://myprop/clust/ns1/ds1", new RetentionPolicies(10, 20));
    cmdTopics.run(split("remove-retention persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeRetention("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-inactive-topic-policies persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-inactive-topic-policies persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-inactive-topic-policies persistent://myprop/clust/ns1/ds1" + " -e -t 1s -m delete_when_no_subscriptions"));
    verify(mockTopicsPolicies).setInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1", new InactiveTopicPolicies(InactiveTopicDeleteMode.delete_when_no_subscriptions, 1, true));
    cmdTopics.run(split("get-compaction-threshold persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getCompactionThreshold("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-compaction-threshold persistent://myprop/clust/ns1/ds1 -t 10k"));
    verify(mockTopicsPolicies).setCompactionThreshold("persistent://myprop/clust/ns1/ds1", 10 * 1024);
    cmdTopics.run(split("remove-compaction-threshold persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeCompactionThreshold("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-producers persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getMaxProducers("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-producers persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeMaxProducers("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-producers persistent://myprop/clust/ns1/ds1 -p 99"));
    verify(mockTopicsPolicies).setMaxProducers("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-dispatch-rate persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopicsPolicies).getDispatchRate("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("remove-dispatch-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeDispatchRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-dispatch-rate persistent://myprop/clust/ns1/ds1 -md -1 -bd -1 -dt 2"));
    verify(mockTopicsPolicies).setDispatchRate("persistent://myprop/clust/ns1/ds1", DispatchRate.builder().dispatchThrottlingRateInMsg(-1).dispatchThrottlingRateInByte(-1).ratePeriodInSecond(2).build());
    cmdTopics.run(split("set-replicator-dispatch-rate persistent://myprop/clust/ns1/ds1 -md -1 -bd -1 -dt 2"));
    verify(mockTopicsPolicies).setReplicatorDispatchRate("persistent://myprop/clust/ns1/ds1", DispatchRate.builder().dispatchThrottlingRateInMsg(-1).dispatchThrottlingRateInByte(-1).ratePeriodInSecond(2).build());
    cmdTopics.run(split("get-replicator-dispatch-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getReplicatorDispatchRate("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-replicator-dispatch-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeReplicatorDispatchRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-subscription-dispatch-rate persistent://myprop/clust/ns1/ds1 -md -1 -bd -1 -dt 2"));
    verify(mockTopicsPolicies).setSubscriptionDispatchRate("persistent://myprop/clust/ns1/ds1", DispatchRate.builder().dispatchThrottlingRateInMsg(-1).dispatchThrottlingRateInByte(-1).ratePeriodInSecond(2).build());
    cmdTopics.run(split("get-subscription-dispatch-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getSubscriptionDispatchRate("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-subscription-dispatch-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeSubscriptionDispatchRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-persistence persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getPersistence("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-persistence persistent://myprop/clust/ns1/ds1 -e 2 -w 1 -a 1 -r 100.0"));
    verify(mockTopicsPolicies).setPersistence("persistent://myprop/clust/ns1/ds1", new PersistencePolicies(2, 1, 1, 100.0d));
    cmdTopics.run(split("remove-persistence persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removePersistence("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-publish-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getPublishRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-publish-rate persistent://myprop/clust/ns1/ds1 -m 10 -b 100"));
    verify(mockTopicsPolicies).setPublishRate("persistent://myprop/clust/ns1/ds1", new PublishRate(10, 100));
    cmdTopics.run(split("remove-publish-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removePublishRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-subscribe-rate persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopicsPolicies).getSubscribeRate("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("set-subscribe-rate persistent://myprop/clust/ns1/ds1 -sr 10 -st 100"));
    verify(mockTopicsPolicies).setSubscribeRate("persistent://myprop/clust/ns1/ds1", new SubscribeRate(10, 100));
    cmdTopics.run(split("remove-subscribe-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeSubscribeRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-message-size persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getMaxMessageSize("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-message-size persistent://myprop/clust/ns1/ds1 -m 1000"));
    verify(mockTopicsPolicies).setMaxMessageSize("persistent://myprop/clust/ns1/ds1", 1000);
    cmdTopics.run(split("remove-max-message-size persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeMaxMessageSize("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-consumers persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getMaxConsumers("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-consumers persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeMaxConsumers("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-consumers persistent://myprop/clust/ns1/ds1 -c 99"));
    verify(mockTopicsPolicies).setMaxConsumers("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("remove-max-unacked-messages-per-consumer persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies, times(1)).removeMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-unacked-messages-per-consumer persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies, times(1)).getMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-max-unacked-messages-per-consumer persistent://myprop/clust/ns1/ds1 -m 999"));
    verify(mockTopicsPolicies, times(1)).setMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", 999);
    cmdTopics.run(split("get-message-ttl persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getMessageTTL("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-message-ttl persistent://myprop/clust/ns1/ds1 -t 10"));
    verify(mockTopicsPolicies).setMessageTTL("persistent://myprop/clust/ns1/ds1", 10);
    cmdTopics.run(split("remove-message-ttl persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeMessageTTL("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-consumers-per-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getMaxConsumersPerSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-consumers-per-subscription persistent://myprop/clust/ns1/ds1 -c 5"));
    verify(mockTopicsPolicies).setMaxConsumersPerSubscription("persistent://myprop/clust/ns1/ds1", 5);
    cmdTopics.run(split("remove-max-consumers-per-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeMaxConsumersPerSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-unacked-messages-per-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies, times(1)).getMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-unacked-messages-per-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies, times(1)).removeMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-unacked-messages-per-subscription persistent://myprop/clust/ns1/ds1 -m 99"));
    verify(mockTopicsPolicies, times(1)).setMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-delayed-delivery persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-delayed-delivery persistent://myprop/clust/ns1/ds1 -t 10s --enable"));
    verify(mockTopicsPolicies).setDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1", DelayedDeliveryPolicies.builder().tickTime(10000).active(true).build());
    cmdTopics.run(split("remove-delayed-delivery persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-deduplication persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getDeduplicationStatus("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-deduplication persistent://myprop/clust/ns1/ds1 --disable"));
    verify(mockTopicsPolicies).setDeduplicationStatus("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-deduplication persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeDeduplicationStatus("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-subscriptions-per-topic persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getMaxSubscriptionsPerTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-subscriptions-per-topic persistent://myprop/clust/ns1/ds1 -s 1024"));
    verify(mockTopicsPolicies).setMaxSubscriptionsPerTopic("persistent://myprop/clust/ns1/ds1", 1024);
    cmdTopics.run(split("remove-max-subscriptions-per-topic persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeMaxSubscriptionsPerTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-deduplication-snapshot-interval persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).getDeduplicationSnapshotInterval("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-deduplication-snapshot-interval persistent://myprop/clust/ns1/ds1 -i 100"));
    verify(mockTopicsPolicies).setDeduplicationSnapshotInterval("persistent://myprop/clust/ns1/ds1", 100);
    cmdTopics.run(split("remove-deduplication-snapshot-interval persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeDeduplicationSnapshotInterval("persistent://myprop/clust/ns1/ds1");
    // Reset the cmd, and check global option
    cmdTopics = new CmdTopicPolicies(() -> admin);
    cmdTopics.run(split("get-retention persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getRetention("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-retention persistent://myprop/clust/ns1/ds1 -t 10m -s 20M -g"));
    verify(mockGlobalTopicsPolicies).setRetention("persistent://myprop/clust/ns1/ds1", new RetentionPolicies(10, 20));
    cmdTopics.run(split("remove-retention persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeRetention("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-backlog-quota persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopicsPolicies).getBacklogQuotaMap("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("set-backlog-quota persistent://myprop/clust/ns1/ds1 -l 10 -p producer_request_hold"));
    verify(mockTopicsPolicies).setBacklogQuota("persistent://myprop/clust/ns1/ds1", BacklogQuota.builder().limitSize(10).retentionPolicy(RetentionPolicy.producer_request_hold).build(), BacklogQuota.BacklogQuotaType.destination_storage);
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopicPolicies(() -> admin);
    cmdTopics.run(split("set-backlog-quota persistent://myprop/clust/ns1/ds1 -lt 1000 -p producer_request_hold -t message_age"));
    verify(mockTopicsPolicies).setBacklogQuota("persistent://myprop/clust/ns1/ds1", BacklogQuota.builder().limitSize(-1).limitTime(1000).retentionPolicy(RetentionPolicy.producer_request_hold).build(), BacklogQuota.BacklogQuotaType.message_age);
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopicPolicies(() -> admin);
    cmdTopics.run(split("remove-backlog-quota persistent://myprop/clust/ns1/ds1"));
    verify(mockTopicsPolicies).removeBacklogQuota("persistent://myprop/clust/ns1/ds1", BacklogQuota.BacklogQuotaType.destination_storage);
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopicPolicies(() -> admin);
    cmdTopics.run(split("remove-backlog-quota persistent://myprop/clust/ns1/ds1 -t message_age"));
    verify(mockTopicsPolicies).removeBacklogQuota("persistent://myprop/clust/ns1/ds1", BacklogQuota.BacklogQuotaType.message_age);
    cmdTopics.run(split("get-max-producers persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getMaxProducers("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-producers persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeMaxProducers("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-producers persistent://myprop/clust/ns1/ds1 -p 99 -g"));
    verify(mockGlobalTopicsPolicies).setMaxProducers("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("remove-max-unacked-messages-per-consumer persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies, times(1)).removeMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-unacked-messages-per-consumer persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies, times(1)).getMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-max-unacked-messages-per-consumer persistent://myprop/clust/ns1/ds1 -m 999 -g"));
    verify(mockGlobalTopicsPolicies, times(1)).setMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", 999);
    cmdTopics.run(split("get-message-ttl persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getMessageTTL("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-message-ttl persistent://myprop/clust/ns1/ds1 -t 10 -g"));
    verify(mockGlobalTopicsPolicies).setMessageTTL("persistent://myprop/clust/ns1/ds1", 10);
    cmdTopics.run(split("remove-message-ttl persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeMessageTTL("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-persistence persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getPersistence("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-persistence persistent://myprop/clust/ns1/ds1 -e 2 -w 1 -a 1 -r 100.0 -g"));
    verify(mockGlobalTopicsPolicies).setPersistence("persistent://myprop/clust/ns1/ds1", new PersistencePolicies(2, 1, 1, 100.0d));
    cmdTopics.run(split("remove-persistence persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removePersistence("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-unacked-messages-per-subscription persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies, times(1)).getMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-unacked-messages-per-subscription persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies, times(1)).removeMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-unacked-messages-per-subscription persistent://myprop/clust/ns1/ds1 -m 99 -g"));
    verify(mockGlobalTopicsPolicies, times(1)).setMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-inactive-topic-policies persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-inactive-topic-policies persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-inactive-topic-policies persistent://myprop/clust/ns1/ds1" + " -e -t 1s -m delete_when_no_subscriptions -g"));
    verify(mockGlobalTopicsPolicies).setInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1", new InactiveTopicPolicies(InactiveTopicDeleteMode.delete_when_no_subscriptions, 1, true));
    cmdTopics.run(split("get-dispatch-rate persistent://myprop/clust/ns1/ds1 -ap -g"));
    verify(mockGlobalTopicsPolicies).getDispatchRate("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("remove-dispatch-rate persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeDispatchRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-dispatch-rate persistent://myprop/clust/ns1/ds1 -md -1 -bd -1 -dt 2 -g"));
    verify(mockGlobalTopicsPolicies).setDispatchRate("persistent://myprop/clust/ns1/ds1", DispatchRate.builder().dispatchThrottlingRateInMsg(-1).dispatchThrottlingRateInByte(-1).ratePeriodInSecond(2).build());
    cmdTopics.run(split("get-publish-rate persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getPublishRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-publish-rate persistent://myprop/clust/ns1/ds1 -m 10 -b 100 -g"));
    verify(mockGlobalTopicsPolicies).setPublishRate("persistent://myprop/clust/ns1/ds1", new PublishRate(10, 100));
    cmdTopics.run(split("remove-publish-rate persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removePublishRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-subscribe-rate persistent://myprop/clust/ns1/ds1 -ap -g"));
    verify(mockGlobalTopicsPolicies).getSubscribeRate("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("set-subscribe-rate persistent://myprop/clust/ns1/ds1 -sr 10 -st 100 -g"));
    verify(mockGlobalTopicsPolicies).setSubscribeRate("persistent://myprop/clust/ns1/ds1", new SubscribeRate(10, 100));
    cmdTopics.run(split("remove-subscribe-rate persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeSubscribeRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-delayed-delivery persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-delayed-delivery persistent://myprop/clust/ns1/ds1 -t 10s --enable -g"));
    verify(mockGlobalTopicsPolicies).setDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1", DelayedDeliveryPolicies.builder().tickTime(10000).active(true).build());
    cmdTopics.run(split("remove-delayed-delivery persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-message-size persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getMaxMessageSize("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-message-size persistent://myprop/clust/ns1/ds1 -m 1000 -g"));
    verify(mockGlobalTopicsPolicies).setMaxMessageSize("persistent://myprop/clust/ns1/ds1", 1000);
    cmdTopics.run(split("remove-max-message-size persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeMaxMessageSize("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-deduplication persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getDeduplicationStatus("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-deduplication persistent://myprop/clust/ns1/ds1 --disable -g"));
    verify(mockGlobalTopicsPolicies).setDeduplicationStatus("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-deduplication persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeDeduplicationStatus("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-deduplication-snapshot-interval persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getDeduplicationSnapshotInterval("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-deduplication-snapshot-interval persistent://myprop/clust/ns1/ds1 -i 100 -g"));
    verify(mockGlobalTopicsPolicies).setDeduplicationSnapshotInterval("persistent://myprop/clust/ns1/ds1", 100);
    cmdTopics.run(split("remove-deduplication-snapshot-interval persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeDeduplicationSnapshotInterval("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-consumers-per-subscription persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getMaxConsumersPerSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-consumers-per-subscription persistent://myprop/clust/ns1/ds1 -c 5 -g"));
    verify(mockGlobalTopicsPolicies).setMaxConsumersPerSubscription("persistent://myprop/clust/ns1/ds1", 5);
    cmdTopics.run(split("remove-max-consumers-per-subscription persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeMaxConsumersPerSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-subscription-types-enabled persistent://myprop/clust/ns1/ds1 -t Shared,Failover -g"));
    verify(mockGlobalTopicsPolicies).setSubscriptionTypesEnabled("persistent://myprop/clust/ns1/ds1", Sets.newHashSet(SubscriptionType.Shared, SubscriptionType.Failover));
    cmdTopics.run(split("get-subscription-types-enabled persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getSubscriptionTypesEnabled("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-subscription-types-enabled persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeSubscriptionTypesEnabled("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-consumers persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getMaxConsumers("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-consumers persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeMaxConsumers("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-consumers persistent://myprop/clust/ns1/ds1 -c 99 -g"));
    verify(mockGlobalTopicsPolicies).setMaxConsumers("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-compaction-threshold persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getCompactionThreshold("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-compaction-threshold persistent://myprop/clust/ns1/ds1 -t 10k -g"));
    verify(mockGlobalTopicsPolicies).setCompactionThreshold("persistent://myprop/clust/ns1/ds1", 10 * 1024);
    cmdTopics.run(split("remove-compaction-threshold persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeCompactionThreshold("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-replicator-dispatch-rate persistent://myprop/clust/ns1/ds1 -md -1 -bd -1 -dt 2 -g"));
    verify(mockGlobalTopicsPolicies).setReplicatorDispatchRate("persistent://myprop/clust/ns1/ds1", DispatchRate.builder().dispatchThrottlingRateInMsg(-1).dispatchThrottlingRateInByte(-1).ratePeriodInSecond(2).build());
    cmdTopics.run(split("get-replicator-dispatch-rate persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getReplicatorDispatchRate("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-replicator-dispatch-rate persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeReplicatorDispatchRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-subscription-dispatch-rate persistent://myprop/clust/ns1/ds1 -md -1 -bd -1 -dt 2 -g"));
    verify(mockGlobalTopicsPolicies).setSubscriptionDispatchRate("persistent://myprop/clust/ns1/ds1", DispatchRate.builder().dispatchThrottlingRateInMsg(-1).dispatchThrottlingRateInByte(-1).ratePeriodInSecond(2).build());
    cmdTopics.run(split("get-subscription-dispatch-rate persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getSubscriptionDispatchRate("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-subscription-dispatch-rate persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeSubscriptionDispatchRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-subscriptions-per-topic persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getMaxSubscriptionsPerTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-subscriptions-per-topic persistent://myprop/clust/ns1/ds1 -s 1024 -g"));
    verify(mockGlobalTopicsPolicies).setMaxSubscriptionsPerTopic("persistent://myprop/clust/ns1/ds1", 1024);
    cmdTopics.run(split("remove-max-subscriptions-per-topic persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeMaxSubscriptionsPerTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-offload-policies persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).getOffloadPolicies("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-offload-policies persistent://myprop/clust/ns1/ds1 -g"));
    verify(mockGlobalTopicsPolicies).removeOffloadPolicies("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-offload-policies persistent://myprop/clust/ns1/ds1 -d s3 -r" + " region -b bucket -e endpoint -m 8 -rb 9 -t 10 -orp tiered-storage-first -g"));
    verify(mockGlobalTopicsPolicies).setOffloadPolicies("persistent://myprop/clust/ns1/ds1", OffloadPoliciesImpl.create("s3", "region", "bucket", "endpoint", null, null, null, null, 8, 9, 10L, null, OffloadedReadPriority.TIERED_STORAGE_FIRST));
}
Also used : RetentionPolicies(org.apache.pulsar.common.policies.data.RetentionPolicies) InactiveTopicPolicies(org.apache.pulsar.common.policies.data.InactiveTopicPolicies) TopicPolicies(org.apache.pulsar.client.admin.TopicPolicies) PersistencePolicies(org.apache.pulsar.common.policies.data.PersistencePolicies) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) SubscribeRate(org.apache.pulsar.common.policies.data.SubscribeRate) Lookup(org.apache.pulsar.client.admin.Lookup) InactiveTopicPolicies(org.apache.pulsar.common.policies.data.InactiveTopicPolicies) PublishRate(org.apache.pulsar.common.policies.data.PublishRate) Schemas(org.apache.pulsar.client.admin.Schemas) Test(org.testng.annotations.Test)

Aggregations

PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)18 Schemas (org.apache.pulsar.client.admin.Schemas)18 Test (org.testng.annotations.Test)12 Lookup (org.apache.pulsar.client.admin.Lookup)9 Topics (org.apache.pulsar.client.admin.Topics)9 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 ManagedLedgerConfig (org.apache.bookkeeper.mledger.ManagedLedgerConfig)6 BeforeMethod (org.testng.annotations.BeforeMethod)6 SchemaInfo (org.apache.pulsar.common.schema.SchemaInfo)5 InactiveTopicPolicies (org.apache.pulsar.common.policies.data.InactiveTopicPolicies)4 PersistencePolicies (org.apache.pulsar.common.policies.data.PersistencePolicies)4 PublishRate (org.apache.pulsar.common.policies.data.PublishRate)4 SubscribeRate (org.apache.pulsar.common.policies.data.SubscribeRate)4 ByteBuf (io.netty.buffer.ByteBuf)3 Field (java.lang.reflect.Field)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 Method (java.lang.reflect.Method)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3