Update code from Main branch..

This commit is contained in:
Shital Savekar 2014-09-08 20:06:33 -07:00
Родитель a8066857b2
Коммит b50c9de45c
3 изменённых файлов: 519 добавлений и 340 удалений

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

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<config> <config>
<global> <global>
<platform>Azure</platform> <platform>Azure</platform>

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

@ -5,6 +5,38 @@ $testResult = ""
$resultArr = @() $resultArr = @()
$passwd = $password.Replace('"','') $passwd = $password.Replace('"','')
Function CreateIbmTar($ip,$port)
{
Logmsg "Creating IBMWebSphere tar .. "
LogMsg "distro: $Distro"
if($Distro -imatch "UBUNTU")
{
$out = RemoteCopy -uploadTo $ip -port $port -files .\remote-scripts\Packages\IBMWebSphere\ibm-java-x86-64-sdk_6.0-10.1_amd64.deb -username $user -password $password -upload 2>&1 | Out-Null
}
else
{
$out = RemoteCopy -uploadTo $ip -port $port -files .\remote-scripts\Packages\IBMWebSphere\ibm-java-x86_64-sdk-6.0-9.1.x86_64.rpm -username $user -password $password -upload 2>&1 | Out-Null
}
$out = RunLinuxCmd -username $user -password $password -ip $ip -port $port -command "mkdir IBMWebSphere" -runAsSudo 2>&1 | Out-Null
$out = RunLinuxCmd -username $user -password $password -ip $ip -port $port -command "tar -xvzf daytrader.tar.gz -C IBMWebSphere" -runAsSudo 2>&1 | Out-Null
$out = RunLinuxCmd -username $user -password $password -ip $ip -port $port -command "mv wasce_setup-2.1.1.6-unix.bin ibm-java* IBMWebSphere/" -runAsSudo 2>&1 | Out-Null
$out = RunLinuxCmd -username $user -password $password -ip $ip -port $port -command "chmod -R +x IBMWebSphere/" -runAsSudo 2>&1 | Out-Null
$out = RunLinuxCmd -username $user -password $password -ip $ip -port $port -command "tar -cvzf IBMWebSphere.tar.gz IBMWebSphere/" -runAsSudo 2>&1 | Out-Null
$out = RunLinuxCmd -username $user -password $password -ip $ip -port $port -command "cp IBMWebSphere.tar.gz /tmp" -runAsSudo 2>&1 | Out-Null
$out = RunLinuxCmd -username $user -password $password -ip $ip -port $port -command "rm -rf IBMWebSphere/" -runAsSudo 2>&1 | Out-Null
$istar = RunLinuxCmd -username $user -password $password -ip $ip -port $port -command "ls /tmp" -runAsSudo
if($istar -imatch "IBMWebSphere.tar")
{
Logmsg "Creating IBMWebsphere tar completed .. "
return $true
}
else
{
Logerr "Creating IBMWebsphere tar Failed .. "
return $false
}
}
$isDeployed = DeployVMS -setupType $currentTestData.setupType -Distro $Distro -xmlConfig $xmlConfig $isDeployed = DeployVMS -setupType $currentTestData.setupType -Distro $Distro -xmlConfig $xmlConfig
if ($isDeployed) if ($isDeployed)
@ -16,51 +48,13 @@ if ($isDeployed)
#Get VMs deployed in the service.. #Get VMs deployed in the service..
$testVMsinService = $testServiceData | Get-AzureVM $testVMsinService = $testServiceData | Get-AzureVM
try{ try{
if($currentTestData.E2ESetupCmdLineArgument -imatch "singleVM_setup") if($currentTestData.E2ESetupCmdLineArgument -imatch "loadbalancer_setup")
{
write-host "Preparing Daytrader SingleVM Setup"
$hs1vm1 = $testVMsinService
$hs1vm1Endpoints = $hs1vm1 | Get-AzureEndpoint
$hs1vm1sshport = GetPort -Endpoints $hs1vm1Endpoints -usage ssh
$hs1VIP = $hs1vm1Endpoints[0].Vip
$hs1ServiceUrl = $hs1vm1.DNSName
$hs1ServiceUrl = $hs1ServiceUrl.Replace("http://","")
$hs1ServiceUrl = $hs1ServiceUrl.Replace("/","")
$wsurl = "http:`/`/"+$hs1ServiceUrl.Replace(" ","")+":8080"
$dturl = "$wsurl`/daytrader"
"#all the IPs should be Internal ips `n<username>$user</username>`n<password>$passwd</password>" > 'Daytrader_install.XML'
# Uploading files into VM
$out = RemoteCopy -uploadTo $hs1VIP -port $hs1vm1sshport -files "Daytrader_install.XML" -username $user -password $password -upload 2>&1 | Out-Null
# Assiging Permissions to uploaded files into VM
$out = RemoteCopy -uploadTo $hs1VIP -port $hs1vm1sshport -files $currentTestData.files -username $user -password $password -upload 2>&1 | Out-Null
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "chmod +x *" -runAsSudo 2>&1 | Out-Null
# converting file format from UTF-16 to ASCII
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "iconv -f UTF-16 -t ASCII Daytrader_install.XML > Daytrader_install.XML.tmp ; mv -f Daytrader_install.XML.tmp Daytrader_install.XML" -runAsSudo 2>&1 | Out-Null
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "chmod +x *.XML" -runAsSudo 2>&1 | Out-Null
LogMsg "Executing : $($currentTestData.testScript)"
Write-host "#################################################################################################"
Write-host ""
Write-host "Daytrader single vm installation has been started." -foregroundcolor "yellow"
Write-host "It takes nearly 20 minutes and may take more time depending on internet speed." -foregroundcolor "yellow"
Write-host ""
Write-host "#################################################################################################"
$dtr_setup_status = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "python $($currentTestData.testScript) $($currentTestData.E2ESetupCmdLineArgument) 2>&1 > print.log" -runAsSudo 2>&1 | Out-Null
Start-Sleep -s 120
$out = RemoteCopy -download -downloadFrom $hs1VIP -files "/home/test/dtr_test.txt, /home/test/logs.tar.gz" -downloadTo $LogDir -port $hs1vm1sshport -username $user -password $password 2>&1 | Out-Null
}
elseif($currentTestData.E2ESetupCmdLineArgument -imatch "loadbalancer_setup")
{ {
$hs1bvm = $testVMsinService[0] $hs1bvm = $testVMsinService[0]
$hs1fevm1 = $testVMsinService[1] $hs1fevm1 = $testVMsinService[1]
$hs1fevm2 = $testVMsinService[2] $hs1fevm2 = $testVMsinService[2]
$hs1fevm3 = $testVMsinService[3] $hs1fevm3 = $testVMsinService[3]
$hs1bvmEndpoints = $hs1bvm | Get-AzureEndpoint $hs1bvmEndpoints = $hs1bvm | Get-AzureEndpoint
$hs1bvmsshport = GetPort -Endpoints $hs1bvmEndpoints -usage ssh $hs1bvmsshport = GetPort -Endpoints $hs1bvmEndpoints -usage ssh
@ -88,39 +82,141 @@ if ($isDeployed)
$hs1fevm3Endpoints = $hs1fevm3 | Get-AzureEndpoint $hs1fevm3Endpoints = $hs1fevm3 | Get-AzureEndpoint
$hs1fevm3sshport = GetPort -Endpoints $hs1fevm3Endpoints -usage ssh $hs1fevm3sshport = GetPort -Endpoints $hs1fevm3Endpoints -usage ssh
#Collecting VM Host names
$hs1bvmHostName = $hs1bvm.Name
$hs1fevm1HostName = $hs1fevm1.Name
$hs1fevm2HostName = $hs1fevm2.Name
$hs1fevm3HostName = $hs1fevm3.Name
#Preparation of daytrader install xml file #Preparation of daytrader install xml file
"#all the IPs should be Internal ips `n<back_endVM_ip>$beip</back_endVM_ip>`n<front_endVM_ips>$fe1ip $fe2ip $fe3ip</front_endVM_ips>`n<username>$user</username>`n<password>$passwd</password>" > 'Daytrader_install.XML' "#all the IPs should be Internal ips `n<back_endVM_ip>$beip</back_endVM_ip>`n<front_endVM_ips>$fe1ip $fe2ip $fe3ip</front_endVM_ips>`n<username>$user</username>`n<password>$passwd</password>" > 'Daytrader_install.XML'
$out = RemoteCopy -uploadTo $hs1VIP -port $hs1bvmsshport -files "Daytrader_install.XML" -username $user -password $password -upload 2>&1 | Out-Null $out = RemoteCopy -uploadTo $hs1VIP -port $hs1bvmsshport -files "Daytrader_install.XML" -username $user -password $password -upload 2>&1 | Out-Null
Remove-Item Daytrader_install.XML Remove-Item Daytrader_install.XML
$out = RemoteCopy -uploadTo $hs1VIP -port $hs1bvmsshport -files $currentTestData.files -username $user -password $password -upload 2>&1 | Out-Null $out = RemoteCopy -uploadTo $hs1VIP -port $hs1bvmsshport -files $currentTestData.files -username $user -password $password -upload 2>&1 | Out-Null
$istarcreated = CreateIbmTar -ip $hs1VIP -port $hs1bvmsshport
if($istarcreated -eq $false){
throw "Failed to create IBMWebSphere tar file"
}
else
{
Logmsg "Creating IBMWebsphere tar completed .. "
}
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bvmsshport -command "chmod +x *" -runAsSudo 2>&1 | Out-Null $out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bvmsshport -command "chmod +x *" -runAsSudo 2>&1 | Out-Null
#TODO fix ssh tcp alive issue
# converting file format from UTF-16 to ASCII # converting file format from UTF-16 to ASCII
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bvmsshport -command "iconv -f UTF-16 -t ASCII Daytrader_install.XML > Daytrader_install.XML.tmp ; mv -f Daytrader_install.XML.tmp Daytrader_install.XML" -runAsSudo 2>&1 | Out-Null $out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bvmsshport -command "iconv -f UTF-16 -t ASCII Daytrader_install.XML > Daytrader_install.XML.tmp ; mv -f Daytrader_install.XML.tmp Daytrader_install.XML" -runAsSudo 2>&1 | Out-Null
#$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bvmsshport -command "iconv -f UTF-16 -t ASCII $($currentTestData.testScript) > Daytrader_install.py.tmp ; mv -f Daytrader_install.py.tmp $($currentTestData.testScript)" -runAsSudo 2>&1 | Out-Null $out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bvmsshport -command "chmod +x *.XML" -runAsSudo 2>&1 | Out-Null
#Uploading temp file fot test
$out = RemoteCopy -uploadTo $hs1VIP -port $hs1fevm1sshport -files .\remote-scripts\temp.txt -username $user -password $password -upload 2>&1 | Out-Null
$out = RemoteCopy -uploadTo $hs1VIP -port $hs1fevm2sshport -files .\remote-scripts\temp.txt -username $user -password $password -upload 2>&1 | Out-Null
$out = RemoteCopy -uploadTo $hs1VIP -port $hs1fevm3sshport -files .\remote-scripts\temp.txt -username $user -password $password -upload 2>&1 | Out-Null
#Checking Hostname is correct or not
$bHostName = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bvmsshport -command "hostname" -runAsSudo
$fe1HostName = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1fevm1sshport -command "hostname" -runAsSudo
$fe2HostName = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1fevm2sshport -command "hostname" -runAsSudo
$fe3HostName = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1fevm3sshport -command "hostname" -runAsSudo
if(($bHostName -imatch $hs1bvmHostName) -and ($fe1HostName -imatch $hs1fevm1HostName) -and ($fe2HostName -imatch $hs1fevm2HostName) -and ($fe3HostName -imatch $hs1fevm3HostName)){
LogMsg "HostName is correct -- no need to set..`n Hostname in WA Portal: $hs1bvmHostName `n Hostname in VM (with hosname command): $bHostName `n Hostname in WA Portal: $hs1fevm1HostName `n Hostname in VM (with hosname command): $fe1HostName `n Hostname in WA Portal: $hs1fevm2HostName `n Hostname in VM (with hosname command): $fe2HostName `n Hostname in WA Portal: $hs1fevm3HostName `n Hostname in VM (with hosname command): $fe3HostName"
}
else{
LogMsg "HostName is not correct -- need to be set.. `n Hostname in WA Portal: $hs1bvmHostName `n Hostname in VM (with hosname command): $bHostName `n Hostname in WA Portal: $hs1fevm1HostName `n Hostname in VM (with hosname command): $fe1HostName `n Hostname in WA Portal: $hs1fevm2HostName `n Hostname in VM (with hosname command): $fe2HostName `n Hostname in WA Portal: $hs1fevm3HostName `n Hostname in VM (with hosname command): $fe3HostName"
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bvmsshport -command "hostname $hs1bvmHostName" -runAsSudo 2>&1 | Out-Null
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1fevm1sshport -command "hostname $hs1fevm1HostName" -runAsSudo 2>&1 | Out-Null
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1fevm2sshport -command "hostname $hs1fevm2HostName" -runAsSudo 2>&1 | Out-Null
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1fevm3sshport -command "hostname $hs1fevm3HostName" -runAsSudo 2>&1 | Out-Null
LogMsg "Setting of correct HostName done.."
}
LogMsg "Executing : $($currentTestData.testScript)" LogMsg "Executing : $($currentTestData.testScript)"
# Daytrader installation on E2EFOURVM
Write-host "#################################################################################################" Write-host "#################################################################################################"
Write-host "" Write-host ""
Write-host "Daytrader four vm installation has been started." -foregroundcolor "yellow" Write-host "Daytrader four vm installation has been started." -foregroundcolor "yellow"
Write-host "It takes nearly 50 minutes and may take even more time depending on internet speed." -foregroundcolor "yellow" Write-host "It takes nearly 50 minutes and may take even more time depending on internet speed." -foregroundcolor "yellow"
Write-host "" Write-host ""
Write-host "#################################################################################################" Write-host "#################################################################################################"
#Here Daytrader setup is Executing... #Here Daytrader setup is Executing...
#TODO collect cmd argument from azure xml file and pass it to python $dtr_setup_status = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bvmsshport -command "python $($currentTestData.testScript) $($currentTestData.E2ESetupCmdLineArgument) 2>&1 > print.log" -runAsSudo -runmaxallowedtime 9000 -ignoreLinuxExitCode 2>&1 | Out-Null
$dtr_setup_status = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bvmsshport -command "python $($currentTestData.testScript) $($currentTestData.E2ESetupCmdLineArgument) 2>&1 > print.log" -runAsSudo 2>&1 | Out-Null
#$dtr_setup_status = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bvmsshport -command "python $($currentTestData.testScript) loadbalancer_setup 2>&1 > print.log" -runAsSudo 2>&1 | Out-Null
# TODO time out for single vm reboot
$out = RemoteCopy -download -downloadFrom $hs1VIP -files "/home/$user/dtr_test.txt,/home/$user/logs.tar.gz" -downloadTo $LogDir -port $hs1bvmsshport -username $user -password $password 2>&1 | Out-Null $out = RemoteCopy -download -downloadFrom $hs1VIP -files "/home/$user/dtr_test.txt,/home/$user/logs.tar.gz" -downloadTo $LogDir -port $hs1bvmsshport -username $user -password $password 2>&1 | Out-Null
}else{ }
elseif($currentTestData.E2ESetupCmdLineArgument -imatch "singleVM_setup")
{
$hs1vm1 = $testVMsinService
$hs1vm1Endpoints = $hs1vm1 | Get-AzureEndpoint
$hs1vm1sshport = GetPort -Endpoints $hs1vm1Endpoints -usage ssh
$hs1VIP = $hs1vm1Endpoints[0].Vip
$hs1ServiceUrl = $hs1vm1.DNSName
$hs1HostName = $hs1vm1.Name
$hs1ServiceUrl = $hs1ServiceUrl.Replace("http://","")
$hs1ServiceUrl = $hs1ServiceUrl.Replace("/","")
$wsurl = "http:`/`/"+$hs1ServiceUrl.Replace(" ","")+":8080"
$dturl = "$wsurl`/daytrader"
$dip = $hs1vm1.Ipaddress.ToString()
"#all the IPs should be Internal ips `n<username>$user</username>`n<password>$passwd</password>" > 'Daytrader_install.XML'
$out = RemoteCopy -uploadTo $hs1VIP -port $hs1vm1sshport -files "Daytrader_install.XML" -username $user -password $password -upload 2>&1 | Out-Null
$out = RemoteCopy -uploadTo $hs1VIP -port $hs1vm1sshport -files $currentTestData.files -username $user -password $password -upload 2>&1 | Out-Null
$istarcreated = CreateIbmTar -ip $hs1VIP -port $hs1vm1sshport
if($istarcreated -eq $false){
throw "Failed to create IBMWebSphere tar file"
}
else{
Logmsg "Creating IBMWebsphere tar completed .. "
}
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "chmod +x *" -runAsSudo 2>&1 | Out-Null
# converting file format from UTF-16 to ASCII
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "iconv -f UTF-16 -t ASCII Daytrader_install.XML > Daytrader_install.XML.tmp ; mv -f Daytrader_install.XML.tmp Daytrader_install.XML" -runAsSudo 2>&1 | Out-Null
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "chmod +x *.XML" -runAsSudo 2>&1 | Out-Null
#Checking Hostname is correct or not
$HostName = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "hostname" -runAsSudo
if($HostName -imatch $hs1HostName){
LogMsg "HostName is correct -- no need to set.. `n Hostname in WA Portal: $hs1HostName `n Hostname in VM (with hosname command): $HostName"
}
else{
LogMsg "HostName is not correct -- need to be set.. `n Hostname in WA Portal: $hs1HostName `n Hostname in VM (with hosname command): $HostName"
RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "hostname $hs1HostName" -runAsSudo 2>&1 | Out-Null
LogMsg "Setting of correct HostName done.."
}
LogMsg "Executing : $($currentTestData.testScript)"
Write-host "#################################################################################################"
Write-host ""
Write-host "Daytrader single vm installation has been started." -foregroundcolor "yellow"
Write-host "It takes nearly 20 minutes and may take more time depending on internet speed." -foregroundcolor "yellow"
Write-host ""
Write-host "#################################################################################################"
$dtr_setup_status = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "python $($currentTestData.testScript) $($currentTestData.E2ESetupCmdLineArgument) 2>&1 > print.log" -runAsSudo -runmaxallowedtime 9000 -ignoreLinuxExitCode 2>&1 | Out-Null
$temp = RetryOperation -operation { Restart-AzureVM -ServiceName $hs1vm1.ServiceName -Name $hs1vm1.Name -Verbose } -description "Restarting VM.." -maxRetryCount 10 -retryInterval 5
if ( $temp.OperationStatus -eq "Succeeded" )
{
LogMsg "Restarted Successfully"
if ((isAllSSHPortsEnabled -DeployedServices $testVMsinService.DeploymentName) -imatch "True")
{
$out = RemoteCopy -download -downloadFrom $hs1VIP -files "/home/$user/dtr_test.txt, /home/$user/logs.tar.gz" -downloadTo $LogDir -port $hs1vm1sshport -username $user -password $password 2>&1 | Out-Null
}
}
else
{
Throw "Error in VM Restart."
}
}
else
{
$testResult="FAIL" $testResult="FAIL"
LogErr "Command line argument not properly added for Daytrader Setup, add the argument for FourVM: loadbalancer_setup, SingleVM: singleVM_setup in azure_ica_all.xml file at E2ESetupCmdLineArgument tag" LogErr "Command line argument not properly added for Daytrader Setup, add the argument for FourVM: loadbalancer_setup, SingleVM: singleVM_setup in azure_ica_all.xml file at E2ESetupCmdLineArgument tag"
} }
#Verifying Daytrader setup id completed or not #Verifying Daytrader setup id completed or not
try{ try
{
$out = Select-String -Simple "DTR_INSTALL_PASS" $LogDir\dtr_test.txt $out = Select-String -Simple "DTR_INSTALL_PASS" $LogDir\dtr_test.txt
if($out){ if($out){
write-host "Daytrader setup finished successfully." write-host "Daytrader setup finished successfully."
@ -130,17 +226,15 @@ if ($isDeployed)
write-host "Daytrader setup failed." write-host "Daytrader setup failed."
$testResult="FAIL" $testResult="FAIL"
} }
} }catch{
catch
{
write-host "Daytrader setup failed..." write-host "Daytrader setup failed..."
$testResult="FAIL" $testResult="FAIL"
} }
}catch{
$testResult="Aborted"
LogMsg "Exception Detected in execution of $($currentTestData.testScript)"
} }
catch{
$ErrorMessage = $_.Exception.Message
$testResult="Aborted"
}
} }
catch catch
{ {
@ -164,28 +258,28 @@ else
} }
#Verification of Daytrader URL #Verification of Daytrader URL
try{ try
$webclient = New-Object System.Net.WebClient {
$webclient.DownloadFile($dturl,"$pwd\daytrader.html") Start-Sleep -s 120
$webclient = New-Object System.Net.WebClient
$out = Select-String -Simple DayTrader daytrader.html $out = $webclient.DownloadString($dturl)
if($out){
if($out -imatch "DayTrader"){
write-host "Daytrader verification using url: $dturl success." write-host "Daytrader verification using url: $dturl success."
$testResult="PASS" $testResult="PASS"
}else{ }else{
write-host "Daytrader verification using url: $dturl failed." write-host "Daytrader verification using url: $dturl failed."
$testResult="FAIL" $testResult="FAIL"
} }
Remove-Item daytrader.html }
}catch{ catch
write-host "Daytrader verification using url: $dturl failed..." {
$testResult="FAIL" write-host "Daytrader verification using url: $dturl failed..."
$testResult="FAIL"
} }
$resultArr += $testResult $resultArr += $testResult
$result = $testResult $result = $testResult
#Clean up the setup
#DoTestCleanUp -result $result -testName $currentTestData.testName -deployedServices $isDeployed
if ($testResult -eq "PASS") if ($testResult -eq "PASS")
{ {
Write-host "#################################################################################################" Write-host "#################################################################################################"

Разница между файлами не показана из-за своего большого размера Загрузить разницу