зеркало из https://github.com/microsoft/lisa.git
Refactor the code (XML processing) (#409)
* Refactor the code (XML processing) 1. Put XML processing code into a PS module so that the main script looks more clear. 2. Other code style change and naming change. Test passed on Azure. * Update Run-LISAv2.ps1 to remove the extra space * Address review comments for above patches
This commit is contained in:
Родитель
1097e45e9a
Коммит
2d179a1ef3
|
@ -2,11 +2,12 @@ XML/AzureSecrets.xml
|
|||
TestResults*
|
||||
TestConfiguration.xml
|
||||
Temp*
|
||||
report*
|
||||
Report*
|
||||
UploadStatusFile*
|
||||
*.azure.env
|
||||
*-buildlogs.zip
|
||||
.vscode/settings.json
|
||||
*.zip
|
||||
*.exe
|
||||
Tools/kvp_*
|
||||
Tools/jq
|
||||
|
|
|
@ -141,20 +141,20 @@ try {
|
|||
mkdir $TestResultsDir | out-null
|
||||
}
|
||||
|
||||
if (! (test-path ".\report")) {
|
||||
mkdir ".\report" | out-null
|
||||
if (! (test-path ".\Report")) {
|
||||
mkdir ".\Report" | out-null
|
||||
}
|
||||
|
||||
$testStartTime = [DateTime]::Now.ToUniversalTime()
|
||||
Set-Variable -Name testStartTime -Value $testStartTime -Scope Global
|
||||
Set-Content -Value "" -Path .\report\testSummary.html -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
Set-Content -Value "" -Path .\report\AdditionalInfo.html -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
Set-Content -Value "" -Path .\Report\testSummary.html -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
Set-Content -Value "" -Path .\Report\AdditionalInfo.html -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
Set-Variable -Name LogFile -Value $LogFile -Scope Global
|
||||
Set-Variable -Name Distro -Value $RGIdentifier -Scope Global
|
||||
Set-Variable -Name onCloud -Value $onCloud -Scope Global
|
||||
Set-Variable -Name xmlConfig -Value $xmlConfig -Scope Global
|
||||
LogMsg "'$LogDir' saved to .\report\lastLogDirectory.txt"
|
||||
Set-Content -Path .\report\lastLogDirectory.txt -Value $LogDir -Force
|
||||
LogMsg "'$LogDir' saved to .\Report\lastLogDirectory.txt"
|
||||
Set-Content -Path .\Report\lastLogDirectory.txt -Value $LogDir -Force
|
||||
Set-Variable -Name vnetIsAllConfigured -Value $false -Scope Global
|
||||
|
||||
if($DoNotDeleteVMs) {
|
||||
|
@ -216,7 +216,7 @@ try {
|
|||
$summaryAll = GetTestSummary -testCycle $testCycle -StartTime $testStartTime -xmlFileName $logDirFilename -distro $Distro -testSuiteResultDetails $testSuiteResultDetails
|
||||
$PlainTextSummary += $summaryAll[0]
|
||||
$HtmlTextSummary += $summaryAll[1]
|
||||
Set-Content -Value $HtmlTextSummary -Path .\report\testSummary.html -Force | Out-Null
|
||||
Set-Content -Value $HtmlTextSummary -Path .\Report\testSummary.html -Force | Out-Null
|
||||
$PlainTextSummary = $PlainTextSummary.Replace("<br />", "`r`n")
|
||||
$PlainTextSummary = $PlainTextSummary.Replace("<pre>", "")
|
||||
$PlainTextSummary = $PlainTextSummary.Replace("</pre>", "")
|
||||
|
|
|
@ -85,12 +85,15 @@ Function RunTestsOnCycle ($cycleName , $xmlConfig, $Distro, $TestIterations, $de
|
|||
$testSuiteResultDetails=@{"totalTc"=0;"totalPassTc"=0;"totalFailTc"=0;"totalAbortedTc"=0}
|
||||
|
||||
# Start JUnit XML report logger.
|
||||
$reportFolder = "$pwd/report"
|
||||
$reportFolder = "$pwd/Report"
|
||||
if(!(Test-Path $reportFolder)) {
|
||||
New-Item -ItemType "Directory" $reportFolder
|
||||
}
|
||||
|
||||
StartLogReport("$reportFolder/report_$($testCycle.cycleName).xml")
|
||||
$TestReportXml = Join-Path "$reportFolder" "LISAv2_TestReport_$TestID.xml"
|
||||
Set-Variable -Name TestReportXml -Value $TestReportXml -Scope Global -Force
|
||||
|
||||
StartLogReport($TestReportXml)
|
||||
$testsuite = StartLogTestSuite "CloudTesting"
|
||||
|
||||
$VmSetup = @()
|
||||
|
@ -313,7 +316,7 @@ Function RunTestsOnCycle ($cycleName , $xmlConfig, $Distro, $TestIterations, $de
|
|||
LogMsg "Cycle Finished.. $($CycleName.ToUpper())"
|
||||
|
||||
FinishLogTestSuite($testsuite)
|
||||
FinishLogReport
|
||||
FinishLogReport $True
|
||||
|
||||
$testSuiteResultDetails
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ def ExecuteTest( JenkinsUser, UpstreamBuildNumber, ImageSource, CustomVHD, Custo
|
|||
" -EnableAcceleratedNetworking"
|
||||
)
|
||||
archiveArtifacts '*-buildlogs.zip'
|
||||
junit "report\\*-junit.xml"
|
||||
junit "Report\\*-junit.xml"
|
||||
emailext body: '${SCRIPT, template="groovy-html.template"}', replyTo: '$DEFAULT_REPLYTO', subject: "${ImageSource}", to: "${Email}"
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ def ExecuteTest( JenkinsUser, UpstreamBuildNumber, ImageSource, CustomVHD, Custo
|
|||
" -OverrideVMSize '${VMSize}'"
|
||||
)
|
||||
archiveArtifacts '*-buildlogs.zip'
|
||||
junit "report\\*-junit.xml"
|
||||
junit "Report\\*-junit.xml"
|
||||
emailext body: '${SCRIPT, template="groovy-html.template"}', replyTo: '$DEFAULT_REPLYTO', subject: "${ImageSource}", to: "${Email}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ def ExecuteTest( JenkinsUser, UpstreamBuildNumber, ImageSource, CustomVHD, Custo
|
|||
" -TestNames '${Testname}'"
|
||||
)
|
||||
archiveArtifacts '*-buildlogs.zip'
|
||||
junit "report\\*-junit.xml"
|
||||
junit "Report\\*-junit.xml"
|
||||
emailext body: '${SCRIPT, template="groovy-html.template"}', replyTo: '$DEFAULT_REPLYTO', subject: "${ImageSource}", to: "${Email}"
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ def ExecuteTest( JenkinsUser, UpstreamBuildNumber, ImageSource, CustomVHD, Custo
|
|||
" -TestNames '${TestName}'"
|
||||
)
|
||||
archiveArtifacts '*-buildlogs.zip'
|
||||
junit "report\\*-junit.xml"
|
||||
junit "Report\\*-junit.xml"
|
||||
emailext body: '${SCRIPT, template="groovy-html.template"}', replyTo: '$DEFAULT_REPLYTO', subject: "${ImageSource}", to: "${Email}"
|
||||
}
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ def ExecuteTest( JenkinsUser, UpstreamBuildNumber, ImageSource, CustomVHD, Custo
|
|||
FinalImageSource
|
||||
)
|
||||
archiveArtifacts '*-buildlogs.zip'
|
||||
junit "report\\*-junit.xml"
|
||||
junit "Report\\*-junit.xml"
|
||||
emailext body: '${SCRIPT, template="groovy-html.template"}', replyTo: '$DEFAULT_REPLYTO', subject: "${ImageSource}", to: "${Email}"
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ def ExecuteTest( JenkinsUser, UpstreamBuildNumber, ImageSource, CustomVHD, Custo
|
|||
FinalImageSource
|
||||
)
|
||||
archiveArtifacts '*-buildlogs.zip'
|
||||
junit "report\\*-junit.xml"
|
||||
junit "Report\\*-junit.xml"
|
||||
emailext body: '${SCRIPT, template="groovy-html.template"}', replyTo: '$DEFAULT_REPLYTO', subject: "${ImageSource}", to: "${Email}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ Param(
|
|||
$DestinationPath = ".\"
|
||||
)
|
||||
Get-ChildItem .\Libraries -Recurse | Where-Object { $_.FullName.EndsWith(".psm1") } | ForEach-Object { Import-Module $_.FullName -Force -Global -DisableNameChecking }
|
||||
ValidateXmlFiles -ParentFolder ".\"
|
||||
Validate-XmlFiles -ParentFolder ".\"
|
||||
|
||||
$xmlData = @()
|
||||
foreach ( $file in (Get-ChildItem -Path .\XML\TestCases\*.xml ))
|
||||
|
|
|
@ -109,30 +109,6 @@ Function LogWarn($text)
|
|||
Write-Log "WARN" $text
|
||||
}
|
||||
|
||||
Function ValidateXmlFiles( [string]$ParentFolder )
|
||||
{
|
||||
LogMsg "Validating XML Files from $ParentFolder folder recursively..."
|
||||
$allXmls = Get-ChildItem "$ParentFolder\*.xml" -Recurse
|
||||
$xmlErrorFiles = @()
|
||||
foreach ($file in $allXmls)
|
||||
{
|
||||
try
|
||||
{
|
||||
$null = [xml](Get-Content $file.FullName)
|
||||
}
|
||||
catch
|
||||
{
|
||||
LogError -text "$($file.FullName) validation failed."
|
||||
$xmlErrorFiles += $file.FullName
|
||||
}
|
||||
}
|
||||
if ( $xmlErrorFiles.Count -gt 0 )
|
||||
{
|
||||
$xmlErrorFiles | ForEach-Object -Process {LogMsg $_}
|
||||
Throw "Please fix above ($($xmlErrorFiles.Count)) XML files."
|
||||
}
|
||||
}
|
||||
|
||||
Function ProvisionVMsForLisa($allVMData, $installPackagesOnRoleNames)
|
||||
{
|
||||
$keysGenerated = $false
|
||||
|
@ -382,8 +358,8 @@ function InstallCustomKernel ($CustomKernel, $allVMData, [switch]$RestartAfterUp
|
|||
{
|
||||
$isKernelUpgraded = $true
|
||||
}
|
||||
Add-Content -Value "Old kernel: $currentKernelVersion" -Path .\report\AdditionalInfo.html -Force
|
||||
Add-Content -Value "New kernel: $upgradedKernelVersion" -Path .\report\AdditionalInfo.html -Force
|
||||
Add-Content -Value "Old kernel: $currentKernelVersion" -Path .\Report\AdditionalInfo.html -Force
|
||||
Add-Content -Value "New kernel: $upgradedKernelVersion" -Path .\Report\AdditionalInfo.html -Force
|
||||
return $isKernelUpgraded
|
||||
}
|
||||
}
|
||||
|
@ -484,8 +460,8 @@ function InstallcustomLIS ($CustomLIS, $customLISBranch, $allVMData, [switch]$Re
|
|||
$upgradedlisVersion = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username "root" -password $password -command "modinfo hv_vmbus"
|
||||
LogMsg "Old lis: $currentlisVersion"
|
||||
LogMsg "New lis: $upgradedlisVersion"
|
||||
Add-Content -Value "Old lis: $currentlisVersion" -Path .\report\AdditionalInfo.html -Force
|
||||
Add-Content -Value "New lis: $upgradedlisVersion" -Path .\report\AdditionalInfo.html -Force
|
||||
Add-Content -Value "Old lis: $currentlisVersion" -Path .\Report\AdditionalInfo.html -Force
|
||||
Add-Content -Value "New lis: $upgradedlisVersion" -Path .\Report\AdditionalInfo.html -Force
|
||||
return $true
|
||||
}
|
||||
else
|
||||
|
@ -2492,18 +2468,20 @@ Function GetFilePathsFromLinuxFolder ([string]$folderToSearch, $IpAddress, $SSHP
|
|||
return $LogFilesPaths, $LogFiles
|
||||
}
|
||||
|
||||
function ZipFiles( $zipfilename, $sourcedir )
|
||||
function New-ZipFile( $zipFileName, $sourceDir )
|
||||
{
|
||||
LogMsg "Creating '$zipfilename' from '$sourcedir'"
|
||||
LogMsg "Creating '$zipFileName' from '$sourceDir'"
|
||||
$currentDir = (Get-Location).Path
|
||||
$7z = (Get-ChildItem .\Tools\7za.exe).FullName
|
||||
$sourcedir = $sourcedir.Trim('\')
|
||||
Set-Location $sourcedir
|
||||
$out = Invoke-Expression "$7z a -mx5 $currentDir\$zipfilename * -r"
|
||||
$sourceDir = $sourceDir.Trim('\')
|
||||
Set-Location $sourceDir
|
||||
$out = Invoke-Expression "$7z a -mx5 $currentDir\$zipFileName * -r"
|
||||
Set-Location $currentDir
|
||||
if ($out -match "Everything is Ok")
|
||||
{
|
||||
LogMsg "$currentDir\$zipfilename created successfully."
|
||||
if ($out -match "Everything is Ok") {
|
||||
LogMsg "$currentDir\$zipFileName created successfully."
|
||||
} else {
|
||||
LogErr "Unexpected output from 7za.exe when creating $currentDir\$zipFileName :"
|
||||
LogErr $out
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,37 +104,36 @@ function Validate-Parameters {
|
|||
}
|
||||
}
|
||||
|
||||
Function Add-ReplaceableTestParameters($XmlConfigFilePath)
|
||||
Function Inject-CustomTestParameters($CustomParameters, $ReplaceableTestParameters, $TestConfigurationXmlFile)
|
||||
{
|
||||
$ReplacableTestParameters = [xml](Get-Content -Path "$WorkingDirectory\XML\Other\ReplaceableTestParameters.xml")
|
||||
if ($CustomParameters)
|
||||
{
|
||||
LogMsg "Checking custom parameters"
|
||||
LogMsg "Checking custom parameters ..."
|
||||
$CustomParameters = $CustomParameters.Trim().Trim(";").Split(";")
|
||||
foreach ($CustomParameter in $CustomParameters)
|
||||
{
|
||||
$CustomParameter = $CustomParameter.Trim()
|
||||
$ReplaceThis = $CustomParameter.Split("=")[0]
|
||||
$ReplaceWith = $CustomParameter.Split("=")[1]
|
||||
$OldValue = ($ReplacableTestParameters.ReplaceableTestParameters.Parameter | Where-Object `
|
||||
{ $_.ReplaceThis -eq $ReplaceThis }).ReplaceWith
|
||||
($ReplacableTestParameters.ReplaceableTestParameters.Parameter | Where-Object `
|
||||
{ $_.ReplaceThis -eq $ReplaceThis }).ReplaceWith = $ReplaceWith
|
||||
$OldValue = ($ReplaceableTestParameters.ReplaceableTestParameters.Parameter | Where-Object `
|
||||
{ $_.ReplaceThis -eq $ReplaceThis }).ReplaceWith
|
||||
($ReplaceableTestParameters.ReplaceableTestParameters.Parameter | Where-Object `
|
||||
{ $_.ReplaceThis -eq $ReplaceThis }).ReplaceWith = $ReplaceWith
|
||||
LogMsg "Custom Parameter: $ReplaceThis=$OldValue --> $ReplaceWith"
|
||||
}
|
||||
LogMsg "Custom parameter(s) are ready to be injected along with default parameters, if any."
|
||||
}
|
||||
|
||||
$XmlConfigContents = (Get-Content -Path $XmlConfigFilePath)
|
||||
foreach ($ReplaceableParameter in $ReplacableTestParameters.ReplaceableTestParameters.Parameter)
|
||||
$XmlConfigContents = (Get-Content -Path $TestConfigurationXmlFile)
|
||||
foreach ($ReplaceableParameter in $ReplaceableTestParameters.ReplaceableTestParameters.Parameter)
|
||||
{
|
||||
if ($XmlConfigContents -match $ReplaceableParameter.ReplaceThis)
|
||||
{
|
||||
$XmlConfigContents = $XmlConfigContents.Replace($ReplaceableParameter.ReplaceThis,$ReplaceableParameter.ReplaceWith)
|
||||
LogMsg "$($ReplaceableParameter.ReplaceThis)=$($ReplaceableParameter.ReplaceWith) injected into $XmlConfigFilePath"
|
||||
LogMsg "$($ReplaceableParameter.ReplaceThis)=$($ReplaceableParameter.ReplaceWith) injected into $TestConfigurationXmlFile"
|
||||
}
|
||||
}
|
||||
Set-Content -Value $XmlConfigContents -Path $XmlConfigFilePath -Force
|
||||
Set-Content -Value $XmlConfigContents -Path $TestConfigurationXmlFile -Force
|
||||
}
|
||||
|
||||
Function UpdateGlobalConfigurationXML($XmlSecretsFilePath)
|
||||
|
@ -633,7 +632,7 @@ Function StartLogReport([string]$reportPath)
|
|||
}
|
||||
else
|
||||
{
|
||||
throw "CI report has been created."
|
||||
throw "LISAv2 test report has been created."
|
||||
}
|
||||
|
||||
return $junitReport
|
||||
|
@ -941,7 +940,7 @@ Function Get-SQLQueryOfTelemetryData ($TestPlatform,$TestLocation,$TestCategory,
|
|||
$testLogFolder = "$($UTCTime.Year)-$($UTCTime.Month)-$($UTCTime.Day)"
|
||||
$ticks= (Get-Date).Ticks
|
||||
$uploadFileName = Join-Path $env:TEMP "$TestName-$ticks.zip"
|
||||
$null = ZipFiles -zipfilename $uploadFileName -sourcedir $LogDir
|
||||
$null = New-ZipFile -zipFileName $uploadFileName -sourceDir $LogDir
|
||||
$UploadedURL = .\Utilities\UploadFilesToStorageAccount.ps1 -filePaths $uploadFileName `
|
||||
-destinationStorageAccount $testLogStorageAccount -destinationContainer "lisav2logs" `
|
||||
-destinationFolder "$testLogFolder" -destinationStorageKey $testLogStorageAccountKey
|
||||
|
|
|
@ -0,0 +1,221 @@
|
|||
##############################################################################################
|
||||
# XmlProcessing.psm1
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the Apache License.
|
||||
# Operations :
|
||||
#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
PS modules for Azure test automation
|
||||
|
||||
.PARAMETER
|
||||
<Parameters>
|
||||
|
||||
.INPUTS
|
||||
|
||||
|
||||
.NOTES
|
||||
Creation Date:
|
||||
Purpose/Change:
|
||||
|
||||
.EXAMPLE
|
||||
|
||||
|
||||
#>
|
||||
###############################################################################################
|
||||
|
||||
Function Import-TestCases($WorkingDirectory, $TestConfigurationXmlFile) {
|
||||
# Consolidate all test cases into a unified test xml file
|
||||
$TestXMLs = Get-ChildItem -Path "$WorkingDirectory\XML\TestCases\*.xml"
|
||||
$SetupTypeXMLs = Get-ChildItem -Path "$WorkingDirectory\XML\VMConfigurations\*.xml"
|
||||
$AllLisaTests = @()
|
||||
$ARMImage = $ARMImageName.Trim().Split(" ")
|
||||
if ( $TestCategory -eq "All") { $TestCategory = "" }
|
||||
if ( $TestArea -eq "All") { $TestArea = "" }
|
||||
if ( $TestNames -eq "All") { $TestNames = "" }
|
||||
if ( $TestTag -eq "All") { $TestTag = "" }
|
||||
|
||||
$AllLisaTests = CollectTestCases -TestXMLs $TestXMLs
|
||||
if( !$AllLisaTests.innerXML ) {
|
||||
Throw "Specified -TestNames or -TestCategory not found"
|
||||
}
|
||||
|
||||
$SetupTypes = $AllLisaTests.SetupType | Sort-Object | Get-Unique
|
||||
|
||||
$tab = CreateArrayOfTabs
|
||||
$TestCycle = "TC-$TestID"
|
||||
$GlobalConfiguration = [xml](Get-content .\XML\GlobalConfigurations.xml)
|
||||
<##########################################################################
|
||||
We're following the Indentation of the XML file to make XML creation easier.
|
||||
##########################################################################>
|
||||
$xmlContent = ("$($tab[0])" + '<?xml version="1.0" encoding="utf-8"?>')
|
||||
$xmlContent += ("$($tab[0])" + "<config>`n")
|
||||
$xmlContent += ("$($tab[0])" + "<CurrentTestPlatform>$TestPlatform</CurrentTestPlatform>`n")
|
||||
if ($TestPlatform -eq "Azure") {
|
||||
$xmlContent += ("$($tab[1])" + "<Azure>`n")
|
||||
# Add Subscription Details
|
||||
$xmlContent += ("$($tab[2])" + "<General>`n")
|
||||
|
||||
foreach ( $line in $GlobalConfiguration.Global.$TestPlatform.Subscription.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[3])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "<Location>$TestLocation</Location>`n")
|
||||
$xmlContent += ("$($tab[2])" + "</General>`n")
|
||||
|
||||
# Database details
|
||||
$xmlContent += ("$($tab[2])" + "<database>`n")
|
||||
foreach ( $line in $GlobalConfiguration.Global.$TestPlatform.ResultsDatabase.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[3])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</database>`n")
|
||||
|
||||
# Deployment details
|
||||
$xmlContent += ("$($tab[2])" + "<Deployment>`n")
|
||||
$xmlContent += ("$($tab[3])" + "<Data>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<Distro>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<Name>$RGIdentifier</Name>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<ARMImage>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Publisher>" + "$($ARMImage[0])" + "</Publisher>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Offer>" + "$($ARMImage[1])" + "</Offer>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Sku>" + "$($ARMImage[2])" + "</Sku>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Version>" + "$($ARMImage[3])" + "</Version>`n")
|
||||
$xmlContent += ("$($tab[5])" + "</ARMImage>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<OsVHD>" + "$OsVHD" + "</OsVHD>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<VMGeneration>" + "$VMGeneration" + "</VMGeneration>`n")
|
||||
$xmlContent += ("$($tab[4])" + "</Distro>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<UserName>" + "$($GlobalConfiguration.Global.$TestPlatform.TestCredentials.LinuxUsername)" + "</UserName>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<Password>" + "$($GlobalConfiguration.Global.$TestPlatform.TestCredentials.LinuxPassword)" + "</Password>`n")
|
||||
$xmlContent += ("$($tab[3])" + "</Data>`n")
|
||||
|
||||
foreach ( $file in $SetupTypeXMLs.FullName) {
|
||||
foreach ( $SetupType in $SetupTypes ) {
|
||||
$CurrentSetupType = ([xml]( Get-Content -Path $file)).TestSetup
|
||||
if ($null -ne $CurrentSetupType.$SetupType) {
|
||||
$SetupTypeElement = $CurrentSetupType.$SetupType
|
||||
$xmlContent += ("$($tab[3])" + "<$SetupType>`n")
|
||||
#$xmlContent += ("$($tab[4])" + "$($SetupTypeElement.InnerXml)`n")
|
||||
foreach ( $line in $SetupTypeElement.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[4])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[3])" + "</$SetupType>`n")
|
||||
}
|
||||
}
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</Deployment>`n")
|
||||
$xmlContent += ("$($tab[1])" + "</Azure>`n")
|
||||
} elseif ($TestPlatform -eq "Hyperv") {
|
||||
$xmlContent += ("$($tab[1])" + "<Hyperv>`n")
|
||||
# Add Hosts Details
|
||||
$xmlContent += ("$($tab[2])" + "<Hosts>`n")
|
||||
$xmlContent += ("$($tab[3])" + "<Host>`n")
|
||||
foreach ( $line in $GlobalConfiguration.Global.HyperV.Hosts.FirstChild.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[4])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[3])" + "</Host>`n")
|
||||
|
||||
if($TestLocation -and $TestLocation.split(',').Length -eq 2){
|
||||
$xmlContent += ("$($tab[3])" + "<Host>`n")
|
||||
foreach ( $line in $GlobalConfiguration.Global.HyperV.Hosts.LastChild.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[4])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[3])" + "</Host>`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</Hosts>`n")
|
||||
|
||||
# Database details
|
||||
$xmlContent += ("$($tab[2])" + "<database>`n")
|
||||
foreach ( $line in $GlobalConfiguration.Global.HyperV.ResultsDatabase.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[3])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</database>`n")
|
||||
|
||||
# Deployment details
|
||||
$xmlContent += ("$($tab[2])" + "<Deployment>`n")
|
||||
$xmlContent += ("$($tab[3])" + "<Data>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<Distro>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<Name>$RGIdentifier</Name>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<ARMImage>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Publisher>" + "$($ARMImage[0])" + "</Publisher>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Offer>" + "$($ARMImage[1])" + "</Offer>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Sku>" + "$($ARMImage[2])" + "</Sku>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Version>" + "$($ARMImage[3])" + "</Version>`n")
|
||||
$xmlContent += ("$($tab[5])" + "</ARMImage>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<OsVHD>" + "$OsVHD" + "</OsVHD>`n")
|
||||
$xmlContent += ("$($tab[4])" + "</Distro>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<UserName>" + "$($GlobalConfiguration.Global.$TestPlatform.TestCredentials.LinuxUsername)" + "</UserName>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<Password>" + "$($GlobalConfiguration.Global.$TestPlatform.TestCredentials.LinuxPassword)" + "</Password>`n")
|
||||
$xmlContent += ("$($tab[3])" + "</Data>`n")
|
||||
|
||||
foreach ( $file in $SetupTypeXMLs.FullName) {
|
||||
foreach ( $SetupType in $SetupTypes ) {
|
||||
$CurrentSetupType = ([xml]( Get-Content -Path $file)).TestSetup
|
||||
if ($null -ne $CurrentSetupType.$SetupType) {
|
||||
$SetupTypeElement = $CurrentSetupType.$SetupType
|
||||
$xmlContent += ("$($tab[3])" + "<$SetupType>`n")
|
||||
#$xmlContent += ("$($tab[4])" + "$($SetupTypeElement.InnerXml)`n")
|
||||
foreach ( $line in $SetupTypeElement.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[4])" + "$line`n")
|
||||
}
|
||||
|
||||
$xmlContent += ("$($tab[3])" + "</$SetupType>`n")
|
||||
}
|
||||
}
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</Deployment>`n")
|
||||
$xmlContent += ("$($tab[1])" + "</Hyperv>`n")
|
||||
}
|
||||
# TestDefinition
|
||||
$xmlContent += ("$($tab[1])" + "<testsDefinition>`n")
|
||||
foreach ( $currentTest in $AllLisaTests) {
|
||||
if ($currentTest.Platform.Contains($TestPlatform)) {
|
||||
$xmlContent += ("$($tab[2])" + "<test>`n")
|
||||
foreach ( $line in $currentTest.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[3])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</test>`n")
|
||||
} else {
|
||||
LogErr "*** UNSUPPORTED TEST *** : $currentTest. Skipped."
|
||||
}
|
||||
}
|
||||
$xmlContent += ("$($tab[1])" + "</testsDefinition>`n")
|
||||
|
||||
# TestCycle
|
||||
$xmlContent += ("$($tab[1])" + "<testCycles>`n")
|
||||
$xmlContent += ("$($tab[2])" + "<Cycle>`n")
|
||||
$xmlContent += ("$($tab[3])" + "<cycleName>$TestCycle</cycleName>`n")
|
||||
foreach ( $currentTest in $AllLisaTests) {
|
||||
$line = $currentTest.TestName
|
||||
$xmlContent += ("$($tab[3])" + "<test>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<Name>$line</Name>`n")
|
||||
$xmlContent += ("$($tab[3])" + "</test>`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</Cycle>`n")
|
||||
$xmlContent += ("$($tab[1])" + "</testCycles>`n")
|
||||
$xmlContent += ("$($tab[0])" + "</config>`n")
|
||||
Set-Content -Value $xmlContent -Path $TestConfigurationXmlFile -Force
|
||||
LogMsg "Test cases are scanned and imported to $TestConfigurationXmlFile"
|
||||
}
|
||||
|
||||
Function Validate-XmlFiles( [string]$ParentFolder )
|
||||
{
|
||||
LogMsg "Validating XML Files from $ParentFolder folder recursively..."
|
||||
$allXmls = Get-ChildItem "$ParentFolder\*.xml" -Recurse
|
||||
$xmlErrorFiles = @()
|
||||
foreach ($file in $allXmls)
|
||||
{
|
||||
try
|
||||
{
|
||||
$null = [xml](Get-Content $file.FullName)
|
||||
}
|
||||
catch
|
||||
{
|
||||
LogError -text "$($file.FullName) validation failed."
|
||||
$xmlErrorFiles += $file.FullName
|
||||
}
|
||||
}
|
||||
if ( $xmlErrorFiles.Count -gt 0 )
|
||||
{
|
||||
$xmlErrorFiles | ForEach-Object -Process {LogMsg $_}
|
||||
Throw "Please fix above ($($xmlErrorFiles.Count)) XML files."
|
||||
}
|
||||
}
|
206
Run-LisaV2.ps1
206
Run-LisaV2.ps1
|
@ -114,7 +114,7 @@ try {
|
|||
New-Item -ItemType Directory -Path $tempWorkingDir -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
$tmpSource = '\\?\' + "$OriginalWorkingDirectory\*"
|
||||
Write-Output "Copying current workspace to $tempWorkingDir"
|
||||
$excludedDirectories = @(".git", "Documents", ".github", "report", "TestResults", "VHDs_Destination_Path", "*.zip", "report")
|
||||
$excludedDirectories = @(".git", "Documents", ".github", "Report", "TestResults", "VHDs_Destination_Path", "*.zip")
|
||||
Copy-Item -Path $tmpSource -Destination $tempWorkingDir -Recurse -Force -Exclude $excludedDirectories | Out-Null
|
||||
Set-Location -Path $tempWorkingDir | Out-Null
|
||||
Write-Output "Working directory has been changed to $tempWorkingDir"
|
||||
|
@ -195,194 +195,24 @@ try {
|
|||
LogErr "Failed to update configuration files. '-XMLSecretFile [FilePath]' is not provided."
|
||||
}
|
||||
|
||||
ValidateXmlFiles -ParentFolder $WorkingDirectory
|
||||
Validate-XmlFiles -ParentFolder $WorkingDirectory
|
||||
|
||||
# Consolidate all test cases into a unified test xml file
|
||||
$TestXMLs = Get-ChildItem -Path "$WorkingDirectory\XML\TestCases\*.xml"
|
||||
$SetupTypeXMLs = Get-ChildItem -Path "$WorkingDirectory\XML\VMConfigurations\*.xml"
|
||||
$AllLisaTests = @()
|
||||
$ARMImage = $ARMImageName.Trim().Split(" ")
|
||||
$TestConfigurationXmlFile = "$WorkingDirectory\TestConfiguration.xml"
|
||||
if ( $TestCategory -eq "All") { $TestCategory = "" }
|
||||
if ( $TestArea -eq "All") { $TestArea = "" }
|
||||
if ( $TestNames -eq "All") { $TestNames = "" }
|
||||
if ( $TestTag -eq "All") { $TestTag = "" }
|
||||
|
||||
$AllLisaTests = CollectTestCases -TestXMLs $TestXMLs
|
||||
if( !$AllLisaTests.innerXML ) {
|
||||
Throw "Specified -TestNames or -TestCategory not found"
|
||||
}
|
||||
|
||||
$SetupTypes = $AllLisaTests.SetupType | Sort-Object | Get-Unique
|
||||
|
||||
#region Create the Test XML file
|
||||
$tab = CreateArrayOfTabs
|
||||
$TestCycle = "TC-$TestID"
|
||||
$GlobalConfiguration = [xml](Get-content .\XML\GlobalConfigurations.xml)
|
||||
<##########################################################################
|
||||
We're following the Indentation of the XML file to make XML creation easier.
|
||||
##########################################################################>
|
||||
$xmlContent = ("$($tab[0])" + '<?xml version="1.0" encoding="utf-8"?>')
|
||||
$xmlContent += ("$($tab[0])" + "<config>`n")
|
||||
$xmlContent += ("$($tab[0])" + "<CurrentTestPlatform>$TestPlatform</CurrentTestPlatform>`n")
|
||||
if ($TestPlatform -eq "Azure") {
|
||||
$xmlContent += ("$($tab[1])" + "<Azure>`n")
|
||||
# Add Subscription Details
|
||||
$xmlContent += ("$($tab[2])" + "<General>`n")
|
||||
|
||||
foreach ( $line in $GlobalConfiguration.Global.$TestPlatform.Subscription.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[3])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "<Location>$TestLocation</Location>`n")
|
||||
$xmlContent += ("$($tab[2])" + "</General>`n")
|
||||
|
||||
# Database details
|
||||
$xmlContent += ("$($tab[2])" + "<database>`n")
|
||||
foreach ( $line in $GlobalConfiguration.Global.$TestPlatform.ResultsDatabase.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[3])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</database>`n")
|
||||
|
||||
# Deployment details
|
||||
$xmlContent += ("$($tab[2])" + "<Deployment>`n")
|
||||
$xmlContent += ("$($tab[3])" + "<Data>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<Distro>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<Name>$RGIdentifier</Name>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<ARMImage>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Publisher>" + "$($ARMImage[0])" + "</Publisher>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Offer>" + "$($ARMImage[1])" + "</Offer>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Sku>" + "$($ARMImage[2])" + "</Sku>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Version>" + "$($ARMImage[3])" + "</Version>`n")
|
||||
$xmlContent += ("$($tab[5])" + "</ARMImage>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<OsVHD>" + "$OsVHD" + "</OsVHD>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<VMGeneration>" + "$VMGeneration" + "</VMGeneration>`n")
|
||||
$xmlContent += ("$($tab[4])" + "</Distro>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<UserName>" + "$($GlobalConfiguration.Global.$TestPlatform.TestCredentials.LinuxUsername)" + "</UserName>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<Password>" + "$($GlobalConfiguration.Global.$TestPlatform.TestCredentials.LinuxPassword)" + "</Password>`n")
|
||||
$xmlContent += ("$($tab[3])" + "</Data>`n")
|
||||
|
||||
foreach ( $file in $SetupTypeXMLs.FullName) {
|
||||
foreach ( $SetupType in $SetupTypes ) {
|
||||
$CurrentSetupType = ([xml]( Get-Content -Path $file)).TestSetup
|
||||
if ($null -ne $CurrentSetupType.$SetupType) {
|
||||
$SetupTypeElement = $CurrentSetupType.$SetupType
|
||||
$xmlContent += ("$($tab[3])" + "<$SetupType>`n")
|
||||
#$xmlContent += ("$($tab[4])" + "$($SetupTypeElement.InnerXml)`n")
|
||||
foreach ( $line in $SetupTypeElement.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[4])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[3])" + "</$SetupType>`n")
|
||||
}
|
||||
}
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</Deployment>`n")
|
||||
$xmlContent += ("$($tab[1])" + "</Azure>`n")
|
||||
} elseif ($TestPlatform -eq "Hyperv") {
|
||||
$xmlContent += ("$($tab[1])" + "<Hyperv>`n")
|
||||
# Add Hosts Details
|
||||
$xmlContent += ("$($tab[2])" + "<Hosts>`n")
|
||||
$xmlContent += ("$($tab[3])" + "<Host>`n")
|
||||
foreach ( $line in $GlobalConfiguration.Global.HyperV.Hosts.FirstChild.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[4])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[3])" + "</Host>`n")
|
||||
|
||||
if($TestLocation -and $TestLocation.split(',').Length -eq 2){
|
||||
$xmlContent += ("$($tab[3])" + "<Host>`n")
|
||||
foreach ( $line in $GlobalConfiguration.Global.HyperV.Hosts.LastChild.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[4])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[3])" + "</Host>`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</Hosts>`n")
|
||||
|
||||
# Database details
|
||||
$xmlContent += ("$($tab[2])" + "<database>`n")
|
||||
foreach ( $line in $GlobalConfiguration.Global.HyperV.ResultsDatabase.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[3])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</database>`n")
|
||||
|
||||
# Deployment details
|
||||
$xmlContent += ("$($tab[2])" + "<Deployment>`n")
|
||||
$xmlContent += ("$($tab[3])" + "<Data>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<Distro>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<Name>$RGIdentifier</Name>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<ARMImage>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Publisher>" + "$($ARMImage[0])" + "</Publisher>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Offer>" + "$($ARMImage[1])" + "</Offer>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Sku>" + "$($ARMImage[2])" + "</Sku>`n")
|
||||
$xmlContent += ("$($tab[6])" + "<Version>" + "$($ARMImage[3])" + "</Version>`n")
|
||||
$xmlContent += ("$($tab[5])" + "</ARMImage>`n")
|
||||
$xmlContent += ("$($tab[5])" + "<OsVHD>" + "$OsVHD" + "</OsVHD>`n")
|
||||
$xmlContent += ("$($tab[4])" + "</Distro>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<UserName>" + "$($GlobalConfiguration.Global.$TestPlatform.TestCredentials.LinuxUsername)" + "</UserName>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<Password>" + "$($GlobalConfiguration.Global.$TestPlatform.TestCredentials.LinuxPassword)" + "</Password>`n")
|
||||
$xmlContent += ("$($tab[3])" + "</Data>`n")
|
||||
|
||||
foreach ( $file in $SetupTypeXMLs.FullName) {
|
||||
foreach ( $SetupType in $SetupTypes ) {
|
||||
$CurrentSetupType = ([xml]( Get-Content -Path $file)).TestSetup
|
||||
if ($null -ne $CurrentSetupType.$SetupType) {
|
||||
$SetupTypeElement = $CurrentSetupType.$SetupType
|
||||
$xmlContent += ("$($tab[3])" + "<$SetupType>`n")
|
||||
#$xmlContent += ("$($tab[4])" + "$($SetupTypeElement.InnerXml)`n")
|
||||
foreach ( $line in $SetupTypeElement.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[4])" + "$line`n")
|
||||
}
|
||||
|
||||
$xmlContent += ("$($tab[3])" + "</$SetupType>`n")
|
||||
}
|
||||
}
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</Deployment>`n")
|
||||
$xmlContent += ("$($tab[1])" + "</Hyperv>`n")
|
||||
}
|
||||
# TestDefinition
|
||||
$xmlContent += ("$($tab[1])" + "<testsDefinition>`n")
|
||||
foreach ( $currentTest in $AllLisaTests) {
|
||||
if ($currentTest.Platform.Contains($TestPlatform)) {
|
||||
$xmlContent += ("$($tab[2])" + "<test>`n")
|
||||
foreach ( $line in $currentTest.InnerXml.Replace("><",">`n<").Split("`n")) {
|
||||
$xmlContent += ("$($tab[3])" + "$line`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</test>`n")
|
||||
} else {
|
||||
LogErr "*** UNSUPPORTED TEST *** : $currentTest. Skipped."
|
||||
}
|
||||
}
|
||||
$xmlContent += ("$($tab[1])" + "</testsDefinition>`n")
|
||||
|
||||
# TestCycle
|
||||
$xmlContent += ("$($tab[1])" + "<testCycles>`n")
|
||||
$xmlContent += ("$($tab[2])" + "<Cycle>`n")
|
||||
$xmlContent += ("$($tab[3])" + "<cycleName>$TestCycle</cycleName>`n")
|
||||
foreach ( $currentTest in $AllLisaTests) {
|
||||
$line = $currentTest.TestName
|
||||
$xmlContent += ("$($tab[3])" + "<test>`n")
|
||||
$xmlContent += ("$($tab[4])" + "<Name>$line</Name>`n")
|
||||
$xmlContent += ("$($tab[3])" + "</test>`n")
|
||||
}
|
||||
$xmlContent += ("$($tab[2])" + "</Cycle>`n")
|
||||
$xmlContent += ("$($tab[1])" + "</testCycles>`n")
|
||||
$xmlContent += ("$($tab[0])" + "</config>`n")
|
||||
Set-Content -Value $xmlContent -Path $TestConfigurationXmlFile -Force
|
||||
Import-TestCases $WorkingDirectory $TestConfigurationXmlFile
|
||||
|
||||
#This function will inject default / custom replaceable test parameters to TestConfiguration.xml
|
||||
Add-ReplaceableTestParameters -XmlConfigFilePath $TestConfigurationXmlFile
|
||||
$ReplaceableTestParameters = [xml](Get-Content -Path "$WorkingDirectory\XML\Other\ReplaceableTestParameters.xml")
|
||||
Inject-CustomTestParameters $CustomParameters $ReplaceableTestParameters $TestConfigurationXmlFile
|
||||
|
||||
try {
|
||||
$xmlConfig = [xml](Get-Content $TestConfigurationXmlFile)
|
||||
$xmlConfig.Save("$TestConfigurationXmlFile")
|
||||
LogMsg "Auto created $TestConfigurationXmlFile validated successfully."
|
||||
} catch {
|
||||
Throw "Framework error: $TestConfigurationXmlFile is not valid. Please report to lisasupport@microsoft.com"
|
||||
Throw "Framework error: $TestConfigurationXmlFile is not valid."
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Prepare execution command
|
||||
$command = ".\AutomationManager.ps1 -xmlConfigFile '$TestConfigurationXmlFile' -cycleName 'TC-$TestID' -RGIdentifier '$RGIdentifier' -runtests"
|
||||
|
||||
if ( $CustomKernel) { $command += " -CustomKernel '$CustomKernel'" }
|
||||
if ( $OverrideVMSize ) { $command += " -OverrideVMSize $OverrideVMSize" }
|
||||
if ( $EnableAcceleratedNetworking ) { $command += " -EnableAcceleratedNetworking" }
|
||||
|
@ -396,9 +226,7 @@ try {
|
|||
if ( $TiPCluster) { $command += " -TiPCluster $TiPCluster" }
|
||||
if ($UseManagedDisks) { $command += " -UseManagedDisks" }
|
||||
if ($XMLSecretFile) { $command += " -XMLSecretFile '$XMLSecretFile'" }
|
||||
|
||||
LogMsg $command
|
||||
#endregion
|
||||
|
||||
Invoke-Expression -Command $command
|
||||
|
||||
|
@ -406,20 +234,16 @@ try {
|
|||
if ( $TestCategory ) { $zipFile += "-$TestCategory" }
|
||||
if ( $TestArea ) { $zipFile += "-$TestArea" }
|
||||
if ( $TestTag ) { $zipFile += "-$($TestTag)" }
|
||||
|
||||
$zipFile += "-$TestID-buildlogs.zip"
|
||||
$out = ZipFiles -zipfilename $zipFile -sourcedir $LogDir
|
||||
|
||||
if ($out -match "Everything is Ok") {
|
||||
LogMsg "$WorkingDirectory\$zipfilename created successfully."
|
||||
}
|
||||
$zipFile += "-$TestID-TestLogs.zip"
|
||||
New-ZipFile -zipFileName $zipFile -sourceDir $LogDir
|
||||
|
||||
try {
|
||||
if (Test-Path -Path ".\report\report_$(($TestCycle).Trim()).xml" ) {
|
||||
$resultXML = [xml](Get-Content ".\report\report_$(($TestCycle).Trim()).xml" -ErrorAction SilentlyContinue)
|
||||
Copy-Item -Path ".\report\report_$(($TestCycle).Trim()).xml" -Destination ".\report\report_$(($TestCycle).Trim())-junit.xml" -Force -ErrorAction SilentlyContinue
|
||||
LogMsg "Copied : .\report\report_$(($TestCycle).Trim()).xml --> .\report\report_$(($TestCycle).Trim())-junit.xml"
|
||||
$reportXmlJUnit = $TestReportXml.Replace(".xml", "-junit.xml")
|
||||
if (Test-Path -Path $TestReportXml ) {
|
||||
Copy-Item -Path $TestReportXml -Destination $reportXmlJUnit -Force -ErrorAction SilentlyContinue
|
||||
LogMsg "Copied : $TestReportXml --> $reportXmlJUnit"
|
||||
LogMsg "Analyzing results.."
|
||||
$resultXML = [xml](Get-Content $TestReportXml -ErrorAction SilentlyContinue)
|
||||
LogMsg "PASS : $($resultXML.testsuites.testsuite.tests - $resultXML.testsuites.testsuite.errors - $resultXML.testsuites.testsuite.failures)"
|
||||
LogMsg "FAIL : $($resultXML.testsuites.testsuite.failures)"
|
||||
LogMsg "ABORT : $($resultXML.testsuites.testsuite.errors)"
|
||||
|
@ -429,7 +253,7 @@ try {
|
|||
$ExitCode = 1
|
||||
}
|
||||
} else {
|
||||
LogErr "Summary file: .\report\report_$(($TestCycle).Trim()).xml does not exist. Exiting with 1."
|
||||
LogErr "Summary file: $TestReportXml does not exist. Exiting with ErrorCode 1."
|
||||
$ExitCode = 1
|
||||
}
|
||||
}
|
||||
|
@ -439,7 +263,7 @@ try {
|
|||
}
|
||||
finally {
|
||||
if ( $ExitWithZero -and ($ExitCode -ne 0) ) {
|
||||
LogMsg "Changed exit code from 1 to 0. (-ExitWithZero specified in command line)"
|
||||
LogMsg "Suppress the exit code from 1 to 0. (-ExitWithZero specified in command line)"
|
||||
$ExitCode = 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
This script authenticates PS session using All test results analysis.
|
||||
This script checks contents of the ./report/*-junit.xml files and exit
|
||||
This script checks contents of the ./Report/*-junit.xml files and exit
|
||||
with zero or non-zero exit code.
|
||||
|
||||
.PARAMETER
|
||||
|
@ -25,7 +25,7 @@
|
|||
#Import Libraries.
|
||||
Get-ChildItem .\Libraries -Recurse | Where-Object { $_.FullName.EndsWith(".psm1") } | ForEach-Object { Import-Module $_.FullName -Force -Global -DisableNameChecking }
|
||||
|
||||
$allReports = Get-ChildItem .\report | Where-Object {($_.FullName).EndsWith("-junit.xml") -and ($_.FullName -imatch "\d\d\d\d\d\d")}
|
||||
$allReports = Get-ChildItem .\Report | Where-Object {($_.FullName).EndsWith("-junit.xml") -and ($_.FullName -imatch "\d\d\d\d\d\d")}
|
||||
$retValue = 0
|
||||
foreach ( $report in $allReports )
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче