Merge pull request #88 from iamshital/master

Enabled ARM support for extension test cases.
This commit is contained in:
lizzha 2015-09-16 10:37:29 +08:00
Родитель 83a35cb732 551796592d
Коммит 2d81aad4db
7 изменённых файлов: 246 добавлений и 58 удалений

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

@ -3696,7 +3696,7 @@
<testScriptps1>ICA-CUSTOM-SCRIPT-EXTENSION-TEST.ps1</testScriptps1>
<setupType>ExtensionTest</setupType>
<ProvisionTimeExtensions>CustomScriptTouchCommand</ProvisionTimeExtensions>
<SupportedExecutionModes>AzureServiceManagement</SupportedExecutionModes>
<SupportedExecutionModes>AzureServiceManagement,AzureResourceManager</SupportedExecutionModes>
<Priority>P0</Priority>
</test>
<test>
@ -3705,7 +3705,7 @@
<testScriptps1>ICA-OS-PATCHING-EXTENSION-TEST.ps1</testScriptps1>
<ProvisionTimeExtensions>OsPatching</ProvisionTimeExtensions>
<setupType>ExtensionTest</setupType>
<SupportedExecutionModes>AzureServiceManagement</SupportedExecutionModes>
<SupportedExecutionModes>AzureServiceManagement,AzureResourceManager</SupportedExecutionModes>
<Priority>P0</Priority>
</test>
<test>
@ -3714,7 +3714,7 @@
<testScriptps1>ICA-VM-DIAGNOSTIC-EXTENSION-TEST.ps1</testScriptps1>
<ProvisionTimeExtensions>LinuxDiagnosticDefaultDataSet</ProvisionTimeExtensions>
<setupType>ExtensionTest</setupType>
<SupportedExecutionModes>AzureServiceManagement</SupportedExecutionModes>
<SupportedExecutionModes>AzureServiceManagement,AzureResourceManager</SupportedExecutionModes>
<Priority>P0</Priority>
</test>
</testsDefinition>

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

