You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by al...@apache.org on 2022/08/17 09:45:33 UTC

[camel-quarkus] branch main updated: perf-regression: add integration tests #3982

This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new 6d88cf18b6 perf-regression: add integration tests #3982
6d88cf18b6 is described below

commit 6d88cf18b60b3b552a5e98a915b85c437e0e0873
Author: aldettinger <al...@gmail.com>
AuthorDate: Thu Aug 11 13:40:51 2022 +0200

    perf-regression: add integration tests #3982
---
 .github/workflows/ci-build.yaml                    |  6 ++
 pom.xml                                            |  2 +-
 tooling/perf-regression/pom.xml                    | 64 +++++++++++++++-
 .../regression/it/PerfRegressionIT.java            | 89 ++++++++++++++++++++++
 4 files changed, 156 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/ci-build.yaml b/.github/workflows/ci-build.yaml
index f09e35e7f3..adb7870f14 100644
--- a/.github/workflows/ci-build.yaml
+++ b/.github/workflows/ci-build.yaml
@@ -243,6 +243,12 @@ jobs:
           ../mvnw ${MAVEN_ARGS} ${BRANCH_OPTIONS} \
             -Dformatter.skip -Dimpsort.skip -Denforcer.skip -Dcamel-quarkus.update-extension-doc-page.skip \
             test
+      - name: cd tooling/perf-regression && mvn verify
+        run: |
+          cd tooling/perf-regression
+          ../../mvnw ${MAVEN_ARGS} ${BRANCH_OPTIONS} \
+            -Dformatter.skip -Dimpsort.skip -Denforcer.skip \
+            verify
 
   extensions-jvm-tests:
     runs-on: ubuntu-latest
diff --git a/pom.xml b/pom.xml
index a8543b9d19..5d0f63c5a3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -161,7 +161,7 @@
         <sshd.version>${sshd-version}</sshd.version>
         <stax2.version>4.2</stax2.version>
         <wiremock.version>2.27.2</wiremock.version>
-        <zt-exec.version>1.11</zt-exec.version>
+        <zt-exec.version>1.12</zt-exec.version>
 
         <!-- Tooling dependency versions (keep sorted alphabetically) -->
         <maven-utils.version>0.1.0</maven-utils.version>
diff --git a/tooling/perf-regression/pom.xml b/tooling/perf-regression/pom.xml
index c41ced90e3..6fea99ea77 100644
--- a/tooling/perf-regression/pom.xml
+++ b/tooling/perf-regression/pom.xml
@@ -17,7 +17,10 @@
     limitations under the License.
 
 -->
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"  xmlns="http://maven.apache.org/POM/4.0.0"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<project
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
+    xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.camel.quarkus</groupId>
@@ -28,6 +31,9 @@
 
     <artifactId>perf-regression</artifactId>
 
+    <name>Camel Quarkus :: Performance Regression Detection Tool</name>
+    <description>Camel Quarkus :: Performance Regression Detection Tool</description>
+
     <dependencyManagement>
         <dependencies>
             <dependency>
