Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified SmokeTest/RmCoreSmokeTests.ps1. #13883

Merged
merged 7 commits into from
Jan 18, 2021
114 changes: 65 additions & 49 deletions tools/Test/SmokeTest/RmCoreSmokeTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,83 +37,99 @@ $resourceGroupName = "azpssmokerg$randomValue"
$storageAccountName = "azpssmokesa$randomValue"

$resourceSetUpCommands=@(
@{Name = "Az.Resources"; Command = {New-AzureRmResourceGroup -Name $resourceGroupName -Location westus -ErrorAction Stop}}
@{Name = "Az.Resources"; Command = {New-AzResourceGroup -Name $resourceGroupName -Location westus -ErrorAction Stop}}
)
$resourceCleanUpCommands = @(
@{Name = "Az.Storage [Cleanup]"; Command = {Remove-AzureRmStorageAccount -Name $storageAccountName -ResourceGroupName $resourceGroupName -Force -ErrorAction Stop}},
@{Name = "Az.Resources [Cleanup]"; Command = {Remove-AzureRmResourceGroup -Name $resourceGroupName -Force -ErrorAction Stop}}
@{Name = "Az.Storage [Cleanup]"; Command = {
$loopLimit = 0
do {
try {
Remove-AzStorageAccount -Name $storageAccountName -ResourceGroupName $resourceGroupName -Force -ErrorAction Stop
break
}
catch {
if (++$loopLimit -gt 30)
{
throw "Failed to invoke Az.Storage [Cleanup]. $_"
} else {
Write-Warning "Retry Az.Storage [Cleanup] after 30 seconds"
Start-Sleep -Seconds 30
}
}
} while ($true)
}},
@{Name = "Az.Resources [Cleanup]"; Command = {Remove-AzResourceGroup -Name $resourceGroupName -Force -ErrorAction Stop}}
LucasYao93 marked this conversation as resolved.
Show resolved Hide resolved
)
$resourceTestCommands = @(
@{Name = "Az.Storage [Management]"; Command = {New-AzureRmStorageAccount -Name $storageAccountName -SkuName Standard_LRS -Location westus -ResourceGroupName $resourceGroupName -ErrorAction Stop}},
@{Name = "Az.Storage [Data]"; Command = {New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey 12345678 -ErrorAction Stop}},
@{Name = "Az.Storage [Management]"; Command = {New-AzStorageAccount -Name $storageAccountName -SkuName Standard_LRS -Location westus -ResourceGroupName $resourceGroupName -ErrorAction Stop}},
@{Name = "Az.Storage [Data]"; Command = {New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey 12345678 -ErrorAction Stop}},
@{Name = "Az.Accounts"; Command = {Get-AzDomain -ErrorAction Stop}},
@{Name = "Az.Advisor"; Command = {Get-AzAdvisorConfiguration -ErrorAction Stop}},
@{Name = "Az.Aks"; Command = {Get-AzAksCluster -ErrorAction Stop}},
@{Name = "Az.AnalysisServices"; Command = {Get-AzureRmAnalysisServicesServer -ErrorAction Stop}},
@{Name = "Az.ApiManagement"; Command = {Get-AzureRmApiManagement -ErrorAction Stop}},
@{Name = "Az.ApplicationInsights"; Command = {Get-AzureRmApplicationInsights -ErrorAction Stop}},
@{Name = "Az.Automation"; Command = {Get-AzureRmAutomationAccount -ErrorAction Stop}},
@{Name = "Az.Batch"; Command = {Get-AzureRmBatchAccount -ErrorAction Stop}},
@{Name = "Az.Billing"; Command = {Get-AzureRmBillingInvoice -ErrorAction Stop}},
@{Name = "Az.Billing [Consumption]"; Command = {try {Get-AzureRmConsumptionUsageDetail -ErrorAction Stop} catch {if ($_.ToString() -notlike "*422*" -and $_.ToString() -notlike "*UnprocessableEntity*" -and $_.ToString() -notlike "*BadRequest*") {throw $_}}}},
@{Name = "Az.Cdn"; Command = {Get-AzureRmCdnProfile -ErrorAction Stop}},
@{Name = "Az.CognitiveServices"; Command = {Get-AzureRmCognitiveServicesAccount -ErrorAction Stop}},
@{Name = "Az.Compute"; Command = {Get-AzureRmVM -ErrorAction Stop}},
@{Name = "Az.ContainerInstance"; Command = {Get-AzureRmContainerGroup -ErrorAction Stop}},
@{Name = "Az.ContainerRegistry"; Command = {Get-AzureRmContainerRegistry -ErrorAction Stop}},
@{Name = "Az.AnalysisServices"; Command = {Get-AzAnalysisServicesServer -ErrorAction Stop}},
@{Name = "Az.ApiManagement"; Command = {Get-AzApiManagement -ErrorAction Stop}},
@{Name = "Az.ApplicationInsights"; Command = {Get-AzApplicationInsights -ErrorAction Stop}},
@{Name = "Az.Automation"; Command = {Get-AzAutomationAccount -ErrorAction Stop}},
@{Name = "Az.Batch"; Command = {Get-AzBatchAccount -ErrorAction Stop}},
@{Name = "Az.Billing"; Command = {Get-AzBillingInvoice -ErrorAction Stop}},
@{Name = "Az.Billing [Consumption]"; Command = {try {Get-AzConsumptionUsageDetail -ErrorAction Stop} catch {if ($_.ToString() -notlike "*422*" -and $_.ToString() -notlike "*UnprocessableEntity*" -and $_.ToString() -notlike "*BadRequest*") {throw $_}}}},
@{Name = "Az.Cdn"; Command = {Get-AzCdnProfile -ErrorAction Stop}},
@{Name = "Az.CognitiveServices"; Command = {Get-AzCognitiveServicesAccount -ErrorAction Stop}},
@{Name = "Az.Compute"; Command = {Get-AzVM -ErrorAction Stop}},
@{Name = "Az.ContainerInstance"; Command = {Get-AzContainerGroup -ErrorAction Stop}},
@{Name = "Az.ContainerRegistry"; Command = {Get-AzContainerRegistry -ErrorAction Stop}},
@{Name = "Az.DataBoxEdge"; Command = {Get-AzDataBoxEdgeDevice -ResourceGroupName $resourceGroupName -ErrorAction Stop}},
@{Name = "Az.Databricks"; Command = {Get-AzDatabricksWorkspace -ResourceGroupName $resourceGroupName -ErrorAction Stop}},
@{Name = "Az.DataFactory [V1]"; Command = {Get-AzureRmDataFactory -ResourceGroupName $resourceGroupName -ErrorAction Stop}},
@{Name = "Az.DataFactoryV2 [V2]"; Command = {Get-AzureRmDataFactoryV2 -ErrorAction Stop}},
@{Name = "Az.DataLakeAnalytics"; Command = {Get-AzureRmDataLakeAnalyticsAccount -ErrorAction Stop}},
@{Name = "Az.DataLakeStore"; Command = {Get-AzureRmDataLakeStoreAccount -ErrorAction Stop}},
@{Name = "Az.DataFactory [V1]"; Command = {Get-AzDataFactory -ResourceGroupName $resourceGroupName -ErrorAction Stop}},
@{Name = "Az.DataFactoryV2 [V2]"; Command = {Get-AzDataFactoryV2 -ErrorAction Stop}},
@{Name = "Az.DataLakeAnalytics"; Command = {Get-AzDataLakeAnalyticsAccount -ErrorAction Stop}},
@{Name = "Az.DataLakeStore"; Command = {Get-AzDataLakeStoreAccount -ErrorAction Stop}},
@{Name = "Az.DataShare"; Command = {Get-AzDataShareAccount -ResourceGroupName $resourceGroupName -ErrorAction Stop}},
# Waiting for an issue fix: https://github.com/Azure/azure-powershell/issues/13522#issuecomment-728659457
# @{Name = "Az.DeploymentManager"; Command = {try {Get-AzDeploymentManagerArtifactSource -ResourceGroupName $resourceGroupName -ErrorAction Stop}catch {if ($_.ToString() -notlike "*not found*") {throw $_}}}},
# Waiting for api '2020-11-02-preview' ready
# @{Name = "Az.DesktopVirtualization"; Command = {Get-AzWvdApplicationGroup -ResourceGroupName $resourceGroupName -ErrorAction Stop}},
@{Name = "Az.DesktopVirtualization"; Command = {Get-AzWvdApplicationGroup -ResourceGroupName $resourceGroupName -ErrorAction Stop}},
@{Name = "Az.DevTestLabs "; Command = {try {Get-AzDtlAllowedVMSizesPolicy -LabName nonexistent -ResourceGroupName nonexistent -ErrorAction Stop} catch {if ($_.ToString() -notlike "*'nonexistent' could not be found.") {throw $_}}}},
@{Name = "Az.Dns"; Command = {Get-AzureRmDnsZone -ErrorAction Stop}},
@{Name = "Az.EventGrid"; Command = {Get-AzureRmEventGridTopic -ErrorAction Stop}},
@{Name = "Az.EventHub"; Command = {Get-AzureRmEventHubNamespace -ErrorAction Stop}},
@{Name = "Az.Dns"; Command = {Get-AzDnsZone -ErrorAction Stop}},
@{Name = "Az.EventGrid"; Command = {Get-AzEventGridTopic -ErrorAction Stop}},
@{Name = "Az.EventHub"; Command = {Get-AzEventHubNamespace -ErrorAction Stop}},
@{Name = "Az.FrontDoor"; Command = {Get-AzFrontDoor -ErrorAction Stop}},
@{Name = "Az.Functions"; Command = {Get-AzFunctionApp -ErrorAction Stop}},
@{Name = "Az.HDInsight "; Command = {Get-AzHDInsightCluster -ErrorAction Stop}},
@{Name = "Az.HealthcareApis"; Command = {Get-AzHealthcareApisService -ErrorAction Stop}},
@{Name = "Az.IotHub"; Command = {Get-AzureRmIotHub -ErrorAction Stop}},
@{Name = "Az.KeyVault"; Command = {Get-AzureRmKeyVault -ErrorAction Stop}},
@{Name = "Az.IotHub"; Command = {Get-AzIotHub -ErrorAction Stop}},
@{Name = "Az.KeyVault"; Command = {Get-AzKeyVault -ErrorAction Stop}},
@{Name = "Az.Kusto"; Command = {Get-AzKustoCluster -ErrorAction Stop}},
@{Name = "Az.LogicApp"; Command = {Get-AzureRmIntegrationAccount -ErrorAction Stop}},
@{Name = "Az.MachineLearning"; Command = {Get-AzureRmMlWebService -ErrorAction Stop}},
@{Name = "Az.LogicApp"; Command = {Get-AzIntegrationAccount -ErrorAction Stop}},
@{Name = "Az.MachineLearning"; Command = {Get-AzMlWebService -ErrorAction Stop}},
@{Name = "Az.Maintenance"; Command = {Get-AzMaintenanceConfiguration -ErrorAction Stop}},
@{Name = "Az.ManagedServices"; Command = {Get-AzManagedServicesAssignment -ErrorAction Stop}},
# Machine learning compute cmdlets are removed. The following line are to be commented until they are brought back
# @{Name = "Az.MachineLearning [Compute]"; Command = {Get-AzureRmMlOpCluster -ErrorAction Stop}},
# @{Name = "Az.MachineLearning [Compute]"; Command = {Get-AzMlOpCluster -ErrorAction Stop}},
@{Name = "Az.MarketplaceOrdering"; Command = {try {Get-AzMarketplaceTerms -Publisher nonexistent -Product nonexistent -Name nonexistent -ErrorAction Stop} catch {if ($_.ToString() -notlike "*not found*") {throw $_}}}},
@{Name = "Az.Media"; Command = {Get-AzureRmMediaService -ResourceGroupName $resourceGroupName -ErrorAction Stop}},
@{Name = "Az.Monitor"; Command = {Get-AzureRmLogProfile -ErrorAction Stop}},
@{Name = "Az.Network"; Command = {Get-AzureRmNetworkInterface -ErrorAction Stop}},
@{Name = "Az.NotificationHubs"; Command = {Get-AzureRmNotificationHubsNamespace -ErrorAction Stop}},
@{Name = "Az.OperationalInsights"; Command = {Get-AzureRmOperationalInsightsWorkspace -ErrorAction Stop}},
@{Name = "Az.Media"; Command = {Get-AzMediaService -ResourceGroupName $resourceGroupName -ErrorAction Stop}},
@{Name = "Az.Monitor"; Command = {Get-AzLogProfile -ErrorAction Stop}},
@{Name = "Az.Network"; Command = {Get-AzNetworkInterface -ErrorAction Stop}},
@{Name = "Az.NotificationHubs"; Command = {Get-AzNotificationHubsNamespace -ErrorAction Stop}},
@{Name = "Az.OperationalInsights"; Command = {Get-AzOperationalInsightsWorkspace -ErrorAction Stop}},
@{Name = "Az.PolicyInsights"; Command = {Get-AzPolicyEvent -ErrorAction Stop}},
@{Name = "Az.PowerBIEmbedded"; Command = {Get-AzPowerBIEmbeddedCapacity -ErrorAction Stop}},
@{Name = "Az.PowerBIUEmbedded"; Command = {Get-AzureRmPowerBIWorkspaceCollection -ErrorAction Stop}},
@{Name = "Az.PowerBIUEmbedded"; Command = {Get-AzPowerBIWorkspaceCollection -ErrorAction Stop}},
@{Name = "Az.PrivateDns"; Command = {Get-AzPrivateDnsZone -ErrorAction Stop}},
@{Name = "Az.RecoveryServices"; Command = {Get-AzRecoveryServicesVault -ErrorAction Stop}},
@{Name = "Az.RedisCache"; Command = {Get-AzureRmRedisCache -ErrorAction Stop}},
@{Name = "Az.Relay"; Command = {Get-AzureRmRelayNamespace -ErrorAction Stop}},
@{Name = "Az.ServiceBus"; Command = {Get-AzureRmServiceBusNamespace -ErrorAction Stop}},
@{Name = "Az.ServiceFabric"; Command = {Get-AzureRmServiceFabricCluster -ErrorAction Stop}},
@{Name = "Az.RedisCache"; Command = {Get-AzRedisCache -ErrorAction Stop}},
@{Name = "Az.Relay"; Command = {Get-AzRelayNamespace -ErrorAction Stop}},
@{Name = "Az.ServiceBus"; Command = {Get-AzServiceBusNamespace -ErrorAction Stop}},
@{Name = "Az.ServiceFabric"; Command = {Get-AzServiceFabricCluster -ErrorAction Stop}},
@{Name = "Az.SignalR"; Command = {Get-AzSignalR -ErrorAction Stop}},
@{Name = "Az.Sql"; Command = {Get-AzureRmSqlServer -ErrorAction Stop}},
@{Name = "Az.Sql"; Command = {Get-AzSqlServer -ErrorAction Stop}},
@{Name = "Az.SqlVirtualMachine"; Command = {Get-AzSqlVM -ErrorAction Stop}},
@{Name = "Az.StreamAnalytics"; Command = {Get-AzureRmStreamAnalyticsJob -ErrorAction Stop}},
@{Name = "Az.StreamAnalytics"; Command = {Get-AzStreamAnalyticsJob -ErrorAction Stop}},
@{Name = "Az.StorageSync"; Command = {Get-AzStorageSyncService -ErrorAction Stop}},
@{Name = "Az.Support"; Command = {Get-AzSupportTicket -ErrorAction Stop}}
@{Name = "Az.Resources [Tags]"; Command = {Get-AzureRmTag -ErrorAction Stop}},
@{Name = "Az.TrafficManager"; Command = {Get-AzureRmTrafficManagerProfile -ErrorAction Stop}},
@{Name = "Az.Support"; Command = {Get-AzSupportTicket -ErrorAction Stop}},
@{Name = "Az.Resources [Tags]"; Command = {Get-AzTag -ErrorAction Stop}},
@{Name = "Az.TrafficManager"; Command = {Get-AzTrafficManagerProfile -ErrorAction Stop}},
@{Name = "Az.Billing [UsageAggregates]"; Command = {Get-UsageAggregates -ReportedStartTime '1/1/2018' -ReportedEndTime '1/2/2018' -ErrorAction Stop}},
@{Name = "Az.Websites"; Command = {Get-AzureRmWebApp -ErrorAction Stop}}
@{Name = "Az.Websites"; Command = {Get-AzWebApp -ErrorAction Stop}}
)

if($Reverse.IsPresent){
Expand All @@ -137,7 +153,7 @@ $resourceCommands | ForEach-Object {
catch
{
Write-Error $_.Exception
$detail = Resolve-AzureRmError -Last
$detail = Resolve-AzError -Last
$testInfo.FailureDetails += (New-Object PSObject -Property @{Name = $testName; Details = $detail})
$testInfo.FailedTests += $testName
}
Expand Down Expand Up @@ -172,6 +188,6 @@ if ($testInfo.FailedTests.Count -gt 0)
throw ("Test run failed with " + $testInfo.FailedTests.Count + " failures.")
}

# Resolve-AzureRmError
# Resolve-AzError
# $DebugPreference = $oldDebug
# $VerbosePreference = $oldVerbose