diff --git a/src/App/Livetests/TestLiveScenarios.ps1 b/src/App/Livetests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..74eb8dc8d352 --- /dev/null +++ b/src/App/Livetests/TestLiveScenarios.ps1 @@ -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 $envName -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 $envName).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-True { $actual.Count -ge 1 } + # 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} + +} diff --git a/src/ContainerInstance/LiveTests/TestLiveScenarios.ps1 b/src/ContainerInstance/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..93daa53c36f1 --- /dev/null +++ b/src/ContainerInstance/LiveTests/TestLiveScenarios.ps1 @@ -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-True { $actual.Count -ge 1 } +} + +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} +} \ No newline at end of file diff --git a/src/ContainerRegistry/LiveTests/TestLiveScenarios.ps1 b/src/ContainerRegistry/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..479ed968b5e6 --- /dev/null +++ b/src/ContainerRegistry/LiveTests/TestLiveScenarios.ps1 @@ -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-True { $actual.Count -ge 1 } +} + +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} +} \ No newline at end of file