@ -216,6 +216,36 @@ $apiVersion = "2015-05-01-preview"
$PublicIPName = $($RGName -replace '[^a-zA-Z]') + "PublicIP"
$sshPath = '/home/' + $user + '/.ssh/authorized_keys'
$sshKeyData = ""
if ( $CurrentTestData.ProvisionTimeExtensions )
{
$extensionString = (Get-Content .\XML\Extensions.xml)
foreach ($line in $extensionString.Split("`n"))
{
if ($line -imatch ">$($CurrentTestData.ProvisionTimeExtensions)<")
{
$ExecutePS = $true
}
if ($line -imatch '</Extension>')
{
$ExecutePS = $false
}
if ( ($line -imatch "EXECUTE-PS-" ) -and $ExecutePS)
{
$PSoutout = ""
$line = $line.Trim()
$line = $line.Replace("EXECUTE-PS-","")
$line = $line.Split(">")
$line = $line.Split("<")
LogMsg "Executing Powershell command from Extensions.XML file : $($line[2])..."
$PSoutout = Invoke-Expression -Command $line[2]
$extensionString = $extensionString.Replace("EXECUTE-PS-$($line[2])",$PSoutout)
sleep -Milliseconds 1
}
}
$extensionXML = [xml]$extensionString
}
LogMsg "ARM Storage Account : $StorageAccountName"
LogMsg "Using API VERSION : $apiVersion "
@ -940,6 +970,77 @@ if ( $numberOfVMs -eq 1)
LogMsg "Added Virtual Machine $vmName"
Add-Content -Value "$($indents[2])}" -Path $jsonFile
#endregion
#region Extensions
if ( $CurrentTestData.ProvisionTimeExtensions)
{
foreach ( $extension in $CurrentTestData.ProvisionTimeExtensions.Split(",") )
{
$extension = $extension.Trim()
foreach ( $newExtn in $extensionXML.Extensions.Extension )
{
if ($newExtn.Name -eq $extension)
{
Add-Content -Value "$($indents[2])," -Path $jsonFile
Add-Content -Value "$($indents[2]){" -Path $jsonFile
Add-Content -Value "$($indents[3])^apiVersion^: ^$apiVersion^," -Path $jsonFile
Add-Content -Value "$($indents[3])^type^: ^Microsoft.Compute/virtualMachines/extensions^," -Path $jsonFile
Add-Content -Value "$($indents[3])^name^: ^$vmName/$extension^," -Path $jsonFile
Add-Content -Value "$($indents[3])^location^: ^[variables('location')]^," -Path $jsonFile
Add-Content -Value "$($indents[3])^dependsOn^: " -Path $jsonFile
Add-Content -Value "$($indents[3])[" -Path $jsonFile
Add-Content -Value "$($indents[4])^[concat('Microsoft.Compute/virtualMachines/', '$vmName')]^" -Path $jsonFile
Add-Content -Value "$($indents[3])]," -Path $jsonFile
Add-Content -Value "$($indents[3])^properties^:" -Path $jsonFile
Add-Content -Value "$($indents[3]){" -Path $jsonFile
Add-Content -Value "$($indents[4])^publisher^:^$($newExtn.Publisher)^," -Path $jsonFile
Add-Content -Value "$($indents[4])^type^:^$($newExtn.OfficialName)^," -Path $jsonFile
Add-Content -Value "$($indents[4])^typeHandlerVersion^:^$($newExtn.LatestVersion)^" -Path $jsonFile
if ($newExtn.PublicConfiguration)
{
Add-Content -Value "$($indents[4])," -Path $jsonFile
Add-Content -Value "$($indents[4])^settings^:" -Path $jsonFile
Add-Content -Value "$($indents[4]){" -Path $jsonFile
$isConfigAdded = $false
foreach ($extnConfig in $newExtn.PublicConfiguration.ChildNodes)
{
if ( $isConfigAdded )
{
Add-Content -Value "$($indents[5])," -Path $jsonFile
}
Add-Content -Value "$($indents[5])^$($extnConfig.Name)^ : ^$($extnConfig.'#text')^" -Path $jsonFile
LogMsg "Added $extension Extension : Public Configuration : $($extnConfig.Name) = $($extnConfig.'#text')"
$isConfigAdded = $true
}
Add-Content -Value "$($indents[4])}" -Path $jsonFile
}
if ( $newExtn.PrivateConfiguration )
{
Add-Content -Value "$($indents[4])," -Path $jsonFile
Add-Content -Value "$($indents[4])^protectedSettings^:" -Path $jsonFile
Add-Content -Value "$($indents[4]){" -Path $jsonFile
$isConfigAdded = $false
foreach ($extnConfig in $newExtn.PrivateConfiguration.ChildNodes)
{
if ( $isConfigAdded )
{
Add-Content -Value "$($indents[5])," -Path $jsonFile
}
Add-Content -Value "$($indents[5])^$($extnConfig.Name)^ : ^$($extnConfig.'#text')^" -Path $jsonFile
LogMsg "Added $extension Extension : Private Configuration : $($extnConfig.Name) = $( ( ( $extnConfig.'#text' -replace "\w","*") -replace "\W","*" ) )"
$isConfigAdded = $true
}
Add-Content -Value "$($indents[4])}" -Path $jsonFile
}
Add-Content -Value "$($indents[3])}" -Path $jsonFile
}
}
}
}
#endregion extension
Add-Content -Value "$($indents[2])}" -Path $jsonFile
Add-Content -Value "$($indents[1])]" -Path $jsonFile
#endregion
}

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

@ -6235,7 +6235,32 @@ Function RetryOperation($operation, $description, $expectResult=$null, $maxRetry
} while ($True)
return $null
}#endregion
}
Function GetStorageAccountKey ($xmlConfig)
{
if ( $UseAzureResourceManager )
{
$storageAccountName = $xmlConfig.config.Azure.General.ARMStorageAccount
$StorageAccounts = Get-AzureStorageAccount
foreach ($SA in $StorageAccounts)
{
if ( $SA.Name -eq $storageAccountName )
{
LogMsg "Getting $storageAccountName storage account key..."
$storageAccountKey = (Get-AzureStorageAccountKey -ResourceGroupName $SA.ResourceGroupName -Name $SA.Name).Key1
}
}
}
else
{
$storageAccountName = $xmlConfig.config.Azure.General.StorageAccount
LogMsg "Getting $storageAccountName storage account key..."
$storageAccountKey = (Get-AzureStorageKey -StorageAccountName $storageAccountName).Primary
}
return $storageAccountKey
}
#endregion
#region LinuxUtilities
Function GetFilePathsFromLinuxFolder ([string]$folderToSearch, $IpAddress, $SSHPort, $username, $password, $maxRetryCount=20)

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

