Skip to content

Commit

Permalink
Merge pull request #266 from michalvavrik/feature/add-retry-and-faile…
Browse files Browse the repository at this point in the history
…d-cmd-output-logging

Add ext list cmd retry and logging for failed command
  • Loading branch information
rsvoboda authored Jan 26, 2024
2 parents 4fa3e74 + a66eaf4 commit ecfb614
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
6 changes: 2 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,8 @@
<quarkus.version>${quarkus.version}</quarkus.version>
</systemPropertyVariables>
<properties>
<configurationParameters>junit.jupiter.execution.parallel.enabled = true
<!-- Execute top-level classes in sequentially but their methods in parallel -->junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.classes.default = same_thread
</configurationParameters>
<!-- Execute top-level classes in sequentially but their methods in parallel -->
<configurationParameters>junit.jupiter.execution.parallel.enabled = true junit.jupiter.execution.parallel.mode.default = concurrent junit.jupiter.execution.parallel.mode.classes.default = same_thread</configurationParameters>
</properties>
<!-- Configure Display name accordingly -->
<statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
package quarkus.extensions.combinator.maven;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;

import quarkus.extensions.combinator.Configuration;
import quarkus.extensions.combinator.utils.CommandBuilder;

public class MavenGetQuarkusExtensions extends MavenCommand {

private static final Logger LOG = Logger.getLogger(MavenGetQuarkusExtensions.class.getName());
private final List<String> extensions = new ArrayList<>();

public List<String> getExtensions() {
extensions.clear();
String quarkusMavenPlugin = getQuarkusMavenPlugin();
runMavenCommandAndWait("-f", "target/test-classes/list-extensions.pom.xml", quarkusMavenPlugin + ":list-extensions",
"-Dformat=id");
withRetry(() -> runMavenCommandAndWait("-f", "target/test-classes/list-extensions.pom.xml",
quarkusMavenPlugin + ":list-extensions", "-Dformat=id"), 3);
return extensions;
}

private void withRetry(Runnable cmd, int retryCount) {
int i = 1;
while (retryCount >= i++) {
try {
cmd.run();
} catch (RuntimeException e) {
LOG.severe("Output of failed Maven command: " + Arrays.toString(extensions.toArray()));
if (retryCount < i) {
throw e;
}
extensions.clear();
continue;
}
break;
}
}

private String getQuarkusMavenPlugin() {
return Configuration.QUARKUS_MAVEN_PLUGIN.get() + ":" + Configuration.QUARKUS_VERSION.get();
}
Expand Down

0 comments on commit ecfb614

Please sign in to comment.