You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by kb...@apache.org on 2023/11/13 08:32:34 UTC
(incubator-kie-kogito-benchmarks) 07/38: Add Spring Boot support
This is an automated email from the ASF dual-hosted git repository.
kbowers pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-kogito-benchmarks.git
commit bb6dcc9d2341fb8b49070cdf05cefa25e0d35ec9
Author: Marián Macik <mm...@redhat.com>
AuthorDate: Fri May 7 17:40:41 2021 +0200
Add Spring Boot support
---
.../org/kie/kogito/benchmarks/framework/App.java | 8 ++++++++
.../kogito/benchmarks/framework/LogBuilder.java | 2 +-
.../org/kie/kogito/benchmarks/framework/Logs.java | 17 ++++++++++-------
.../kie/kogito/benchmarks/framework/MvnCmds.java | 8 ++++++--
.../threshold.properties | 4 ++--
.../smarthouse-03-dm-quarkus/threshold.properties | 2 +-
.../threshold.properties | 4 ++--
.../kogito/benchmarks/AbstractTemplateTest.java | 22 ++++++++++++++++------
.../kie/kogito/benchmarks/QuarkusSmallTest.java | 2 --
.../org/kie/kogito/benchmarks/StartStopTest.java | 10 +++++-----
10 files changed, 51 insertions(+), 28 deletions(-)
diff --git a/framework/src/main/java/org/kie/kogito/benchmarks/framework/App.java b/framework/src/main/java/org/kie/kogito/benchmarks/framework/App.java
index 805b4fa..e363ba9 100644
--- a/framework/src/main/java/org/kie/kogito/benchmarks/framework/App.java
+++ b/framework/src/main/java/org/kie/kogito/benchmarks/framework/App.java
@@ -62,4 +62,12 @@ public enum App {
public File getAppDir() {
return new File(APPS_DIR, dir);
}
+
+ public boolean isQuarkus() {
+ return this.name().contains("QUARKUS");
+ }
+
+ public boolean isSpringBoot() {
+ return this.name().contains("SPRING");
+ }
}
diff --git a/framework/src/main/java/org/kie/kogito/benchmarks/framework/LogBuilder.java b/framework/src/main/java/org/kie/kogito/benchmarks/framework/LogBuilder.java
index 2294df5..2caeb80 100644
--- a/framework/src/main/java/org/kie/kogito/benchmarks/framework/LogBuilder.java
+++ b/framework/src/main/java/org/kie/kogito/benchmarks/framework/LogBuilder.java
@@ -72,7 +72,7 @@ public class LogBuilder {
}
public LogBuilder stoppedInMs(long stoppedInMs) {
- if (stoppedInMs <= 0) {
+ if (stoppedInMs <= 0 && !app.isSpringBoot()) { // Spring Boot doesn't provide stop time
throw new IllegalArgumentException("stoppedInMs must be a positive long, was: " + stoppedInMs);
}
this.stoppedInMs = stoppedInMs;
diff --git a/framework/src/main/java/org/kie/kogito/benchmarks/framework/Logs.java b/framework/src/main/java/org/kie/kogito/benchmarks/framework/Logs.java
index fb781fc..2e2d031 100644
--- a/framework/src/main/java/org/kie/kogito/benchmarks/framework/Logs.java
+++ b/framework/src/main/java/org/kie/kogito/benchmarks/framework/Logs.java
@@ -31,7 +31,7 @@ public class Logs {
public static final String jarSuffix = "redhat";
private static final Pattern jarNamePattern = Pattern.compile("^((?!" + jarSuffix + ").)*jar$");
- private static final Pattern startedPattern = Pattern.compile(".* started in ([0-9\\.]+)s.*", Pattern.DOTALL);
+ private static final Pattern startedPattern = Pattern.compile(".* [Ss]tarted.* in ([0-9\\.]+)(?:s| seconds).*", Pattern.DOTALL);
private static final Pattern stoppedPattern = Pattern.compile(".* stopped in ([0-9\\.]+)s.*", Pattern.DOTALL);
/*
* Due to console colouring, Windows has control characters in the sequence.
@@ -44,7 +44,7 @@ public class Logs {
* depending on whether you checked AllowInteractingWithDesktop.
* // TODO to make it smoother?
*/
- private static final Pattern startedPatternControlSymbols = Pattern.compile(".* started in .*188m([0-9\\.]+).*", Pattern.DOTALL);
+ private static final Pattern startedPatternControlSymbols = Pattern.compile(".* [Ss]tarted.* in .*188m([0-9\\.]+)(?:s| seconds).*", Pattern.DOTALL);
private static final Pattern stoppedPatternControlSymbols = Pattern.compile(".* stopped in .*188m([0-9\\.]+).*", Pattern.DOTALL);
private static final Pattern warnErrorDetectionPattern = Pattern.compile("(?i:.*(ERROR|WARN|SLF4J:).*)");
@@ -79,6 +79,9 @@ public class Logs {
}
public static void checkListeningHost(String testClass, String testMethod, MvnCmds cmd, File log) throws IOException {
+ if (cmd.name().startsWith("SPRING")) {
+ return; // Spring Boot doesn't provide the host information by default (only at debug level)
+ }
boolean isOffending = true;
try (Scanner sc = new Scanner(log, UTF_8)) {
while (sc.hasNextLine()) {
@@ -142,7 +145,7 @@ public class Logs {
public static void checkThreshold(App app, MvnCmds cmd, long rssKb, long timeToFirstOKRequest, long timeToReloadedOKRequest) {
String propPrefix = isThisWindows ? "windows" : "linux";
- if (cmd == MvnCmds.QUARKUS_JVM) {
+ if (cmd.isJVM()) {
propPrefix += ".jvm";
} else if (cmd == MvnCmds.NATIVE) {
propPrefix += ".native";
@@ -294,7 +297,7 @@ public class Logs {
.collect(Collectors.toList());
}
- public static float[] parseStartStopTimestamps(File log) throws IOException {
+ public static float[] parseStartStopTimestamps(File log, App app) throws IOException {
float[] startedStopped = new float[] { -1f, -1f };
try (Scanner sc = new Scanner(log, UTF_8)) {
while (sc.hasNextLine()) {
@@ -326,12 +329,12 @@ public class Logs {
}
if (startedStopped[0] == -1f) {
LOGGER.error("Parsing start time from log failed. " +
- "Might not be the right time to call this method. The process might have ben killed before it wrote to log." +
+ "Might not be the right time to call this method. The process might have ben killed before it wrote to log. " +
"Find " + log.getName() + " in your target dir.");
}
- if (startedStopped[1] == -1f) {
+ if (startedStopped[1] == -1f && !app.isSpringBoot()) { // Spring Boot doesn't provide stop time
LOGGER.error("Parsing stop time from log failed. " +
- "Might not be the right time to call this method. The process might have been killed before it wrote to log." +
+ "Might not be the right time to call this method. The process might have been killed before it wrote to log. " +
"Find " + log.getName() + " in your target dir.");
}
return startedStopped;
diff --git a/framework/src/main/java/org/kie/kogito/benchmarks/framework/MvnCmds.java b/framework/src/main/java/org/kie/kogito/benchmarks/framework/MvnCmds.java
index ca11c75..d6e8135 100644
--- a/framework/src/main/java/org/kie/kogito/benchmarks/framework/MvnCmds.java
+++ b/framework/src/main/java/org/kie/kogito/benchmarks/framework/MvnCmds.java
@@ -12,11 +12,11 @@ public enum MvnCmds {
}),
SPRING_BOOT_02_JVM(new String[][] {
new String[] { "mvn", "clean", "package" }, // There is no possibility of changing the final name of the artifact
- new String[] { "java", "-jar", "target/smarthouse-02-springboot-1.0-SNAPSHOT.jar" }
+ new String[] { "java", "-jar", "target/smarthouse-02-dm-springboot-1.0-SNAPSHOT.jar" }
}),
SPRING_BOOT_03_JVM(new String[][] {
new String[] { "mvn", "clean", "package" },
- new String[] { "java", "-jar", "target/smarthouse-03-springboot-1.0-SNAPSHOT.jar" }
+ new String[] { "java", "-jar", "target/smarthouse-03-dm-springboot-1.0-SNAPSHOT.jar" }
}),
DEV(new String[][] {
new String[] { "mvn", "clean", "quarkus:dev", "-Dmaven.repo.local=" + getLocalMavenRepoDir() }
@@ -54,4 +54,8 @@ public enum MvnCmds {
MvnCmds(String[][] mvnCmds) {
this.mvnCmds = mvnCmds;
}
+
+ public boolean isJVM() {
+ return this.name().contains("JVM");
+ }
}
diff --git a/framework/src/main/resources/smarthouse-02-dm-springboot/threshold.properties b/framework/src/main/resources/smarthouse-02-dm-springboot/threshold.properties
index 36c0c1c..c541e43 100644
--- a/framework/src/main/resources/smarthouse-02-dm-springboot/threshold.properties
+++ b/framework/src/main/resources/smarthouse-02-dm-springboot/threshold.properties
@@ -1,5 +1,5 @@
-linux.jvm.time.to.first.ok.request.threshold.ms=3400
-linux.jvm.RSS.threshold.kB=380000
+linux.jvm.time.to.first.ok.request.threshold.ms=6000
+linux.jvm.RSS.threshold.kB=750000
linux.native.time.to.first.ok.request.threshold.ms=35
linux.native.RSS.threshold.kB=90000
windows.jvm.time.to.first.ok.request.threshold.ms=2000
diff --git a/framework/src/main/resources/smarthouse-03-dm-quarkus/threshold.properties b/framework/src/main/resources/smarthouse-03-dm-quarkus/threshold.properties
index 36c0c1c..427e226 100644
--- a/framework/src/main/resources/smarthouse-03-dm-quarkus/threshold.properties
+++ b/framework/src/main/resources/smarthouse-03-dm-quarkus/threshold.properties
@@ -1,5 +1,5 @@
linux.jvm.time.to.first.ok.request.threshold.ms=3400
-linux.jvm.RSS.threshold.kB=380000
+linux.jvm.RSS.threshold.kB=400000
linux.native.time.to.first.ok.request.threshold.ms=35
linux.native.RSS.threshold.kB=90000
windows.jvm.time.to.first.ok.request.threshold.ms=2000
diff --git a/framework/src/main/resources/smarthouse-03-dm-springboot/threshold.properties b/framework/src/main/resources/smarthouse-03-dm-springboot/threshold.properties
index 36c0c1c..c541e43 100644
--- a/framework/src/main/resources/smarthouse-03-dm-springboot/threshold.properties
+++ b/framework/src/main/resources/smarthouse-03-dm-springboot/threshold.properties
@@ -1,5 +1,5 @@
-linux.jvm.time.to.first.ok.request.threshold.ms=3400
-linux.jvm.RSS.threshold.kB=380000
+linux.jvm.time.to.first.ok.request.threshold.ms=6000
+linux.jvm.RSS.threshold.kB=750000
linux.native.time.to.first.ok.request.threshold.ms=35
linux.native.RSS.threshold.kB=90000
windows.jvm.time.to.first.ok.request.threshold.ms=2000
diff --git a/tests/src/test/java/org/kie/kogito/benchmarks/AbstractTemplateTest.java b/tests/src/test/java/org/kie/kogito/benchmarks/AbstractTemplateTest.java
index ee1f7c7..2fbac17 100644
--- a/tests/src/test/java/org/kie/kogito/benchmarks/AbstractTemplateTest.java
+++ b/tests/src/test/java/org/kie/kogito/benchmarks/AbstractTemplateTest.java
@@ -71,14 +71,15 @@ public abstract class AbstractTemplateTest {
cleanTarget(app);
Files.createDirectories(Paths.get(appDir.getAbsolutePath() + File.separator + "logs"));
- // Build
+ // Build first time to download dependencies
BuildResult buildResult = buildApp(app, mn, cn, whatIDidReport);
buildLogA = buildResult.getBuildLog();
assertTrue(buildLogA.exists());
checkLog(cn, mn, app, mvnCmds, buildLogA);
- // Prepare for run
+ // Prepare for measurements
+ List<Long> buildTimeValues = new ArrayList<>(START_STOP_ITERATIONS);
List<Long> rssKbValues = new ArrayList<>(START_STOP_ITERATIONS);
List<Long> timeToFirstOKRequestValues = new ArrayList<>(START_STOP_ITERATIONS);
List<Long> startedInMsValues = new ArrayList<>(START_STOP_ITERATIONS);
@@ -86,8 +87,15 @@ public abstract class AbstractTemplateTest {
List<Long> openedFilesValues = new ArrayList<>(START_STOP_ITERATIONS);
for (int i = 0; i < START_STOP_ITERATIONS; i++) {
- // Run
LOGGER.info("Running... round " + i);
+ // Build
+ buildResult = buildApp(app, mn, cn, whatIDidReport);
+ buildLogA = buildResult.getBuildLog();
+
+ assertTrue(buildLogA.exists());
+ checkLog(cn, mn, app, mvnCmds, buildLogA);
+
+ // Run
RunInfo runInfo = startApp(app, whatIDidReport);
pA = runInfo.getProcess();
runLogA = runInfo.getRunLog();
@@ -107,7 +115,7 @@ public abstract class AbstractTemplateTest {
checkLog(cn, mn, app, mvnCmds, runLogA);
checkListeningHost(cn, mn, mvnCmds, runLogA);
- float[] startedStopped = parseStartStopTimestamps(runLogA);
+ float[] startedStopped = parseStartStopTimestamps(runLogA, app);
long startedInMs = (long) (startedStopped[0] * 1000);
long stoppedInMs = (long) (startedStopped[1] * 1000);
@@ -126,6 +134,7 @@ public abstract class AbstractTemplateTest {
appendln(whatIDidReport, "Measurements:");
appendln(whatIDidReport, log.headerMarkdown + "\n" + log.lineMarkdown);
+ buildTimeValues.add(buildResult.getBuildTimeMs());
rssKbValues.add(rssKb);
openedFilesValues.add(openedFiles);
timeToFirstOKRequestValues.add(runInfo.getTimeToFirstOKRequest());
@@ -133,6 +142,7 @@ public abstract class AbstractTemplateTest {
stoppedInMsValues.add(stoppedInMs);
}
+ long buildTimeAvgWithoutMinMax = getAvgWithoutMinMax(buildTimeValues);
long rssKbAvgWithoutMinMax = getAvgWithoutMinMax(rssKbValues);
long openedFilesAvgWithoutMinMax = getAvgWithoutMinMax(openedFilesValues);
long timeToFirstOKRequestAvgWithoutMinMax = getAvgWithoutMinMax(timeToFirstOKRequestValues);
@@ -144,7 +154,7 @@ public abstract class AbstractTemplateTest {
LogBuilder.Log log = new LogBuilder()
.app(app)
.mode(mvnCmds)
- .buildTimeMs(buildResult.getBuildTimeMs())
+ .buildTimeMs(buildTimeAvgWithoutMinMax)
.timeToFirstOKRequestMs(timeToFirstOKRequestAvgWithoutMinMax)
.startedInMs(startedInMsAvgWithoutMinMax)
.stoppedInMs(stoppedInMsAvgWithoutMinMax)
@@ -305,7 +315,7 @@ public abstract class AbstractTemplateTest {
checkLog(cn, mn, app, mvnCmds, runLogA);
checkListeningHost(cn, mn, mvnCmds, runLogA);
- float[] startedStopped = parseStartStopTimestamps(runLogA);// Don't need this in the load test?
+ float[] startedStopped = parseStartStopTimestamps(runLogA, app);// Don't need this in the load test?
long startedInMs = (long) (startedStopped[0] * 1000);
long stoppedInMs = (long) (startedStopped[1] * 1000);
diff --git a/tests/src/test/java/org/kie/kogito/benchmarks/QuarkusSmallTest.java b/tests/src/test/java/org/kie/kogito/benchmarks/QuarkusSmallTest.java
index ea1eafd..e012a7e 100644
--- a/tests/src/test/java/org/kie/kogito/benchmarks/QuarkusSmallTest.java
+++ b/tests/src/test/java/org/kie/kogito/benchmarks/QuarkusSmallTest.java
@@ -10,12 +10,10 @@ public class QuarkusSmallTest extends AbstractTemplateTest {
private static final App APP_TO_TEST = App.SMARTHOUSE_02_QUARKUS_JVM;
- @Test
public void startStop(TestInfo testInfo) throws IOException, InterruptedException {
startStop(testInfo, APP_TO_TEST);
}
- @Test
public void loadTest(TestInfo testInfo) {
// TODO
}
diff --git a/tests/src/test/java/org/kie/kogito/benchmarks/StartStopTest.java b/tests/src/test/java/org/kie/kogito/benchmarks/StartStopTest.java
index b3b94dc..edf04e7 100644
--- a/tests/src/test/java/org/kie/kogito/benchmarks/StartStopTest.java
+++ b/tests/src/test/java/org/kie/kogito/benchmarks/StartStopTest.java
@@ -140,7 +140,7 @@ public class StartStopTest {
checkLog(cn, mn, app, mvnCmds, runLogA);
checkListeningHost(cn, mn, mvnCmds, runLogA);
- float[] startedStopped = parseStartStopTimestamps(runLogA);
+ float[] startedStopped = parseStartStopTimestamps(runLogA, app);
Path measurementsLog = Paths.get(getLogsDir(cn, mn).toString(), "measurements.csv");
LogBuilder.Log log = new LogBuilder()
@@ -185,10 +185,10 @@ public class StartStopTest {
return (long) listOfValues.stream().mapToLong(val -> val).average().orElse(Long.MAX_VALUE);
}
- @Test
- public void kogito(TestInfo testInfo) throws IOException, InterruptedException {
- testRuntime(testInfo, App.SMARTHOUSE_02_QUARKUS_JVM, MvnCmds.QUARKUS_JVM);
- }
+// @Test
+// public void kogito(TestInfo testInfo) throws IOException, InterruptedException {
+// testRuntime(testInfo, App.SMARTHOUSE_02_QUARKUS_JVM, MvnCmds.QUARKUS_JVM);
+// }
// @Test
// public void jaxRsMinimalJVM(TestInfo testInfo) throws IOException, InterruptedException {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org