@ -3,18 +3,18 @@
<Extension>
<Name>CustomScriptTouchCommand</Name>
<OfficialName>CustomScriptForLinux</OfficialName>
<Publisher>"Microsoft.OSTCExtensions"</Publisher>
<Publisher>Microsoft.OSTCExtensions</Publisher>
<PublicConfiguration>
<timestamp>EXECUTE-PS-(Get-Date).ticks</timestamp>
<fileUris></fileUris>
<commandToExecute>touch /var/log/CustomExtensionSuccessful</commandToExecute>
</PublicConfiguration>
<Version>1.*</Version>
<LatestVersion>1.3</LatestVersion>
</Extension>
<Extension>
<Name>OsPatching</Name>
<OfficialName>OSPatchingForLinux</OfficialName>
<Publisher>"Microsoft.OSTCExtensions"</Publisher>
<Publisher>Microsoft.OSTCExtensions</Publisher>
<PublicConfiguration>
<timestamp>EXECUTE-PS-(Get-Date).ticks</timestamp>
<rebootAfterPatch>Auto</rebootAfterPatch>
@ -28,16 +28,18 @@
<stop>$false</stop>
</PublicConfiguration>
<Version>2.*</Version>
<LatestVersion>2.0</LatestVersion>
</Extension>
<Extension>
<Name>LinuxDiagnosticDefaultDataSet</Name>
<OfficialName>LinuxDiagnostic</OfficialName>
<Publisher>"Microsoft.OSTCExtensions"</Publisher>
<Publisher>Microsoft.OSTCExtensions</Publisher>
<PrivateConfiguration>
<storageAccountName>EXECUTE-PS-$xmlConfig.config.Azure.General.StorageAccount</storageAccountName>
<storageAccountKey>EXECUTE-PS-(Get-AzureStorageKey -StorageAccountName $xmlConfig.config.Azure.General.StorageAccount).Primary</storageAccountKey>
<storageAccountName>EXECUTE-PS-if($UseAzureResourceManager){$xmlConfig.config.Azure.General.ARMStorageAccount}else{$xmlConfig.config.Azure.General.StorageAccount}</storageAccountName>
<storageAccountKey>EXECUTE-PS-GetStorageAccountKey -xmlConfig $xmlConfig</storageAccountKey>
</PrivateConfiguration>
<Version>2.*</Version>
<LatestVersion>2.0</LatestVersion>
</Extension>
</Extensions>

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

