Copilot commented on code in PR #11607:
URL: https://github.com/apache/gravitino/pull/11607#discussion_r3395654235
##########
clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/TopicAuthorizationIT.java:
##########
@@ -151,24 +151,31 @@ public void testCreateTopic() {
@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"),
Review Comment:
`TopicCatalog.listTopics()` ultimately comes from Kafka
`AdminClient#listTopics().names()` which returns a `Set`, so the returned
`NameIdentifier[]` order is not deterministic. Using `assertArrayEquals` makes
this assertion order-sensitive and can still be flaky/time out even after
adding Awaitility. Sort the result (or compare as a set / use an
order-insensitive assertion) before asserting equality.
##########
clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/TopicAuthorizationIT.java:
##########
@@ -151,24 +151,31 @@ public void testCreateTopic() {
@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")
+ },
Review Comment:
Same ordering issue as above: the normal-user `listTopics()` result may be
returned in arbitrary order, so `assertArrayEquals` is order-sensitive. Sort
the array (or use an order-insensitive assertion) before comparing to avoid
reintroducing flakiness.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]