From 8d964877c72de7c24c523333d0ec3033adf0043d Mon Sep 17 00:00:00 2001 From: Vincent Dai <23257217+vidai-msft@users.noreply.github.com> Date: Wed, 26 Apr 2023 11:19:33 +0800 Subject: [PATCH 1/2] Updated agent pool from windows to linux --- .azure-pipelines/test-coverage.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.azure-pipelines/test-coverage.yml b/.azure-pipelines/test-coverage.yml index d1e43eca23ec..e7aa0f01591a 100644 --- a/.azure-pipelines/test-coverage.yml +++ b/.azure-pipelines/test-coverage.yml @@ -1,8 +1,8 @@ parameters: -- name: windowsImage - displayName: Windows Image +- name: poolName + displayName: Pool Name type: string - default: windows-2019 + default: pool-ubuntu-2004 - name: dotnet_sdk_3_1 displayName: .NET Core 3.1 default: 3.1.x @@ -30,7 +30,7 @@ jobs: - job: TestCoverage timeoutInMinutes: 600 pool: - vmImage: ${{ parameters.windowsImage }} + name: ${{ parameters.poolName }} steps: - task: UseDotNet@2 From 39f0c117e7b145a8cb6adcdf47a19ada4d0a1acd Mon Sep 17 00:00:00 2001 From: Vincent Dai <23257217+vidai-msft@users.noreply.github.com> Date: Wed, 26 Apr 2023 20:19:40 +0800 Subject: [PATCH 2/2] Fixed Kusto util arguments issue and removed the unnecessary parameters from the list --- .azure-pipelines/test-coverage.yml | 4 +- .../Coverage/SaveTestCoverageResult.ps1 | 44 +++++-------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/.azure-pipelines/test-coverage.yml b/.azure-pipelines/test-coverage.yml index e7aa0f01591a..3ccd4781aab3 100644 --- a/.azure-pipelines/test-coverage.yml +++ b/.azure-pipelines/test-coverage.yml @@ -2,7 +2,7 @@ parameters: - name: poolName displayName: Pool Name type: string - default: pool-ubuntu-2004 + default: pool-windows-2019 - name: dotnet_sdk_3_1 displayName: .NET Core 3.1 default: 3.1.x @@ -102,7 +102,7 @@ jobs: pwsh: true targetType: filePath filePath: ./tools/TestFx/Coverage/SaveTestCoverageResult.ps1 - arguments: CITest $(Build.BuildId) $(KustoServicePrincipalTenantId) $(KustoServicePrincipalId) $(KustoServicePrincipalSecret) $(KustoClusterName) $(KustoClusterRegion) $(TestCoverageDatabaseName) $(TestCoverageTableName) $(TestCoverageLocation) + arguments: CITest $(KustoServicePrincipalTenantId) $(KustoServicePrincipalId) $(KustoServicePrincipalSecret) $(KustoClusterName) $(KustoClusterRegion) - task: PowerShell@2 displayName: Update Test Coverage Baseline diff --git a/tools/TestFx/Coverage/SaveTestCoverageResult.ps1 b/tools/TestFx/Coverage/SaveTestCoverageResult.ps1 index 9027f2e0325c..8f5723f26687 100644 --- a/tools/TestFx/Coverage/SaveTestCoverageResult.ps1 +++ b/tools/TestFx/Coverage/SaveTestCoverageResult.ps1 @@ -5,55 +5,39 @@ param ( [Parameter(Mandatory, Position = 1)] [ValidateNotNullOrEmpty()] - [string] $BuildId, - - [Parameter(Mandatory, Position = 2)] - [ValidateNotNullOrEmpty()] [guid] $KustoServicePrincipalTenantId, - [Parameter(Mandatory, Position = 3)] + [Parameter(Mandatory, Position = 2)] [ValidateNotNullOrEmpty()] [guid] $KustoServicePrincipalId, - [Parameter(Mandatory, Position = 4)] + [Parameter(Mandatory, Position = 3)] [ValidateNotNullOrEmpty()] [string] $KustoServicePrincipalSecret, - [Parameter(Mandatory, Position = 5)] + [Parameter(Mandatory, Position = 4)] [ValidateNotNullOrEmpty()] [string] $ClusterName, - [Parameter(Mandatory, Position = 6)] - [ValidateNotNullOrEmpty()] - [string] $ClusterRegion, - - [Parameter(Mandatory, Position = 7)] - [ValidateNotNullOrEmpty()] - [string] $DatabaseName, - - [Parameter(Mandatory, Position = 8)] + [Parameter(Mandatory, Position = 5)] [ValidateNotNullOrEmpty()] - [string] $TableName, - - [Parameter(Mandatory, Position = 9)] - [ValidateNotNull()] - [ValidateScript({ Test-Path -LiteralPath $_ -PathType Container })] - [string] $DataLocation + [string] $ClusterRegion ) $script:AzPSCommonParameters = @("-Break", "-Confirm", "-Debug", "-DefaultProfile", "-ErrorAction", "-ErrorVariable", "-HttpPipelineAppend", "-HttpPipelinePrepend", "-InformationAction", "-InformationVariable", "-OutBuffer", "-OutVariable", "-PassThru", "-PipelineVariable", "-Proxy", "-ProxyCredential", "-ProxyUseDefaultCredentials", "-Verbose", "-WarningAction", "-WarningVariable", "-WhatIf") -$cvgDir = Join-Path -Path $DataLocation -ChildPath "TestCoverageAnalysis" | Join-Path -ChildPath "Raw" +$cvgDir = Join-Path -Path ${env:TESTCOVERAGELOCATION} -ChildPath "TestCoverageAnalysis" | Join-Path -ChildPath "Raw" if (Test-Path -LiteralPath $cvgDir -PathType Container) { - Import-Module (Join-Path -Path ($PSScriptRoot | Split-Path) -ChildPath "Utilities" | Join-Path -ChildPath "KustoUtility.psd1") -Force + $kustoUtil = Join-Path -Path ($PSScriptRoot | Split-Path) -ChildPath "Utilities" | Join-Path -ChildPath "KustoUtility.psd1" + Import-Module $kustoUtil -ArgumentList $KustoServicePrincipalTenantId, $KustoServicePrincipalId, $KustoServicePrincipalSecret, $ClusterName, $ClusterRegion -Force $cvgRawCsv = Get-ChildItem -Path $cvgDir -Filter "*.csv" -File | Select-Object -ExpandProperty FullName $cvgRawCsv | ForEach-Object { (Import-Csv -Path $_) | Select-Object ` @{ Name = "Source"; Expression = { $Source } }, ` - @{ Name = "BuildId"; Expression = { $BuildId } }, ` + @{ Name = "BuildId"; Expression = { ${env:BUILD_BUILDID} } }, ` @{ Name = "Module"; Expression = { $_.Module } }, ` @{ Name = "CommandName"; Expression = { $_.CommandName } }, ` @{ Name = "TotalCommands"; Expression = { $_.TotalCommands } }, ` @@ -69,15 +53,7 @@ if (Test-Path -LiteralPath $cvgDir -PathType Container) { Export-Csv -Path $_ -Encoding utf8 -NoTypeInformation -Force } - Import-KustoDataFromCsv ` - -ServicePrincipalTenantId $KustoServicePrincipalTenantId ` - -ServicePrincipalId $KustoServicePrincipalId ` - -ServicePrincipalSecret $KustoServicePrincipalSecret ` - -ClusterName $ClusterName ` - -ClusterRegion $ClusterRegion ` - -DatabaseName $DatabaseName ` - -TableName $TableName ` - -CsvFile $cvgRawCsv + Import-KustoDataFromCsv -DatabaseName ${env:TESTCOVERAGEDATABASENAME} -TableName ${env:TESTCOVERAGETABLENAME} -CsvFile $cvgRawCsv } else { Write-Host "##[warning]No test coverage data was found." -ForegroundColor Yellow