Skip to content

Commit

Permalink
Generate a run annotation when test environment fails to start
Browse files Browse the repository at this point in the history
When product tests fail, they produce an report, which is used to
generate GitHub Actions annotations so it's easier to know the failure
cause, without having to browse the failed job logs. Generate a similar
annotation when the test environment fails to start, which is a common
failure cause.

The original error is still produced, so it can be looked up in logs,
for anyone that's used to doing it.
  • Loading branch information
nineinchnick authored and wendigo committed Sep 20, 2024
1 parent 6c25ebf commit 093e458
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import static io.trino.tests.product.launcher.env.Environments.pruneEnvironment;
import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_TRINO_ETC;
import static java.lang.String.format;
import static java.lang.System.getenv;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.time.Duration.ofMinutes;
import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -126,7 +127,12 @@ public Environment start()
.onFailedAttempt(event -> log.warn(event.getLastException(), "Could not start environment '%s'", this))
.onRetry(event -> log.info("Trying to start environment '%s', %d failed attempt(s)", this, event.getAttemptCount() + 1))
.onSuccess(event -> log.info("Environment '%s' started in %s, %d attempt(s)", this, event.getElapsedTime(), event.getAttemptCount()))
.onFailure(event -> log.info("Environment '%s' failed to start in attempt(s): %d: %s", this, event.getAttemptCount(), event.getException()))
.onFailure(event -> {
if (getenv("GITHUB_RUN_ID") != null) {
log.info("::error title=Failed to start environment '%s'::%s", this, event.getException());
}
log.info("Environment '%s' failed to start in attempt(s): %d: %s", this, event.getAttemptCount(), event.getException());
})
.build();

return Failsafe
Expand Down

0 comments on commit 093e458

Please sign in to comment.