Migrated REDIS perf test from LISA to Azure

This commit is contained in:
Shital Savekar 2016-02-03 20:37:18 +05:30
Родитель db0353ba42
Коммит bdde9cdf4e
4 изменённых файлов: 287 добавлений и 4 удалений

Просмотреть файл

@ -2686,6 +2686,37 @@
</VirtualMachine>
</HostedService>
</ExtensionTest>
<M1S1>
<isDeployed>NO</isDeployed>
<HostedService>
<VirtualMachine>
<state></state>
<InstanceSize>Standard_G5</InstanceSize>
<ARMInstanceSize>Standard_G5</ARMInstanceSize>
<RoleName>server-vm</RoleName>
<EndPoints>
<Name>SSH</Name>
<Protocol>tcp</Protocol>
<LocalPort>22</LocalPort>
<PublicPort>12122</PublicPort>
</EndPoints>
<DataDisk></DataDisk>
</VirtualMachine>
<VirtualMachine>
<state></state>
<InstanceSize>Standard_G5</InstanceSize>
<ARMInstanceSize>Standard_G5</ARMInstanceSize>
<RoleName>client-vm</RoleName>
<EndPoints>
<Name>SSH</Name>
<Protocol>tcp</Protocol>
<LocalPort>22</LocalPort>
<PublicPort>12222</PublicPort>
</EndPoints>
<DataDisk></DataDisk>
</VirtualMachine>
</HostedService>
</M1S1>
<M1S5>
<!-- This setup type defines One Master and Three slave machines. Hence name is M(aster)1S(lave)3. -->
<isDeployed>NO</isDeployed>
@ -4717,15 +4748,25 @@
<!-- Hadoop version is optional here. If left blank then hadoop version will be taken from remoteXML file of this definition.-->
<HADOOP_VERSION></HADOOP_VERSION>
<SupportedExecutionModes>AzureServiceManagement,AzureResourceManager</SupportedExecutionModes>
<!--Remote Files will be directly downloaded to test VM.-->
<remoteFiles>https://raw.githubusercontent.com/LIS/lis-test/master/WS2012R2/lisa/remote-scripts/ica/perf_hadoopterasort.sh</remoteFiles>
<!--Remote XML will be downloaded to automation server for analysis-->
<remoteXML>https://raw.githubusercontent.com/LIS/lis-test/master/WS2012R2/lisa/xml/perf_hadoopterasort.xml</remoteXML>
<SubtestValues>SOME,TEXTS,NEEDS,TO,BE,PRESENT,HERE,FOR,PRINTING,TEST,SUMMARY</SubtestValues>
<Priority>P0</Priority>
</test>
</testsDefinition>
<test>
<testName>ICA-PERF-REDIS-TEST</testName>
<testScript></testScript>
<testScriptps1>ICA-PERF-REDIS-TEST.ps1</testScriptps1>
<setupType>M1S1</setupType>
<SupportedExecutionModes>AzureServiceManagement,AzureResourceManager</SupportedExecutionModes>
<remoteFiles>https://raw.githubusercontent.com/LIS/lis-test/master/WS2012R2/lisa/remote-scripts/ica/performance_redis.sh</remoteFiles>
<!--Remote XML will be downloaded to automation server for analysis-->
<remoteXML>https://raw.githubusercontent.com/LIS/lis-test/master/WS2012R2/lisa/xml/Perf_Redis.xml</remoteXML>
<SubtestValues>SOME,TEXTS,NEEDS,TO,BE,PRESENT,HERE,FOR,PRINTING,TEST,SUMMARY</SubtestValues>
<Priority>P0</Priority>
</test>
</testsDefinition>
<testCycles>
<!-- Setup related tests -->
@ -5431,6 +5472,13 @@
<Name>ICA-TERASORT-BENCHMARK-TEST</Name>
</test>
</Cycle>
<Cycle>
<cycleName>LISA-REDIS-PERF</cycleName>
<!--You can add individual tests here and run them for debugging purpose. You can also add new cycles. -->
<test>
<Name>ICA-PERF-REDIS-TEST</Name>
</test>
</Cycle>
<Cycle>
<cycleName>DEBUG</cycleName>

50
TestLibs/LISALibrary.psm1 Normal file
Просмотреть файл