@ -42,24 +42,44 @@ if ($isDeployed)
{
$extensionVerified = $false
}
$ConfirmExtensionScriptBlock = {
$ExtensionName = "CustomScriptForLinux"
if ( $UseAzureResourceManager )
{
$ConfirmExtensionScriptBlock = {
$ExtensionStatus = Get-AzureResource -OutputObjectFormat New -ResourceGroupName $isDeployed -ResourceType "Microsoft.Compute/virtualMachines/extensions" -ExpandProperties
if ( ($ExtensionStatus.Properties.ProvisioningState -eq "Succeeded") -and ( $ExtensionStatus.Properties.Type -eq $ExtensionName ) )
{
LogMsg "$ExtensionName extension status is Succeeded in Properties.ProvisioningState"
$ExtensionVerfiedWithPowershell = $true
}
else
{
LogErr "$ExtensionName extension status is Failed in Properties.ProvisioningState"
$ExtensionVerfiedWithPowershell = $false
}
return $ExtensionVerfiedWithPowershell
}
}
else
{
$ConfirmExtensionScriptBlock = {
$vmDetails = Get-AzureVM -ServiceName $isDeployed
if ( ( $vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Status -eq "Success" ) -and ($vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Name -imatch "CustomScriptForLinux" ))
{
$ExtensionVerfiedWithPowershell = $true
LogMsg "CustomScriptForLinux extension status is SUCCESS in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
$vmDetails = Get-AzureVM -ServiceName $isDeployed
if ( ( $vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Status -eq "Success" ) -and ($vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Name -imatch $ExtensionName ))
{
$ExtensionVerfiedWithPowershell = $true
LogMsg "$ExtensionName extension status is SUCCESS in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
}
else
{
$ExtensionVerfiedWithPowershell = $false
LogErr "$ExtensionName extension status is FAILED in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
}
return $ExtensionVerfiedWithPowershell
}
else
{
$ExtensionVerfiedWithPowershell = $false
LogErr "CustomScriptForLinux extension status is FAILED in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
}
return $ExtensionVerfiedWithPowershell
}
$ExtensionVerfiedWithPowershell = RetryOperation -operation $ConfirmExtensionScriptBlock -description "Confirming CustomScript extension from Azure side." -expectResult $true -maxRetryCount 10 -retryInterval 10
$ExtensionVerfiedWithPowershell = RetryOperation -operation $ConfirmExtensionScriptBlock -description "Confirming $ExtensionName extension from Azure side." -expectResult $true -maxRetryCount 10 -retryInterval 10
if ( $ExtensionVerfiedWithPowershell -and $extensionVerified )
{
@ -85,10 +105,8 @@ if ($isDeployed)
$testResult = "Aborted"
}
$resultArr += $testResult
#$resultSummary += CreateResultSummary -testResult $testResult -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"
@ -98,7 +116,7 @@ else
$result = GetFinalResultHeader -resultarr $resultArr
#Clean up the setup
DoTestCleanUp -result $result -testName $currentTestData.testName -deployedServices $isDeployed
DoTestCleanUp -result $result -testName $currentTestData.testName -deployedServices $isDeployed -ResourceGroups $isDeployed
#Return the result and summery to the test suite script..
return $result

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

@ -98,24 +98,43 @@ if ($isDeployed)
LogErr "No Extension logs are available."
$extensionVerified = $false
}
$ConfirmExtensionScriptBlock = {
$vmDetails = Get-AzureVM -ServiceName $isDeployed
if ( ( $vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Status -eq "Success" ) -and ($vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Name -imatch "OSPatchingForLinux" ))
{
$ExtensionVerfiedWithPowershell = $true
LogMsg "OSPatchingForLinux extension status is SUCCESS in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
}
else
{
$ExtensionVerfiedWithPowershell = $false
LogErr "OSPatchingForLinux extension status is FAILED in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
$ExtensionName = "OSPatchingForLinux"
if ( $UseAzureResourceManager )
{
$ConfirmExtensionScriptBlock = {
$ExtensionStatus = Get-AzureResource -OutputObjectFormat New -ResourceGroupName $isDeployed -ResourceType "Microsoft.Compute/virtualMachines/extensions" -ExpandProperties
if ( ($ExtensionStatus.Properties.ProvisioningState -eq "Succeeded") -and ( $ExtensionStatus.Properties.Type -eq $ExtensionName ) )
{
LogMsg "$ExtensionName extension status is Succeeded in Properties.ProvisioningState"
$ExtensionVerfiedWithPowershell = $true
}
else
{
LogErr "$ExtensionName extension status is Failed in Properties.ProvisioningState"
$ExtensionVerfiedWithPowershell = $false
}
}
return $ExtensionVerfiedWithPowershell
}
$ExtensionVerfiedWithPowershell = RetryOperation -operation $ConfirmExtensionScriptBlock -description "Confirming OS PATCHING extension from Azure side." -expectResult $true -maxRetryCount 10 -retryInterval 10
else
{
$ConfirmExtensionScriptBlock = {
$vmDetails = Get-AzureVM -ServiceName $isDeployed
if ( ( $vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Status -eq "Success" ) -and ($vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Name -imatch $ExtensionName ))
{
$ExtensionVerfiedWithPowershell = $true
LogMsg "$ExtensionName extension status is SUCCESS in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
}
else
{
$ExtensionVerfiedWithPowershell = $false
LogErr "$ExtensionName extension status is FAILED in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
}
return $ExtensionVerfiedWithPowershell
}
}
$ExtensionVerfiedWithPowershell = RetryOperation -operation $ConfirmExtensionScriptBlock -description "Confirming $ExtensionName extension from Azure side." -expectResult $true -maxRetryCount 10 -retryInterval 10
if ( $ExtensionVerfiedWithPowershell -and $extensionVerified )
{
$testResult = "PASS"
@ -153,7 +172,7 @@ else
$result = GetFinalResultHeader -resultarr $resultArr
#Clean up the setup
DoTestCleanUp -result $result -testName $currentTestData.testName -deployedServices $isDeployed
DoTestCleanUp -result $result -testName $currentTestData.testName -deployedServices $isDeployed -ResourceGroups $isDeployed
#Return the result and summery to the test suite script..
return $result

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

@ -51,6 +51,7 @@ if ($isDeployed)
LogMsg "Extension Agent not started in Linux VM"
$waitForExtension = $true
$extensionVerified = $false
WaitFor -Seconds 30
}
}
else
@ -69,22 +70,44 @@ if ($isDeployed)
LogErr "No Extension logs are available."
$extensionVerified = $false
}
$ConfirmExtensionScriptBlock = {
$vmDetails = Get-AzureVM -ServiceName $isDeployed
if ( ( $vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Status -eq "Success" ) -and ($vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Name -imatch "Microsoft.OSTCExtensions.LinuxDiagnostic" ))
{
$ExtensionVerfiedWithPowershell = $true
LogMsg "LinuxDiagnostic extension status is SUCCESS in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
$ExtensionName = "LinuxDiagnostic"
if ( $UseAzureResourceManager )
{
$ConfirmExtensionScriptBlock = {
$ExtensionStatus = Get-AzureResource -OutputObjectFormat New -ResourceGroupName $isDeployed -ResourceType "Microsoft.Compute/virtualMachines/extensions" -ExpandProperties
if ( ($ExtensionStatus.Properties.ProvisioningState -eq "Succeeded") -and ( $ExtensionStatus.Properties.Type -eq $ExtensionName ) )
{
LogMsg "$ExtensionName extension status is Succeeded in Properties.ProvisioningState"
$ExtensionVerfiedWithPowershell = $true
}
else
{
LogErr "$ExtensionName extension status is Failed in Properties.ProvisioningState"
$ExtensionVerfiedWithPowershell = $false
}
return $ExtensionVerfiedWithPowershell
}
else
{
$ExtensionVerfiedWithPowershell = $false
LogErr "LinuxDiagnostic extension status is FAILED in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
}
return $ExtensionVerfiedWithPowershell
}
$ExtensionVerfiedWithPowershell = RetryOperation -operation $ConfirmExtensionScriptBlock -description "Confirming VM DIAGNOSTICS extension from Azure side." -expectResult $true -maxRetryCount 10 -retryInterval 10
else
{
$ConfirmExtensionScriptBlock = {
$vmDetails = Get-AzureVM -ServiceName $isDeployed
if ( ( $vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Status -eq "Success" ) -and ($vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Name -imatch $ExtensionName ))
{
$ExtensionVerfiedWithPowershell = $true
LogMsg "$ExtensionName extension status is SUCCESS in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
}
else
{
$ExtensionVerfiedWithPowershell = $false
LogErr "$ExtensionName extension status is FAILED in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
}
return $ExtensionVerfiedWithPowershell
}
}
$ExtensionVerfiedWithPowershell = RetryOperation -operation $ConfirmExtensionScriptBlock -description "Confirming $ExtensionName extension from Azure side." -expectResult $true -maxRetryCount 10 -retryInterval 10
if ( $ExtensionVerfiedWithPowershell -and $extensionVerified)
{
$testResult = "PASS"
@ -122,7 +145,7 @@ else
$result = GetFinalResultHeader -resultarr $resultArr
#Clean up the setup
DoTestCleanUp -result $result -testName $currentTestData.testName -deployedServices $isDeployed
DoTestCleanUp -result $result -testName $currentTestData.testName -deployedServices $isDeployed -ResourceGroups $isDeployed
#Return the result and summery to the test suite script..
return $result