Skip to content

Commit

Permalink
Fix TopicPoliciesTest
Browse files Browse the repository at this point in the history
  • Loading branch information
BewareMyPower committed Sep 3, 2024
1 parent 0829ec5 commit 614d804
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3041,15 +3041,15 @@ public void testGlobalTopicPolicies() throws Exception {
Awaitility.await().untilAsserted(() -> assertNotNull(
TestUtils.getGlobalTopicPolicies(topicPoliciesService, TopicName.get(topic))));
TopicPolicies topicPolicies = TestUtils.getGlobalTopicPolicies(topicPoliciesService, TopicName.get(topic));
assertNull(TestUtils.getTopicPolicies(topicPoliciesService, (TopicName.get(topic))));
assertNull(TestUtils.getLocalTopicPolicies(topicPoliciesService, TopicName.get(topic)));
assertEquals(topicPolicies.getRetentionPolicies().getRetentionTimeInMinutes(), 1);
assertEquals(topicPolicies.getRetentionPolicies().getRetentionSizeInMB(), 2);

// check global topic policies can be updated correctly.
admin.topicPolicies(true).setRetention(topic, new RetentionPolicies(3, 4));
Awaitility.await().untilAsserted(() -> {
TopicPolicies tempPolicies = TestUtils.getGlobalTopicPolicies(topicPoliciesService, TopicName.get(topic));
assertNull(TestUtils.getTopicPolicies(topicPoliciesService, (TopicName.get(topic))));
assertNull(TestUtils.getLocalTopicPolicies(topicPoliciesService, (TopicName.get(topic))));
assertEquals(tempPolicies.getRetentionPolicies().getRetentionTimeInMinutes(), 3);
assertEquals(tempPolicies.getRetentionPolicies().getRetentionSizeInMB(), 4);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public static TopicPolicies getTopicPolicies(TopicPoliciesService topicPoliciesS
.orElse(null);
}

public static TopicPolicies getLocalTopicPolicies(TopicPoliciesService topicPoliciesService, TopicName topicName)
throws ExecutionException, InterruptedException {
return topicPoliciesService.getTopicPoliciesAsync(topicName, TopicPoliciesService.GetType.LOCAL_ONLY).get()
.orElse(null);
}

public static TopicPolicies getGlobalTopicPolicies(TopicPoliciesService topicPoliciesService, TopicName topicName)
throws ExecutionException, InterruptedException {
return topicPoliciesService.getTopicPoliciesAsync(topicName, TopicPoliciesService.GetType.GLOBAL_ONLY).get()
Expand Down

0 comments on commit 614d804

Please sign in to comment.