@@ -37,6 +43,13 @@
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
+            <dependency>
+                <groupId>org.apache.camel.quarkus</groupId>
+                <artifactId>camel-quarkus-bom</artifactId>
+                <version>${project.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
             <dependency>
                 <groupId>org.apache.commons</groupId>
                 <artifactId>commons-exec</artifactId>
@@ -47,6 +60,12 @@
                 <artifactId>tablesaw-core</artifactId>
                 <version>${tablesaw.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.zeroturnaround</groupId>
+                <artifactId>zt-exec</artifactId>
+                <version>${zt-exec.version}</version>
+                <scope>test</scope>
+            </dependency>
         </dependencies>
     </dependencyManagement>
     <dependencies>
@@ -78,6 +97,22 @@
             <groupId>io.quarkus</groupId>
             <artifactId>quarkus-junit5</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.zeroturnaround</groupId>
+            <artifactId>zt-exec</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-junit5-internal</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <!-- Let the reactor know that camel-quarkus-platform-http-deployment should be built before integration-tests -->
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-platform-http-deployment</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
@@ -91,11 +126,15 @@
                             <target>
                                 <copy file="${basedir}/../../mvnw"
                                     todir="${basedir}/cq-perf-regression-sample-base/" />
-                                <copy file="${basedir}/../../mvnw.cmd"
+                                <copy
+                                    file="${basedir}/../../mvnw.cmd"
                                     todir="${basedir}/cq-perf-regression-sample-base/" />
-                                <copy file="${basedir}/../../.mvn/wrapper/maven-wrapper.properties"
+                                <copy
+                                    file="${basedir}/../../.mvn/wrapper/maven-wrapper.properties"
                                     todir="${basedir}/cq-perf-regression-sample-base/.mvn/wrapper/" />
-                                <chmod file="${basedir}/cq-perf-regression-sample-base/mvnw" perm="775"/>
+                                <chmod
+                                    file="${basedir}/cq-perf-regression-sample-base/mvnw"
+                                    perm="775" />
                             </target>
                         </configuration>
                         <goals>
@@ -119,6 +158,23 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <configuration>
+                    <systemPropertyVariables>
+                        <camel.quarkus.version>${project.version}</camel.quarkus.version>
+                    </systemPropertyVariables>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 </project>
diff --git a/tooling/perf-regression/src/test/java/org/apache/camel/quarkus/performance/regression/it/PerfRegressionIT.java b/tooling/perf-regression/src/test/java/org/apache/camel/quarkus/performance/regression/it/PerfRegressionIT.java
new file mode 100644
index 0000000000..fc0d50d93b
--- /dev/null
+++ b/tooling/perf-regression/src/test/java/org/apache/camel/quarkus/performance/regression/it/PerfRegressionIT.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.performance.regression.it;
+
+import java.io.IOException;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.commons.lang3.StringUtils;
+import org.junit.jupiter.api.Test;
+import org.zeroturnaround.exec.InvalidExitValueException;
+import org.zeroturnaround.exec.ProcessExecutor;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class PerfRegressionIT {
+
+    @Test
+    void noArgsShouldPrintHelp() throws IOException, InterruptedException, TimeoutException {
+        try {
+            String processOutput = new ProcessExecutor()
+                    .command("java", "-jar", "target/quarkus-app/quarkus-run.jar")
+                    .readOutput(true)
+                    .exitValue(2)
+                    .execute()
+                    .outputUTF8();
+
+            assertThat(processOutput, containsString("Missing required parameter: '<versions>'"));
+            assertThat(processOutput, containsString("-an, --also-run-native-mode"));
+            assertThat(processOutput, containsString("-cqs, --camel-quarkus-staging-repository=<cqStagingRepository>"));
+            assertThat(processOutput, containsString("-cs, --camel-staging-repository=<camelStagingRepository>"));
+            assertThat(processOutput, containsString("-d, --duration=<singleScenarioDuration>"));
+        } catch (InvalidExitValueException ievex) {
+            fail("The perf-regression process has finished with an unexpected exit value", ievex);
+        }
+    }
+
+    @Test
+    void nominalShouldPrintReport() throws IOException, InterruptedException, TimeoutException {
+
+        try {
+            String cqVersion = System.getProperty("camel.quarkus.version");
+
+            String processOutput = new ProcessExecutor()
+                    .command("java", "-jar", "target/quarkus-app/quarkus-run.jar", "-d", "1s", cqVersion)
+                    .readOutput(true)
+                    .exitValue(0)
+                    .execute()
+                    .outputUTF8();
+
+            String reportSummary = "Camel Quarkus Throughput Performance Increase Compared to Previous Version";
+            assertThat(processOutput, containsString(reportSummary));
+
+            String reportAndStopLogs = StringUtils.substringAfter(processOutput, reportSummary);
+            assertNotNull(reportAndStopLogs);
+            String[] reportAndStopLines = reportAndStopLogs.split(System.lineSeparator());
+            assertThat(reportAndStopLines.length, greaterThanOrEqualTo(4));
+
+            String titleLine = reportAndStopLines[1];
+            assertThat(titleLine, containsString(" JVM req/s [%increase] "));
+
+            String reportLine = reportAndStopLines[3];
+            assertThat(reportLine, containsString(" " + cqVersion + " "));
+            assertThat(reportLine, containsString(" 1s "));
+            assertThat(reportLine, containsString(" req/s [+0.00%] "));
+            assertThat(reportLine, containsString(" OK "));
+        } catch (InvalidExitValueException ievex) {
+            fail("The perf-regression process has finished with an unexpected exit value", ievex);
+        }
+    }
+
+}