Skip to content

Commit

Permalink
SQ-10: test with SonarScanner 6.1.0.4477
Browse files Browse the repository at this point in the history
SonarScanner 6.x is a major refactoring of SonarSource. The parameters, default values and especially the output in the LOG file has changed. Because our CI/CD test evaluates the texts in the LOG file, the Pyhton scripts had to be adapted accordingly.

There was a braking change in scanner parameter sonar.host.url:
- For SonarScanner CLI from v6.0, .NET from v7.0, and NPM from v4.0:  https://sonarcloud.io
- For older versions of the SonarScanner CLI, .NET, and NPM:  http://localhost:9000

got the message below:

```
06:50:43.753 INFO  Scanner configuration file: /home/runner/work/sonar-cxx/sonar-cxx/test/sonar-scanner-6.1.0.4477/conf/sonar-scanner.properties
06:50:43.756 INFO  Project root configuration file: /home/runner/work/sonar-cxx/sonar-cxx/integration-tests/testdata/boosttest_project/sonar-project.properties
06:50:43.769 INFO  SonarScanner CLI 6.1.0.4477
06:50:43.772 INFO  Java 17.0.12 Eclipse Adoptium (64-bit)
06:50:43.772 INFO  Linux 6.5.0-1025-azure amd64
06:50:43.779 DEBUG Scanner max available memory: 3 GB
06:50:43.797 DEBUG uname -m returned 'x86_64'
06:50:43.798 DEBUG Create: /home/runner/.sonar/cache
06:50:43.799 INFO  User cache: /home/runner/.sonar/cache
06:50:43.799 DEBUG Create: /home/runner/.sonar/cache/_tmp
06:50:44.107 DEBUG Loaded [413] system trusted certificates
06:50:44.253 INFO  JRE provisioning: os[linux], arch[x86_64]
06:50:44.279 DEBUG --> GET https://api.sonarcloud.io/analysis/jres?os=linux&arch=x86_64
06:50:45.445 DEBUG <-- 401 https://api.sonarcloud.io/analysis/jres?os=linux&arch=x86_64 (1165ms, 83-byte body)
06:50:45.445 INFO  EXECUTION FAILURE
06:50:45.446 INFO  Total time: 1.694s
06:50:45.447 ERROR Error during SonarScanner CLI execution
java.lang.IllegalStateException: Error status returned by url [https://api.sonarcloud.io/analysis/jres?os=linux&arch=x86_64]: 401
	at org.sonarsource.scanner.lib.internal.http.ServerConnection.callUrl(ServerConnection.java:182)
	at org.sonarsource.scanner.lib.internal.http.ServerConnection.callApi(ServerConnection.java:145)
	at org.sonarsource.scanner.lib.internal.http.ServerConnection.callRestApi(ServerConnection.java:123)
	at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.getJreMetadata(JavaRunnerFactory.java:159)
	at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.getJreFromServer(JavaRunnerFactory.java:138)
	at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.createRunner(JavaRunnerFactory.java:85)
	at org.sonarsource.scanner.lib.internal.ScannerEngineLauncherFactory.createLauncher(ScannerEngineLauncherFactory.java:53)
	at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.bootstrap(ScannerEngineBootstrapper.java:118)
	at org.sonarsource.scanner.cli.Main.analyze(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:63)
```
- new: WARN The properties 'sonar.login' and 'sonar.password' are deprecated and will be removed in the future. Please pass a token with the 'sonar.token' property instead.
- fix tests: colon removed after ERROR, INFO, WARN
- get_url_from_log: INFO is now without colon
- fix warnings in integration tests: scanner using different formats/texts
  • Loading branch information
guwirth committed Aug 20, 2024
1 parent 776c530 commit 7b516d3
Show file tree
Hide file tree
Showing 13 changed files with 428 additions and 418 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cxx-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ jobs:
java: [ '17' ]
distribution: [ 'temurin' ]
sonarqube: [ '10.6.0.92116' ]
sonarscanner: [ '5.0.1.3006' ]
sonarscanner: [ '6.1.0.4477' ]

runs-on: ${{ matrix.os }}
needs: [build-linux, verify-rules]
Expand Down Expand Up @@ -450,7 +450,7 @@ jobs:
java: [ '17' ]
distribution: [ 'temurin' ]
sonarqube: [ '10.6.0.92116' ]
sonarscanner: [ '5.0.1.3006' ]
sonarscanner: [ '6.1.0.4477' ]

