From 80652d61c0171987e26727e11f646bcb18ddd7ec Mon Sep 17 00:00:00 2001 From: Steven Sheehy <17552371+steven-sheehy@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:49:02 -0600 Subject: [PATCH] Retry incomplete address book during acceptance tests (0.117) (#9750) Retry incomplete address book during acceptance tests (#9744) Signed-off-by: Steven Sheehy --- .../e2e/acceptance/client/MirrorNodeClient.java | 1 + .../test/e2e/acceptance/client/SDKClient.java | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/MirrorNodeClient.java b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/MirrorNodeClient.java index 7236acb587f..1e536a59604 100644 --- a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/MirrorNodeClient.java +++ b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/MirrorNodeClient.java @@ -125,6 +125,7 @@ public SubscriptionResponse subscribeToTopic(SDKClient sdkClient, TopicMessageQu // allow time for connection to be made and error to be caught await("responseEncountered") .atMost(Durations.ONE_MINUTE) + .pollInterval(Durations.ONE_SECOND) .pollDelay(Durations.ONE_HUNDRED_MILLISECONDS) .until(() -> subscriptionResponse.hasResponse()); diff --git a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/SDKClient.java b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/SDKClient.java index 1bcdda3cdd6..b8db14277c4 100644 --- a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/SDKClient.java +++ b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/SDKClient.java @@ -17,6 +17,7 @@ package com.hedera.mirror.test.e2e.acceptance.client; import static com.hedera.mirror.test.e2e.acceptance.config.AcceptanceTestProperties.HederaNetwork.OTHER; +import static org.awaitility.Awaitility.await; import com.google.common.base.Stopwatch; import com.hedera.hashgraph.sdk.AccountBalanceQuery; @@ -49,6 +50,8 @@ import lombok.CustomLog; import lombok.Getter; import lombok.Value; +import org.apache.commons.lang3.StringUtils; +import org.awaitility.Durations; import org.springframework.util.CollectionUtils; @CustomLog @@ -56,6 +59,7 @@ @Value public class SDKClient implements Cleanable { + private static final String RESET_IP = "1.0.0.0"; private static final SecureRandom RANDOM = new SecureRandom(); private final Client client; @@ -152,7 +156,13 @@ private Client createClient() throws InterruptedException { if (acceptanceTestProperties.isRetrieveAddressBook()) { try { - return toClient(getAddressBook()); + log.info("Waiting for a valid address book"); + var addressBook = await("retrieveAddressBook") + .atMost(acceptanceTestProperties.getStartupTimeout()) + .pollDelay(Duration.ofMillis(100)) + .pollInterval(Durations.FIVE_SECONDS) + .until(this::getAddressBook, ab -> !ab.isEmpty()); + return toClient(addressBook); } catch (Exception e) { log.warn("Error retrieving address book", e); } @@ -283,7 +293,7 @@ private Map getAddressBook() { for (var serviceEndpoint : node.getServiceEndpoints()) { var ip = serviceEndpoint.getIpAddressV4(); var port = serviceEndpoint.getPort(); - if (port == 50211) { + if (port == 50211 && StringUtils.isNotBlank(ip) && !RESET_IP.equals(ip)) { networkMap.putIfAbsent(ip + ":" + port, accountId); } }