Sometimes Sonarqube doesn't compare to period 5 - sonarqube

I have setup a project with a specific date in sonar.timemachine.period5 in my project.properties file. This usually works perfectly, but sometimes the sonarqube runner doesn't make the comparison.
sonar.timemachine.period5=2015-11-04
Here is a part of the log output from two consecutive sonar-runner analysis:
This one is not comparing against period 5:
10:28:17.546 INFO - Loaded quality gate 'MyProject'
10:28:17.591 INFO - Compare to previous analysis (2015-10-26)
10:28:17.596 INFO - Compare over 30 days (2015-10-24, analysis of Mon Oct 26 09:26:01 CET 2015)
10:28:17.597 INFO - Compare to previous version (2015-10-26)
while this one is....
10:37:43.996 INFO - Loaded quality gate 'MyProject'
10:37:44.054 INFO - Compare to previous analysis (2015-11-23)
10:37:44.060 INFO - Compare over 30 days (2015-10-24, analysis of Mon Oct 26 09:26:01 CET 2015)
10:37:44.061 INFO - Compare to previous version (2015-11-23)
10:37:44.062 INFO - Compare to date 2015-11-04 (analysis of 2015-11-23
Any clues on why this is happening?
The result is that the project sometimes passes the qualitygate when it certainly shouldn't.
Im running SonarQube 5.1.2 and using Sonar-Runner 2.4

Periods 4 and 5 are not set globally but on the project level. Double-check your first project to make sure it has a valid Period 5 value.

Related

My problem is regarding Jmeter when I am trying to use the non-GUI mode

When I am passing the command in command prompt then I am getting the below error-
C:\Users\ShivangiT\Downloads\apache-jmeter-5.3\apache-jmeter-5.3\bin>Jmeter.bat -Jjmeter.save.saveservice.output_format=xml -n -t \Users\ShivangiT\Downloads\apache-jmeter-5.3\apache-jmeter-5.3\bin\vieweventpage.jmx -l \Users\ShivangiT\Downloads\apache-jmeter-5.3\apache-jmeter-5.3\bin\rr.jtl
Creating summariser <summary>
Created the tree successfully using \Users\ShivangiT\Downloads\apache-jmeter-5.3\apache-jmeter-5.3\bin\vieweventpage.jmx
Starting standalone test # Fri Aug 21 07:29:38 BST 2020 (1597991378434)
Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
summary = 41 in 00:00:14 = 2.9/s Avg: 5256 Min: 7 Max: 13688 Err: 13 (31.71%)
Tidying up ... # Fri Aug 21 07:29:52 BST 2020 (1597991392905)
... end of run
The JVM should have exited but did not.
The following non-daemon threads are still running (DestroyJavaVM is OK):
Thread[DestroyJavaVM,5,main], stackTrace:
Thread[AWT-EventQueue-0,6,main], stackTrace:sun.misc.Unsafe#park
java.util.concurrent.locks.LockSupport#park
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject#await
java.awt.EventQueue#getNextEvent
java.awt.EventDispatchThread#pumpOneEventForFilters
java.awt.EventDispatchThread#pumpEventsForFilter
java.awt.EventDispatchThread#pumpEventsForHierarchy
java.awt.EventDispatchThread#pumpEvents
java.awt.EventDispatchThread#pumpEvents
java.awt.EventDispatchThread#run
Thread[AWT-Shutdown,5,system], stackTrace:java.lang.Object#wait
sun.awt.AWTAutoShutdown#run
java.lang.Thread#run
Can anybody please help me with this.
This is a known issue of JMeter 5.3 when test plan contains Http(s) Test script recorder.
The workaround is to remove it.
See:
https://bz.apache.org/bugzilla/show_bug.cgi?id=64479
Alternatively you can try nightly build:
https://ci.apache.org/projects/jmeter/nightlies/
Shiva, I would suggest that you should use the older version of JMeter always. The reason is very simple. There is not much of a change in JMeter since JMeter 4. JMeter is more inclined towards its compatibility with JDK 11 as currently, it supports JDK 8 flawlessly in the older versions. Use JMeter 4 from the JMeter official archive and you'll be able to execute everything smoothly. No need to look for workarounds. Make sure you use JMeter 4

Why are jest-based unit tests now resulting in 0% test coverage?

I'm not a front-end developer, but I need to get a sonarqube scan working with unit test coverage. All of this WAS working, but we had a big SonarQube version upgrade (6.x to 7.9.1), and it was broken for a while, and now I'm trying to get it working again.
As this used to work, what we have must be close, but there's some detail that isn't quite right.
When the build runs, it runs the unit tests and appears to generate coverage data, and the call to "sonar-scanner" sends the path to the lcov.info file. In the SonarQube project, it has a large number of "lines to cover", but with the same number of uncovered lines. I also note that it doesn't have a "Unit Tests" section in the overview.
In the build output, I see quite a few lines like this:
DEBUG: 'src/api/Api.spec.tsx' indexed as test with language 'ts'
But as noted above, the SonarQube project doesn't appear to think there are any unit tests.
As part of the build script, at the end of the tests run, I ran "ls -lt coverage" to see what was generated, and it showed this:
total 6264
-rw-r--r-- 1 81050 20059 1229978 Jan 4 19:12 clover.xml
-rw-r--r-- 1 81050 20059 720443 Jan 4 19:12 lcov.info
drwxr-xr-x 6 81050 20059 4096 Jan 4 19:12 lcov-report
-rw-r--r-- 1 81050 20059 4455341 Jan 4 19:12 coverage-final.json
I see references in this file to "Api.tsx" (and many others), but I don't see a reference to "Api.spec.tsx", but I have no idea whether I should expect any.
I've looked at the jest configuration in "package.json", but I don't see any obvious problems.
What else can I show here that might provide a clue?
Update:
Here is the resulting sonar-scanner command line, with some elisions:
sonar-scanner -Dsonar.typescript.node=/opt/app/bin/node -Dsonar.nodejs.executable=/opt/app/bin/node -Dsonar.host.url=http://... -Dsonar.login=... -Dsonar.password= -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info -Dsonar.typescript.lcov.reportPaths=coverage/lcov.info -Dsonar.branch.name= -Dsonar.language=js -Dsonar.projectKey=... -Dsonar.projectName=... '-Dsonar.exclusions=**/*.scss.d.ts, **/*.scss, **/*Props.ts, **/*State.ts, **/*index.ts' '-Dsonar.coverage.exclusions=**/*.spec.tsx, **/*.spec.ts, **/*.scss.d.ts, **/*.css.d.ts, **/*.scss' -Dsonar.projectVersion=1.0.0 '-Dsonar.sources=src/components/,src/api/,src/models/mappers/, src/utils/' '-Dsonar.lang.patterns.js=*/.ts,*/.tsx' -Dsonar.js.file.suffixes=.ts,.tsx -Dsonar.sourceEncoding=UTF-8 -Dsonar.tests=src '-Dsonar.test.inclusions=**/*.spec.tsx' -Dsonar.typescript.tslintconfigpath=tslint.json -Dsonar.log.level=DEBUG -Dsonar.verbose=true '-Dsonar.exec.maxBuffer=1024 * 1024'
I'd forgotten I'd asked this question. I had to go back to the code and history to see if I could remember what I did to fix it. I assume it would be what I discovered here:
https://community.sonarsource.com/t/sensor-sonarts-coverage-fails-to-match-path-with-symbolic-link/14601
In short, if file paths in the generated files include symbolic link entries, there was a bug in SonarTS that made it fail to follow symbolic links. What I did to fix this particular problem was examine my generated files to understand the pattern of what symbolic links were being utilized, and I wrote a script to post-process the lcov.info and test-report.xml file to replace paths to symbolic links with the absolute path to the non-symlinked file.

SonarQube Analyse WARNING Journal flush operation (Does not End)

Running SonarQube Server 4.5.6, Tested with Maven 3.0.5, Maven 3.3.9,
Using the command line like this:
mvn -B org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar
Also tested different versions of the plugin (3.1.1 etc.).
I have already tested to enhance the memory options from 2 G to 22 G
-Xmx6g -XX:-UseGCOverheadLimit
which did not help. Always the scan does not continue and getting this output:
00:23:08.815 15:36:06.724 WARN - [JOURNAL_FLUSHER] WARNING Journal flush operation took 14.164ms last 8 cycles average is 1.770ms
00:23:55.507 15:37:10.917 WARN - [JOURNAL_FLUSHER] WARNING Journal flush operation took 3.696ms last 8 cycles average is 2.232ms
00:25:03.219 15:38:16.429 WARN - [JOURNAL_FLUSHER] WARNING Journal flush operation took 3.493ms last 8 cycles average is 898ms
00:29:09.760 15:42:01.239 WARN - [JOURNAL_FLUSHER] WARNING Journal flush operation took 3.513ms last 8 cycles average is 439ms
00:31:01.208 15:44:17.868 WARN - [JOURNAL_FLUSHER] WARNING Journal flush operation took 3.611ms last 8 cycles average is 451ms
00:34:22.694 15:47:30.643 WARN - [JOURNAL_FLUSHER] WARNING Journal flush operation took 22.496ms last 8 cycles average is 2.812ms
We have a large number of modules (ca. 600) in a single multi module build (Java / Tycho)...
Update: So the result keeps failure. Does a scan really take so much memory which is done module by module?
So after more investigation and research I found the following related issues:
https://jira.sonarsource.com/browse/SONAR-5995
https://jira.sonarsource.com/browse/SONAR-5878
https://jira.sonarsource.com/browse/SONAR-5551
Which means in other words I have to update the SonarQube version to a newer version.

Sonarqube - Resolution changed to FIXED

I have a strange behaviour while analysing my Java Code.
The analysis is done on a daily basis.
On the first run some issue are identified, so far so good.
After the next run there are issues marked as Fixed.
The Message i got in sonarQube:
Juli 2015 10:33 Uhr Created
Juli 2015 20:30 Uhr Resolution changed to FIXED
Status changed to CLOSED (was OPEN)
But there was no change at this File between the two runs.....
Java: JDK 1.8.0_u45
SonarQube: 5.1.1
Any Idea???
Thanks in advance
Kai

Teamcity Configuration Settings

I need to know the teamcity settings which prevents the re-trigger/trigger of outdated builds/jobs if the new builds are successful.
I am facing a issue where teamcity jobs can be re triggered even if the next builds are successful.And If the trigger event is fired before, then it must stop teamcity to run that job if the latest build is successful.
So I have to 2 jobs in TC for 1 branch -- Build-Precheck and the other is Build-compile
So I could see that Build-compile is just picking the latest available successful build from Build-Precheck and then queing up the next which may be the outdated build.
Build-Precheck is just taking 2 min to finish the builds , it quickly triggers the latest builds , I guess following the principal First In First Out
Build-Precheck
06 Oct 14 14:33 - 14:35 (2m:01s) –7.1.4345
06 Oct 14 14:41 - 14:43 (2m:16s)- 7.1.4346
06 Oct 14 14:45 - 14:47 (2m:10s)- 7.1.4347
Build-compile
06 Oct 14 14:35 - 15:00 -7.1.0.4345
06 Oct 14 14:52 - 15:20 (28m:02s)- 7.1.4347
06 Oct 14 16:08 - 16:33 (24m:52s)- 7.1.4346
Is there any fix for this that TC runs incremental builds rather than outdated ones
Sounds like you are looking for Configuring Build Trigger.
AFAIK, there isn't a way to cancel queued builds if a given build passes. However, you can adjust the Build Triggers that queue those builds. Most likely, you'll need to set the Quiet Period on your VCS Build Trigger to longer than it takes for your build.
For example, if your full build takes 5 minutes, you should set the Quiet Period to 7. This way additional builds wont queue while a build is running.

Resources