@ -0,0 +1,50 @@
Function ProvisionVMsForLisa($allVMData)
{
$scriptUrl = "https://raw.githubusercontent.com/LIS/lis-test/master/WS2012R2/lisa/remote-scripts/ica/provisionLinuxForLisa.sh"
$sshPrivateKeyPath = ".\ssh\myPrivateKey.key"
$sshPrivateKey = "myPrivateKey.key"
LogMsg "Downloading $scriptUrl ..."
$scriptName = $scriptUrl.Split("/")[$scriptUrl.Split("/").Count-1]
$start_time = Get-Date
$out = Invoke-WebRequest -Uri $scriptUrl -OutFile "$LogDir\$scriptName"
LogMsg "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"
Set-Content -Value "echo `"Host *`" > /home/$user/.ssh/config" -Path "$LogDir\disableHostKeyVerification.sh"
Add-Content -Value "echo StrictHostKeyChecking=no >> /home/$user/.ssh/config" -Path "$LogDir\disableHostKeyVerification.sh"
Add-Content -Value "echo IdentityFile /root/$sshPrivateKey >> /home/$user/.ssh/config" -Path "$LogDir\disableHostKeyVerification.sh"
foreach ( $vmData in $allVMData )
{
LogMsg "Configuring $($vmData.RoleName) for LISA test..."
RemoteCopy -uploadTo $vmData.PublicIP -port $vmData.SSHPort -files ".\remote-scripts\enableRoot.sh,$sshPrivateKeyPath,.\$LogDir\disableHostKeyVerification.sh,.\$LogDir\provisionLinuxForLisa.sh" -username $user -password $password -upload
$out = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username $user -password $password -command "chmod +x /home/$user/*.sh" -runAsSudo
$rootPasswordSet = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username $user -password $password -command "/home/$user/enableRoot.sh -password $($password.Replace('"',''))" -runAsSudo
LogMsg $rootPasswordSet
if (( $rootPasswordSet -imatch "ROOT_PASSWRD_SET" ) -and ( $rootPasswordSet -imatch "SSHD_RESTART_SUCCESSFUL" ))
{
LogMsg "root user enabled for $($vmData.RoleName) and password set to $password"
}
else
{
Throw "Failed to enable root password / starting SSHD service. Please check logs. Aborting test."
}
$out = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username "root" -password $password -command "chmod 600 /home/$user/$sshPrivateKey && cp -ar /home/$user/* /root/"
$out = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username "root" -password $password -command "mkdir -p /root/.ssh/ && cp /home/$user/.ssh/authorized_keys /root/.ssh/"
$out = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username "root" -password $password -command "/home/$user/disableHostKeyVerification.sh"
$out = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username "root" -password $password -command "cp /home/$user/.ssh/config /root/.ssh/"
$out = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username "root" -password $password -command "service sshd restart"
LogMsg "Executing $scriptName ..."
$provisionJob = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username "root" -password $password -command "/root/$scriptName" -RunInBackground
while ( (Get-Job -Id $provisionJob).State -eq "Running" )
{
$currentStatus = RunLinuxCmd -ip $serverVMData.PublicIP -port $serverVMData.SSHPort -username "root" -password $password -command "tail -n 1 /root/provisionLinux.log"
LogMsg "Current Staus : $currentStatus"
WaitFor -seconds 10
}
RemoteCopy -download -downloadFrom $vmData.PublicIP -port $vmData.SSHPort -files "/root/provisionLinux.log" -username "root" -password $password -downloadTo $LogDir
Rename-Item -Path "$LogDir\provisionLinux.log" -NewName "$($vmData.RoleName)-provisionLinux.log" -Force | Out-Null
LogMsg "$($vmData.RoleName) preparation finished."
}
}

Просмотреть файл

@ -1,7 +1,7 @@
#region Azure RDFE Methods
Import-Module .\TestLibs\ExtensionLibrary.psm1 -Force
Import-Module .\TestLibs\LISALibrary.psm1 -Force
<#
.SYNOPSIS
List All OS Images in Cluster

Просмотреть файл

@ -0,0 +1,185 @@
<#-------------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
$redisSummary = $null
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 "SERVER VM details :"
LogMsg " RoleName : $($serverVMData.RoleName)"
LogMsg " Public IP : $($serverVMData.PublicIP)"
LogMsg " SSH Port : $($serverVMData.SSHPort)"
LogMsg "CLIENT VM details :"
LogMsg " RoleName : $($clientVMData.RoleName)"
LogMsg " Public IP : $($clientVMData.PublicIP)"
LogMsg " SSH Port : $($clientVMData.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
foreach ( $vmData in $allVMData )
{
LogMsg "Adding $($vmData.InternalIP) $($vmData.RoleName) to /etc/hosts of $($serverVMData.RoleName) "
$out = RunLinuxCmd -ip $serverVMData.PublicIP -port $serverVMData.SSHPort -username "root" -password $password -command "echo $($vmData.InternalIP) $($vmData.RoleName) >> /etc/hosts"
}
#endregion
#region Geting Test Data from remote XML file
$redisXMLURL = $($currentTestData.remoteXML)
LogMsg "Downloading redis XML : $redisXMLURL ..."
$redisXMLFileName = $($redisXMLURL.Split("/")[$redisXMLURL.Split("/").Count-1])
$out = Invoke-WebRequest -Uri $redisXMLURL -OutFile "$LogDir\$redisXMLFileName"
$redisXMLData = [xml](Get-Content -Path "$LogDir\$redisXMLFileName")
LogMsg "Generating constansts.sh ..."
$constantsFile = "$LogDir\constants.sh"
Set-Content -Value "#Generated by Azure Automation." -Path $constantsFile
foreach ($redisParam in $redisXMLData.config.testCases.test.testParams.param )
{
if ($redisParam -imatch "REDIS_HOST_IP")
{
Add-Content -Value "REDIS_HOST_IP=$($clientVMData.InternalIP)" -Path $constantsFile
LogMsg "REDIS_HOST_IP=$($clientVMData.InternalIP) added to constansts.sh"
}
else
{
Add-Content -Value "$redisParam" -Path $constantsFile
LogMsg "$redisParam added to constansts.sh"
}
if ($redisParam -imatch "REDIS_PACKAGE")
{
$redisPackage = $redisParam.Replace("REDIS_PACKAGE=","")
}
}
LogMsg "constanst.sh created successfully..."
#endregion
#region Download remote files needed to run tests
LogMsg "Downloading remote files ..."
foreach ( $fileURL in $($currentTestData.remoteFiles).Split(",") )
{
LogMsg "Downloading $fileURL ..."
$start_time = Get-Date
$fileName = $fileURL.Split("/")[$fileURL.Split("/").Count-1]
$out = Invoke-WebRequest -Uri $fileURL -OutFile "$LogDir\$fileName"
LogMsg "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"
}
LogMsg "Downloading REDIS package : $redisPackage"
$redisPackageUrl = "http://download.redis.io/releases/$redisPackage"
$start_time = Get-Date
$out = Invoke-WebRequest -Uri $redisPackageUrl -OutFile "$LogDir\$redisPackage"
LogMsg "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"
#endregion
#region EXECUTE TEST
Set-Content -Value "/root/performance_redis.sh &> redisConsoleLogs.txt" -Path "$LogDir\StartRedisTest.sh"
RemoteCopy -uploadTo $serverVMData.PublicIP -port $serverVMData.SSHPort -files ".\$LogDir\$redisPackage,.\$constantsFile,.\$LogDir\performance_redis.sh,.\$LogDir\StartRedisTest.sh" -username "root" -password $password -upload
$out = RunLinuxCmd -ip $serverVMData.PublicIP -port $serverVMData.SSHPort -username "root" -password $password -command "chmod +x *.sh"
$testJob = RunLinuxCmd -ip $serverVMData.PublicIP -port $serverVMData.SSHPort -username "root" -password $password -command "/root/StartRedisTest.sh" -RunInBackground
#endregion
#region MONITOR TEST
while ( (Get-Job -Id $testJob).State -eq "Running" )
{
$currentStatus = RunLinuxCmd -ip $serverVMData.PublicIP -port $serverVMData.SSHPort -username "root" -password $password -command "tail -n 1 /root/redisConsoleLogs.txt"
LogMsg "Current Test Staus : $currentStatus"
WaitFor -seconds 10
}
$redisResult = RunLinuxCmd -ip $serverVMData.PublicIP -port $serverVMData.SSHPort -username "root" -password $password -command "sed -i '/^$/d' /root/redis.log && tail -n 1 /root/redis.log"
$finalStatus = RunLinuxCmd -ip $serverVMData.PublicIP -port $serverVMData.SSHPort -username "root" -password $password -command "cat /root/state.txt"
RemoteCopy -downloadFrom $serverVMData.PublicIP -port $serverVMData.SSHPort -username "root" -password $password -download -downloadTo $LogDir -files "/root/redisConsoleLogs.txt"
RemoteCopy -downloadFrom $serverVMData.PublicIP -port $serverVMData.SSHPort -username "root" -password $password -download -downloadTo $LogDir -files "/root/summary.log"
$redisSummary = Get-Content -Path "$LogDir\summary.log" -ErrorAction SilentlyContinue
#endregion
if (!$redisSummary)
{
LogMsg "summary.log file is empty."
$redisSummary = "<EMPTY>"
}
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 : $redisResult."
$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\redisConsoleLogs.txt"
LogMsg "Contests of summary.log : $redisResult"
$testResult = "PASS"
}
LogMsg "Test result : $testResult"
LogMsg "Test Completed"
}
catch
{
$ErrorMessage = $_.Exception.Message
LogMsg "EXCEPTION : $ErrorMessage"
}
Finally
{
$metaData = "REDIS RESULT"
if (!$testResult)
{
$testResult = "Aborted"
}
$resultArr += $testResult
$resultSummary += CreateResultSummary -testResult $redisResult -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