2016-01-11 15:19:58 +03:00
<# -------------Create Deployment Start------------------ #>
Import-Module . \ TestLibs \ RDFELibs . psm1 -Force
$result = " "
$testResult = " "
$resultArr = @ ( )
$isDeployed = DeployVMS -setupType $currentTestData . setupType -Distro $Distro -xmlConfig $xmlConfig
if ( $isDeployed )
{
try
{
$slaveMachines = @ ( )
$slaveMachinesHostNames = " "
$noMaster = $true
$noSlave = $true
2016-01-18 17:58:21 +03:00
$terasortSummary = $null
2016-01-11 15:19:58 +03:00
foreach ( $vmData in $allVMData )
{
if ( $vmData . RoleName -imatch " master " )
{
$masterVMData = $vmData
$noMaster = $false
}
elseif ( $vmData . RoleName -imatch " slave " )
{
$slaveMachines + = $vmData
$noSlave = $fase
$slaveMachinesHostNames + = " $( $vmData . RoleName ) "
}
}
$slaveMachinesHostNames = $slaveMachinesHostNames . Trim ( )
if ( $noMaster )
{
Throw " No any master VM defined. Be sure that, Master VM role name matches with the pattern `" *master* `" . Aborting Test. "
}
if ( $noSlave )
{
Throw " No any slave VM defined. Be sure that, Slave machine role names matches with pattern `" *slave* `" Aborting Test. "
}
#region CONFIGURE VM FOR TERASORT TEST
LogMsg " MASTER VM details : "
LogMsg " RoleName : $( $masterVMData . RoleName ) "
LogMsg " Public IP : $( $masterVMData . PublicIP ) "
LogMsg " SSH Port : $( $masterVMData . SSHPort ) "
$i = 1
foreach ( $vmData in $slaveMachines )
{
LogMsg " SLAVE # $i VM details : "
LogMsg " RoleName : $( $vmData . RoleName ) "
LogMsg " Public IP : $( $vmData . PublicIP ) "
LogMsg " SSH Port : $( $vmData . SSHPort ) "
$i + = 1
}
2016-02-19 18:47:57 +03:00
#
# PROVISION VMS FOR LISA WILL ENABLE ROOT USER AND WILL MAKE ENABLE PASSWORDLESS AUTHENTICATION ACROSS ALL VMS IN SAME HOSTED SERVICE.
#
ProvisionVMsForLisa -allVMData $allVMData -installPackagesOnRoleNames " master "
foreach ( $vmData in $allVMData )
{
LogMsg " Adding $( $vmData . InternalIP ) $( $vmData . RoleName ) to /etc/hosts of $( $masterVMData . RoleName ) "
$out = RunLinuxCmd -ip $masterVMData . PublicIP -port $masterVMData . SSHPort -username " root " -password $password -command " echo $( $vmData . InternalIP ) $( $vmData . RoleName ) >> /etc/hosts "
}
2016-01-11 15:19:58 +03:00
if ( $currentTestData . HADOOP_VERSION )
{
$hadoopVersion = $currentTestData . HADOOP_VERSION
LogMsg " Hadoop version set to : $hadoopVersion from local XML file. "
}
else
{
LogMsg " Downloading terasort XML : $( $currentTestData . remoteXML ) ... "
$terasortXMLData = ( Invoke-WebRequest -Uri $ ( $currentTestData . remoteXML ) ) . Content
$hadoopVersion = ( $terasortXMLData . Split ( ) -match " <param>HADOOP_VERSION= " ) . Replace ( " <param>HADOOP_VERSION= " , " " ) . Replace ( " </param> " , " " )
LogMsg " Hadoop version set to : $hadoopVersion from remote XML file. "
}
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 " Generating constanst.sh ... "
$constantsFile = " $LogDir \constants.sh "
$sshKeyPath = $currentTestData . sshKey
$sshKey = $sshKeyPath . Split ( " \ " ) [ $sshKeyPath . Split ( " \ " ) . count -1 ]
Set-Content -Value " #Generated by Azure Automation. " -Path $constantsFile
Add-Content -Value " HADOOP_MASTER_HOSTNAME= `" $( $masterVMData . RoleName ) `" " -Path $constantsFile
Add-Content -Value " RESOURCE_MANAGER_HOSTNAME= `" $( $masterVMData . RoleName ) `" " -Path $constantsFile
Add-Content -Value " SLAVE_HOSTNAMES= `" $slaveMachinesHostNames `" " -Path $constantsFile
Add-Content -Value " TERAGEN_RECORDS= $( $currentTestData . TERAGEN_RECORDS ) " -Path $constantsFile
Add-Content -Value " HADOOP_VERSION= `" $hadoopVersion `" " -Path $constantsFile
Add-Content -Value " sshKey= `" /root/ $sshKey `" " -Path $constantsFile
2016-01-18 17:58:21 +03:00
# You can add as much as teerasort test parameters here.
2016-01-11 15:19:58 +03:00
LogMsg " constanst.sh created successfully... "
2016-01-29 16:10:53 +03:00
LogMsg ( Get-Content $constantsFile )
2016-02-19 18:47:57 +03:00
2016-01-11 15:19:58 +03:00
#endregion
#region EXECUTE TEST
2016-02-19 18:47:57 +03:00
Set-Content -Value " /root/perf_hadoopterasort.sh &> terasortConsoleLogs.txt " -Path " $LogDir \StartTerasortTest.sh "
RemoteCopy -uploadTo $masterVMData . PublicIP -port $masterVMData . SSHPort -files " .\ $constantsFile ,.\ $LogDir \perf_hadoopterasort.sh, $sshKeyPath ,.\ $LogDir \StartTerasortTest.sh " -username " root " -password $password -upload
$out = RunLinuxCmd -ip $masterVMData . PublicIP -port $masterVMData . SSHPort -username " root " -password $password -command " chmod +x *.sh "
$out = RunLinuxCmd -ip $masterVMData . PublicIP -port $masterVMData . SSHPort -username " root " -password $password -command " chmod 600 $sshKey "
2016-01-11 15:19:58 +03:00
$testJob = RunLinuxCmd -ip $masterVMData . PublicIP -port $masterVMData . SSHPort -username " root " -password $password -command " /root/StartTerasortTest.sh " -RunInBackground
#endregion
while ( ( Get-Job -Id $testJob ) . State -eq " Running " )
{
$currentStatus = RunLinuxCmd -ip $masterVMData . PublicIP -port $masterVMData . SSHPort -username " root " -password $password -command " tail -n 1 /root/hadoop.log "
LogMsg " Current Test Staus : $currentStatus "
WaitFor -seconds 10
}
2016-01-18 17:58:21 +03:00
2016-01-11 15:19:58 +03:00
$currentStatus = RunLinuxCmd -ip $masterVMData . PublicIP -port $masterVMData . SSHPort -username " root " -password $password -command " tail -n 1 /root/hadoop.log "
$finalStatus = RunLinuxCmd -ip $masterVMData . PublicIP -port $masterVMData . SSHPort -username " root " -password $password -command " cat /root/state.txt "
2016-01-18 17:58:21 +03:00
RemoteCopy -downloadFrom $masterVMData . PublicIP -port $masterVMData . SSHPort -username " root " -password $password -download -downloadTo $LogDir -files " /root/terasortConsoleLogs.txt "
RemoteCopy -downloadFrom $masterVMData . PublicIP -port $masterVMData . SSHPort -username " root " -password $password -download -downloadTo $LogDir -files " /root/summary.log "
$terasortSummary = Get-Content -Path " $LogDir \summary.log " -ErrorAction SilentlyContinue
if ( ! $terasortSummary )
{
LogMsg " summary.log file is empty. "
$terasortSummary = " <EMPTY> "
}
2016-01-11 15:19:58 +03:00
if ( $finalStatus -imatch " TestFailed " )
{
LogErr " Test failed. Last known status : $currentStatus . "
2016-01-18 17:58:21 +03:00
LogMsg " Contests of summary.log : $terasortSummary "
2016-01-11 15:19:58 +03:00
$testResult = " FAIL "
}
elseif ( $finalStatus -imatch " TestAborted " )
{
LogErr " Test Aborted. Last known status : $currentStatus . "
2016-01-18 17:58:21 +03:00
LogMsg " Contests of summary.log : $terasortSummary "
2016-01-11 15:19:58 +03:00
$testResult = " ABORTED "
}
elseif ( $finalStatus -imatch " TestCompleted " )
{
LogMsg " Test Completed. Last known status : $currentStatus . "
2016-01-18 17:58:21 +03:00
LogMsg " $terasortSummary "
2016-01-11 15:19:58 +03:00
$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 \terasortConsoleLogs.txt "
2016-01-18 17:58:21 +03:00
LogMsg " Contests of summary.log : $terasortSummary "
2016-01-11 15:19:58 +03:00
$testResult = " PASS "
}
LogMsg " Test result : $testResult "
LogMsg " Test Completed "
}
catch
{
$ErrorMessage = $_ . Exception . Message
LogMsg " EXCEPTION : $ErrorMessage "
}
Finally
{
2016-01-18 17:58:21 +03:00
$metaData = " summary.log "
2016-01-11 15:19:58 +03:00
if ( ! $testResult )
{
$testResult = " Aborted "
}
$resultArr + = $testResult
2016-01-18 17:58:21 +03:00
$resultSummary + = CreateResultSummary -testResult $terasortSummary -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!
2016-01-11 15:19:58 +03:00
}
}
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..
2016-01-18 17:58:21 +03:00
return $result , $resultSummary