186 строки
6.7 KiB
PowerShell
186 строки
6.7 KiB
PowerShell
<#-------------Create Deployment Start------------------#>
|
|
Import-Module .\TestLibs\RDFELibs.psm1 -Force
|
|
$result = ""
|
|
$testResult = ""
|
|
$resultArr = @()
|
|
$isDeployed = DeployVMS -setupType $currentTestData.setupType -Distro $Distro -xmlConfig $xmlConfig
|
|
if ($isDeployed)
|
|
{
|
|
try
|
|
{
|
|
$noServer = $true
|
|
$noClient = $true
|
|
foreach ( $vmData in $allVMData )
|
|
{
|
|
if ( $vmData.RoleName -imatch "Server" )
|
|
{
|
|
$serverVMData = $vmData
|
|
$noServer = $false
|
|
}
|
|
elseif ( $vmData.RoleName -imatch "Client" )
|
|
{
|
|
$clientVMData = $vmData
|
|
$noClient = $fase
|
|
}
|
|
}
|
|
if ( $noServer )
|
|
{
|
|
Throw "No any server VM defined. Be sure that, server VM role name matches with the pattern `"*server*`". Aborting Test."
|
|
}
|
|
if ( $noSlave )
|
|
{
|
|
Throw "No any client VM defined. Be sure that, client machine role names matches with pattern `"*client*`" Aborting Test."
|
|
}
|
|
#region CONFIGURE VMs for TEST
|
|
|
|
LogMsg "CLIENT VM details :"
|
|
LogMsg " RoleName : $($clientVMData.RoleName)"
|
|
LogMsg " Public IP : $($clientVMData.PublicIP)"
|
|
LogMsg " SSH Port : $($clientVMData.SSHPort)"
|
|
LogMsg "SERVER VM details :"
|
|
LogMsg " RoleName : $($serverVMData.RoleName)"
|
|
LogMsg " Public IP : $($serverVMData.PublicIP)"
|
|
LogMsg " SSH Port : $($serverVMData.SSHPort)"
|
|
|
|
#
|
|
# PROVISION VMS FOR LISA WILL ENABLE ROOT USER AND WILL MAKE ENABLE PASSWORDLESS AUTHENTICATION ACROSS ALL VMS IN SAME HOSTED SERVICE.
|
|
#
|
|
ProvisionVMsForLisa -allVMData $allVMData
|
|
|
|
#endregion
|
|
|
|
#region Geting Test Data from remote XML file
|
|
#$mdXMLURL = $($currentTestData.remoteXML)
|
|
#LogMsg "Downloading apache test XML : $mdXMLURL ..."
|
|
#$mdXMLFileName = $($mdXMLURL.Split("/")[$mdXMLURL.Split("/").Count-1])
|
|
#$out = Invoke-WebRequest -Uri $mdXMLURL -OutFile "$LogDir\$mdXMLFileName"
|
|
|
|
$mdXMLData = [xml](Get-Content -Path ".\XML\Perf_MangoDB_2VM.xml")
|
|
|
|
LogMsg "Generating constansts.sh ..."
|
|
$constantsFile = "$LogDir\constants.sh"
|
|
Set-Content -Value "#Generated by Azure Automation." -Path $constantsFile
|
|
foreach ($mdParam in $mdXMLData.config.testCases.test.testParams.param )
|
|
{
|
|
if ($mdParam -imatch "MD_SERVER")
|
|
{
|
|
Add-Content -Value "MD_SERVER=$($serverVMData.InternalIP)" -Path $constantsFile
|
|
LogMsg "MD_SERVER=$($serverVMData.InternalIP) added to constansts.sh"
|
|
}
|
|
else
|
|
{
|
|
Add-Content -Value "$mdParam" -Path $constantsFile
|
|
LogMsg "$mdParam added to constansts.sh"
|
|
}
|
|
}
|
|
LogMsg "constanst.sh created successfully..."
|
|
|
|
LogMsg "Generating MongoDB workload file ..."
|
|
$workloadFile = "$LogDir\workloadAzure"
|
|
Set-Content -Value "#Generated by Azure Automation." -Path $workloadFile
|
|
foreach ($mdParam in $mdXMLData.config.testCases.test.testParams.mdparam )
|
|
{
|
|
Add-Content -Value "$mdParam" -Path $workloadFile
|
|
LogMsg "$mdParam added to workloadAzure"
|
|
}
|
|
LogMsg "workloadAzure file created successfully..."
|
|
|
|
#endregion
|
|
|
|
|
|
#region EXECUTE TEST
|
|
Set-Content -Value "/root/performance_mongod.sh &> mongodConsoleLogs.txt" -Path "$LogDir\StartMONGODTest.sh"
|
|
RemoteCopy -uploadTo $clientVMData.PublicIP -port $clientVMData.SSHPort -files ".\$constantsFile,.\remote-scripts\performance_mongod.sh,.\$LogDir\StartMONGODTest.sh,.\$LogDir\workloadAzure" -username "root" -password $password -upload
|
|
$out = RunLinuxCmd -ip $clientVMData.PublicIP -port $clientVMData.SSHPort -username "root" -password $password -command "chmod +x *.sh"
|
|
$testJob = RunLinuxCmd -ip $clientVMData.PublicIP -port $clientVMData.SSHPort -username "root" -password $password -command "/root/StartMONGODTest.sh" -RunInBackground
|
|
#endregion
|
|
|
|
#region MONITOR TEST
|
|
while ( (Get-Job -Id $testJob).State -eq "Running" )
|
|
{
|
|
$currentStatus = RunLinuxCmd -ip $clientVMData.PublicIP -port $clientVMData.SSHPort -username "root" -password $password -command "tail -n 1 /root/mongodConsoleLogs.txt"
|
|
LogMsg "Current Test Staus : $currentStatus"
|
|
WaitFor -seconds 10
|
|
}
|
|
|
|
RemoteCopy -downloadFrom $clientVMData.PublicIP -port $clientVMData.SSHPort -username "root" -password $password -download -downloadTo $LogDir -files "/root/mongodConsoleLogs.txt"
|
|
RemoteCopy -downloadFrom $clientVMData.PublicIP -port $clientVMData.SSHPort -username "root" -password $password -download -downloadTo $LogDir -files "/root/summary.log"
|
|
$finalStatus = RunLinuxCmd -ip $clientVMData.PublicIP -port $clientVMData.SSHPort -username "root" -password $password -command "cat /root/state.txt"
|
|
$mdSummary = Get-Content -Path "$LogDir\summary.log" -ErrorAction SilentlyContinue
|
|
|
|
if ($finalStatus -imatch "TestCompleted")
|
|
{
|
|
$mdConsoleData = Get-Content -Path "$LogDir\mongodConsoleLogs.txt"
|
|
foreach ($line in $mdConsoleData.Split("`n"))
|
|
{
|
|
if (($line -imatch 'OVERALL') -and ($line -imatch 'Throughput'))
|
|
{
|
|
$overallThroghput = $line.Trim().Split()[2].Trim()
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$overallThroghput = ""
|
|
}
|
|
#endregion
|
|
|
|
if (!$mdSummary)
|
|
{
|
|
LogMsg "summary.log file is empty."
|
|
$mdSummary = $finalStatus
|
|
}
|
|
if ( $finalStatus -imatch "TestFailed")
|
|
{
|
|
LogErr "Test failed. Last known status : $currentStatus."
|
|
$testResult = "FAIL"
|
|
}
|
|
elseif ( $finalStatus -imatch "TestAborted")
|
|
{
|
|
LogErr "Test Aborted. Last known status : $currentStatus."
|
|
$testResult = "ABORTED"
|
|
}
|
|
elseif ( $finalStatus -imatch "TestCompleted")
|
|
{
|
|
LogMsg "Test Completed. Result : $finalStatus."
|
|
$testResult = "PASS"
|
|
}
|
|
elseif ( $finalStatus -imatch "TestRunning")
|
|
{
|
|
LogMsg "Powershell backgroud job for test is completed but VM is reporting that test is still running. Please check $LogDir\mdConsoleLogs.txt"
|
|
LogMsg "Contests of state.txt : $finalStatus"
|
|
$testResult = "PASS"
|
|
}
|
|
LogMsg "Test result : $testResult"
|
|
LogMsg "Test Completed"
|
|
}
|
|
catch
|
|
{
|
|
$ErrorMessage = $_.Exception.Message
|
|
LogMsg "EXCEPTION : $ErrorMessage"
|
|
}
|
|
Finally
|
|
{
|
|
$metaData = "8KB IOPS"
|
|
if (!$testResult)
|
|
{
|
|
$testResult = "Aborted"
|
|
}
|
|
$resultArr += $testResult
|
|
$resultSummary += CreateResultSummary -testResult $overallThroghput -metaData $metaData -checkValues "PASS,FAIL,ABORTED" -testName $currentTestData.testName# if you want to publish all result then give here all test status possibilites. if you want just failed results, then give here just "FAIL". You can use any combination of PASS FAIL ABORTED and corresponding test results will be published!
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
$testResult = "Aborted"
|
|
$resultArr += $testResult
|
|
}
|
|
|
|
$result = GetFinalResultHeader -resultarr $resultArr
|
|
|
|
#Clean up the setup
|
|
DoTestCleanUp -result $result -testName $currentTestData.testName -deployedServices $isDeployed -ResourceGroups $isDeployed
|
|
|
|
#Return the result and summery to the test suite script..
|
|
return $result, $resultSummary |