Skip to content

Commit

Permalink
Retry incomplete address book during acceptance tests (0.118) (#9749)
Browse files Browse the repository at this point in the history
Retry incomplete address book during acceptance tests (#9744)

Signed-off-by: Steven Sheehy <steven.sheehy@swirldslabs.com>
  • Loading branch information
steven-sheehy authored Nov 12, 2024
1 parent 08bb610 commit d2abb21
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -49,13 +50,16 @@
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
@Named
@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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -283,7 +293,7 @@ private Map<String, AccountId> 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);
}
}
Expand Down

0 comments on commit d2abb21

Please sign in to comment.