runs-on: ${{ matrix.os }}
# needs build-linux because of JAR artifacts
Expand Down
7 changes: 4 additions & 3 deletions integration-tests/features/boosttest.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Feature: Providing test execution measures
And the analysis in server has completed
And the analysis log contains no error/warning messages except those matching:
"""
.*WARN.*Unable to get a valid mac address, will use a dummy address
.*WARN.*The properties 'sonar\.login' and 'sonar\.password' are deprecated and will be removed in the future.*
"""
And the following metrics have following values:
| metric | value |
Expand All @@ -57,7 +57,7 @@ Feature: Providing test execution measures
And the analysis in server has completed
And the analysis log contains no error/warning messages except those matching:
"""
.*WARN.*Unable to get a valid mac address, will use a dummy address
.*WARN.*The properties 'sonar\.login' and 'sonar\.password' are deprecated and will be removed in the future.*
"""
And the following metrics have following values:
| metric | value |
Expand All @@ -78,8 +78,9 @@ Feature: Providing test execution measures
And the analysis in server has completed
And the analysis log contains no error/warning messages except those matching:
"""
.*WARN.*Unable to get a valid mac address, will use a dummy address
.*WARN.*The properties 'sonar\.login' and 'sonar\.password' are deprecated and will be removed in the future.*
.*WARN.*cannot find the sources for '.*'
.*WARN.*Preprocessor:.*
"""
And the following metrics have following values:
| metric | value |
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/features/clangtidy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: Importing Clang-Tidy reports
And the server log (if locatable) contains no error/warning messages
And the analysis log contains no error/warning messages except those matching:
"""
.*WARN.*Unable to get a valid mac address, will use a dummy address
.*WARN.*The properties 'sonar\.login' and 'sonar\.password' are deprecated and will be removed in the future.*
"""
And the number of violations fed is <violations>
Examples:
Expand Down
10 changes: 3 additions & 7 deletions integration-tests/features/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,11 @@ def analyse_log(logpath, toignore=None):
return badlines, errors, warnings

def get_url_from_log(lines):
url = ''
for line in lines:
if 'INFO: More about the report processing at' in line:
url = line.split('INFO: More about the report processing at')[1].strip()

if 'INFO - More about the report processing at' in line:
url = line.split('INFO - More about the report processing at')[1].strip()
if 'More about the report processing at' in line:
return line.split('at ')[1].strip()

return url
return ''

def analyse_log_lines(lines, toignore=None):
badlines = []
Expand Down
10 changes: 6 additions & 4 deletions integration-tests/features/coverage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ Feature: Importing coverage data
And the analysis in server has completed
And the analysis log contains no error/warning messages except those matching:
"""
.*WARN.*Unable to get a valid mac address, will use a dummy address
.*WARN.*The properties 'sonar\.login' and 'sonar\.password' are deprecated and will be removed in the future.*
.*WARN.*cannot find the sources for '#include <iostream>'
.*WARN.*Preprocessor:.*
"""
And the following metrics have following values:
| metric | value |
Expand All @@ -29,7 +30,7 @@ Feature: Importing coverage data
And the analysis in server has completed
And the analysis log contains no error/warning messages except those matching:
"""
.*WARN.*Unable to get a valid mac address, will use a dummy address
.*WARN.*The properties 'sonar\.login' and 'sonar\.password' are deprecated and will be removed in the future.*
"""
And the following metrics have following values:
| metric | value |
Expand All @@ -51,9 +52,10 @@ Feature: Importing coverage data
And the analysis in server has completed
And the analysis log contains no error/warning messages except those matching:
"""
.*WARN.*Unable to get a valid mac address, will use a dummy address
.*WARN.*The properties 'sonar\.login' and 'sonar\.password' are deprecated and will be removed in the future.*
.*WARN.*cannot find the sources for '#include <iostream>'
.*WARN.*Cannot find a report for '.*'
.*WARN.*Property 'sonar.cxx.cobertura.reportPaths': cannot find any files.*
.*WARN.*Preprocessor:.*
"""
And the following metrics have following values:
| metric | value |
Expand Down
11 changes: 6 additions & 5 deletions integration-tests/features/cppcheck.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Feature: Importing Cppcheck reports
And the server log (if locatable) contains no error/warning messages
But the analysis log contains a line matching
"""
WARN: The 'Cppcheck V2' report is empty.*skipping
WARN The 'Cppcheck V2' report is empty.*skipping
"""
And the number of violations fed is 0

Expand All @@ -35,7 +35,7 @@ Feature: Importing Cppcheck reports
And the server log (if locatable) contains no error/warning messages
But the analysis log contains a line matching
"""
WARN: Cannot find the file.*skipping
WARN Cannot find the file 'component1\.cc'.*skipping
"""
And the number of violations fed is 0

Expand Down Expand Up @@ -70,7 +70,7 @@ Feature: Importing Cppcheck reports
And the server log (if locatable) contains no error/warning messages
But the analysis log contains a line matching
"""
WARN: The 'Cppcheck V2' report is invalid.*skipping
WARN The 'Cppcheck V2' report is invalid.*skipping
"""
And the number of violations fed is <violations>
Examples:
Expand All @@ -93,7 +93,7 @@ Feature: Importing Cppcheck reports
And the server log (if locatable) contains no error/warning messages
And the analysis log contains no error/warning messages except those matching:
"""
.*WARN.*Unable to get a valid mac address, will use a dummy address
.*WARN.*The properties 'sonar\.login' and 'sonar\.password' are deprecated and will be removed in the future.*
"""
And the number of violations fed is <violations>
Examples:
Expand All @@ -116,7 +116,8 @@ Feature: Importing Cppcheck reports
And the server log (if locatable) contains no error/warning messages
And the analysis log contains no error/warning messages except those matching:
"""
.*WARN.*Unable to get a valid mac address, will use a dummy address
.*WARN.*The properties 'sonar\.login' and 'sonar\.password' are deprecated and will be removed in the future.*
.*WARN.*Preprocessor:.*
"""
And the number of violations fed is <violations>
Examples:
Expand Down
Loading

0 comments on commit 7b516d3

Please sign in to comment.