-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Livetest #21044
Livetest #21044
Changes from 10 commits
6108814
2e367e1
3d4b1dd
6fd1ceb
4acc963
923b7f1
ee5e0bc
1aa3b2c
a3cec44
a9949dd
69403d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Invoke-LiveTestScenario -Name "List ContainerApp" -Description "Test listing ContainerApp" -ScenarioScript ` | ||
{ | ||
param ($rg) | ||
$rgName = $rg.ResourceGroupName | ||
$appName = New-LiveTestResourceName | ||
$workspaceName = New-LiveTestResourceName | ||
$envName = New-LiveTestResourceName | ||
$headerName = New-LiveTestResourceName | ||
$secretName = New-LiveTestResourceName | ||
$appLocation = "westus" | ||
$null = New-AzOperationalInsightsWorkspace -ResourceGroupName $rgName -Name $workspaceName -Sku PerGB2018 -Location $appLocation -PublicNetworkAccessForIngestion "Enabled" -PublicNetworkAccessForQuery "Enabled" | ||
$CustomId = (Get-AzOperationalInsightsWorkspace -ResourceGroupName $rgName -Name $workspaceName).CustomerId | ||
$SharedKey = (Get-AzOperationalInsightsWorkspaceSharedKey -ResourceGroupName $rgName -Name $workspaceName).PrimarySharedKey | ||
$null = New-AzContainerAppManagedEnv -EnvName $workspaceName -ResourceGroupName $rgName -Location $appLocation -AppLogConfigurationDestination "log-analytics" -LogAnalyticConfigurationCustomerId $CustomId -LogAnalyticConfigurationSharedKey $SharedKey -VnetConfigurationInternal:$false | ||
$trafficWeight = New-AzContainerAppTrafficWeightObject -Label production -LatestRevision $True -Weight 100 | ||
$secretObject = New-AzContainerAppSecretObject -Name $secretName -Value "facebook-password" | ||
$containerAppHttpHeader = New-AzContainerAppProbeHeaderObject -Name $headerName -Value Awesome | ||
$probe = New-AzContainerAppProbeObject -HttpGetPath "/health" -HttpGetPort 8080 -InitialDelaySecond 3 -PeriodSecond 3 -Type Liveness -HttpGetHttpHeader $containerAppHttpHeader | ||
$image = New-AzContainerAppTemplateObject -Name $appName -Image mcr.microsoft.com/azuredocs/containerapps-helloworld:latest -Probe $probe -ResourceCpu 2.0 -ResourceMemory 4.0Gi | ||
$EnvId = (Get-AzContainerAppManagedEnv -ResourceGroupName $rgName -EnvName $workspaceName).Id | ||
$scaleRule = @() | ||
# Test creating AzContainerApp | ||
$actual = New-AzContainerApp -Name $appName -ResourceGroupName $rgName -Location $appLocation -ConfigurationActiveRevisionsMode 'Single' -ManagedEnvironmentId $EnvId -IngressExternal -IngressTransport 'auto' -IngressTargetPort 80 -TemplateContainer $image -ConfigurationSecret $secretObject -IngressTraffic $trafficWeight -DaprEnabled -DaprAppProtocol 'http' -DaprAppId "container-app-1" -DaprAppPort 8080 -ScaleRule $scaleRule | ||
Assert-AreEqual $appName $actual.Name | ||
Assert-AreEqual 8080 $actual.DaprAppPort | ||
# Test listing ContainerApp | ||
$null = New-AzContainerApp -Name $appName -ResourceGroupName $rgName -Location $appLocation -ConfigurationActiveRevisionsMode 'Single' -ManagedEnvironmentId $EnvId -IngressExternal -IngressTransport 'auto' -IngressTargetPort 80 -TemplateContainer $image -ConfigurationSecret $secretObject -IngressTraffic $trafficWeight -DaprEnabled -DaprAppProtocol 'http' -DaprAppId "container-app-1" -DaprAppPort 8080 -ScaleRule $scaleRule | ||
$actual = Get-AzContainerApp -ResourceGroupName $rgName | ||
Assert-AreEqual 1 $actual.Count | ||
# Test getting one ContainerApp | ||
$null = New-AzContainerApp -Name $appName -ResourceGroupName $rgName -Location $appLocation -ConfigurationActiveRevisionsMode 'Single' -ManagedEnvironmentId $EnvId -IngressExternal -IngressTransport 'auto' -IngressTargetPort 80 -TemplateContainer $image -ConfigurationSecret $secretObject -IngressTraffic $trafficWeight -DaprEnabled -DaprAppProtocol 'http' -DaprAppId "container-app-1" -DaprAppPort 8080 -ScaleRule $scaleRule | ||
$actual = Get-AzContainerApp -ResourceGroupName $rgName -Name $appName | ||
Assert-AreEqual $appName $actual.Name | ||
# Test Updating one specific ContainerApp | ||
$null = New-AzContainerApp -Name $appName -ResourceGroupName $rgName -Location $appLocation -ConfigurationActiveRevisionsMode 'Single' -ManagedEnvironmentId $EnvId -IngressExternal -IngressTransport 'auto' -IngressTargetPort 80 -TemplateContainer $image -ConfigurationSecret $secretObject -IngressTraffic $trafficWeight -DaprEnabled -DaprAppProtocol 'http' -DaprAppId "container-app-1" -DaprAppPort 8080 -ScaleRule $scaleRule | ||
$null = Update-AzContainerApp -Name $appName -ResourceGroupName $rgName -DaprAppPort 8888 -Location $appLocation | ||
$actual = Get-AzContainerApp -ResourceGroupName $rgName -Name $appName | ||
Assert-AreEqual $actual.DaprAppPort 8888 | ||
# Test Removing ContainerApp | ||
$null = New-AzContainerApp -Name $appName -ResourceGroupName $rgName -Location $appLocation -ConfigurationActiveRevisionsMode 'Single' -ManagedEnvironmentId $EnvId -IngressExternal -IngressTransport 'auto' -IngressTargetPort 80 -TemplateContainer $image -ConfigurationSecret $secretObject -IngressTraffic $trafficWeight -DaprEnabled -DaprAppProtocol 'http' -DaprAppId "container-app-1" -DaprAppPort 8080 -ScaleRule $scaleRule | ||
$null = Remove-AzContainerApp -ResourceGroupName $rgName -Name $appName | ||
$GetServiceList = Get-AzContainerApp -ResourceGroupName $rgName | ||
Assert-False { $GetServiceList.Name -contains $appName} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
Invoke-LiveTestScenario -Name "Create ContainerGroup" -Description "Test New-AzContainerGroup" -ScenarioScript ` | ||
{ | ||
param ($rg) | ||
$rgName = $rg.ResourceGroupName | ||
$containerName = New-LiveTestResourceName | ||
$cgName = New-LiveTestResourceName | ||
$cgLocation = "westus" | ||
$container = New-AzContainerInstanceObject -Name $containerName -Image alpine | ||
$actual = New-AzContainerGroup -ResourceGroupName $rgName -Name $cgName -Location $cgLocation -Container $container | ||
Assert-AreEqual $cgName $actual.Name | ||
Assert-AreEqual $cgLocation $actual.Location | ||
} | ||
|
||
Invoke-LiveTestScenario -Name "List ContainerGroup" -Description "Test listing ContainerGroup" -ScenarioScript ` | ||
{ | ||
param ($rg) | ||
|
||
$rgName = $rg.ResourceGroupName | ||
$containerName = New-LiveTestResourceName | ||
$cgName = New-LiveTestResourceName | ||
$cgLocation = "westus" | ||
$container = New-AzContainerInstanceObject -Name $containerName -Image alpine | ||
$null = New-AzContainerGroup -ResourceGroupName $rgName -Name $cgName -Location $cgLocation -Container $container | ||
$actual = Get-AzContainerGroup -ResourceGroupName $rgName | ||
Assert-AreEqual 1 $actual.Count | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assertion may have potential risk due to retry mechanism. If Get- fails, then the next time the resource group will host 2 container instances. The reason is that retry won't create new resource group but create under the same resource group where the error is thrown. |
||
} | ||
|
||
Invoke-LiveTestScenario -Name "Get ContainerGroup" -Description "Test getting one ContainerGroup" -ScenarioScript ` | ||
{ | ||
param ($rg) | ||
|
||
$rgName = $rg.ResourceGroupName | ||
$containerName = New-LiveTestResourceName | ||
$cgName = New-LiveTestResourceName | ||
$cgLocation = "westus" | ||
$container = New-AzContainerInstanceObject -Name $containerName -Image alpine | ||
$null = New-AzContainerGroup -ResourceGroupName $rgName -Name $cgName -Location $cgLocation -Container $container | ||
$actual = Get-AzContainerGroup -ResourceGroupName $rgName -Name $cgName | ||
Assert-AreEqual $cgName $actual.Name | ||
} | ||
|
||
Invoke-LiveTestScenario -Name "Update ContainerGroup" -Description "Test Updating one specific ContainerGroup" -ScenarioScript ` | ||
{ | ||
param ($rg) | ||
|
||
$rgName = $rg.ResourceGroupName | ||
$containerName = New-LiveTestResourceName | ||
$cgName = New-LiveTestResourceName | ||
$cgLocation = "westus" | ||
$tag = @{'key'='v'} | ||
$container = New-AzContainerInstanceObject -Name $containerName -Image alpine | ||
$null = New-AzContainerGroup -ResourceGroupName $rgName -Name $cgName -Location $cgLocation -Container $container | ||
$null = Update-AzContainerGroup -Name $cgName -ResourceGroupName $rgName -Tag $tag | ||
$actual = Get-AzContainerGroup -ResourceGroupName $rgName -Name $cgName | ||
Assert-AreEqual $actual.$tag.Count 1 | ||
} | ||
|
||
Invoke-LiveTestScenario -Name "Remove ContainerGroup" -Description "Test Removing ContainerGroup" -ScenarioScript ` | ||
{ | ||
param ($rg) | ||
$rgName = $rg.ResourceGroupName | ||
$containerName = New-LiveTestResourceName | ||
$cgName = New-LiveTestResourceName | ||
$cgLocation = "westus" | ||
$container = New-AzContainerInstanceObject -Name $containerName -Image alpine | ||
$null = New-AzContainerGroup -ResourceGroupName $rgName -Name $cgName -Location $cgLocation -Container $container | ||
$null = Remove-AzContainerGroup -ResourceGroupName $rgName -Name $cgName | ||
$GetServiceList = Get-AzContainerGroup -ResourceGroupName $rgName | ||
Assert-False { $GetServiceList.Name -contains $cgName} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Invoke-LiveTestScenario -Name "Create ContainerRegistry" -Description "Test Create AzContainerRegistry" -ScenarioScript ` | ||
{ | ||
param ($rg) | ||
$rgName = $rg.ResourceGroupName | ||
$cgName = New-LiveTestResourceName | ||
$cgLocation = "westus" | ||
$actual = New-AzContainerRegistry -ResourceGroupName $rgName -Name $cgName -Location $cgLocation -Sku Basic | ||
Assert-AreEqual $cgName $actual.Name | ||
Assert-AreEqual $cgLocation $actual.Location | ||
} | ||
|
||
Invoke-LiveTestScenario -Name "List ContainerRegistry" -Description "Test listing ContainerRegistry" -ScenarioScript ` | ||
{ | ||
param ($rg) | ||
|
||
$rgName = $rg.ResourceGroupName | ||
$cgName = New-LiveTestResourceName | ||
$cgLocation = "westus" | ||
$null = New-AzContainerRegistry -ResourceGroupName $rgName -Name $cgName -Location $cgLocation -Sku Basic | ||
$actual = Get-AzContainerRegistry -ResourceGroupName $rgName | ||
Assert-AreEqual 1 $actual.Count | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as the previous. |
||
} | ||
|
||
Invoke-LiveTestScenario -Name "Get ContainerRegistry" -Description "Test getting one ContainerRegistry" -ScenarioScript ` | ||
{ | ||
param ($rg) | ||
|
||
$rgName = $rg.ResourceGroupName | ||
|
||
$cgName = New-LiveTestResourceName | ||
$cgLocation = "westus" | ||
|
||
$null = New-AzContainerRegistry -ResourceGroupName $rgName -Name $cgName -Location $cgLocation -Sku Basic | ||
$actual = Get-AzContainerRegistry -ResourceGroupName $rgName -Name $cgName | ||
Assert-AreEqual $cgName $actual.Name | ||
} | ||
|
||
Invoke-LiveTestScenario -Name "Update ContainerRegistry" -Description "Test Updating one specific ContainerRegistry" -ScenarioScript ` | ||
{ | ||
param ($rg) | ||
$rgName = $rg.ResourceGroupName | ||
$cgName = New-LiveTestResourceName | ||
$cgLocation = "westus" | ||
$null = New-AzContainerRegistry -ResourceGroupName $rgName -Name $cgName -Location $cgLocation -Sku Basic | ||
$null = Update-AzContainerRegistry -Name $cgName -ResourceGroupName $rgName -EnableAdminUser | ||
$actual = Get-AzContainerRegistry -ResourceGroupName $rgName -Name $cgName | ||
Assert-AreEqual $actual.AdminUserEnabled True | ||
} | ||
|
||
Invoke-LiveTestScenario -Name "Remove ContainerRegistry" -Description "Test Removing ContainerRegistry" -ScenarioScript ` | ||
{ | ||
param ($rg) | ||
$rgName = $rg.ResourceGroupName | ||
$cgName = New-LiveTestResourceName | ||
$cgLocation = "westus" | ||
$null = New-AzContainerRegistry -ResourceGroupName $rgName -Name $cgName -Location $cgLocation -Sku Basic | ||
$null = Remove-AzContainerRegistry -ResourceGroupName $rgName -Name $cgName | ||
$GetServiceList = Get-AzContainerRegistry -ResourceGroupName $rgName | ||
Assert-False { $GetServiceList.Name -contains $cgName} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change : Assert-True { $actual.Count -ge 1 }