This is an automated email from the ASF dual-hosted git repository.
mchades pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new b242db2f01 [#11602] fix(test): Fix flaky TopicAuthorizationIT (#11607)
b242db2f01 is described below
commit b242db2f011e4fa4156675315a3c01707cb81241
Author: Qi Yu <[email protected]>
AuthorDate: Thu Jun 11 21:32:00 2026 +0800
[#11602] fix(test): Fix flaky TopicAuthorizationIT (#11607)
### What changes were proposed in this pull request?
Use Awaitility in `TopicAuthorizationIT.testListTopic()` to wait until
all created Kafka topics are visible to both the owner and the normal
user.
### Why are the changes needed?
Kafka topic metadata may not be immediately visible after topic
creation, causing `testListTopic()` to intermittently return only two of
the three expected topics.
Fix: #11602
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
- `./gradlew :clients:client-java:spotlessApply`
- `./gradlew :clients:client-java:compileTestJava -PskipITs`
The Kafka integration test was not run locally because Docker was
unavailable.
---
.../test/authorization/TopicAuthorizationIT.java | 35 +++++++++++++---------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git
a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/TopicAuthorizationIT.java
b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/TopicAuthorizationIT.java
index 0e1f35bfc6..fb0a90036b 100644
---
a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/TopicAuthorizationIT.java
+++
b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/TopicAuthorizationIT.java
@@ -151,24 +151,31 @@ public class TopicAuthorizationIT extends
BaseRestApiAuthorizationIT {
@Order(2)
public void testListTopic() {
TopicCatalog topicCatalog =
client.loadMetalake(METALAKE).loadCatalog(CATALOG).asTopicCatalog();
- NameIdentifier[] topicsList =
topicCatalog.listTopics(Namespace.of(SCHEMA));
- assertArrayEquals(
- new NameIdentifier[] {
- NameIdentifier.of(SCHEMA, "topic1"),
- NameIdentifier.of(SCHEMA, "topic2"),
- NameIdentifier.of(SCHEMA, "topic3")
- },
- topicsList);
// normal user can only see topics they have privilege for
TopicCatalog topicCatalogNormalUser =
normalUserClient.loadMetalake(METALAKE).loadCatalog(CATALOG).asTopicCatalog();
- NameIdentifier[] topicsListNormalUser =
topicCatalogNormalUser.listTopics(Namespace.of(SCHEMA));
- assertArrayEquals(
- new NameIdentifier[] {
- NameIdentifier.of(SCHEMA, "topic2"), NameIdentifier.of(SCHEMA,
"topic3")
- },
- topicsListNormalUser);
+ Awaitility.await()
+ .atMost(30, TimeUnit.SECONDS)
+ .untilAsserted(
+ () -> {
+ NameIdentifier[] topicsList =
topicCatalog.listTopics(Namespace.of(SCHEMA));
+ assertArrayEquals(
+ new NameIdentifier[] {
+ NameIdentifier.of(SCHEMA, "topic1"),
+ NameIdentifier.of(SCHEMA, "topic2"),
+ NameIdentifier.of(SCHEMA, "topic3")
+ },
+ topicsList);
+
+ NameIdentifier[] topicsListNormalUser =
+ topicCatalogNormalUser.listTopics(Namespace.of(SCHEMA));
+ assertArrayEquals(
+ new NameIdentifier[] {
+ NameIdentifier.of(SCHEMA, "topic2"),
NameIdentifier.of(SCHEMA, "topic3")
+ },
+ topicsListNormalUser);
+ });
}
@Test