我有 SonarQube 5.1,SonarQube 中安装的 JMeter 插件是 0.3。Maven是:3.1.0
我有一个简单的单级 Maven 项目,其中包含一些测试和 JMeter jmx 文件。
我成功生成了测试结果(单元测试)和 JMeter 结果文件(XML 格式的.jtl 文件,而不是默认的 CSV 格式)。参考:Sonarqube + Jmeter 在 jtl 文件中的错误
项目的 pom.xml 看起来像:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://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>com.company.csa.reference</groupId>
<artifactId>csa-reference-app</artifactId>
<version>0.0.17-SNAPSHOT</version>
</parent>
<properties>
<sonar.host.url>http://sandboxserver12.tsh.thomson.com:9000</sonar.host.url>
<sonar.jdbc.url>jdbc:h2:tcp://sandboxserver12.tsh.thomson.com:9092/sonar</sonar.jdbc.url>
<sonar.jdbc.driverClassName>org.h2.Driver</sonar.jdbc.driverClassName>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<sonar.junit.reportsPath>target/surefire-reports</sonar.junit.reportsPath>
<sonar.surefire.reportsPath>target/surefire-reports</sonar.surefire.reportsPath>
<sonar.java.junit.reportsPath>target/surefire-reports</sonar.java.junit.reportsPath>
<sonar.java.surefire.reportsPath>target/surefire-reports</sonar.java.surefire.reportsPath>
<sonar.groovy.junit.reportsPath>target/surefire-reports</sonar.groovy.junit.reportsPath>
<sonar.groovy.surefire.reportsPath>target/surefire-reports</sonar.groovy.surefire.reportsPath>
<sonar.language>java</sonar.language>
<sonar.sources>src/main/java</sonar.sources>
<sonar.tests>src/test/java</sonar.tests>
<sonar.binaries>target/classes</sonar.binaries>
<sonar.java.binaries>target/classes</sonar.java.binaries>
<sonar.groovy.binaries>target/classes</sonar.groovy.binaries>
</properties>
<artifactId>a_test_app</artifactId>
<packaging>war</packaging>
<name>a_test_app Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>8.1.15.v20140411</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>8.1.15.v20140411</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>a_test_app</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.7.1</version>
</plugin>
</plugins>
</build>
</project>
当我运行mvn sonar:sonar时,它可以成功运行,但显示以下几行:
[INFO] [02:35:54.784] Sensor JMeterSensor
[INFO] [02:35:54.784] Sensor JMeterSensor (done) | time=0ms
..
..
[DEBUG] [02:35:57.410] Post-jobs : org.sonar.plugins.jmeter.JMeterPostJob@79854a9e -> org.sonar.plugins.issueassign.notification.SendIssueNotificationsPostJob@3c848bb2 -> org.sonar.plugins.buildbreaker.AlertBreaker@55faaed1 -> org.sonar.plugins.buildbreaker.ForbiddenConfigurationBreaker@295790db
[INFO] [02:35:57.410] Executing post-job class org.sonar.plugins.jmeter.JMeterPostJob
[DEBUG] [02:35:57.411] START JMeterPostJob
[INFO] [02:35:57.411] Getting JMeter results from /path/home/user/giga/csa/a_test_app/target/jmeter/results/CSARefApp.jtl
[DEBUG] [02:35:57.420] getInputStreamByTestConfig for config 'a_test_app Maven Webapp'
[DEBUG] [02:35:57.420] JTL path: /path/home/user/giga/csa/a_test_app/target/jmeter/results/CSARefApp.jtl
[DEBUG] [02:35:57.423] Creating JtlAbstractSampleReader ...
[INFO] [02:35:57.636] Starting global summary report for config 'testapp Maven Webapp'
[DEBUG] [02:35:58.055] JtlAbstractSampleReader read 240 nodes
[INFO] [02:35:58.055] Global summary report successful finished for config 'testapp Maven Webapp'
[DEBUG] [02:35:58.062] JMeter GlobalSummary:
mostUnstableTransBytesOkAvgDevPercent=0.0
mostUnstableTransName=null
mostUnstableTransResponseTimeOkAvgDevPercent=0.0
requestsBytesOkAvg=17003.4375
requestsBytesOkAvgDev=41125.73795246031
requestsBytesOkAvgDevPercent=241.86719863239603
requestsErrorPercent=0.0
requestsErrorTotal=0
requestsOkPerMinute=2452.7337761880426
requestsOkPerMinuteAndUser=122.63668880940213
requestsOkTotal=160
requestsResponseTimeOkAvg=48.5
requestsResponseTimeOkAvgDev=152.453354037334
requestsResponseTimeOkAvgDevPercent=314.33681244811135
requestsTotal=160
slowestTransBytesOkAvgDevPercent=0.0
slowestTransName=null
...
......
..........
transMapResponseTimeOkAvgDevPercent={Transaction_Welcome=57.41068190712635, Transaction_Snoop=56.1112617700907, Transaction_Healthcheck=139.89028322965896, Transaction_Logout=50.02351333561716}
transOkPerMinute=1226.3668880940213
transOkPerMinuteAndUser=61.318344404701065
transOkTotal=80
transOrder=[Transaction_Healthcheck, Transaction_Snoop, Transaction_Welcome, Transaction_Logout]
transResponseTimeOkAvg=97.0
transResponseTimeOkAvgDev=210.29557258321267
transResponseTimeOkAvgDevPercent=216.79955936413677
transTotal=80
usersLogged=20
[DEBUG] [02:35:58.066] END JMeterPostJob
一切看起来都不错,但我想知道为什么它显示以下行,即使我拥有的.jtl文件是有效的并且 Jenkins Performance 插件报告显示有效的数据/图表。为什么 Sonar 忽略它。我尝试将 JMeter 结果 .jtl 文件放在target/jmeter/results和target/jmeter-reports文件夹下,但 SonarQube 中的 JMeter 小部件(在项目的仪表板上)不显示如下所示的任何数据。
[INFO] [02:35:54.784] Sensor JMeterSensor (done) | time=0ms
这是因为现在 JMeter 插件已被弃用http://docs.sonarqube.org/display/PLUG/Deprecated+Plugins吗?
我在 SonarQube 的 JMeter 插件部分不再看到该设置,您可以在我的 SonarQube 版本中指定您的本地 jtl 文件。
如果我看到这个矩阵,它表明 SonarQube 中 JMeter 插件的 0.3 版与所有可用的 SonarQube 版本兼容。请参阅此处了解 JMeter 兼容性:http ://docs.sonarqube.org/display/PLUG/Plugin+Version+Matrix
GitHub 中的 sonar-plugin 也是 0.5 版本https://github.com/SonarCommunity/sonar-jmeter(但根据其兼容性矩阵未在 SonarQube Docs 站点中列出)。
不确定我此时缺少什么。