azure-linux-automation/remote-scripts/DiskHotAddRemove-Parallel.ps1

101 строка
4.3 KiB
PowerShell
Исходник Обычный вид История

Merging upstream (#15) * Disk Hot Add Parallel and Serial ARM mode tests (#39) * Fix picking OSVHD * Fix xml * trivial xml issue * Fix picking osVHD for Deployment * Use BaseOsVHD to pick captured VHD for deployment * Disk Hot Add/Removal Code containing disk hot add/removal in parallel and serial * Added test cycle for Disk Hot Add/Remove * Hot VM resize, hot add tests in BVT MK cycle * Removed redundant tests * Added new test script to verify KVP daemon status (#40) * Updated the detect_linux_distribution_version lib function to get proper distro version * Minor fix to support package installation for CentOS * Minor fix to support package installation for CentOS and RHEL distros in FIO perf test * Minor fix for FIO test * Minor fix for detect distro version * Updated the perf_iperf3.sh script to install the required packages for CentOS & RHEL * Added new test scripts for LIS build scenario tests 1. Added new test scripts for LIS build 8 scenario tests 2. Updated ARM test execution mode * Minor Fix to display upgrade & uninstall LIS console messages * Minor fix to support ARM mode * Added ARM support for Wordpress test and fixed minor issues * Minor fix for ARM instance size support * Minor fix for SLES 11 & update repos * Added new test script, to verify KVP daemon status in BVT test * Added new test script for TRIM test on Azure (#41) * Updated the detect_linux_distribution_version lib function to get proper distro version * Minor fix to support package installation for CentOS * Minor fix to support package installation for CentOS and RHEL distros in FIO perf test * Minor fix for FIO test * Minor fix for detect distro version * Updated the perf_iperf3.sh script to install the required packages for CentOS & RHEL * Added new test scripts for LIS build scenario tests 1. Added new test scripts for LIS build 8 scenario tests 2. Updated ARM test execution mode * Minor Fix to display upgrade & uninstall LIS console messages * Minor fix to support ARM mode * Added ARM support for Wordpress test and fixed minor issues * Minor fix for ARM instance size support * Minor fix for SLES 11 & update repos * Added new test script, to verify KVP daemon status in BVT test * Added new script for TRIM test in Azure and updated ARM support * Minor fix for Clean up VM in TRIM test * Updated TRIM script for collecting Active pages after creating file * Minor fix for Trim test * Minor fix for Trim test * Minor fix to get host build for TRIm test * Minor fix to get SA key in TRIM test * Minor fix to get SA key in TRIM test
2017-09-05 15:59:02 +03:00
Import-Module .\TestLibs\RDFELibs.psm1 -Force
$result = ""
$testResult = ""
$resultArr = @()
$allDiskNames = @()
try
{
$isDeployed = DeployVMS -setupType $currentTestData.setupType -Distro $Distro -xmlConfig $xmlConfig
if ($isDeployed)
{
foreach ($VM in $allVMData)
{
$ResourceGroupUnderTest = $VM.ResourceGroupName
$VirtualMachine = Get-AzureRmVM -ResourceGroupName $VM.ResourceGroupName -Name $VM.RoleName
$diskCount = (Get-AzureRmVMSize -Location $allVMData.Location | Where-Object {$_.Name -eq $allVMData.InstanceSize}).MaxDataDiskCount
LogMsg "------------------------------------------"
LogMsg "Parallel Addition of Data Disks to the VM "
While($count -lt $diskCount)
{
$count += 1
$diskName = "disk"+ $count.ToString()
$allDiskNames += $diskName
$diskSizeinGB = "1023"
$VHDuri = $VirtualMachine.StorageProfile.OsDisk.Vhd.Uri
$VHDUri = $VHDUri.Replace("osdisk",$diskName)
LogMsg "Adding an empty data disk of size $diskSizeinGB GB"
$out = Add-AzureRMVMDataDisk -VM $VirtualMachine -Name $diskName -DiskSizeInGB $diskSizeinGB -LUN $count -VhdUri $VHDuri.ToString() -CreateOption Empty
LogMsg "Successfully created an empty data disk of size $diskSizeinGB GB"
}
LogMsg "Number of data disks added to the VM $count"
$out = Update-AzureRMVM -VM $VirtualMachine -ResourceGroupName $ResourceGroupUnderTest
LogMsg "Successfully added $diskCount empty data disks to the VM"
LogMsg "Verifying if data disk is added to the VM: Running fdisk on remote VM"
$fdiskOutput = RunLinuxCmd -username $user -password $password -ip $VM.PublicIP -port $VM.SSHPort -command "/sbin/fdisk -l | grep /dev/sd" -runAsSudo
foreach($line in ($fdiskOutput.Split([Environment]::NewLine)))
{
if($line -imatch "Disk /dev/sd[^ab]" -and ([int]($line.Split()[2]) -ge [int]$diskSizeinGB))
{
LogMsg "Data disk is successfully mounted to the VM: $line"
$verifiedDiskCount += 1
}
}
LogMsg "Number of data disks verified inside VM $verifiedDiskCount"
if($verifiedDiskCount -ge $diskCount)
{
LogMsg "Data disks added to the VM are successfully verified inside VM"
$testResult = "PASS"
}
else
{
LogMsg "Data disks added to the VM failed to verify inside VM"
$testResult = "FAIL"
Break
}
LogMsg "------------------------------------------"
LogMsg "Parallel Removal of Data Disks from the VM"
$out = Remove-AzureRmVMDataDisk -VM $VirtualMachine -DataDiskNames $allDiskNames
$out = Update-AzureRMVM -VM $VirtualMachine -ResourceGroupName $ResourceGroupUnderTest
LogMsg "Successfully removed the data disk from the VM"
LogMsg "Verifying if data disks are removed from the VM: Running fdisk on remote VM"
$fdiskFinalOutput = RunLinuxCmd -username $user -password $password -ip $VM.PublicIP -port $VM.SSHPort -command "/sbin/fdisk -l | grep /dev/sd" -runAsSudo
foreach($line in ($fdiskFinalOutput.Split([Environment]::NewLine)))
{
if($line -imatch "Disk /dev/sd[^ab]" -and ([int]($line.Split()[2]) -ge [int]$diskSizeinGB))
{
LogMsg "Data disk is NOT removed from the VM at $line"
$testResult = "FAIL"
Break
}
}
LogMsg "Successfully verified that all data disks are removed from the VM"
$testResult = "PASS"
}
}
}
catch
{
$ErrorMessage = $_.Exception.Message
LogMsg "EXCEPTION : $ErrorMessage"
}
Finally
{
if (!$testResult)
{
$testResult = "Aborted"
}
$resultArr += $testResult
}
$result = GetFinalResultHeader -resultarr $resultArr
#Clean up the setup
DoTestCleanUp -result $result -testName $currentTestData.testName -ResourceGroups $isDeployed
#Return the result and summery to the test suite script..
return $result