Get Code Coverage from utPLSQL within Azure DevOps Pipeline? - oracle

I'm using utPLSQL 3.1.12.3589 on an Oracle 19c database.
The business logic to be tested is deployed in schema BUSINESS_LOGIC, the unit tests are deployed in schema UNIT_TESTS.
When I collect the code coverage within an Azure DevOps pipeline it seems to pick up only that from schema UNIT_TESTS. How can I get the coverage from schema BUSINESS_LOGIC?
utPLSQL-cli is called from a Powershell script (connection parameters are in the variables):
$argstr = #("run $db_user/$db_pw#$db_conn", "-f=UT_JUNIT_REPORTER", "-o=dbtest.xml", "-f=UT_COVERAGE_COBERTURA_REPORTER", "-o=dbcoverage.xml", "-f=UT_COVERAGE_HTML_REPORTER", "-o=html_coverage/coverage.html")
Start-Process -FilePath "\\my-server\utPLSQL-cli\bin\utplsql.bat" -ArgumentList $argstr -Wait -NoNewWindow
This is necessary because the tests are integrated in an Azure DevOps pipeline.
Thus the recommended approach to set the coverage does not work for me (
http://www.utplsql.org/utPLSQL/latest/userguide/coverage.html):
exec ut.run(ut_varchar2_list('BUSINESS_LOGIC'), ut_coverage_html_reporter());
I simply don't know where I could place the above statement to run the tests, gather the code coverage and report back to DevOps? I thought the command for the appropriate schema must be passed to the utPLSQL-cli?

I noticed that I used an up-to-date version of utPLSQL but not of utPLSQL-cli. Version 3.1.9 now supports a command line parameter to pass a list of coverage schemes: coverage-schemes.
This can be added to the argument list:
$argstr = #("run $db_user/$db_pw#$db_conn", ..., "--coverage-schemes=BUSINESS_LOGIC")
Now the coverage from BUSINESS_LOGIC is retrieved!

Related

Error on Publish Quality Gate Result in Azure DevOps Release pipeline

In my particular case I have to run the sonar analysis in the release, I can’t do it in the pipeline because it depends on the environment.
I have been using sonar in azure devops for several years but always running sonar from the pipeline
In this very special case I have to run the sonar in the release and this is where the error occurs.
Error in: Publish Quality Gate Result:
##[error]The "path" argument must be of type string. Received type undefined
enter image description here
enter image description here
Run Code Analysis: no Warning and no error:
enter image description here
if i run it manually on my pc it works fine:
sonar-scanner.bat -D"sonar.projectKey=SQLAA" -D"sonar.sources=Develop" -D"sonar.host.url=https://sssss.ssss.uuuu" -D"sonar.login=nnnnnnnnnnnn" -D"sonar.sql.dialect=tsql" -D"sonar.language=sql" -D"sonar.exclusions=DefinitionName/**" -D"sonar.scm.disabled=true" -D"sonar.verbose=true"
I use standalone scanner
is a simple release
enter image description here
It was tried as seen in the images, but it gives an error

Cannot use object of type Illuminate\Support\Facades\Config as array error while running test commad with coverage report

I have one project with Laravel 9 and I am performing testing with coverage report on it, The test cases successfully passed but I'm getting the below error, and if I remove --coverage-html tmp/coverage from command it's working fine. It means this error are occurring while generating a coverage report.
Please help me to figure out this issue.
Command:
XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html tmp/coverage
Error:
Generating code coverage report in HTML format ... Cannot use object of type Illuminate\Support\Facades\Config as array
Note: I haven't written any new test cases it has only default two test files which come with the default laravel setup.

Attribute error while executing jmeter script with robotframework

I am trying to execute jmeter with Robot Framework but getting attribute error when I tried to pass extra parameter. I tried below solution but it doesn't work.
How to pass values to the user defined variable in jmeter's jmx file via robot framework
Error:
robot TestCases/TC2_jmeter.robot
==============================================================================
TC2 jmeter
==============================================================================
Get_weather_info | FAIL |
AttributeError: module 'string' has no attribute 'split'
------------------------------------------------------------------------------
TC2 jmeter | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Sounds like usage of a deprecated string function
If you're using this library then it supposed to work with Python 2.7, I think you should be able to still get it, or alternatively identify and re-write the problematic piece of the library, it's open source in any case.
In general you should not need any extra libraries, it's quite possible to kick off a JMeter test in non-GUI mode or generate a HTML Reporting Dashboard using subprocess module

Job failed for Integration in GitLab (jq: error (at <stdin>:9): Cannot iterate over null (null))

I am working in GitLab and I connect my GitLab with salesforce. I created a Gitlab-ci.yml in my project directory. Now when I execute the pipeline in GitLab testing phase pass but failed in integration part at following code PACKAGE_VERSION_JSON="$(eval sfdx force:package:version:list --concise --released --packages $PACKAGE_NAME --json | jq '.result | sort_by(-.MajorVersion, -.MinorVersion, -.PatchVersion, -.BuildNumber) | .[0]? // ""')"
Can anyone tell me how can I resolve this issue. ?
Please make sure that you have generated package in the same org,which you are using for git lab authentication.

Fail VSTS build if SonarQube fails quality gate

We use VSTS build with standard SonarQube build steps:
SonarQube for MsBuild - Begin Analysis
... build
SonarQube for MsBuild - End Analysis
Some time after build I can see Analysis results in SonarQube - whether it Passed or Failed quality gate.
But the VSTS build is successful even if quality gate is Failed.
Is there a way to fail a VSTS build if quaility gate is failed?
Following this:
http://docs.sonarqube.org/display/SONAR/Breaking+the+CI+Build
I've tried looking for report-task.txt file, but I can't see it anywhere.
I can probably just run MSBuild.SonarQube.Runner.exe as command-line build step, as described here:
http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Scanner+for+MSBuild#AnalyzingwithSonarQubeScannerforMSBuild-AnalyzingfromtheCommandLine
But I thought I should first try standard Build Steps for SonarQube
Here is a link to failing the build on quality gate violations with 5.3 or later, it uses the SonarQube for MSBuild - Begin Analysis task
https://blogs.msdn.microsoft.com/visualstudioalm/2016/02/11/use-sonarqube-quality-gates-to-control-your-visual-studio-team-services-builds/
This updated task is not available with TFS 2015 Update 1 but is available in Update 2 RC1 and VSTS (VSO).
Regards,
Wes
I too had this requirement to fail the Build if sonar quality gate fails. I did created a power shell task after sonarqube display task. Here is the script to find the status:
function Get-SonarQubeStatus() {
# Step 1. Create a username:password pair
$credPair = "username:password"
# Step 2. Encode the pair to Base64 string
$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($credPair))
# Step 3. Form the header and add the Authorization attribute to it
$headers = #{ Authorization = "Basic $encodedCredentials" }
# Step 4. Make the GET request
$responseData = Invoke-WebRequest -Uri https://localhost/api/qualitygates/project_status?projectKey=<projectkey> -Method Get -Headers $headers -UseBasicParsing
#write-host $responseData.content
$x = $responseData.content | ConvertFrom-Json
$sonarQualityGateResult = $x.projectStatus.status
if($sonarQualityGateResult -eq "ERROR")
{
write-host "CI failed due to Sonarqube quality Gate"
exit 1
}
}

Resources