Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abhitiwaritest #3416

Draft
wants to merge 13 commits into
base: master-se-1
Choose a base branch
from
2 changes: 1 addition & 1 deletion LISAv2-Framework.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function Start-LISAv2 {
}
}

if (($failedCount -eq 0 -and $errorCount -eq 0 -and $testCount -gt 0) -or (-not $RunInParallel -and $TestIdInParallel)) {
if (($failedCount -eq 0 -and $errorCount -eq 0 -and $testCount -ge 0) -or (-not $RunInParallel -and $TestIdInParallel)) {
$ExitCode = 0
} else {
$ExitCode = 1
Expand Down
12 changes: 10 additions & 2 deletions Libraries/TestReport.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,18 @@ Class JUnitReportGenerator
[System.Xml.XmlElement] $ReportRootNode
[object] $TestSuiteLogTable
[object] $TestSuiteCaseLogTable

JUnitReportGenerator([string]$ReportPath)
[string] $TestCategory
[string] $ovlname
JUnitReportGenerator([string]$ReportPath,[string]$TestCategory,[string]$ovlname)
{
$this.JunitReportPath = $ReportPath
$this.JunitReport = New-Object System.Xml.XmlDocument
$newElement = $this.JunitReport.CreateElement("testsuites")
$this.ReportRootNode = $this.JunitReport.AppendChild($newElement)
$this.TestSuiteLogTable = @{}
$this.TestSuiteCaseLogTable = @{}
$this.TestCategory=$TestCategory
$this.ovlname=$ovlname
}

[void] SaveLogReport()
Expand All @@ -156,6 +159,11 @@ Class JUnitReportGenerator
$newElement.SetAttribute("errors", 0)
$newElement.SetAttribute("skipped", 0)
$newElement.SetAttribute("time", 0)
$newElement.SetAttribute("TestCategory", $this.TestCategory)
$newElement.SetAttribute("ovlname", $this.ovlname)
if ( $global:BaseOSVHD ) {
$newElement.SetAttribute("ImageUnderTest", $global:BaseOSVHD )
}
$testsuiteNode = $this.ReportRootNode.AppendChild($newElement)

$testsuite = [ReportNode]::New($testsuiteNode)
Expand Down
17 changes: 14 additions & 3 deletions TestControllers/TestController.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Class TestController {
[string] $RGIdentifier
[string] $OsVHD
[string] $TestCategory
[string] $ovlname
[string] $TestNames
[string] $TestArea
[string] $TestTag
Expand Down Expand Up @@ -270,6 +271,7 @@ Class TestController {
$this.SetupTypeToTestCases = @{}
$this.SetupTypeTable = @{}
$allTests = $null
$this.ovlname=""
$SetupTypeXMLs = Get-ChildItem -Path "$WorkingDirectory\XML\VMConfigurations\*.xml"
foreach ($file in $SetupTypeXMLs.FullName) {
$setupXml = [xml]( Get-Content -Path $file)
Expand Down Expand Up @@ -302,11 +304,19 @@ Class TestController {
foreach ($CustomParameter in $CustomTestParameters) {
$ReplaceThis = $CustomParameter.Split("=")[0]
$ReplaceWith = $CustomParameter.Substring($CustomParameter.IndexOf("=") + 1)
if($ReplaceThis -eq "ovlname")
{
$this.ovlname=$ReplaceWith
}
else {


$OldValue = ($ReplaceableTestParameters.ReplaceableTestParameters.Parameter | Where-Object `
{ $_.ReplaceThis -eq $ReplaceThis }).ReplaceWith
($ReplaceableTestParameters.ReplaceableTestParameters.Parameter | Where-Object `
{ $_.ReplaceThis -eq $ReplaceThis }).ReplaceWith = $ReplaceWith
Write-LogInfo "Custom Parameter: $ReplaceThis=$OldValue --> $ReplaceWith"
}
}
Write-LogInfo "Custom parameter(s) are ready to be injected along with default parameters, if any."
}
Expand All @@ -323,12 +333,12 @@ Class TestController {
}
}
if (!$allTests) {
Throw "Not able to collect any test cases from XML files"
Write-LogWarn "Not able to collect any test cases from XML files"
}
else {
$collectedTCCount = $allTests.Count
Write-LogInfo "$collectedTCCount Test Cases have been collected"
}

$this.PrepareSetupTypeToTestCases($this.SetupTypeToTestCases, $allTests)
if (($this.TotalCaseNum -eq 0) -or ($allTests.Count -eq 0)) {
Write-LogWarn "All collected test cases are skipped, because the test case has native SetupConfig that conflicts with current Run-LISAv2 parameters, or LISAv2 needs more specific parameters to run against selected test cases, please check again"
Expand Down Expand Up @@ -364,6 +374,7 @@ Class TestController {
$parallelTestsDoc.Save("$parallelTestsFilePath")
}
}
}
}

[void] PrepareTestImage() {}
Expand Down Expand Up @@ -903,7 +914,7 @@ Class TestController {

Write-LogInfo "Prepare test log structure and start testing now ..."
# Start JUnit XML report logger.
$this.JunitReport = [JUnitReportGenerator]::New($TestReportXmlPath)
$this.JunitReport = [JUnitReportGenerator]::New($TestReportXmlPath,$this.TestCategory,$this.ovlname)
$this.JunitReport.StartLogTestSuite("LISAv2Test-$($this.TestPlatform)")
$this.TestSummary = [TestSummary]::New($this.TestCategory, $this.TestArea, $this.TestNames, $this.TestTag, $this.TestPriority, $this.TotalCaseNum)

Expand Down