0

I have SonarQube 5.1, JMeter plugin installed in SonarQube is 0.3. Maven is: 3.1.0

I have a simple single level Maven project with some tests and JMeter jmx file.

I'm successfully generating the Test results (Unit tests) and JMeter result file (.jtl file in XML format instead of default CSV format). Refer: Sonarqube + Jmeter error in jtl file

Project's pom.xml looks like:

<?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>

When I run mvn sonar:sonar, it works successfully but shows the following lines:

[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

Everything looks good but I'm wondering why it shows the following line even though the .jtl file I have is valid and the Jenkins Performance plugin reports shows valid data/graphs. Why Sonar is ignoring it. I have tried putting the JMeter result .jtl file under both target/jmeter/results and target/jmeter-reports folder but JMeter widget in SonarQube (on the project's dashboard) does NOT show any data like shown below.

[INFO] [02:35:54.784] Sensor JMeterSensor (done) | time=0ms

enter image description here

Is this due to the fact that now JMeter plugin is deprecated http://docs.sonarqube.org/display/PLUG/Deprecated+Plugins?

I don't see the setting anymore in JMeter Plugin section in SonarQube where you can specify your LOCAL jtl file in my SonarQube version.

If I see this matrix, it shows version 0.3 of JMeter plugin in SonarQube is compatible with all available SonarQube versions. See here for JMeter compatibility: http://docs.sonarqube.org/display/PLUG/Plugin+Version+Matrix

Also sonar-plugin in GitHub is 0.5 version https://github.com/SonarCommunity/sonar-jmeter (but not listed in SonarQube Docs site as per their compatibility matrix).

Not sure what I'm missing at this point.

Community
  • 1
  • 1
AKS
  • 16,482
  • 43
  • 166
  • 258

1 Answers1

1

Did you configure the JMeter property on the Sonar project?

  • Make sure that you installed the Jmeter plugin for SonarQube.

Sonar jmeter

  • Configure your project

Sonar Jmeter

  • Give the path to your .jtl files.

    Project > Settings > General Settings > JMeter > Local jtl file

enter image description here

Then in the Project Overview tab, go to Configure widgets > Search:, search for JMeter > Add widget.

Run your Sonar again to see the new result.

enter image description here

Tuan
  • 2,303
  • 2
  • 25
  • 37
  • Hi Tuan. As I mentioned in my post, I don't see the option for Local JTL box in JMeter settings (within SonarQube GUI). JMeter widget is already turned on. It seems like the newer versions of SonarQube 5.1 or onwards, don't have a box/field to specify "local .jtl" file. Also, I tried to pass -Dsonar.jmeter.jtlpath=... it didn't work either. – AKS Nov 17 '15 at 16:52
  • @ArunSangal I'm using SonarQube 5.1.1. I've added images into my answer. – Tuan Nov 18 '15 at 02:38
  • Thanks Tuan. I now see there's JMeter in Global settings and at project level as well. Im able to get the JMeter widget populate the results now. Is there any way to click on any of the sections / links / graphs within the JMeter widget? – AKS Nov 18 '15 at 18:55
  • @ArunSangal Unfortunately, I've the same question like you. :) – Tuan Nov 19 '15 at 02:15
  • I did see somewhere (while researching to find the GUI jtl path box in JMeter section in SonarQube), someone mentioned that it's possible to see more details clicking on the graphs/highlights links in JMeter widget section on the project's dashboard. I'll post if if I find it again. It was something about to get details about each performance test run / details about the individual run etc. – AKS Nov 19 '15 at 18:12
  • Would you know how I can get this to work for a multi module project? I only have 1 jtl file now, but I can't get it to show. What would be an example of the path in sonar/sonar property in maven? – bobK Jan 18 '16 at 20:41
  • @bobK Sorry but I don't know clearly. It's better to post a new question. – Tuan Jan 19 '16 at 03:01
  • I found it. It turns out, that if you have a jtl file in a submodule, you will see the widget only in the submodule – bobK Jan 19 '16 at 08:08