Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Test timeouts for Windows #32387

Merged
merged 1 commit into from
Apr 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.awaitility.Awaitility;
import org.awaitility.core.ConditionTimeoutException;

Expand Down Expand Up @@ -42,36 +39,33 @@ public ContinuousTestingMavenTestUtils(URL url) {
}

public TestStatus waitForNextCompletion() {
try (CloseableHttpClient client = HttpClientBuilder.create().build()) {
Awaitility.waitAtMost(1, TimeUnit.MINUTES).pollInterval(50, TimeUnit.MILLISECONDS).until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
TestStatus ts = objectMapper.readValue(url, TestStatus.class);
if (ts.getLastRun() > runtToWaitFor) {
throw new RuntimeException(
"Waiting for run " + runtToWaitFor + " but run " + ts.getLastRun() + " has already occurred");
}
boolean runComplete = ts.getLastRun() == runtToWaitFor;
if (runComplete && ts.getRunning() > 0) {
//there is a small chance of a race, where changes are picked up twice, due to how filesystems work
//this works around it by waiting for the next run
runtToWaitFor = ts.getRunning();
return false;
} else if (runComplete) {
runtToWaitFor++;
}
return runComplete;
try {
Awaitility.waitAtMost(2, TimeUnit.MINUTES).pollInterval(200, TimeUnit.MILLISECONDS).until(() -> {
TestStatus ts = objectMapper.readValue(url, TestStatus.class);
if (ts.getLastRun() > runtToWaitFor) {
throw new RuntimeException(
"Waiting for run " + runtToWaitFor + " but run " + ts.getLastRun() + " has already occurred");
}
boolean runComplete = ts.getLastRun() == runtToWaitFor;
if (runComplete && ts.getRunning() > 0) {
//there is a small chance of a race, where changes are picked up twice, due to how filesystems work
//this works around it by waiting for the next run
runtToWaitFor = ts.getRunning();
return false;
} else if (runComplete) {
runtToWaitFor++;
}
return runComplete;
});
return objectMapper.readValue(url, TestStatus.class);
} catch (Exception e) {
TestStatus ts = null;
TestStatus ts;
try {
ts = objectMapper.readValue(url, TestStatus.class);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
throw new ConditionTimeoutException("Failed to wait for test run" + runtToWaitFor + " " + ts);
throw new ConditionTimeoutException("Failed to wait for test run " + runtToWaitFor + " " + ts, e);
}
}

Expand Down