diff --git a/.azure-pipelines/live-test.yml b/.azure-pipelines/live-test.yml index 61cc7c56afd9..35c596f161e4 100644 --- a/.azure-pipelines/live-test.yml +++ b/.azure-pipelines/live-test.yml @@ -1,13 +1,17 @@ parameters: -- name: win_image - displayName: Windows Image Version +- name: img_windows_2019 + displayName: Windows 2019 Image Version type: string default: windows-2019 -- name: linux_image +- name: img_windows_2022 + displayName: Windows 2022 Image Version + type: string + default: windows-2022 +- name: img_linux displayName: Linux Image Version type: string default: ubuntu-20.04 -- name: macOS_image +- name: img_macos displayName: MacOS Image Version type: string default: macOS-11 @@ -18,15 +22,19 @@ parameters: - name: ps_7_0_x displayName: PowerShell 7.0.x Version type: string - default: 7.0.13 + default: 7.0.* - name: ps_7_1_x displayName: PowerShell 7.1.x Version type: string - default: 7.1.7 + default: 7.1.* - name: ps_7_2_x displayName: PowerShell 7.2.x Version type: string - default: 7.2.7 + default: 7.2.* +- name: ps_7_3_x + displayName: PowerShell 7.3.x Version + type: string + default: 7.3.* - name: ps_latest displayName: PowerShell Latest Version type: string @@ -41,10 +49,16 @@ parameters: default: 7.0.x variables: - LiveTestArtifactsName: LiveTestArtifacts - LiveTestDataLocation: $(Pipeline.Workspace)/$(LiveTestArtifactsName) - EnableTestCoverage: true - TestCoverageLocation: $(LiveTestDataLocation) + ArtifactsName: LiveTestArtifacts + DataLocation: $(Pipeline.Workspace)/$(ArtifactsName) + +schedules: +- cron: "0 19 * * *" + displayName: Daily Live Test + branches: + include: + - main + always: true pr: none trigger: none @@ -52,77 +66,144 @@ trigger: none jobs: - template: util/live-test-steps.yml parameters: - name: 'win_ps_5_1' - vmImage: ${{ parameters.win_image }} + name: 'win_ps_5_1_win_2019' + vmImage: ${{ parameters.img_windows_2019 }} + osType: 'Windows' + psVersion: ${{ parameters.win_ps_5_1 }} + dotnetVersion: ${{ parameters.dotnet_sdk_6 }} + +- template: util/live-test-steps.yml + parameters: + name: 'win_ps_5_1_win_2022' + vmImage: ${{ parameters.img_windows_2022 }} + osType: 'Windows' psVersion: ${{ parameters.win_ps_5_1 }} dotnetVersion: ${{ parameters.dotnet_sdk_6 }} - template: util/live-test-steps.yml parameters: - name: 'ps_7_0_x_win' - vmImage: ${{ parameters.win_image }} + name: 'ps_7_0_x_win_2019' + vmImage: ${{ parameters.img_windows_2019 }} + osType: 'Windows' psVersion: ${{ parameters.ps_7_0_x }} dotnetVersion: ${{ parameters.dotnet_sdk_6 }} - template: util/live-test-steps.yml parameters: - name: 'ps_7_1_x_win' - vmImage: ${{ parameters.win_image }} + name: 'ps_7_1_x_win_2019' + vmImage: ${{ parameters.img_windows_2019 }} + osType: 'Windows' psVersion: ${{ parameters.ps_7_1_x }} dotnetVersion: ${{ parameters.dotnet_sdk_6 }} - template: util/live-test-steps.yml parameters: - name: 'ps_7_2_x_win' - vmImage: ${{ parameters.win_image }} + name: 'ps_7_2_x_win_2019' + vmImage: ${{ parameters.img_windows_2019 }} + osType: 'Windows' psVersion: ${{ parameters.ps_7_2_x }} dotnetVersion: ${{ parameters.dotnet_sdk_6 }} - template: util/live-test-steps.yml parameters: - name: 'ps_latest_win' - vmImage: ${{ parameters.win_image }} - psVersion: ${{ parameters.ps_latest }} + name: 'ps_7_3_x_win_2019' + vmImage: ${{ parameters.img_windows_2019 }} + osType: 'Windows' + psVersion: ${{ parameters.ps_7_3_x }} + dotnetVersion: ${{ parameters.dotnet_sdk_7 }} + +- template: util/live-test-steps.yml + parameters: + name: 'ps_7_0_x_win_2022' + vmImage: ${{ parameters.img_windows_2022 }} + osType: 'Windows' + psVersion: ${{ parameters.ps_7_0_x }} + dotnetVersion: ${{ parameters.dotnet_sdk_6 }} + +- template: util/live-test-steps.yml + parameters: + name: 'ps_7_1_x_win_2022' + vmImage: ${{ parameters.img_windows_2022 }} + osType: 'Windows' + psVersion: ${{ parameters.ps_7_1_x }} + dotnetVersion: ${{ parameters.dotnet_sdk_6 }} + +- template: util/live-test-steps.yml + parameters: + name: 'ps_7_2_x_win_2022' + vmImage: ${{ parameters.img_windows_2022 }} + osType: 'Windows' + psVersion: ${{ parameters.ps_7_2_x }} + dotnetVersion: ${{ parameters.dotnet_sdk_6 }} + +- template: util/live-test-steps.yml + parameters: + name: 'ps_7_3_x_win_2022' + vmImage: ${{ parameters.img_windows_2022 }} + osType: 'Windows' + psVersion: ${{ parameters.ps_7_3_x }} dotnetVersion: ${{ parameters.dotnet_sdk_7 }} - template: util/live-test-steps.yml parameters: name: 'ps_7_0_x_linux' - vmImage: ${{ parameters.linux_image }} + vmImage: ${{ parameters.img_linux }} + osType: 'Linux' psVersion: ${{ parameters.ps_7_0_x }} dotnetVersion: ${{ parameters.dotnet_sdk_6 }} - template: util/live-test-steps.yml parameters: name: 'ps_7_1_x_linux' - vmImage: ${{ parameters.linux_image }} + vmImage: ${{ parameters.img_linux }} + osType: 'Linux' psVersion: ${{ parameters.ps_7_1_x }} dotnetVersion: ${{ parameters.dotnet_sdk_6 }} - template: util/live-test-steps.yml parameters: name: 'ps_7_2_x_linux' - vmImage: ${{ parameters.linux_image }} + vmImage: ${{ parameters.img_linux }} + osType: 'Linux' psVersion: ${{ parameters.ps_7_2_x }} dotnetVersion: ${{ parameters.dotnet_sdk_6 }} - template: util/live-test-steps.yml parameters: - name: 'ps_latest_linux' - vmImage: ${{ parameters.linux_image }} - psVersion: ${{ parameters.ps_latest }} + name: 'ps_7_3_x_linux' + vmImage: ${{ parameters.img_linux }} + osType: 'Linux' + psVersion: ${{ parameters.ps_7_3_x }} dotnetVersion: ${{ parameters.dotnet_sdk_7 }} +- template: util/live-test-steps.yml + parameters: + name: 'ps_7_0_x_macOS' + vmImage: ${{ parameters.img_macos }} + osType: 'MacOS' + psVersion: ${{ parameters.ps_7_0_x }} + dotnetVersion: ${{ parameters.dotnet_sdk_6 }} + +- template: util/live-test-steps.yml + parameters: + name: 'ps_7_1_x_macOS' + vmImage: ${{ parameters.img_macos }} + osType: 'MacOS' + psVersion: ${{ parameters.ps_7_1_x }} + dotnetVersion: ${{ parameters.dotnet_sdk_6 }} + - template: util/live-test-steps.yml parameters: name: 'ps_7_2_x_macOS' - vmImage: ${{ parameters.macOS_image }} + vmImage: ${{ parameters.img_macos }} + osType: 'MacOS' psVersion: ${{ parameters.ps_7_2_x }} dotnetVersion: ${{ parameters.dotnet_sdk_6 }} - template: util/live-test-steps.yml parameters: - name: 'ps_latest_macOS' - vmImage: ${{ parameters.macOS_image }} - psVersion: ${{ parameters.ps_latest }} + name: 'ps_7_3_x_macOS' + vmImage: ${{ parameters.img_macos }} + osType: 'MacOS' + psVersion: ${{ parameters.ps_7_3_x }} dotnetVersion: ${{ parameters.dotnet_sdk_7 }} diff --git a/.azure-pipelines/util/live-test-steps.yml b/.azure-pipelines/util/live-test-steps.yml index 22d211805e90..f5c34a25ab9f 100644 --- a/.azure-pipelines/util/live-test-steps.yml +++ b/.azure-pipelines/util/live-test-steps.yml @@ -1,12 +1,13 @@ parameters: - name: name - name: vmImage +- name: osType - name: psVersion - name: dotnetVersion jobs: - job: ${{ parameters.name }} - timeoutInMinutes: 180 + timeoutInMinutes: 600 pool: vmImage: ${{ parameters.vmImage }} @@ -32,40 +33,64 @@ jobs: pwsh: true targetType: inline script: - New-Item -Name $(LiveTestArtifactsName) -Path $(Pipeline.Workspace) -ItemType Directory -Force + New-Item -Name $(ArtifactsName) -Path $(Pipeline.Workspace) -ItemType Directory -Force - task: DownloadPipelineArtifact@2 - condition: and(succeeded(), eq(variables['GalleryName'], 'DailyBuild'), eq(variables['BuildPipelineBuildId'], '')) + condition: and(succeeded(), eq(variables['GalleryName'], 'DailyBuild'), eq(variables['PipelineBuildId'], '')) displayName: Download latest artifacts from daily build pipeline main branch inputs: - buildType: specific - project: $(ProjectToDownloadArtifacts) + buildType: 'specific' + project: $(BuildPipelineProject) definition: $(BuildPipelineDefinitionId) - buildVersionToDownload: latestFromBranch - branchName: refs/heads/master - artifactName: $(ArtifactName) + buildVersionToDownload: 'latestFromBranch' + branchName: 'refs/heads/main' + artifactName: 'artifacts' targetPath: $(Pipeline.Workspace) - task: DownloadPipelineArtifact@2 - condition: and(succeeded(), eq(variables['GalleryName'], 'DailyBuild'), ne(variables['BuildPipelineBuildId'], '')) + condition: and(succeeded(), eq(variables['GalleryName'], 'DailyBuild'), ne(variables['PipelineBuildId'], '')) displayName: Download specific artifacts from daily build pipeline inputs: - buildType: specific - project: $(ProjectToDownloadArtifacts) + buildType: 'specific' + project: $(BuildPipelineProject) definition: $(BuildPipelineDefinitionId) - buildVersionToDownload: specific - pipelineId: $(BuildPipelineBuildId) - artifactName: $(ArtifactName) + buildVersionToDownload: 'specific' + pipelineId: $(PipelineBuildId) + artifactName: 'artifacts' + targetPath: $(Pipeline.Workspace) + + - task: DownloadPipelineArtifact@2 + condition: and(succeeded(), eq(variables['GalleryName'], 'Sign'), eq(variables['PipelineBuildId'], '')) + displayName: Download latest artifacts from sign pipeline internal/release branch + inputs: + buildType: 'specific' + project: $(SignPipelineProject) + definition: $(SignPipelineDefinitionId) + buildVersionToDownload: 'latestFromBranch' + branchName: 'refs/heads/internal/release' + artifactName: 'artifacts' + targetPath: $(Pipeline.Workspace) + + - task: DownloadPipelineArtifact@2 + condition: and(succeeded(), eq(variables['GalleryName'], 'Sign'), ne(variables['PipelineBuildId'], '')) + displayName: Download specific artifacts from sign pipeline + inputs: + buildType: 'specific' + project: $(SignPipelineProject) + definition: $(SignPipelineDefinitionId) + buildVersionToDownload: 'specific' + pipelineId: $(PipelineBuildId) + artifactName: 'artifacts' targetPath: $(Pipeline.Workspace) - task: PowerShell@2 - condition: and(succeeded(), eq(variables['GalleryName'], 'DailyBuild')) + condition: and(succeeded(), ne(variables['GalleryName'], 'PSGallery')) displayName: Copy artifacts to local repository inputs: pwsh: true targetType: inline script: | - $azPackagesDir = New-Item -Name AzPackages -Path $(LiveTestDataLocation) -ItemType Directory -Force + $azPackagesDir = New-Item -Name AzPreviewPackages -Path $(DataLocation) -ItemType Directory -Force $azPackagesFiles = Join-Path -Path $(Pipeline.Workspace) -ChildPath *.nupkg Move-Item -Path $azPackagesFiles -Destination $azPackagesDir Get-ChildItem -LiteralPath $azPackagesDir @@ -76,7 +101,7 @@ jobs: pwsh: true targetType: filePath filePath: ./tools/TestFx/Live/InvokeLiveTestCITask.ps1 - arguments: -UseWindowsPowerShell ('${{ parameters.psVersion }}' -eq '5.1') -ScriptFile './tools/TestFx/Live/InstallLiveTestAzModules.ps1 -Source $(GalleryName) -AzPackagesLocation (Convert-Path -LiteralPath $(LiveTestDataLocation) | Join-Path -ChildPath AzPackages)' + arguments: -UseWindowsPowerShell ('${{ parameters.psVersion }}' -eq '5.1') -ScriptFile './tools/TestFx/Live/InstallLiveTestAzModules.ps1 -Source $(GalleryName) -AzPackagesLocation (Join-Path -Path $(DataLocation) -ChildPath AzPreviewPackages)' - task: PowerShell@2 displayName: Connect Azure with live test service principal @@ -85,6 +110,8 @@ jobs: targetType: filePath filePath: ./tools/TestFx/Live/InvokeLiveTestCITask.ps1 arguments: -UseWindowsPowerShell ('${{ parameters.psVersion }}' -eq '5.1') -ScriptFile './tools/TestFx/Live/ConnectLiveTestServicePrincipal.ps1 $(LiveTestServicePrincipalSubscriptionId) $(LiveTestServicePrincipalTenantId) $(LiveTestServicePrincipalId) $(LiveTestServicePrincipalSecret)' + failOnStderr: true + retryCountOnTaskFailure: 3 - task: PowerShell@2 displayName: Run top E2E live scenarios @@ -92,20 +119,22 @@ jobs: pwsh: true targetType: filePath filePath: ./tools/TestFx/Live/InvokeLiveTestCITask.ps1 - arguments: -UseWindowsPowerShell ('${{ parameters.psVersion }}' -eq '5.1') -ScriptFile './tools/TestFx/Live/InvokeLiveTestScenarios.ps1 $(Build.BuildId) ${{ parameters.vmImage }} ${{ parameters.psVersion }} $(Build.SourcesDirectory) $(LiveTestDataLocation)' - failOnStderr: true + arguments: -UseWindowsPowerShell ('${{ parameters.psVersion }}' -eq '5.1') -ScriptFile './tools/TestFx/Live/InvokeLiveTestScenarios.ps1 -RunPlatform ${{ parameters.osType }} -RepoLocation $(Build.SourcesDirectory) -DataLocation $(DataLocation)' - task: PowerShell@2 displayName: Save live test results to Kusto + condition: succeededOrFailed() inputs: pwsh: true targetType: filePath filePath: ./tools/TestFx/Live/SaveLiveTestResult.ps1 - arguments: $(KustoServicePrincipalTenantId) $(KustoServicePrincipalId) $(KustoServicePrincipalSecret) $(KustoClusterName) $(KustoClusterRegion) $(LiveTestDatabaseName) $(LiveTestTableName) $(TestCoverageTableName) $(LiveTestDataLocation) + arguments: $(KustoServicePrincipalTenantId) $(KustoServicePrincipalId) $(KustoServicePrincipalSecret) $(KustoClusterName) $(KustoClusterRegion) $(LiveTestDatabaseName) $(LiveTestTableName) $(DataLocation) $(Build.BuildId) ${{ parameters.vmImage }} "$(Tag)" + failOnStderr: true + retryCountOnTaskFailure: 3 - task: PublishPipelineArtifact@1 displayName: Publish live test results to pipeline artifact inputs: - artifact: livetest-os-${{ parameters.vmImage }}-powershell-${{ parameters.psVersion }} - targetPath: $(LiveTestDataLocation) + artifact: livetest-os-${{ parameters.vmImage }}-powershell-${{ parameters.name }} + targetPath: $(DataLocation) condition: always() diff --git a/src/Accounts/Accounts.Test/LiveTests/TestLiveScenarios.ps1 b/src/Accounts/Accounts.Test/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..78aef5e46e70 --- /dev/null +++ b/src/Accounts/Accounts.Test/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,20 @@ +Invoke-LiveTestScenario -Name "Validate access token" -Description "Test validating access token" -NoResourceGroup -ScenarioScript ` +{ + $account = (Get-AzContext).Account + $applicationId = $account.Id + $tenantId = $account.Tenants[0] + $token = Get-AzAccessToken + Assert-AreEqual $applicationId $token.UserId + Assert-AreEqual $tenantId $token.TenantId +} + +Invoke-LiveTestScenario -Name "Disconnect service principal account" -Description "Test disconnecting service principal account" -NoResourceGroup -ScenarioScript ` +{ + $account = (Get-AzContext).Account + $applicationId = $account.Id + $tenantId = $account.Tenants[0] + Disconnect-AzAccount -ApplicationId $applicationId -TenantId $tenantId + + $token = Get-AzAccessToken -ErrorAction SilentlyContinue + Assert-True { ($null -eq $token) -or ($null -ne $token -and $token.UserId -ne $applicationId) } +} diff --git a/src/Aks/Aks.Test/LiveTests/TestLiveScenarios.ps1 b/src/Aks/Aks.Test/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..42d43b460d1f --- /dev/null +++ b/src/Aks/Aks.Test/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,155 @@ +Invoke-LiveTestScenario -Name "Test_AKS_CURD" -Description "Test AKS Cluster CRUD and node pool CRU" -Platform Linux -PowerShellVersion Latest -ScenarioScript ` +{ + param ($rg) + + $resourceGroupName = $rg.ResourceGroupName + + # Generate random resource name if necessary + $kubeClusterName = New-LiveTestResourceName + + # step 1: create a default aks cluster with default node pool + + ssh-keygen -t rsa -f id_rsa -q -N '"123456"' + $sshKeyValue = Get-Content id_rsa.pub -Raw + + $kvName = "LiveTestKeyVault" + $aksSPIdKey = "AKSSPId" + $aksSPSecretKey = "AKSSPSecret" + $ServicePrincipalId = Get-AzKeyVaultSecret -VaultName $kvName -Name $aksSPIdKey -AsPlainText + $ServicePrincipalSecret = Get-AzKeyVaultSecret -VaultName $kvName -Name $aksSPSecretKey -AsPlainText + $servicePrincipalSecureSecret = ConvertTo-SecureString -String $ServicePrincipalSecret -AsPlainText -Force + $servicePrincipalCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ServicePrincipalId, $servicePrincipalSecureSecret + + Write-Host "##[section]Start to create Aks cluster : New-AzAksCluster" + New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName -SshKeyValue $sshKeyValue -ServicePrincipalIdAndSecret $servicePrincipalCredential + Write-Host "##[section]Finished creating Aks cluster : New-AzAksCluster" + + Write-Host "##[section]Start to retrieve Aks cluster : Get-AzAksCluster" + $cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName + Write-Host "##[section]Finished retrieving Aks cluster : Get-AzAksCluster" + + Assert-NotNull $cluster.Fqdn + Assert-NotNull $cluster.KubernetesVersion + Assert-NotNull $cluster.DnsPrefix + Assert-NotNull $cluster.NodeResourceGroup + Assert-AreEqual "Succeeded" $cluster.ProvisioningState + Assert-AreEqual 100 $cluster.MaxAgentPools + Assert-AreEqual $cluster.CurrentKubernetesVersion $cluster.KubernetesVersion + Assert-AreEqual "default" $cluster.AgentPoolProfiles.Name + Assert-AreEqual 1 $cluster.AgentPoolProfiles.Length + Assert-AreEqual 3 $cluster.AgentPoolProfiles[0].Count + Assert-NotNull $cluster.AgentPoolProfiles[0].NodeImageVersion + + Write-Host "##[section]Start to retrieve Aks node pool : Get-AzAksNodePool" + $pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName + Write-Host "##[section]Finished retrieving Aks node pool : Get-AzAksNodePool" + + Assert-NotNull $pools.VmSize + Assert-NotNull $pools.OsDiskSizeGB + Assert-NotNull $pools.OrchestratorVersion + Assert-NotNull $pools.NodeImageVersion + Assert-NotNull $pools.Id + Assert-AreEqual "Managed" $pools.OsDiskType + Assert-AreEqual "OS" $pools.KubeletDiskType + Assert-AreEqual 30 $pools.MaxPods + Assert-AreEqual "Linux" $pools.OsType + Assert-AreEqual "Ubuntu" $pools.OsSKU + Assert-AreEqual "System" $pools.Mode + Assert-AreEqual "VirtualMachineScaleSets" $pools.AgentPoolType + Assert-AreEqual $pools.CurrentOrchestratorVersion $pools.OrchestratorVersion + Assert-AreEqual "Succeeded" $pools.ProvisioningState + Assert-AreEqual "Running" $pools.PowerState.Code + Assert-AreEqual 0 $pools.Tags.Count + Assert-AreEqual 0 $pools.NodeLabels.Count + Assert-AreEqual 0 $pools.NodeTaints.Count + Assert-AreEqual "Microsoft.ContainerService/managedClusters/agentPools" $pools.Type + Assert-AreEqual 3 $pools.Count + Assert-Null $pools.VnetSubnetID + Assert-Null $pools.PodSubnetID + Assert-Null $pools.MaxCount + Assert-Null $pools.MinCount + Assert-Null $pools.EnableAutoScaling + Assert-Null $pools.UpgradeSettings + Assert-Null $pools.EnableNodePublicIP + Assert-Null $pools.ScaleSetPriority + Assert-Null $pools.ScaleSetEvictionPolicy + Assert-Null $pools.NodePublicIPPrefixID + Assert-Null $pools.SpotMaxPrice + Assert-Null $pools.ProximityPlacementGroupID + Assert-Null $pools.KubeletConfig + Assert-Null $pools.LinuxOSConfig + Assert-Null $pools.EnableEncryptionAtHost + Assert-Null $pools.EnableUltraSSD + Assert-Null $pools.GpuInstanceProfile + Assert-Null $pools.CreationData + Assert-Null $pools.HostGroupID + Assert-False {$pools.EnableFIPS} + + # step 2: update the aks cluster + Write-Host "##[section]Start to update Aks cluster : Set-AzAksCluster" + $cluster = $cluster | Set-AzAksCluster -NodeCount 4 -EnableUptimeSLA + Write-Host "##[section]Finished updating Aks cluster : Set-AzAksCluster" + + Assert-AreEqual 4 $cluster.AgentPoolProfiles[0].Count + Assert-AreEqual "Basic" $cluster.Sku.Name + Assert-AreEqual "Paid" $cluster.Sku.Tier + + # step 3: create the second node pool + $pool1Name = "default" + $pool2Name = "pool2" + + Write-Host "##[section]Start to create Aks node pool : New-AzAksNodePool" + New-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName -Name $pool2Name -OsType "Windows" -OsSKU "Windows2022" -Count 1 -VmSetType VirtualMachineScaleSets + Write-Host "##[section]Finished creating Aks node pool : New-AzAksNodePool" + + Write-Host "##[section]Start to retrieve Aks node pool : Get-AzAksNodePool" + $pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName + Write-Host "##[section]Finished retrieving Aks node pool : Get-AzAksNodePool" + + Assert-AreEqual 2 $pools.Count + Assert-AreEqualArray "Linux" ($pools | where {$_.Name -eq $pool1Name}).OsType + Assert-AreEqualArray "Ubuntu" ($pools | where {$_.Name -eq $pool1Name}).OsSKU + Assert-AreEqualArray "Windows" ($pools | where {$_.Name -eq $pool2Name}).OsType + Assert-AreEqualArray "Windows2022" ($pools | where {$_.Name -eq $pool2Name}).OsSKU + + # step4: update the second node pool + $labels = @{"someId" = 127; "tier" = "frontend"; "environment" = "qa" } + $tags = @{"dept"="MM"; "costcenter"=7777; "Admin"="Cindy"} + + Write-Host "##[section]Start to update Aks node pool : Update-AzAksNodePool" + Update-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName -Name $pool2Name -NodeLabel $labels -Tag $tags + Write-Host "##[section]Finished updating Aks node pool : Update-AzAksNodePool" + + Write-Host "##[section]Start to retrieve Aks cluster : Get-AzAksCluster" + $cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName + Write-Host "##[section]Finished retrieving Aks cluster : Get-AzAksCluster" + + Assert-AreEqual 2 $cluster.AgentPoolProfiles.Count + Assert-AreEqual 0 ($cluster.AgentPoolProfiles | where {$_.Name -eq $pool1Name}).NodeLabels.Count + Assert-AreEqual 0 ($cluster.AgentPoolProfiles | where {$_.Name -eq $pool1Name}).Tags.Count + Assert-AreEqual 127 ($cluster.AgentPoolProfiles | where {$_.Name -eq $pool2Name}).NodeLabels.someId + Assert-AreEqual frontend ($cluster.AgentPoolProfiles | where {$_.Name -eq $pool2Name}).NodeLabels.tier + Assert-AreEqual qa ($cluster.AgentPoolProfiles | where {$_.Name -eq $pool2Name}).NodeLabels.environment + Assert-AreEqual MM ($cluster.AgentPoolProfiles | where {$_.Name -eq $pool2Name}).Tags.dept + Assert-AreEqual 7777 ($cluster.AgentPoolProfiles | where {$_.Name -eq $pool2Name}).Tags.costcenter + Assert-AreEqual Cindy ($cluster.AgentPoolProfiles | where {$_.Name -eq $pool2Name}).Tags.Admin + + Write-Host "##[section]Start to retrieve Aks node pool : Get-AzAksNodePool" + $pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName + Write-Host "##[section]Finished retrieving Aks node pool : Get-AzAksNodePool" + + Assert-AreEqual 2 $pools.Count + Assert-AreEqual 0 ($pools | where {$_.Name -eq $pool1Name}).NodeLabels.Count + Assert-AreEqual 0 ($pools | where {$_.Name -eq $pool1Name}).Tags.Count + Assert-AreEqual 127 ($pools | where {$_.Name -eq $pool2Name}).NodeLabels.someId + Assert-AreEqual frontend ($pools | where {$_.Name -eq $pool2Name}).NodeLabels.tier + Assert-AreEqual qa ($pools | where {$_.Name -eq $pool2Name}).NodeLabels.environment + Assert-AreEqual MM ($pools | where {$_.Name -eq $pool2Name}).Tags.dept + Assert-AreEqual 7777 ($pools | where {$_.Name -eq $pool2Name}).Tags.costcenter + Assert-AreEqual Cindy ($pools | where {$_.Name -eq $pool2Name}).Tags.Admin + + Write-Host "##[section]Start to remove Aks cluster : Remove-AzAksCluster" + $cluster | Remove-AzAksCluster -Force + Write-Host "##[section]Finished removing Aks cluster : Remove-AzAksCluster" + +} diff --git a/src/AnalysisServices/AnalysisServices.Test/LiveTests/TestLiveScenarios.disabled.ps1 b/src/AnalysisServices/AnalysisServices.Test/LiveTests/TestLiveScenarios.disabled.ps1 new file mode 100644 index 000000000000..38caeaf2b21d --- /dev/null +++ b/src/AnalysisServices/AnalysisServices.Test/LiveTests/TestLiveScenarios.disabled.ps1 @@ -0,0 +1,89 @@ +Invoke-LiveTestScenario -Name "Create a new Analysis Service Server" -Description "Test creating a new Analysis Service Server" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $serverName = New-LiveTestResourceName + $location = "westus" + $SkuName = "S1" + + $actual = New-AzAnalysisServicesServer -ResourceGroupName $rgName -Name $serverName -Location $location -Sku $SkuName + Assert-AreEqual $serverName $actual.Name + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $SkuName $actual.Sku.Name +} + +Invoke-LiveTestScenario -Name "Get an Analysis Service Server" -Description "Test getting an Analysis Service Server" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $serverName = New-LiveTestResourceName + $location = "westus" + $SkuName = "S1" + + $null = New-AzAnalysisServicesServer -ResourceGroupName $rgName -Name $serverName -Location $location -Sku $SkuName + $actual = Get-AzAnalysisServicesServer -ResourceGroupName $rgName -Name $serverName + Assert-AreEqual $serverName $actual.Name + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $SkuName $actual.Sku.Name +} + +Invoke-LiveTestScenario -Name "Update an Analysis Service Server" -Description "Test invoking Set-AzAnalysisServicesServer" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $serverName = New-LiveTestResourceName + $location = "westus" + $SkuName = "S1" + $key = new-LiveTestResourceName + $value = new-LiveTestResourceName + + $null = New-AzAnalysisServicesServer -ResourceGroupName $rgName -Name $serverName -Location $location -Sku $SkuName + $null = Set-AzAnalysisServicesServer -Name $serverName -ResourceGroupName $rgName -Tag @{$key = $value} + $actual = get-AzAnalysisServicesServer -Name $serverName -ResourceGroupName $rgName + + Assert-AreEqual $serverName $actual.Name + Assert-AreEqual $actual.Tag[$key] $value +} + +Invoke-LiveTestScenario -Name "Delete an Analysis Service Server" -Description "Test invoking Remove-AzAnalysisServicesServer" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $serverName = New-LiveTestResourceName + $location = "westus" + $SkuName = "S1" + + $null = New-AzAnalysisServicesServer -ResourceGroupName $rgName -Name $serverName -Location $location -Sku $SkuName + # Delete Analysis Servicesserver + Remove-AzAnalysisServicesServer -ResourceGroupName $rgName -Name $serverName -PassThru + + # Verify that it is gone by trying to get it again + Assert-Throws {Get-AzAnalysisServicesServer -ResourceGroupName $rgName -Name $serverName} +} + +Invoke-LiveTestScenario -Name "Suspend and Resume an Analysis Service Server" -Description "Test Suspend-AzAnalysisServicesServer & Resume-AzAnalysisServicesServer" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $serverName = New-LiveTestResourceName + $location = "westus" + $SkuName = "S1" + + $null = New-AzAnalysisServicesServer -ResourceGroupName $rgName -Name $serverName -Location $location -Sku $SkuName + # Suspend Analysis Servicesserver + Suspend-AzAnalysisServicesServer -ResourceGroupName $rgName -Name $serverName + $serverGet = Get-AzAnalysisServicesServer -ResourceGroupName $rgName -Name $serverName + Assert-True {$serverGet.State -like "Paused"} + # Assert-True {$serverGet.ProvisioningState -like "Succeeded"} # TODO: Uncomment this in future after fix is deployed. + + # Resume Analysis Servicesserver + Resume-AzAnalysisServicesServer -ResourceGroupName $rgName -Name $serverName + $serverGet = Get-AzAnalysisServicesServer -ResourceGroupName $rgName -Name $serverName + Assert-True {$serverGet.ProvisioningState -like "Succeeded"} + Assert-True {$serverGet.State -like "Succeeded"} +} 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/ApplicationInsights/LiveTests/TestLiveScenarios.ps1 b/src/ApplicationInsights/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..c7c792ae226a --- /dev/null +++ b/src/ApplicationInsights/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,58 @@ +Invoke-LiveTestScenario -Name "Create ApplicationInsights" -Description "Test New-AzApplicationInsights" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $appName = New-LiveTestResourceName + $appLocation = "westus" + $appKind = "java" + + $actual = New-AzApplicationInsights -Kind $appKind -ResourceGroupName $rgName -Name $appName -location $appLocation + Assert-AreEqual $appName $actual.Name + Assert-AreEqual $appLocation $actual.Location + Assert-AreEqual $appKind $actual.Kind +} + +Invoke-LiveTestScenario -Name "Get ApplicationInsights" -Description "Test getting one ApplicationInsights" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $appName = New-LiveTestResourceName + $appLocation = "westus" + $appKind = "java" + + $null = New-AzApplicationInsights -Kind $appKind -ResourceGroupName $rgName -Name $appName -location $appLocation + $actual = Get-AzApplicationInsights -ResourceGroupName $rgName -Name $appName + Assert-AreEqual $appName $actual.Name +} + +Invoke-LiveTestScenario -Name "Update ApplicationInsights" -Description "Test Updating one specific ApplicationInsights" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $appName = New-LiveTestResourceName + $appLocation = "westus" + $appKind = "java" + + $null = New-AzApplicationInsights -Kind $appKind -ResourceGroupName $rgName -Name $appName -location $appLocation + $null = Update-AzApplicationInsights -ResourceGroupName $rgName -Name $appName -PublicNetworkAccessForIngestion "Disabled" + $actual = Get-AzApplicationInsights -Name $appName -ResourceGroupName $rgName + Assert-AreEqual $actual.PublicNetworkAccessForIngestion "Disabled" +} + +Invoke-LiveTestScenario -Name "Remove ApplicationInsights" -Description "Test Removing ApplicationInsights" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $appName = New-LiveTestResourceName + $appLocation = "westus" + $appKind = "java" + + $null = New-AzApplicationInsights -Kind $appKind -ResourceGroupName $rgName -Name $appName -location $appLocation + Remove-AzApplicationInsights -ResourceGroupName $rgName -Name $appName + $GetServiceList = Get-AzApplicationInsights -ResourceGroupName $rgName + Assert-False { $GetServiceList.Name -contains $appName} +} \ No newline at end of file diff --git a/src/Automation/Automation.Test/LiveTests/TestLiveScenarios.ps1 b/src/Automation/Automation.Test/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..25a12fbcaaf9 --- /dev/null +++ b/src/Automation/Automation.Test/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,64 @@ +Invoke-LiveTestScenario -Name "Create automation account" -Description "Test creating automation account with different sku" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $autoAccParams = @( + @{ + Name = New-LiveTestResourceName; + Location = "westus"; + Plan = "Free" + }, + @{ + Name = New-LiveTestResourceName; + Location = "eastus"; + Plan = "Basic" + } + ) + + $autoAccParams | ForEach-Object { + New-AzAutomationAccount -ResourceGroupName $rgName -Name $_.Name -Location $_.Location -Plan $_.Plan + + $actual = Get-AzAutomationAccount -ResourceGroupName $rgName -Name $_.Name + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $_.Name $actual.AutomationAccountName + Assert-AreEqual $_.Location $actual.Location + #Assert-AreEqual $_.Plan $actual.Plan + Assert-AreEqual "Ok" $actual.State + } +} + +Invoke-LiveTestScenario -Name "Update automation account" -Description "Test updating an existing automation account" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $accName = New-LiveTestResourceName + $accLocation = "centralus" + + New-AzAutomationAccount -ResourceGroupName $rgName -Name $accName -Location $accLocation + Set-AzAutomationAccount -ResourceGroupName $rgName -Name $accName -AssignSystemIdentity -DisablePublicNetworkAccess -Tags @{ "key" = "val" } + + $actual = Get-AzAutomationAccount -ResourceGroupName $rgName -Name $accName + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $accName $actual.AutomationAccountName + Assert-AreEqual $accLocation $actual.Location + Assert-AreEqual "Ok" $actual.State +} + +Invoke-LiveTestScenario -Name "Remove automation account" -Description "Test removing an automation account" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $accName = New-LiveTestResourceName + $accLocation = "eastus" + + New-AzAutomationAccount -ResourceGroupName $rgName -Name $accName -Location $accLocation + Remove-AzAutomationAccount -ResourceGroupName $rgName -Name $accName -Force + + $actual = Get-AzAutomationAccount -ResourceGroupName $rgName -Name $accName -ErrorAction SilentlyContinue + Assert-Null $actual +} diff --git a/src/BotService/LiveTests/TestLiveScenarios_disabled.ps1 b/src/BotService/LiveTests/TestLiveScenarios_disabled.ps1 new file mode 100644 index 000000000000..e65298e5e7f5 --- /dev/null +++ b/src/BotService/LiveTests/TestLiveScenarios_disabled.ps1 @@ -0,0 +1,71 @@ +Invoke-LiveTestScenario -Name "Create new registration bot service" -Description "Test creating a new registration bot service with all default values" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $botName = New-LiveTestResourceName + $botLocation = "westus" + $WebApplication1 = "ae96ba8b-3711-4464-abc4-9aeec3531a87" + + $actual = New-AzBotService -ResourceGroupName $rgName -Name $botName -ApplicationId $WebApplication1 -Location $botLocation -Sku F0 -Description "description" -Registration + Assert-AreEqual $botName $actual.Name + Assert-AreEqual $botLocation $actual.Location + Assert-AreEqual "F0" $actual.Sku.Name +} + +Invoke-LiveTestScenario -Name "List bot service" -Description "Test listing bot services in a resourcegroup" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $botName = New-LiveTestResourceName + $botLocation = "westus" + $WebApplication1 = "ae96ba8b-3711-4464-abc4-9aeec3531a87" + + $null = New-AzBotService -ResourceGroupName $rgName -Name $botName -ApplicationId $WebApplication1 -Location $botLocation -Sku F0 -Description "description" -Registration + $actual = Get-AzBotService -ResourceGroupName $rgName + Assert-AreEqual 1 $actual.Count +} + +Invoke-LiveTestScenario -Name "Get bot service" -Description "Test getting one specific bot service" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $botName = New-LiveTestResourceName + $botLocation = "westus" + $WebApplication1 = "ae96ba8b-3711-4464-abc4-9aeec3531a87" + + $null = New-AzBotService -ResourceGroupName $rgName -Name $botName -ApplicationId $WebApplication1 -Location $botLocation -Sku F0 -Description "description" -Registration + $actual = Get-AzBotService -ResourceGroupName $rgName -Name $botName + Assert-AreEqual $botName $actual.Name +} + +Invoke-LiveTestScenario -Name "Update bot service" -Description "Test Updating one specific bot service" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $botName = New-LiveTestResourceName + $botLocation = "westus" + $WebApplication1 = "ae96ba8b-3711-4464-abc4-9aeec3531a87" + + $null = New-AzBotService -ResourceGroupName $rgName -Name $botName -ApplicationId $WebApplication1 -Location $botLocation -Sku F0 -Description "description" -Registration + $actual = Update-AzBotService -Name $botName -ResourceGroupName $rgName -Kind bot + Assert-AreEqual "bot" $actual.Kind +} + +Invoke-LiveTestScenario -Name "Remove bot servcie" -Description "Test Removing a bot service" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $botName = New-LiveTestResourceName + $botLocation = "westus" + $WebApplication1 = "ae96ba8b-3711-4464-abc4-9aeec3531a87" + + $null = New-AzBotService -ResourceGroupName $rgName -Name $botName -ApplicationId $WebApplication1 -Location $botLocation -Sku F0 -Description "description" -Registration + Invoke-LiveTestCommand -Command "Remove-AzBotService -ResourceGroupName $rgName -Name $botName" + $GetServiceList = Get-AzBotService + Assert-False { $GetServiceList.Name -contains $botName} +} diff --git a/src/Compute/Compute.Test/LiveTests/TestLiveScenarios.ps1 b/src/Compute/Compute.Test/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..7582ae618a00 --- /dev/null +++ b/src/Compute/Compute.Test/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,174 @@ +Invoke-LiveTestScenario -Name "Creates a virtual machine." -Description "Test create new VM" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $name = New-LiveTestResourceName + + $VMLocalAdminUser = New-LiveTestResourceName; + $VMLocalAdminSecurePassword = ConvertTo-SecureString "Aalexwdy5#" -AsPlainText -Force; + $LocationName = "eastus"; + $domainNameLabel = New-LiveTestResourceName; + $Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $VMLocalAdminSecurePassword); + $text = New-LiveTestResourceName; + $bytes = [System.Text.Encoding]::Unicode.GetBytes($text); + $userData = [Convert]::ToBase64String($bytes); + + $actual = New-AzVM -ResourceGroupName $rgName -Name $name -Credential $Credential -DomainNameLabel $domainNameLabel -UserData $userData; + + Assert-AreEqual $name $actual.Name + # Assert-AreEqual "Succeeded" Label $actual.ProvisioningState + # Assert-AreEqual $userData $actual.UserData +} + +Invoke-LiveTestScenario -Name "Removes a virtual machine from Azure" -Description "Test removes a virtual machine from Azure." -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $name = New-LiveTestResourceName + + $VMLocalAdminUser = New-LiveTestResourceName; + $VMLocalAdminSecurePassword = ConvertTo-SecureString "Aalexwdy5#" -AsPlainText -Force; + $LocationName = "eastus"; + $domainNameLabel = New-LiveTestResourceName; + $Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $VMLocalAdminSecurePassword); + $text = New-LiveTestResourceName; + $bytes = [System.Text.Encoding]::Unicode.GetBytes($text); + $userData = [Convert]::ToBase64String($bytes); + + New-AzVM -ResourceGroupName $rgName -Name $name -Credential $Credential -DomainNameLabel $domainNameLabel -UserData $userData; + Remove-AzVM -ResourceGroupName $rgName -Name $name -Force + + $removedVM = Get-AzVM -ResourceGroupName $rgName -Name $name -ErrorAction SilentlyContinue + Assert-Null $removedVM +} + +Invoke-LiveTestScenario -Name "Create a managed disk" -Description "Test creating a managed disk" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $diskName = New-LiveTestResourceName + $diskLocation = "westus" + $diskSize = 10 + $diskSkuName = "Standard_LRS" + + $diskCfg = New-AzDiskConfig -Location $diskLocation -DiskSizeGB $diskSize -SkuName $diskSkuName -OsType Windows -CreateOption Empty + New-AzDisk -ResourceGroupName $rgName -DiskName $diskName -Disk $diskCfg | Out-Null + $actual = Get-AzDisk -ResourceGroupName $rgName -DiskName $diskName + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $diskName $actual.Name + Assert-AreEqual $diskLocation $actual.Location + Assert-AreEqual $diskSize $actual.DiskSizeGB + Assert-AreEqual $diskSkuName $actual.Sku.Name + Assert-AreEqual Windows $actual.OsType +} + +Invoke-LiveTestScenario -Name "Update a managed disk" -Description "Test updating an existing managed disk" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $diskName = New-LiveTestResourceName + $diskLocation = "westus" + $diskSize = 10 + $diskSizeUpdated = 20 + $diskSkuName = "Standard_LRS" + $diskSkuNameUpdated = "StandardSSD_LRS" + + $diskCfg = New-AzDiskConfig -Location $diskLocation -DiskSizeGB $diskSize -SkuName $diskSkuName -OsType Windows -CreateOption Empty + New-AzDisk -ResourceGroupName $rgName -DiskName $diskName -Disk $diskCfg + + $disk = Get-AzDisk -ResourceGroupName $rgName -DiskName $diskName + $disk.DiskSizeGB = $diskSizeUpdated + Update-AzDisk -ResourceGroupName $rgName -DiskName $diskName -Disk $disk + + $diskUpdateCfg = New-AzDiskUpdateConfig -SkuName $diskSkuNameUpdated + Update-AzDisk -ResourceGroupName $rgName -DiskName $diskName -DiskUpdate $diskUpdateCfg + + $actual = Get-AzDisk -ResourceGroupName $rgName -DiskName $diskName + Assert-NotNull $actual + Assert-AreEqual $diskSizeUpdated $actual.DiskSizeGB + Assert-AreEqual $diskSkuNameUpdated $actual.Sku.Name +} + +Invoke-LiveTestScenario -Name "Remove a managed disk" -Description "Test removing an existing managed disk" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $diskName = New-LiveTestResourceName + $diskLocation = "westus" + $diskSize = 10 + $diskSkuName = "Standard_LRS" + + $diskCfg = New-AzDiskConfig -Location $diskLocation -DiskSizeGB $diskSize -SkuName $diskSkuName -OsType Windows -CreateOption Empty + New-AzDisk -ResourceGroupName $rgName -DiskName $diskName -Disk $diskCfg + Remove-AzDisk -ResourceGroupName $rgName -DiskName $diskName -Force + + $actual = Get-AzDisk -ResourceGroupName $rgName -DiskName $diskName -ErrorAction SilentlyContinue + Assert-Null $actual +} + +Invoke-LiveTestScenario -Name "Create a ssh key" -Description "Test creating a ssh key" -PowerShellVersion "5.1", "Latest" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $keyName = New-LiveTestResourceName + + New-AzSshKey -ResourceGroupName $rgName -Name $keyName + + $actual = Get-AzSshKey -ResourceGroupName $rgName -Name $keyName + Assert-NotNull $actual + Assert-AreEqual $keyName $actual.Name +} + +Invoke-LiveTestScenario -Name "Update a ssh key" -Description "Test updating an existing ssh key" -PowerShellVersion "5.1", "Latest" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $key1Name = New-LiveTestResourceName + $key2Name = New-LiveTestResourceName + + $key1 = New-AzSshKey -ResourceGroupName $rgName -Name $key1Name + $publicKey1 = $key1.publicKey + + $key2 = New-AzSshKey -ResourceGroupname $rgName -Name $key2Name + $publicKey2 = $key2.publicKey + + Get-AzSshKey -ResourceGroupName $rgName -Name $key1Name | Update-AzSshKey -PublicKey $publicKey2 + Update-AzSshKey -ResourceId $key2.Id -PublicKey $publicKey1 + + $actual1 = Get-AzSshKey -ResourceGroupname $rgName -Name $key1Name + Assert-NotNull $actual1 + Assert-AreEqual $key1Name $actual1.Name + Assert-AreEqual $publicKey2 $actual1.publicKey + + $actual2 = Get-AzSshKey -ResourceGroupname $rgName -Name $key2Name + Assert-NotNull $actual2 + Assert-AreEqual $key2Name $actual2.Name + Assert-AreEqual $publicKey1 $actual2.publicKey +} + +Invoke-LiveTestScenario -Name "Delete a ssh key" -Description "Test deleting a ssh key" -PowerShellVersion "5.1", "Latest" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $key1Name = New-LiveTestResourceName + $key2Name = New-LiveTestResourceName + + New-AzSshKey -ResourceGroupName $rgName -Name $key1Name + Remove-AzSshKey -ResourceGroupName $rgName -name $key1Name + $actual = Get-AzSshKey -ResourceGroupName $rgName -Name $key1Name -ErrorAction SilentlyContinue + Assert-Null $actual + + $key2 = New-AzSshKey -ResourceGroupName $rgName -Name $key2Name + Remove-AzSshKey -ResourceId $key2.Id + $actual = Get-AzSshKey -ResourceGroupName $rgName -Name $key2Name -ErrorAction SilentlyContinue + Assert-Null $actual +} 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 diff --git a/src/Databricks/LiveTests/TestLiveScenarios.ps1 b/src/Databricks/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..7b41de7ce3b9 --- /dev/null +++ b/src/Databricks/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,52 @@ +Invoke-LiveTestScenario -Name "Create access connector for databricks" -Description "Test creating access connector for data bricks" -ResourceGroupLocation "eastus" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $connName = New-LiveTestResourceName + $location = "eastus" + + New-AzDatabricksAccessConnector -ResourceGroupName $rgName -Name $connName -Location $location + + $actual = Get-AzDatabricksAccessConnector -ResourceGroupName $rgName -Name $connName + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $connName $actual.Name + Assert-AreEqual $location $actual.Location + Assert-AreEqual "Succeeded" $actual.ProvisioningState +} + +Invoke-LiveTestScenario -Name "Update access connector for databricks" -Description "Test updating an existing access connector for data bricks" -ResourceGroupLocation "eastus" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $connName = New-LiveTestResourceName + $location = "eastus" + + $connector = New-AzDatabricksAccessConnector -ResourceGroupName $rgName -Name $connName -Location $location + $connector | Update-AzDatabricksAccessConnector -Tag @{ "key" = "value" } + + $actual = Get-AzDatabricksAccessConnector -ResourceGroupName $rgName -Name $connName + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $connName $actual.Name + Assert-AreEqual $location $actual.Location + Assert-AreEqual "Succeeded" $actual.ProvisioningState + Assert-AreEqual 1 $actual.Tag.Count +} + +Invoke-LiveTestScenario -Name "Remove access connector for data bricks" -Description "Test removing access connector for data bricks" -ResourceGroupLocation "eastus" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $connName = New-LiveTestResourceName + $location = "eastus" + + New-AzDatabricksAccessConnector -ResourceGroupName $rgName -Name $connName -Location $location + Remove-AzDatabricksAccessConnector -ResourceGroupName $rgName -name $connName + + $actual = Get-AzDatabricksAccessConnector -ResourceGroupName $rgName -Name $connName -ErrorAction SilentlyContinue + Assert-Null $actual +} diff --git a/src/DesktopVirtualization/LiveTests/TestLiveScenarios.ps1 b/src/DesktopVirtualization/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..eaaf6bd6527c --- /dev/null +++ b/src/DesktopVirtualization/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,75 @@ +Invoke-LiveTestScenario -Name "Create a Windows virtual desktop" -Description "Test creating a Windows virtual desktop" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "westus" + $poolName = New-LiveTestResourceName + $poolFriName = New-LiveTestRandomName -Option AllLetters + $groupName = New-LiveTestResourceName + $groupFriName = New-LiveTestRandomName -Option AllLetters + $appName = New-LiveTestResourceName + $appFriName = New-LiveTestRandomName -Option AllLetters + + $pool = New-AzWvdHostPool -ResourceGroupName $rgName -Name $poolName -Location $location -FriendlyName $poolFriName -HostPoolType 'Pooled' -LoadBalancerType 'DepthFirst' -PreferredAppGroupType 'RailApplications' -ExpirationTime (Get-Date).ToUniversalTime().AddDays(1) -MaxSessionLimit 5 + New-AzWvdApplicationGroup -ResourceGroupName $rgName -Name $groupName -Location $location -FriendlyName $groupFriName -HostPoolArmPath $pool.Id -ApplicationGroupType 'RemoteApp' + New-AzWvdApplication -ResourceGroupName $rgName -Name $appName -GroupName $groupName -FriendlyName $appFriName -FilePath "C:\Windows\System32\mspaint.exe" -IconIndex 0 -IconPath "C:\Windows\System32\mspaint.exe" -CommandLineSetting Allow -ShowInPortal:$true + + $actual = Get-AzWvdApplication -Name $appName -ResourceGroupName $rgName -GroupName $groupName + Assert-NotNull $actual + Assert-AreEqual "$groupName/$appName" $actual.Name + Assert-AreEqual $appFriName $actual.FriendlyName + Assert-True { $actual.FilePath -like "*mspaint*" } +} + +Invoke-LiveTestScenario -Name "Update a Windows virtual desktop" -Description "Test updating an existing Windows virtual desktop" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "westus" + $poolName = New-LiveTestResourceName + $poolFriName = New-LiveTestRandomName -Option AllLetters + $groupName = New-LiveTestResourceName + $groupFriName = New-LiveTestRandomName -Option AllLetters + $appName = New-LiveTestResourceName + $appFriName = New-LiveTestRandomName -Option AllLetters + $appFriNameNew = New-LiveTestRandomName -Option AllLetters -MaxLength 9 + + $pool = New-AzWvdHostPool -ResourceGroupName $rgName -Name $poolName -Location $location -FriendlyName $poolFriName -HostPoolType 'Pooled' -LoadBalancerType 'DepthFirst' -PreferredAppGroupType 'RailApplications' -ExpirationTime (Get-Date).ToUniversalTime().AddDays(1) -MaxSessionLimit 5 + New-AzWvdApplicationGroup -ResourceGroupName $rgName -Name $groupName -Location $location -FriendlyName $groupFriName -HostPoolArmPath $pool.Id -ApplicationGroupType 'RemoteApp' + New-AzWvdApplication -ResourceGroupName $rgName -Name $appName -GroupName $groupName -FriendlyName $appFriName -FilePath "C:\Windows\System32\mspaint.exe" -IconIndex 0 -IconPath "C:\Windows\System32\mspaint.exe" -CommandLineSetting Allow -ShowInPortal:$true + + $app = Get-AzWvdApplication -Name $appName -ResourceGroupName $rgName -GroupName $groupName + $app | Update-AzWvdApplication -FilePath 'C:\Windows\System32\WindowsPowerShell\v1. 0\powershell.exe' + + Update-AzWvdApplication -Name $appName -ResourceGroupName $rgName -GroupName $groupName -FriendlyName $appFriNameNew + + $actual = Get-AzWvdApplication -Name $appName -ResourceGroupName $rgName -GroupName $groupName + Assert-NotNull $actual + Assert-AreEqual "$groupName/$appName" $actual.Name + Assert-AreEqual $appFriNameNew $actual.FriendlyName + Assert-True { $actual.FilePath -like "*powershell*" } +} + +Invoke-LiveTestScenario -Name "Delete a Windows virtual desktop" -Description "Test deleting a Windows virtual desktop" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "westus" + $poolName = New-LiveTestResourceName + $poolFriName = New-LiveTestRandomName -Option AllLetters + $groupName = New-LiveTestResourceName + $groupFriName = New-LiveTestRandomName -Option AllLetters + $appName = New-LiveTestResourceName + $appFriName = New-LiveTestRandomName -Option AllLetters + + $pool = New-AzWvdHostPool -ResourceGroupName $rgName -Name $poolName -Location $location -FriendlyName $poolFriName -HostPoolType 'Pooled' -LoadBalancerType 'DepthFirst' -PreferredAppGroupType 'RailApplications' -ExpirationTime (Get-Date).ToUniversalTime().AddDays(1) -MaxSessionLimit 5 + New-AzWvdApplicationGroup -ResourceGroupName $rgName -Name $groupName -Location $location -FriendlyName $groupFriName -HostPoolArmPath $pool.Id -ApplicationGroupType 'RemoteApp' + New-AzWvdApplication -ResourceGroupName $rgName -Name $appName -GroupName $groupName -FriendlyName $appFriName -FilePath "C:\Windows\System32\mspaint.exe" -IconIndex 0 -IconPath "C:\Windows\System32\mspaint.exe" -CommandLineSetting Allow -ShowInPortal:$true + Remove-AzWvdApplication -ResourceGroupName $rgName -Name $appName -GroupName $groupName + + $actual = Get-AzWvdApplication -Name $appName -ResourceGroupName $rgName -GroupName $groupName -ErrorAction SilentlyContinue + Assert-Null $actual +} diff --git a/src/Dns/Dns.Test/LiveTests/TestLiveScenarios.ps1 b/src/Dns/Dns.Test/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..32bc45d2b1bb --- /dev/null +++ b/src/Dns/Dns.Test/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,66 @@ +Invoke-LiveTestScenario -Name "Create public DNS zone" -Description "Test creating a public DNS zone" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $r5l = New-LiveTestRandomName -Option AllLetters -MaxLength 5 + $zoneName = "$r5l.public.contoso.com" + + New-AzDnsZone -ResourceGroupName $rgName -Name $zoneName -ZoneType Public + + $actual = Get-AzDnsZone -ResourceGroupName $rgName -Name $zoneName + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $zoneName $actual.Name + Assert-AreEqual "Public" $actual.ZoneType +} + +Invoke-LiveTestScenario -Name "Update DNS zone" -Description "Test updating an existing public DNS zone" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $r5l = New-LiveTestRandomName -Option AllLetters -MaxLength 5 + $zoneName = "$r5l.public.contoso.com" + + New-AzDnsZone -ResourceGroupName $rgName -Name $zoneName -ZoneType Public + Set-AzDnsZone -ResourceGroupName $rgName -Name $zoneName -Tag @{ "Severity" = "Medium" } + + $actual = Get-AzDnsZone -ResourceGroupName $rgName -Name $zoneName + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $zoneName $actual.Name + Assert-AreEqual "Public" $actual.ZoneType + Assert-AreEqual 1 $actual.Tags.Keys.Count + Assert-AreEqual "Severity" $actual.Tags.Keys[0] + Assert-AreEqual 1 $actual.Tags.Values.Count + Assert-AreEqual "Medium" $actual.Tags.Values[0] + + $actual.Tags = @{ "Impact" = "Low" } + Set-AzDnsZone -Zone $actual + + $actual = Get-AzDnsZone -ResourceGroupName $rgName -Name $zoneName + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $zoneName $actual.Name + Assert-AreEqual "Public" $actual.ZoneType + Assert-AreEqual 1 $actual.Tags.Keys.Count + Assert-AreEqual "Impact" $actual.Tags.Keys[0] + Assert-AreEqual 1 $actual.Tags.Values.Count + Assert-AreEqual "Low" $actual.Tags.Values[0] +} + +Invoke-LiveTestScenario -Name "Remove DNS zone" -Description "Test removing a public DNS zone" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $r5l = New-LiveTestRandomName -Option AllLetters -MaxLength 5 + $zoneName = "$r5l.public.contoso.com" + + New-AzDnsZone -ResourceGroupName $rgName -Name $zoneName -ZoneType Public + Remove-AzDnsZone -ResourceGroupName $rgName -Name $zoneName -Confirm:$false + + $actual = Get-AzDnsZone -ResourceGroupName $rgName -Name $zoneName -ErrorAction SilentlyContinue + Assert-Null $actual +} diff --git a/src/Functions/LiveTests/TestLiveScenarios.ps1 b/src/Functions/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..3e20e999a91c --- /dev/null +++ b/src/Functions/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,88 @@ +Invoke-LiveTestScenario -Name "Create function app" -Description "Test creating function app" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $saName = New-LiveTestStorageAccountName + $funcAppName = New-LiveTestResourceName + $location = "westus" + + New-AzStorageAccount -ResourceGroupName $rgName -Name $saName -Location $location -SkuName Standard_LRS + New-AzFunctionApp -ResourceGroupName $rgName -Name $funcAppName -Location $location -FunctionsVersion 4 -StorageAccountName $saName -OSType Windows -Runtime PowerShell -RuntimeVersion 7.2 + + $actual = Get-AzFunctionApp -ResourceGroupName $rgName -Name $funcAppName + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $funcAppName $actual.Name + Assert-AreEqual "Running" $actual.State + Assert-AreEqual "Windows" $actual.OSType + Assert-AreEqual "PowerShell" $actual.Runtime +} + +Invoke-LiveTestScenario -Name "Update function app" -Description "Test updating an existing function app" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $saName = New-LiveTestStorageAccountName + $funcAppName = New-LiveTestResourceName + $location = "eastus" + + New-AzStorageAccount -ResourceGroupName $rgName -Name $saName -Location $location -SkuName Standard_LRS + $funcApp = New-AzFunctionApp -ResourceGroupName $rgName -Name $funcAppName -Location $location -FunctionsVersion 4 -StorageAccountName $saName -OSType Windows -Runtime PowerShell -RuntimeVersion 7.2 + $funcApp | Update-AzFunctionApp -Tag @{ "key" = "value" } -Force + Update-AzFunctionApp -ResourceGroupName $rgName -Name $funcAppName -IdentityType SystemAssigned -Force + + $actual = Get-AzFunctionApp -ResourceGroupName $rgName -Name $funcAppName + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $funcAppName $actual.Name + Assert-AreEqual "Running" $actual.State + Assert-AreEqual "SystemAssigned" $actual.IdentityType + Assert-AreEqual 1 $actual.Tag.Count +} + +Invoke-LiveTestScenario -Name "Remove function app" -Description "Test removing function app" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $saName = New-LiveTestStorageAccountName + $funcAppName = New-LiveTestResourceName + $location = "centralus" + + New-AzStorageAccount -ResourceGroupName $rgName -Name $saName -Location $location -SkuName Standard_LRS + New-AzFunctionApp -ResourceGroupName $rgName -Name $funcAppName -Location $location -FunctionsVersion 4 -StorageAccountName $saName -OSType Windows -Runtime PowerShell -RuntimeVersion 7.2 + Remove-AzFunctionApp -ResourceGroupName $rgName -name $funcAppName -Force + + $actual = Get-AzFunctionApp -ResourceGroupName $rgName -Name $funcAppName -ErrorAction SilentlyContinue + Assert-Null $actual +} + +Invoke-LiveTestScenario -Name "Operate function app" -Description "Test operating function app by starting, stopping and restarting it" -ResourceGroupLocation "eastus" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $saName = New-LiveTestStorageAccountName + $funcAppName = New-LiveTestResourceName + $location = "eastus" + + New-AzStorageAccount -ResourceGroupName $rgName -Name $saName -Location $location -SkuName Standard_LRS + New-AzFunctionApp -ResourceGroupName $rgName -Name $funcAppName -Location $location -FunctionsVersion 4 -StorageAccountName $saName -OSType Windows -Runtime PowerShell -RuntimeVersion 7.2 + + Stop-AzFunctionApp -ResourceGroupName $rgName -Name $funcAppName -Force + $app = Get-AzFunctionApp -ResourceGroupName $rgName -Name $funcAppName + Assert-NotNull $app + Assert-AreEqual "Stopped" $app.State + + $app | Start-AzFunctionApp + $app = Get-AzFunctionApp -ResourceGroupName $rgName -Name $funcAppName + Assert-NotNull $app + Assert-AreEqual "Running" $app.State + + Restart-AzFunctionApp -ResourceGroupName $rgName -Name $funcAppName -Force + $app = Get-AzFunctionApp -ResourceGroupName $rgName -Name $funcAppName + Assert-NotNull $app + Assert-AreEqual "Running" $app.State +} diff --git a/src/KeyVault/KeyVault.Test/LiveTests/TestLiveScenarios.ps1 b/src/KeyVault/KeyVault.Test/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..c1ca27a822ab --- /dev/null +++ b/src/KeyVault/KeyVault.Test/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,208 @@ +Invoke-LiveTestScenario -Name "Create new standard key vault" -Description "Test creating a new standard key vault with all default values" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $vaultName = New-LiveTestResourceName + $vaultLocation = "westus" + + New-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName -Location $vaultLocation + $actual = Get-AzKeyVault -ResourceGroupName $rgName -VaultName $vaultName + Assert-AreEqual $vaultName $actual.VaultName + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $vaultLocation $actual.Location + Assert-AreEqual "Standard" $actual.Sku + Assert-AreEqual $false $actual.EnabledForDeployment + Assert-True { $actual.EnableSoftDelete } "By default EnableSoftDelete should be true" + Assert-Null $actual.EnablePurgeProtection "By default EnablePurgeProtection should be null" + Assert-False { $actual.EnableRbacAuthorization } "By default EnableRbacAuthorization should be false" + Assert-AreEqual 90 $actual.SoftDeleteRetentionInDays "By default SoftDeleteRetentionInDays should be 90" +} + +Invoke-LiveTestScenario -Name "Create new premium key vault" -Description "Test creating a new premium key vault with all default values" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $vaultName = New-LiveTestResourceName + $vaultLocation = "eastus" + + New-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName -Location $vaultLocation -Sku premium -EnabledForDeployment + $actual = Get-AzKeyVault -ResourceGroupName $rgName -VaultName $vaultName + Assert-AreEqual $vaultName $actual.VaultName + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $vaultLocation $actual.Location + Assert-AreEqual "Premium" $actual.Sku + Assert-AreEqual $true $actual.EnabledForDeployment +} + +Invoke-LiveTestScenario -Name "Update key vault" -Description "Test updating properties EnableRbacAuthorization and Tag for existing key vault" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $vaultName = New-LiveTestResourceName + $vaultLocation = "eastus" + + # Update EnableRbacAuthorization + $vault = New-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName -Location $vaultLocation + + $vault = $vault | Update-AzKeyVault -EnableRbacAuthorization $false + Assert-False { $vault.EnableRbacAuthorization } "EnableRbacAuthorization should be false" + + # Update Tags + $vault = $vault | Update-AzKeyVault -Tag @{ key = "value" } + Assert-AreEqual 1 $vault.Tags.Count "Tags should contain a key-value pair (key, value)" + Assert-True { $vault.Tags.Contains("key") } "Tags should contain a key-value pair (key, value)" + Assert-AreEqual "value" $vault.Tags["key"] "Tags should contain a key-value pair (key, value)" + + # Clean Tags + $vault = $vault | Update-AzKeyVault -Tag @{} + Assert-AreEqual 0 $vault.Tags.Count "Tags should be empty" +} + +Invoke-LiveTestScenario -Name "Delete key vault" -Description "Test deleting key vault" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $vaultName = New-LiveTestResourceName + $vaultLocation = "westus" + + New-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgname -Location $vaultLocation + Remove-AzKeyVault -VaultName $vaultName -Force + + $deletedVault = Get-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName + Assert-Null $deletedVault + + # purge deleted vault + Remove-AzKeyVault -VaultName $vaultName -Location $vaultLocation -InRemovedState -Force +} + +Invoke-LiveTestScenario -Name "Create key vault secret" -Description "Test creating a key vault secret" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $vaultName = New-LiveTestResourceName + $vaultLocation = "eastus" + $secretName = New-LiveTestResourceName + + New-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName -Location $vaultLocation + $sp = Get-AzADServicePrincipal -ApplicationId (Get-AzContext).Account.Id + $objectId = $sp.Id + Set-AzKeyVaultAccessPolicy -VaultName $vaultName -ObjectId $objectId -PermissionsToSecrets get, set, list + + $secretValue = ConvertTo-SecureString -String 'Password' -AsPlainText -Force + Set-AzKeyVaultSecret -VaultName $vaultName -Name $secretName -SecretValue $secretValue + + $actual = Get-AzKeyVaultSecret -VaultName $vaultName -Name $secretName -ErrorAction SilentlyContinue + Assert-NotNull $actual + Assert-AreEqual $vaultName $actual.VaultName + Assert-AreEqual $secretName $actual.Name +} + +Invoke-LiveTestScenario -Name "Create key vault secret with multi-versions" -Description "Test creating a key vault secret with multiple versions" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $vaultName = New-LiveTestResourceName + $vaultLocation = "westus" + $secretName = New-LiveTestResourceName + + New-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName -Location $vaultLocation + $sp = Get-AzADServicePrincipal -ApplicationId (Get-AzContext).Account.Id + $objectId = $sp.Id + Set-AzKeyVaultAccessPolicy -VaultName $vaultName -ObjectId $objectId -PermissionsToSecrets get, set, list + + $secretValue = ConvertTo-SecureString -String 'Password' -AsPlainText -Force + Set-AzKeyVaultSecret -VaultName $vaultName -Name $secretName -SecretValue $secretValue + Set-AzKeyVaultSecret -VaultName $vaultName -name $secretName -SecretValue $secretValue + + $actual = Get-AzKeyVaultSecret -VaultName $vaultName -Name $secretName -IncludeVersions -ErrorAction SilentlyContinue + Assert-NotNull $actual + Assert-AreEqual 2 $actual.Count +} + +Invoke-LiveTestScenario -Name "Update key vault secret attributes" -Description "Test updating attributes of a key vault secret" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $vaultName = New-LiveTestResourceName + $vaultLocation = "westus" + $secretName = New-LiveTestResourceName + + New-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName -Location $vaultLocation + $sp = Get-AzADServicePrincipal -ApplicationId (Get-AzContext).Account.Id + $objectId = $sp.Id + Set-AzKeyVaultAccessPolicy -VaultName $vaultName -ObjectId $objectId -PermissionsToSecrets get, set, list + + $secretValue = ConvertTo-SecureString -String 'Password' -AsPlainText -Force + Set-AzKeyVaultSecret -VaultName $vaultName -Name $secretName -SecretValue $secretValue + + $exp = (Get-Date).AddYears(1).ToUniversalTime() + $nbf = (Get-Date).ToUniversalTime() + $ctp= "text" + $tags = @{ "Severity" = "low" } + Update-AzKeyVaultSecret -VaultName $vaultName -Name $secretName -NotBefore $nbf -Expires $exp -ContentType $ctp -Tag $tags -Enable $true + + $actual = Get-AzKeyVaultSecret -VaultName $vaultName -Name $secretName -ErrorAction SilentlyContinue + Assert-NotNull $actual + Assert-AreEqual $true $actual.Enabled + Assert-AreEqual $ctp $actual.ContentType +} + +Invoke-LiveTestScenario -Name "Remove key vault secret" -Description "Test removing a key vault secret" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $vaultName = New-LiveTestResourceName + $vaultLocation = "eastus" + $secretName = New-LiveTestResourceName + + New-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName -Location $vaultLocation + $sp = Get-AzADServicePrincipal -ApplicationId (Get-AzContext).Account.Id + $objectId = $sp.Id + Set-AzKeyVaultAccessPolicy -VaultName $vaultName -ObjectId $objectId -PermissionsToSecrets get, set, list, delete + + $secretValue = ConvertTo-SecureString -String 'Password' -AsPlainText -Force + Set-AzKeyVaultSecret -VaultName $vaultName -Name $secretName -SecretValue $secretValue + + Remove-AzKeyVaultSecret -VaultName $vaultName -Name $secretName -Force + + $actual = Get-AzKeyVaultSecret -VaultName $vaultName -Name $secretName -ErrorAction SilentlyContinue + Assert-Null $actual +} + +Invoke-LiveTestScenario -Name "Backup and restore key vault secret" -Description "Test backing up and restoring a key vault secret" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $vaultName1 = New-LiveTestResourceName + $vaultName2 = New-LiveTestResourceName + $vaultLocation = "eastus" + $secretName = New-LiveTestResourceName + + New-AzKeyVault -VaultName $vaultName1 -ResourceGroupName $rgName -Location $vaultLocation + New-AzKeyVault -VaultName $vaultName2 -ResourceGroupName $rgName -Location $vaultLocation + $sp = Get-AzADServicePrincipal -ApplicationId (Get-AzContext).Account.Id + $objectId = $sp.Id + Set-AzKeyVaultAccessPolicy -VaultName $vaultName1 -ObjectId $objectId -PermissionsToSecrets get, set, list, backup + Set-AzKeyVaultAccessPolicy -VaultName $vaultName2 -ObjectId $objectId -PermissionsToSecrets get, set, list, restore + + $secretValue = ConvertTo-SecureString -String 'Password' -AsPlainText -Force + Set-AzKeyVaultSecret -VaultName $vaultName1 -Name $secretName -SecretValue $secretValue + + Backup-AzKeyVaultSecret -VaultName $vaultName1 -Name $secretName -OutputFile "SecretBackup.blob" -Force + + Restore-AzKeyVaultSecret -VaultName $vaultName2 -InputFile "SecretBackup.blob" + + $actual = Get-AzKeyVaultSecret -VaultName $vaultName2 -Name $secretName -ErrorAction SilentlyContinue + Assert-NotNull $actual + Assert-AreEqual $vaultName2 $actual.VaultName + Assert-AreEqual $secretName $actual.Name +} diff --git a/src/Network/Network.Test/LiveTests/TestLiveScenarios.ps1 b/src/Network/Network.Test/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..2239a6e0c7f5 --- /dev/null +++ b/src/Network/Network.Test/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,567 @@ +Invoke-LiveTestScenario -Name "Network interface CRUD with public IP address" -Description "Test CRUD for network interface with public IP address" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "westus" + $vnetName = New-LiveTestResourceName + $snetName = New-LiveTestResourceName + $pipName = New-LiveTestResourceName + $domainNameLabel = New-LiveTestResourceName + $ipcfgName = New-LiveTestResourceName + $nicName = New-LiveTestResourceName + + $snet = New-AzVirtualNetworkSubnetConfig -Name $snetName -AddressPrefix 10.0.1.0/24 + $vnet = New-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $snet + $pip = New-AzPublicIpAddress -ResourceGroupName $rgName -Name $pipName -Location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel + $ipcfg = New-AzNetworkInterfaceIpConfig -Name $ipcfgName -Subnet $vnet.Subnets[0] -PublicIpAddress $pip + New-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName -Location $location -IpConfiguration $ipcfg + $actualNic = Get-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName + + Assert-AreEqual $rgName $actualNic.ResourceGroupName + Assert-AreEqual $nicName $actualNic.Name + Assert-AreEqual "Succeeded" $actualNic.ProvisioningState + + $actualNic = Get-AzNetworkInterface -ResourceId $actualNic.Id + Assert-AreEqual $rgName $actualNic.ResourceGroupName + Assert-AreEqual $nicName $actualNic.Name + Assert-AreEqual "Succeeded" $actualNic.ProvisioningState + + Assert-AreEqual 1 $actualNic.IpConfigurations.Count + Assert-AreEqual $ipcfgName $actualNic.IpConfigurations[0].Name + + $actualPip = Get-AzPublicIpAddress -ResourceGroupName $rgName -Name $pipName + Assert-AreEqual $rgName $actualPip.ResourceGroupName + Assert-AreEqual $pipName $actualPip.Name + Assert-AreEqual "Dynamic" $actualPip.PublicIpAllocationMethod + Assert-AreEqual $actualPip.Id $actualNic.IpConfigurations[0].PublicIpAddress.Id + + $actualVnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgName + Assert-AreEqual $rgName $actualVnet.ResourceGroupName + Assert-AreEqual $vnetName $actualVnet.Name + Assert-AreEqual $actualVnet.Subnets[0].Id $actualNic.IpConfigurations[0].Subnet[0].Id + + Remove-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName -Force + $actual = Get-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName -ErrorAction SilentlyContinue + Assert-Null $actual +} + +Invoke-LiveTestScenario -Name "Network interface CRUD without public IP address" -Description "Test CRUD for network interface without public IP address" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "eastus" + $vnetName = New-LiveTestResourceName + $snetName = New-LiveTestResourceName + $nicName = New-LiveTestResourceName + + $snet = New-AzVirtualNetworkSubnetConfig -Name $snetName -AddressPrefix 10.0.1.0/24 + $vnet = New-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $snet + + New-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName -Location $location -Subnet $vnet.Subnets[0] + $actualNic = Get-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName + + Assert-AreEqual $rgName $actualNic.ResourceGroupName + Assert-AreEqual $nicName $actualNic.Name + Assert-AreEqual "Succeeded" $actualNic.ProvisioningState + + Assert-AreEqual 1 $actualNic.IpConfigurations.Count + Assert-Null $actualNic.IpConfigurations[0].PublicIpAddress.Id + + $actualVnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgName + Assert-AreEqual $rgName $actualVnet.ResourceGroupName + Assert-AreEqual $vnetName $actualVnet.Name + Assert-AreEqual $actualVnet.Subnets[0].Id $actualNic.IpConfigurations[0].Subnet[0].Id + + Remove-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName -Force + $actual = Get-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName -ErrorAction SilentlyContinue + Assert-Null $actual +} + +Invoke-LiveTestScenario -Name "Network interface CRUD with IP configuration" -Description "Test CRUD for network interface with IP configuration" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "centralus" + $vnetName = New-LiveTestResourceName + $snetName = New-LiveTestResourceName + $pipName = New-LiveTestResourceName + $domainNameLabel = New-LiveTestResourceName + $ipconfig1Name = New-LiveTestResourceName + $ipconfig2Name = New-LiveTestResourceName + $nicName = New-LiveTestResourceName + + $snet = New-AzVirtualNetworkSubnetConfig -Name $snetName -AddressPrefix 10.0.1.0/24 + $vnet = New-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $snet + + $pip = New-AzPublicIpAddress -ResourceGroupName $rgName -Name $pipName -Location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel + $ipconfig1 = New-AzNetworkInterfaceIpConfig -Name $ipconfig1Name -Subnet $vnet.Subnets[0] -PublicIpAddress $pip + $ipconfig2 = New-AzNetworkInterfaceIpConfig -Name $ipconfig2Name -PrivateIpAddressVersion IPv6 + + New-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName -Location $location -IpConfiguration $ipconfig1,$ipconfig2 -Tag @{ testtag = "testval" } + + $actualNic = Get-AzNetworkInterface -Name $nicName -ResourceGroupName $rgName + Assert-AreEqual $rgName $actualNic.ResourceGroupName + Assert-AreEqual $nicName $actualNic.Name + Assert-AreEqual "Succeeded" $actualNic.ProvisioningState + + $actualPip = Get-AzPublicIpAddress -ResourceGroupName $rgName -Name $pipName + Assert-AreEqual $rgName $actualPip.ResourceGroupName + Assert-AreEqual $pipName $actualPip.Name + Assert-AreEqual "Dynamic" $actualPip.PublicIpAllocationMethod + Assert-AreEqual $actualPip.Id $actualNic.IpConfigurations[0].PublicIpAddress.Id + + $actualVnet = Get-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName + Assert-AreEqual $rgName $actualVnet.ResourceGroupName + Assert-AreEqual $vnetName $actualVnet.Name + Assert-AreEqual $actualVnet.Subnets[0].Id $actualNic.IpConfigurations[0].Subnet[0].Id + + Assert-AreEqual 2 $actualNic.IpConfigurations.Count + + Assert-AreEqual $ipconfig1Name $actualNic.IpConfigurations[0].Name + Assert-AreEqual $pip.Id $actualNic.IpConfigurations[0].PublicIpAddress.Id + Assert-AreEqual $actualVnet.Subnets[0].Id $actualNic.IpConfigurations[0].Subnet.Id + Assert-AreEqual "Dynamic" $actualNic.IpConfigurations[0].PrivateIpAllocationMethod + Assert-AreEqual IPv4 $actualNic.IpConfigurations[0].PrivateIpAddressVersion + + Assert-AreEqual $ipconfig2Name $actualNic.IpConfigurations[1].Name + Assert-Null $actualNic.IpConfigurations[1].PublicIpAddress + Assert-AreEqual IPv6 $actualNic.IpConfigurations[1].PrivateIpAddressVersion + + Remove-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName -Force + $actual = Get-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName -ErrorAction SilentlyContinue + Assert-Null $actual +} + +Invoke-LiveTestScenario -Name "Network interface CRUD with accelerated networking" -Description "Test CRUD for network interface with accelerated networking" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "westus" + $vnetName = New-LiveTestResourceName + $snetName = New-LiveTestResourceName + $pipName = New-LiveTestResourceName + $domainNameLabel = New-LiveTestResourceName + $ipcfgName = New-LiveTestResourceName + $nicName = New-LiveTestResourceName + + $snet = New-AzVirtualNetworkSubnetConfig -Name $snetName -AddressPrefix 10.0.1.0/24 + $vnet = New-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $snet + $pip = New-AzPublicIpAddress -ResourceGroupName $rgName -Name $pipName -Location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel + $ipcfg = New-AzNetworkInterfaceIpConfig -Name $ipcfgName -Subnet $vnet.Subnets[0] -PublicIpAddress $pip + New-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName -Location $location -IpConfiguration $ipcfg -EnableAcceleratedNetworking + + $actualNic = Get-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName + Assert-AreEqual $rgName $actualNic.ResourceGroupName + Assert-AreEqual $nicName $actualNic.Name + Assert-AreEqual "Succeeded" $actualNic.ProvisioningState + + Assert-AreEqual 1 $actualNic.IpConfigurations.Count + Assert-AreEqual $ipcfgName $actualNic.IpConfigurations[0].Name + Assert-AreEqual $true $actualNic.EnableAcceleratedNetworking + + $actualPip = Get-AzPublicIpAddress -ResourceGroupName $rgname -name $pipName + Assert-AreEqual $rgName $actualPip.ResourceGroupName + Assert-AreEqual $pipName $actualPip.Name + Assert-AreEqual "Dynamic" $actualPip.PublicIpAllocationMethod + Assert-AreEqual $actualPip.Id $actualNic.IpConfigurations[0].PublicIpAddress.Id + + $actualVnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgName + Assert-AreEqual $rgName $actualVnet.ResourceGroupName + Assert-AreEqual $vnetName $actualVnet.Name + Assert-AreEqual $actualVnet.Subnets[0].Id $actualNic.IpConfigurations[0].Subnet[0].Id + + Remove-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName -Force + $actual = Get-AzNetworkInterface -ResourceGroupName $rgName -Name $nicName -ErrorAction SilentlyContinue + Assert-Null $actual +} + +Invoke-LiveTestScenario -Name "Network private link service" -Description "Test CRUD for network private link service" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "westus" + $vnetName = New-LiveTestResourceName + $feSnetName = New-LiveTestResourceName + $beSnetName = New-LiveTestResourceName + $oSnetName = New-LiveTestResourceName + $lbIpCfgName = New-LiveTestResourceName + $lbPoolCfgName = New-LiveTestResourceName + $lbName = New-LiveTestResourceName + $plsIpCfgName = New-LiveTestResourceName + $plsName = New-LiveTestResourceName + + $feSubnet = New-AzVirtualNetworkSubnetConfig -Name $feSnetName -AddressPrefix 10.0.1.0/24 + $beSubnet = New-AzVirtualNetworkSubnetConfig -Name $beSnetName -AddressPrefix 10.0.2.0/24 + $oSubnet = New-AzVirtualNetworkSubnetConfig -Name $oSnetName -AddressPrefix 10.0.3.0/24 -PrivateLinkServiceNetworkPoliciesFlag Disabled + $vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgName -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $feSubnet,$beSubnet,$oSubnet + + $lbIpCfg = New-AzLoadBalancerFrontendIpConfig -Name $lbIpCfgName -PrivateIpAddress 10.0.1.5 -Subnet $vnet.Subnets[0] + $lbPoolCfg = New-AzLoadBalancerBackendAddressPoolConfig -Name $lbPoolCfgName + New-AzLoadBalancer -Name $lbName -ResourceGroupName $rgName -Location $location -FrontendIpConfiguration $lbIpCfg -BackendAddressPool $lbPoolCfg -Sku Standard + + $plsIpCfg = New-AzPrivateLinkServiceIpConfig -Name $plsIpCfgName -PrivateIpAddress 10.0.3.5 -Subnet $vnet.Subnets[2] + + $actualPls = New-AzPrivateLinkService -Name $plsName -ResourceGroupName $rgName -Location $location -LoadBalancerFrontendIpConfiguration $lbIpCfg -IpConfiguration $plsIpCfg + + Assert-AreEqual $actualPls.Name $plsName + Assert-AreEqual $actualPls.ResourceGroupName $rgName + Assert-AreEqual $actualPls.Location $location + + Remove-AzPrivateLinkService -Name $plsName -ResourceGroupName $rgName -Force + $actualPls = Get-AzPrivateLinkService -Name $plsName -ResourceGroupName $rgName -ErrorAction SilentlyContinue + Assert-Null $actualPls +} + +Invoke-LiveTestScenario -Name "Create network load balancer" -Description "Test creating a network load balancer" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "westus" + $publicIpName = New-LiveTestResourceName + $feIpCfgName = New-LiveTestResourceName + $bePoolCfgName = New-LiveTestResourceName + $probeName = New-LiveTestResourceName + $lbRuleName = New-LiveTestResourceName + $lbName = New-LiveTestResourceName + + $publicIp = New-AzPublicIpAddress -ResourceGroupName $rgName -Name $publicIpName -Location $location -AllocationMethod Dynamic + $feIpCfg = New-AzLoadBalancerFrontendIpConfig -Name $feIpCfgName -PublicIpAddress $publicIp + $bePoolCfg = New-AzLoadBalancerBackendAddressPoolConfig -Name $bePoolCfgName + $probe = New-AzLoadBalancerProbeConfig -Name $probeName -Protocol "Http" -Port 80 -RequestPath "healthcheck.aspx" -IntervalInSeconds 15 -ProbeCount 5 -ProbeThreshold 5 + $lbRule = New-AzLoadBalancerRuleConfig -Name $lbRuleName -FrontendIpConfiguration $feIpCfg -BackendAddressPool $bePoolCfg -Protocol "Tcp" -FrontendPort 80 -BackendPort 80 -IdleTimeoutInMinutes 5 -EnableFloatingIP -LoadDistribution "SourceIP" + New-AzLoadBalancer -ResourceGroupName $rgName -Name $lbName -Location $location -FrontendIpConfiguration $feIpCfg -BackendAddressPool $bePoolCfg -Probe $probe -LoadBalancingRule $lbRule + + $actual = Get-AzLoadBalancer -ResourceGroupName $rgName -Name $lbName + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $lbName $actual.Name + Assert-AreEqual $location $actual.Location + Assert-AreEqual "Succeeded" $actual.ProvisioningState + + Assert-AreEqual 1 $actual.Probes.Count + Assert-AreEqual "Http" $actual.Probes[0].Protocol + Assert-AreEqual 80 $actual.Probes[0].Port + + Assert-AreEqual 1 $actual.LoadBalancingRules.Count + Assert-AreEqual "Tcp" $actual.LoadBalancingRules[0].Protocol + Assert-AreEqual 80 $actual.LoadBalancingRules[0].FrontendPort + Assert-AreEqual 80 $actual.LoadBalancingRules[0].BackendPort +} + +Invoke-LiveTestScenario -Name "Update network load balancer" -Description "Test updating an existing network load balancer" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "eastus" + $publicIpName = New-LiveTestResourceName + $feIpCfgName = New-LiveTestResourceName + $bePoolCfgName = New-LiveTestResourceName + $probeName1 = New-LiveTestResourceName + $probeName2 = New-LiveTestResourceName + $lbRuleName = New-LiveTestResourceName + $lbName = New-LiveTestResourceName + $natRuleName = New-LiveTestResourceName + + $publicIp = New-AzPublicIpAddress -ResourceGroupName $rgName -Name $publicIpName -Location $location -AllocationMethod Dynamic + $feIpCfg = New-AzLoadBalancerFrontendIpConfig -Name $feIpCfgName -PublicIpAddress $publicIp + $bePoolCfg = New-AzLoadBalancerBackendAddressPoolConfig -Name $bePoolCfgName + $probe = New-AzLoadBalancerProbeConfig -Name $probeName1 -Protocol "Http" -Port 80 -RequestPath "healthcheck80.aspx" -IntervalInSeconds 15 -ProbeCount 5 -ProbeThreshold 5 + $lbRule = New-AzLoadBalancerRuleConfig -Name $lbRuleName -FrontendIpConfiguration $feIpCfg -BackendAddressPool $bePoolCfg -Protocol "Tcp" -FrontendPort 80 -BackendPort 80 -IdleTimeoutInMinutes 5 -EnableFloatingIP -LoadDistribution "SourceIP" + New-AzLoadBalancer -ResourceGroupName $rgName -Name $lbName -Location $location -FrontendIpConfiguration $feIpCfg -BackendAddressPool $bePoolCfg -Probe $probe -LoadBalancingRule $lbRule + $lb = Get-AzLoadBalancer -ResourceGroupName $rgName -Name $lbName + + $lb | Add-AzLoadBalancerProbeConfig -Name $probeName2 -Protocol "Http" -Port 443 -RequestPath "healthcheck443.aspx" -IntervalInSeconds 10 -ProbeCount 3 -ProbeThreshold 3 + $lb | Add-AzLoadBalancerInboundNatRuleConfig -Name $natRuleName -FrontendIPConfiguration $lb.FrontendIpConfigurations[0] -Protocol "Tcp" -FrontendPort 3350 -BackendPort 3350 -EnableFloatingIP + $lb | Set-AzLoadBalancerRuleConfig -Name $lbRuleName -FrontendIPConfiguration $lb.FrontendIpConfigurations[0] -Protocol "Tcp" -FrontendPort 8080 -BackendPort 8080 + $lb | Set-AzLoadBalancer + + $actual = Get-AzLoadBalancer -ResourceGroupName $rgName -Name $lbName + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $lbName $actual.Name + Assert-AreEqual $location $actual.Location + Assert-AreEqual "Succeeded" $actual.ProvisioningState + + Assert-AreEqual 1 $actual.LoadBalancingRules.Count + Assert-AreEqual "Tcp" $actual.LoadBalancingRules[0].Protocol + Assert-AreEqual 8080 $actual.LoadBalancingRules[0].FrontendPort + Assert-AreEqual 8080 $actual.LoadBalancingRules[0].BackendPort + + Assert-AreEqual 1 $actual.InboundNatRules.Count + Assert-AreEqual "Tcp" $actual.InboundNatRules[0].Protocol + Assert-AreEqual 3350 $actual.InboundNatRules[0].FrontendPort + Assert-AreEqual 3350 $actual.InboundNatRules[0].BackendPort + + Assert-AreEqual 2 $actual.Probes.Count +} + +Invoke-LiveTestScenario -Name "Remove network load balancer" -Description "Test removing a network load balancer" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "centralus" + $publicIpName = New-LiveTestResourceName + $feIpCfgName = New-LiveTestResourceName + $bePoolCfgName = New-LiveTestResourceName + $probeName = New-LiveTestResourceName + $lbRuleName = New-LiveTestResourceName + $lbName = New-LiveTestResourceName + + $publicIp = New-AzPublicIpAddress -ResourceGroupName $rgName -Name $publicIpName -Location $location -AllocationMethod Dynamic + $feIpCfg = New-AzLoadBalancerFrontendIpConfig -Name $feIpCfgName -PublicIpAddress $publicIp + $bePoolCfg = New-AzLoadBalancerBackendAddressPoolConfig -Name $bePoolCfgName + $probe = New-AzLoadBalancerProbeConfig -Name $probeName -Protocol "Http" -Port 80 -RequestPath "healthcheck.aspx" -IntervalInSeconds 15 -ProbeCount 5 -ProbeThreshold 5 + $lbRule = New-AzLoadBalancerRuleConfig -Name $lbRuleName -FrontendIpConfiguration $feIpCfg -BackendAddressPool $bePoolCfg -Protocol "Tcp" -FrontendPort 80 -BackendPort 80 -IdleTimeoutInMinutes 5 -EnableFloatingIP -LoadDistribution "SourceIP" + New-AzLoadBalancer -ResourceGroupName $rgName -Name $lbName -Location $location -FrontendIpConfiguration $feIpCfg -BackendAddressPool $bePoolCfg -Probe $probe -LoadBalancingRule $lbRule + + Remove-AzLoadBalancer -ResourceGroupName $rgName -Name $lbName -Force + $actual = Get-AzLoadBalancer -ResourceGroupName $rgName -Name $lbName -ErrorAction SilentlyContinue + Assert-Null $actual +} + +Invoke-LiveTestScenario -Name "Create virtual network" -Description "Test creating a virtual network" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "westus" + $feSnetName = New-LiveTestResourceName + $beSnetName = New-LiveTestResourceName + $vnetName = New-LiveTestResourceName + + $feSnet = New-AzVirtualNetworkSubnetConfig -Name $feSnetName -AddressPrefix "10.0.1.0/24" + $beSnet = New-AzVirtualNetworkSubnetConfig -Name $beSnetName -AddressPrefix "10.0.2.0/24" + New-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -Location $location -AddressPrefix "10.0.0.0/16" -Subnet $feSnet, $beSnet -DnsServer 10.0.1.10, 10.0.1.11 + + $actual = Get-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $vnetName $actual.Name + Assert-AreEqual $location $actual.Location + Assert-AreEqual "Succeeded" $actual.ProvisioningState + Assert-AreEqual 1 $actual.AddressSpace.AddressPrefixes.Count + Assert-AreEqual "10.0.0.0/16" $actual.AddressSpace.AddressPrefixes[0] + Assert-AreEqual 2 $actual.Subnets.Count +} + +Invoke-LiveTestScenario -Name "Update virtual network" -Description "Test updating an existing virtual network" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "eastus" + $feSnetName = New-LiveTestResourceName + $beSnetName = New-LiveTestResourceName + $vnetName = New-LiveTestResourceName + + $feSnet = New-AzVirtualNetworkSubnetConfig -Name $feSnetName -AddressPrefix "10.0.1.0/24" + New-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -Location $location -AddressPrefix "10.0.0.0/16" -Subnet $feSnet + + $vnet = Get-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName + Assert-NotNull $vnet + Assert-AreEqual $rgName $vnet.ResourceGroupName + Assert-AreEqual $vnetName $vnet.Name + Assert-AreEqual $location $vnet.Location + Assert-AreEqual "Succeeded" $vnet.ProvisioningState + Assert-AreEqual 1 $vnet.Subnets.Count + + $vnet | Add-AzVirtualNetworkSubnetConfig -Name $beSnetName -AddressPrefix "10.0.2.0/24" + $vnet | Remove-AzVirtualNetworkSubnetConfig -Name $feSnetName + $vnet | Set-AzVirtualNetwork + + $actual = Get-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName + Assert-NotNull $actual + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $vnetName $actual.Name + Assert-AreEqual $location $actual.Location + Assert-AreEqual "Succeeded" $actual.ProvisioningState + Assert-AreEqual 1 $actual.Subnets.Count + Assert-AreEqual $beSnetName $actual.Subnets[0].Name +} + +Invoke-LiveTestScenario -Name "Remove virtual network" -Description "Test removing a virtual network" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "centralus" + $feSnetName = New-LiveTestResourceName + $beSnetName = New-LiveTestResourceName + $vnetName = New-LiveTestResourceName + + $feSnet = New-AzVirtualNetworkSubnetConfig -Name $feSnetName -AddressPrefix "10.0.1.0/24" + $beSnet = New-AzVirtualNetworkSubnetConfig -Name $beSnetName -AddressPrefix "10.0.2.0/24" + New-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -Location $location -AddressPrefix "10.0.0.0/16" -Subnet $feSnet, $beSnet + Remove-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -Force + + $actual = Get-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -ErrorAction SilentlyContinue + Assert-Null $actual +} + +Invoke-LiveTestScenario -Name "Create private DNS zone group" -Description "Test creating a private DNS zone group" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "westus" + $feSnetName = New-LiveTestResourceName + $beSnetName = New-LiveTestResourceName + $oSnetName = New-LiveTestResourceName + $vnetName = New-LiveTestResourceName + $feIpCfgName = New-LiveTestResourceName + $bePoolCfgName = New-LiveTestResourceName + $lbName = New-LiveTestResourceName + $plsIpCfgName = New-LiveTestResourceName + $plsName = New-LiveTestResourceName + $plsConnName = New-LiveTestResourceName + $peName = New-LiveTestResourceName + + $r5l = New-LiveTestRandomName -Option AllLetters -MaxLength 5 + $zoneName = "$r5l.private.contoso.com" + $zoneCfgName = New-LiveTestResourceName + $zoneGroupName = New-LiveTestResourceName + + $feSnet = New-AzVirtualNetworkSubnetConfig -Name $feSnetName -AddressPrefix "10.0.1.0/24" -PrivateEndpointNetworkPoliciesFlag Disabled -PrivateLinkServiceNetworkPoliciesFlag Disabled + $beSnet = New-AzVirtualNetworkSubnetConfig -Name $beSnetName -AddressPrefix "10.0.2.0/24" -PrivateEndpointNetworkPoliciesFlag Disabled -PrivateLinkServiceNetworkPoliciesFlag Disabled + $oSnet = New-AzVirtualNetworkSubnetConfig -Name $oSnetName -AddressPrefix "10.0.3.0/24" -PrivateEndpointNetworkPoliciesFlag Disabled -PrivateLinkServiceNetworkPoliciesFlag Disabled + $vnet = New-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -Location $location -AddressPrefix "10.0.0.0/16" -Subnet $feSnet, $beSnet, $oSnet + $feSnet = $vnet.Subnets | Where-Object Name -eq $feSnetName + $oSnet = $vnet.Subnets | Where-Object Name -eq $oSnetName + $feIpCfg = New-AzLoadBalancerFrontendIpConfig -Name $feIpCfgName -Subnet $feSnet -PrivateIpAddress "10.0.1.10" + $bePoolCfg = New-AzLoadBalancerBackendAddressPoolConfig -Name $bePoolCfgName + $lb = New-AzLoadBalancer -ResourceGroupName $rgName -Name $lbName -Location $location -FrontendIpConfiguration $feIpCfg -BackendAddressPool $bePoolCfg -Sku Standard + $plsIpCfg = New-AzPrivateLinkServiceIpConfig -Name $plsIpCfgName -PrivateIpAddress "10.0.3.10" -Subnet $oSnet + $feIpCfg = $lb | Get-AzLoadBalancerFrontendIpConfig + $pls = New-AzPrivateLinkService -ResourceGroupName $rgName -Name $plsName -Location $location -IpConfiguration $plsIpCfg -LoadBalancerFrontendIpConfiguration $feIpCfg + $plsConn = New-AzPrivateLinkServiceConnection -Name $plsConnName -PrivateLinkServiceId $pls.Id + New-AzPrivateEndpoint -ResourceGroupName $rgName -Name $peName -Location $location -Subnet $feSnet -PrivateLinkServiceConnection $plsConn + + New-AzPrivateDnsZone -ResourceGroupName $rgName -Name $zoneName + $zone = Get-AzPrivateDnsZone -ResourceGroupName $rgName -Name $zoneName + $zoneCfg = New-AzPrivateDnsZoneConfig -Name $zoneCfgName -PrivateDnsZoneId $zone.ResourceId + New-AzPrivateDnsZoneGroup -ResourceGroupName $rgName -Name $zoneGroupName -PrivateEndpointName $peName -PrivateDnsZoneConfig $zoneCfg + + $actual = Get-AzPrivateDnsZoneGroup -ResourceGroupName $rgName -Name $zoneGroupName -PrivateEndpointName $peName + Assert-NotNull $actual + Assert-AreEqual $zoneGroupName $actual.Name + Assert-AreEqual "Succeeded" $actual.ProvisioningState + Assert-AreEqual 1 $actual.PrivateDnsZoneConfigs.Count + Assert-AreEqual $zoneCfgName $actual.PrivateDnsZoneConfigs[0].Name + Assert-AreEqual $zone.ResourceId $actual.PrivateDnsZoneConfigs[0].PrivateDnsZoneId +} + +Invoke-LiveTestScenario -Name "Update private DNS zone group" -Description "Test updating an existing private DNS zone group with different zone config" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "eastus" + $feSnetName = New-LiveTestResourceName + $beSnetName = New-LiveTestResourceName + $oSnetName = New-LiveTestResourceName + $vnetName = New-LiveTestResourceName + $feIpCfgName = New-LiveTestResourceName + $bePoolCfgName = New-LiveTestResourceName + $lbName = New-LiveTestResourceName + $plsIpCfgName = New-LiveTestResourceName + $plsName = New-LiveTestResourceName + $plsConnName = New-LiveTestResourceName + $peName = New-LiveTestResourceName + + $r5l1 = New-LiveTestRandomName -Option AllLetters -MaxLength 5 + $zoneName1 = "$r5l1.private.contoso.com" + $zoneCfgName1 = New-LiveTestResourceName + $zoneGroupName = New-LiveTestResourceName + + $feSnet = New-AzVirtualNetworkSubnetConfig -Name $feSnetName -AddressPrefix "10.0.1.0/24" -PrivateEndpointNetworkPoliciesFlag Disabled -PrivateLinkServiceNetworkPoliciesFlag Disabled + $beSnet = New-AzVirtualNetworkSubnetConfig -Name $beSnetName -AddressPrefix "10.0.2.0/24" -PrivateEndpointNetworkPoliciesFlag Disabled -PrivateLinkServiceNetworkPoliciesFlag Disabled + $oSnet = New-AzVirtualNetworkSubnetConfig -Name $oSnetName -AddressPrefix "10.0.3.0/24" -PrivateEndpointNetworkPoliciesFlag Disabled -PrivateLinkServiceNetworkPoliciesFlag Disabled + $vnet = New-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -Location $location -AddressPrefix "10.0.0.0/16" -Subnet $feSnet, $beSnet, $oSnet + $feSnet = $vnet.Subnets | Where-Object Name -eq $feSnetName + $oSnet = $vnet.Subnets | Where-Object Name -eq $oSnetName + $feIpCfg = New-AzLoadBalancerFrontendIpConfig -Name $feIpCfgName -Subnet $feSnet -PrivateIpAddress "10.0.1.10" + $bePoolCfg = New-AzLoadBalancerBackendAddressPoolConfig -Name $bePoolCfgName + $lb = New-AzLoadBalancer -ResourceGroupName $rgName -Name $lbName -Location $location -FrontendIpConfiguration $feIpCfg -BackendAddressPool $bePoolCfg -Sku Standard + $plsIpCfg = New-AzPrivateLinkServiceIpConfig -Name $plsIpCfgName -PrivateIpAddress "10.0.3.10" -Subnet $oSnet + $feIpCfg = $lb | Get-AzLoadBalancerFrontendIpConfig + $pls = New-AzPrivateLinkService -ResourceGroupName $rgName -Name $plsName -Location $location -IpConfiguration $plsIpCfg -LoadBalancerFrontendIpConfiguration $feIpCfg + $plsConn = New-AzPrivateLinkServiceConnection -Name $plsConnName -PrivateLinkServiceId $pls.Id + New-AzPrivateEndpoint -ResourceGroupName $rgName -Name $peName -Location $location -Subnet $feSnet -PrivateLinkServiceConnection $plsConn + + $zone1 = New-AzPrivateDnsZone -ResourceGroupName $rgName -Name $zoneName1 + $zoneCfg1 = New-AzPrivateDnsZoneConfig -Name $zoneCfgName1 -PrivateDnsZoneId $zone1.ResourceId + New-AzPrivateDnsZoneGroup -ResourceGroupName $rgName -Name $zoneGroupName -PrivateEndpointName $peName -PrivateDnsZoneConfig $zoneCfg1 + + $r5l2 = New-LiveTestRandomName -Option AllLetters -MaxLength 5 + $zoneName2 = "$r5l2.private.contoso.com" + $zoneCfgName2 = New-LiveTestResourceName + + $zone2 = New-AzPrivateDnsZone -ResourceGroupName $rgName -Name $zoneName2 + $zoneCfg2 = New-AzPrivateDnsZoneConfig -Name $zoneCfgName2 -PrivateDnsZoneId $zone2.ResourceId + Set-AzPrivateDnsZoneGroup -ResourceGroupName $rgName -Name $zoneGroupName -PrivateEndpointName $peName -PrivateDnsZoneConfig $zoneCfg2 + + $actual = Get-AzPrivateDnsZoneGroup -ResourceGroupName $rgName -Name $zoneGroupName -PrivateEndpointName $peName + Assert-NotNull $actual + Assert-AreEqual $zoneGroupName $actual.Name + Assert-AreEqual "Succeeded" $actual.ProvisioningState + Assert-AreEqual 1 $actual.PrivateDnsZoneConfigs.Count + Assert-AreEqual $zoneCfgName2 $actual.PrivateDnsZoneConfigs[0].Name + Assert-AreEqual $zone2.ResourceId $actual.PrivateDnsZoneConfigs[0].PrivateDnsZoneId +} + +Invoke-LiveTestScenario -Name "Remove private DNS zone group" -Description "Test removing a private DNS zone group" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "eastus" + $feSnetName = New-LiveTestResourceName + $beSnetName = New-LiveTestResourceName + $oSnetName = New-LiveTestResourceName + $vnetName = New-LiveTestResourceName + $feIpCfgName = New-LiveTestResourceName + $bePoolCfgName = New-LiveTestResourceName + $lbName = New-LiveTestResourceName + $plsIpCfgName = New-LiveTestResourceName + $plsName = New-LiveTestResourceName + $plsConnName = New-LiveTestResourceName + $peName = New-LiveTestResourceName + + $r5l = New-LiveTestRandomName -Option AllLetters -MaxLength 5 + $zoneName = "$r5l.private.contoso.com" + $zoneCfgName = New-LiveTestResourceName + $zoneGroupName = New-LiveTestResourceName + + $feSnet = New-AzVirtualNetworkSubnetConfig -Name $feSnetName -AddressPrefix "10.0.1.0/24" -PrivateEndpointNetworkPoliciesFlag Disabled -PrivateLinkServiceNetworkPoliciesFlag Disabled + $beSnet = New-AzVirtualNetworkSubnetConfig -Name $beSnetName -AddressPrefix "10.0.2.0/24" -PrivateEndpointNetworkPoliciesFlag Disabled -PrivateLinkServiceNetworkPoliciesFlag Disabled + $oSnet = New-AzVirtualNetworkSubnetConfig -Name $oSnetName -AddressPrefix "10.0.3.0/24" -PrivateEndpointNetworkPoliciesFlag Disabled -PrivateLinkServiceNetworkPoliciesFlag Disabled + $vnet = New-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -Location $location -AddressPrefix "10.0.0.0/16" -Subnet $feSnet, $beSnet, $oSnet + $feSnet = $vnet.Subnets | Where-Object Name -eq $feSnetName + $oSnet = $vnet.Subnets | Where-Object Name -eq $oSnetName + $feIpCfg = New-AzLoadBalancerFrontendIpConfig -Name $feIpCfgName -Subnet $feSnet -PrivateIpAddress "10.0.1.10" + $bePoolCfg = New-AzLoadBalancerBackendAddressPoolConfig -Name $bePoolCfgName + $lb = New-AzLoadBalancer -ResourceGroupName $rgName -Name $lbName -Location $location -FrontendIpConfiguration $feIpCfg -BackendAddressPool $bePoolCfg -Sku Standard + $plsIpCfg = New-AzPrivateLinkServiceIpConfig -Name $plsIpCfgName -PrivateIpAddress "10.0.3.10" -Subnet $oSnet + $feIpCfg = $lb | Get-AzLoadBalancerFrontendIpConfig + $pls = New-AzPrivateLinkService -ResourceGroupName $rgName -Name $plsName -Location $location -IpConfiguration $plsIpCfg -LoadBalancerFrontendIpConfiguration $feIpCfg + $plsConn = New-AzPrivateLinkServiceConnection -Name $plsConnName -PrivateLinkServiceId $pls.Id + New-AzPrivateEndpoint -ResourceGroupName $rgName -Name $peName -Location $location -Subnet $feSnet -PrivateLinkServiceConnection $plsConn + + New-AzPrivateDnsZone -ResourceGroupName $rgName -Name $zoneName + $zone = Get-AzPrivateDnsZone -ResourceGroupName $rgName -Name $zoneName + $zoneCfg = New-AzPrivateDnsZoneConfig -Name $zoneCfgName -PrivateDnsZoneId $zone.ResourceId + New-AzPrivateDnsZoneGroup -ResourceGroupName $rgName -Name $zoneGroupName -PrivateEndpointName $peName -PrivateDnsZoneConfig $zoneCfg + + Remove-AzPrivateDnsZoneGroup -ResourceGroupName $rgName -Name $zoneGroupName -PrivateEndpointName $peName -Force + + $actual = Get-AzPrivateDnsZoneGroup -ResourceGroupName $rgName -Name $zoneGroupName -PrivateEndpointName $peName -ErrorAction SilentlyContinue + Assert-Null $actual +} diff --git a/src/SpringCloud/LiveTests/TestLiveScenarios.ps1 b/src/SpringCloud/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..391c3e53b262 --- /dev/null +++ b/src/SpringCloud/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,45 @@ +Invoke-LiveTestScenario -Name "Create Spring Cloud Instance" -Description "Test the process of create a new spring cloud instance." -Platform Linux -PowerShellVersion Latest -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "eastus" + $springCloudServiceName = New-LiveTestResourceName + + $springCloudInstance = New-AzSpringCloud -ResourceGroupName $rgName -Name $springCloudServiceName -Location $location -SkuTier "Basic" -SkuName "B0" + + Assert-AreEqual $springCloudServiceName $springCloudInstance.Name +} + +Invoke-LiveTestScenario -Name "Create Spring Cloud App Instance" -Description "Test the process of create a new spring cloud app instance." -Platform Linux -PowerShellVersion Latest -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "eastus" + $springCloudServiceName = New-LiveTestResourceName + $appName = New-LiveTestResourceName + + $springCloudInstance = New-AzSpringCloud -ResourceGroupName $rgName -Name $springCloudServiceName -Location $location -SkuTier "Basic" -SkuName "B0" + $appInstance = New-AzSpringCloudApp -ResourceGroupName $rgName -ServiceName $springCloudServiceName -Name $appName + + Assert-AreEqual $appName $appInstance.Name +} + +Invoke-LiveTestScenario -Name "Create Spring Cloud App Deployment Instance" -Description "Test the process of create a new spring cloud app deployment instance." -Platform Linux -PowerShellVersion Latest -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "eastus" + $springCloudServiceName = New-LiveTestResourceName + $appName = New-LiveTestResourceName + $deploymentName = "default" + + $springCloudInstance = New-AzSpringCloud -ResourceGroupName $rgName -Name $springCloudServiceName -Location $location -SkuTier "Basic" -SkuName "B0" + $appInstance = New-AzSpringCloudApp -ResourceGroupName $rgName -ServiceName $springCloudServiceName -Name $appName + $jarSource = New-AzSpringCloudAppDeploymentJarUploadedObject -RuntimeVersion "Java_8" + $deployment = New-AzSpringCloudAppDeployment -ResourceGroupName $rgName -ServiceName $springCloudServiceName -AppName $appName -DeploymentName $deploymentName -Source $jarSource -EnvironmentVariable @{"env" = "prod"} + + Assert-AreEqual $appName $appInstance.Name +} diff --git a/src/Sql/Sql.Test/LiveTests/TestLiveScenarios.ps1 b/src/Sql/Sql.Test/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..c153f29040d5 --- /dev/null +++ b/src/Sql/Sql.Test/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,98 @@ +Invoke-LiveTestScenario -Name "Create, get, update and remove a new SQL Server" -Description "Test on new SQL Server" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $location = "eastus" + $adminSqlLogin = New-LiveTestResourceName + $password = "password@123" + $serverName = New-LiveTestResourceName + # Create a Sql Server + $actual = New-AzSqlServer -ResourceGroupName $rgName ` + -ServerName $serverName ` + -Location $location ` + -SqlAdministratorCredentials ` + $(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $adminSqlLogin, $(ConvertTo-SecureString -String $password -AsPlainText -Force)) + Assert-AreEqual $serverName $actual.ServerName + Assert-AreEqual $rgName $actual.ResourceGroupName + # Get created Sql Server + $actual = Get-AzSqlServer -ResourceGroupName $rgName -ServerName $serverName + Assert-AreEqual $serverName $actual.ServerName + # Update a Sql server + $updatedPassword = "newpassword@123" + $secureString = ConvertTo-SecureString $updatedPassword -AsPlainText -Force + $null = Set-AzSqlServer -ResourceGroupName $rgName -ServerName $serverName -PublicNetworkAccess Disabled + $actual = Get-AzSqlServer -ResourceGroupName $rgName -ServerName $serverName + Assert-AreEqual "Disabled" $actual.PublicNetworkAccess + # Remove a Sql server + $null = Remove-AzSqlServer -ResourceGroup $rgName -ServerName $serverName + $actual = Get-AzSqlServer -ResourceGroup $rgName + Assert-False { $actual.ServerName -contains $serverName} +} +# After testing the cmdlets of Sql Server, create a Sql Server for sql database testing. + +$ServerResourceGroup = New-LiveTestResourceGroup -Location eastus +$ServerResourceGroup +$ServerResourceGroup.ResourceGroupName +$RgName = $ServerResourceGroup.ResourceGroupName +$ResourceGroupLocation = $ServerResourceGroup.Location +Write-Host "##[section]Successfully created the resource group for sql server." -ForegroundColor Green +$AdminSqlLogin = New-LiveTestResourceName +$Password = "password@1234" +$ServerName = New-LiveTestResourceName + +$SqlServer = New-AzSqlServer -ResourceGroupName $RgName ` + -ServerName $ServerName ` + -Location $ResourceGroupLocation ` + -SqlAdministratorCredentials ` + $(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $AdminSqlLogin, $(ConvertTo-SecureString -String $Password -AsPlainText -Force)) + +Invoke-LiveTestScenario -Name "Create a Sql Database" -Description "Test New-AzSqlDatabase" -NoResourceGroup -ScenarioScript ` +{ + $dbName = New-LiveTestResourceName + + $actual = New-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName + $actual.ServerName + Assert-AreEqual $ServerName $actual.ServerName + Assert-AreEqual $RgName $actual.ResourceGroupName + Assert-AreEqual $dbName $actual.DatabaseName + Remove-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName +} + +Invoke-LiveTestScenario -Name "Get a Sql Database" -Description "Test Get-AzSqlDatabase" -NoResourceGroup -ScenarioScript ` +{ + $dbName = New-LiveTestResourceName + + $null = New-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName + $actual = Get-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName + Assert-AreEqual $serverName $actual.ServerName + Assert-AreEqual $rgName $actual.ResourceGroupName + Assert-AreEqual $dbName $actual.DatabaseName + Remove-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName +} + +Invoke-LiveTestScenario -Name "Update a Sql Database" -Description "Test Set-AzSqlDatabase" -NoResourceGroup -ScenarioScript ` +{ + $dbName = New-LiveTestResourceName + + $null = New-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName + $null = Set-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName -Edition "Standard" -RequestedServiceObjectiveName "S0" + $actual = Get-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName + Assert-AreEqual $dbName $actual.DatabaseName + Assert-AreEqual "S0" $actual.RequestedServiceObjectiveName + Assert-AreEqual "Standard" $actual.Edition + Remove-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName +} + +Invoke-LiveTestScenario -Name "Remove a Sql Database" -Description "Test Remove-AzSqlDatabase" -NoResourceGroup -ScenarioScript ` +{ + $dbName = New-LiveTestResourceName + + $null = New-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName + Remove-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName + $actual = Get-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName + + Assert-False { $actual.DatabaseName -contains $dbName} +} +# At the end of db test, clear the resource group +Clear-LiveTestResources -Name $RgName \ No newline at end of file diff --git a/src/Storage/Storage.Management.Test/LiveTests/TestLiveScenarios.ps1 b/src/Storage/Storage.Management.Test/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..3d8b8748a5ee --- /dev/null +++ b/src/Storage/Storage.Management.Test/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,36 @@ +Invoke-LiveTestScenario -Name "Creates a Storage account" -Description "Test create storage account" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + # $name = "alex12391d87" + $name = New-LiveTestResourceName + $location = "westus" + $actual = New-AzStorageAccount -ResourceGroupName $rgName -Name $name -Location $location -SkuName Standard_GRS + + Assert-AreEqual $name $actual.StorageAccountName + # Assert-AreEqual $rgName $actual.ResourceGroupName + # Assert-AreEqual $vaultLocation $actual.PrimaryLocation + # Assert-AreEqual "Standard_GRS" $actual.SkuName + # Assert-AreEqual $false $actual.EnabledForDeployment + # Assert-True { $actual.AllowBlobPublicAccess } "By default AllowBlobPublicAccess should be true" + # Assert-Null $actual.AllowSharedKeyAccess "By default AllowSharedKeyAccess should be null" + # Assert-False { $actual.EnableHttpsTrafficOnly } "By default EnableHttpsTrafficOnly should be false" +} + +Invoke-LiveTestScenario -Name "Removes a Storage account" -Description "Test removes a Storage account from Azure." -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + # $name = "alex12391d87" + $name = New-LiveTestResourceName + $location = "westus" + + New-AzStorageAccount -ResourceGroupName $rgname -Name $name -Location $location -SkuName Standard_GRS + Remove-AzStorageAccount -ResourceGroupName $rgname -Name $name -Force + + $removedAccount = Get-AzStorageAccount -ResourceGroupName $rgName -Name $name -ErrorAction SilentlyContinue + Assert-Null $removedAccount + +} diff --git a/src/Synapse/Synapse.Test/LiveTests/TestLiveScenarios.ps1 b/src/Synapse/Synapse.Test/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..bd9865c0f0d8 --- /dev/null +++ b/src/Synapse/Synapse.Test/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,80 @@ +function GenerateDefinitionFile { + param ( + [Parameter()] + [string] $File + ) + + $definition = [PSCustomObject]@{ + name = "DataFlow" + properties = [PSCustomObject]@{ + type = "MappingDataFlow" + typeProperties = [PSCustomObject]@{ + sources = @() + sinks = @() + transformations = @() + scriptLines = @("") + } + } + } + + ConvertTo-Json $definition -Compress -Depth 3 | Out-File -FilePath $File -Encoding utf8 -NoNewline -Force +} + +Invoke-LiveTestScenario -Name "Create synapse data flow" -Description "Test creating a synapse data flow" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $wsName = New-LiveTestResourceName + $location = "eastus" + $saName = New-LiveTestStorageAccountName + $fsName = New-LiveTestStorageAccountName + $flowName = New-LiveTestResourceName + $fileName = New-LiveTestRandomName -Option AllLetters -MaxLength 8 + $file = "$fileName.json" + + $username = "sqladmin" + $password = ConvertTo-SecureString "Password123!" -AsPlainText -Force + $sqlAdminCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $password + New-AzSynapseWorkspace -Name $wsName -ResourceGroupName $rgName -Location $location -DefaultDataLakeStorageAccountName $saName -DefaultDataLakeStorageFilesystem $fsName -SqlAdministratorLoginCredential $sqlAdminCred + New-AzSynapseFirewallRule -WorkspaceName $wsName -AllowAllIp + + Start-Sleep -Seconds 30 + + GenerateDefinitionFile($file) + Set-AzSynapseDataFlow -Name $flowName -WorkspaceName $wsName -DefinitionFile $file + + $actual = Get-AzSynapseDataFlow -Name $flowName -WorkspaceName $wsName + Assert-NotNull $actual + Assert-AreEqual $wsName $actual.WorkspaceName + Assert-AreEqual $flowName $actual.Name +} + +Invoke-LiveTestScenario -Name "Remove synapse data flow" -Description "Test removing a synapse data flow" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $wsName = New-LiveTestResourceName + $location = "eastus" + $saName = New-LiveTestStorageAccountName + $fsName = New-LiveTestStorageAccountName + $flowName = New-LiveTestResourceName + $fileName = New-LiveTestRandomName -Option AllLetters -MaxLength 8 + $file = "$fileName.json" + + $username = "sqladmin" + $password = ConvertTo-SecureString "Password123!" -AsPlainText -Force + $sqlAdminCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $password + New-AzSynapseWorkspace -Name $wsName -ResourceGroupName $rgName -Location $location -DefaultDataLakeStorageAccountName $saName -DefaultDataLakeStorageFilesystem $fsName -SqlAdministratorLoginCredential $sqlAdminCred + New-AzSynapseFirewallRule -WorkspaceName $wsName -AllowAllIp + + Start-Sleep -Seconds 60 + + GenerateDefinitionFile($file) + Set-AzSynapseDataFlow -Name $flowName -WorkspaceName $wsName -DefinitionFile $file + Remove-AzSynapseDataFlow -Name $flowName -WorkspaceName $wsName -Force + + $actual = Get-AzSynapseDataFlow -Name $flowName -WorkspaceName $wsName -ErrorAction SilentlyContinue + Assert-Null $actual +} diff --git a/src/Websites/Websites.Test/LiveTests/TestLiveScenarios.ps1 b/src/Websites/Websites.Test/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..d1e63af78480 --- /dev/null +++ b/src/Websites/Websites.Test/LiveTests/TestLiveScenarios.ps1 @@ -0,0 +1,143 @@ +Invoke-LiveTestScenario -Name "Create new web with service plan" -Description "Test creating a new web app with service plan" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $webName = New-LiveTestResourceName + $webLocation = "westus" + $whpName = New-LiveTestResourceName + $tier = "Shared" + + $serverFarm = New-AzAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $weblocation -Tier $tier + $actual = New-AzWebApp -ResourceGroupName $rgname -Name $webName -Location $webLocation -AppServicePlan $whpName + Assert-AreEqual $webName $actual.Name + Assert-AreEqual $serverFarm.Id $actual.ServerFarmId +} + +Invoke-LiveTestScenario -Name "Get a webapp" -Description "Test getting a new webapp" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $webName = New-LiveTestResourceName + $webLocation = "westus" + $whpName = New-LiveTestResourceName + $tier = "Shared" + + $serverFarm = New-AzAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $weblocation -Tier $tier + $null = New-AzWebApp -ResourceGroupName $rgname -Name $webName -Location $webLocation -AppServicePlan $whpName + $webApp = Get-AzWebApp -ResourceGroupName $rgname -Name $webName + Assert-AreEqual $webName $webApp.Name + Assert-AreEqual $rgName $webApp.ResourceGroup + Assert-AreEqual $serverFarm.Id $webApp.ServerFarmId +} + +Invoke-LiveTestScenario -Name "Update web app" -Description "Test updating service plan & set site properties for existing web app" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $webAppName = New-LiveTestResourceName + $webLocation = "westus" + $appServicePlanName1 = New-LiveTestResourceName + $appServicePlanName2 = New-LiveTestResourceName + $tier1 = "Shared" + $tier2 = "Standard" + + $serverFarm1 = New-AzAppServicePlan -ResourceGroupName $rgname -Name $appServicePlanName1 -Location $webLocation -Tier $tier1 + $serverFarm2 = New-AzAppServicePlan -ResourceGroupName $rgname -Name $appServicePlanName2 -Location $webLocation -Tier $tier2 + $webApp = New-AzWebApp -ResourceGroupName $rgname -Name $webAppName -Location $webLocation -AppServicePlan $appServicePlanName1 + + Assert-AreEqual $webAppName $webApp.Name + Assert-AreEqual $serverFarm1.Id $webApp.ServerFarmId + Assert-Null $webApp.Identity + Assert-NotNull $webApp.SiteConfig.phpVersion + Assert-AreEqual $false $webApp.HttpsOnly + Assert-AreEqual "AllAllowed" $webApp.SiteConfig.FtpsState + + # Update service plan & set site properties + $job = Set-AzWebApp -ResourceGroupName $rgname -Name $webAppName -AppServicePlan $appServicePlanName2 -HttpsOnly $true -AlwaysOn $false -AsJob + $job | Wait-Job + $webApp = $job | Receive-Job + + # Assert + Assert-AreEqual $webAppName $webApp.Name + Assert-AreEqual $serverFarm2.Id $webApp.ServerFarmId + Assert-AreEqual $true $webApp.HttpsOnly + Assert-AreEqual $false $webapp.SiteConfig.AlwaysOn + + # Set config properties + $webapp.SiteConfig.HttpLoggingEnabled = $true + $webapp.SiteConfig.RequestTracingEnabled = $true + $webapp.SiteConfig.FtpsState = "FtpsOnly" + $webApp.SiteConfig.MinTlsVersion = "1.0" + $webApp.SiteConfig.HealthCheckPath = "/api/path" + + # Set site properties + $webApp = $webApp | Set-AzWebApp + + # Assert + Assert-AreEqual $webAppName $webApp.Name + Assert-AreEqual $serverFarm2.Id $webApp.ServerFarmId + Assert-AreEqual $true $webApp.SiteConfig.HttpLoggingEnabled + Assert-AreEqual $true $webApp.SiteConfig.RequestTracingEnabled + Assert-AreEqual $false $webApp.SiteConfig.AlwaysOn + Assert-AreEqual "FtpsOnly" $webApp.SiteConfig.FtpsState + Assert-AreEqual "1.0" $webApp.SiteConfig.MinTlsVersion + Assert-AreEqual "/api/path" $webApp.SiteConfig.HealthCheckPath +} + +Invoke-LiveTestScenario -Name "Delete web app" -Description "Test deleting web app" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $webName = New-LiveTestResourceName + $webLocation = "westus" + $whpName = New-LiveTestResourceName + $tier = "Shared" + + $null = New-AzAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $webLocation -Tier $tier + $null = New-AzWebApp -ResourceGroupName $rgname -Name $webName -Location $webLocation -AppServicePlan $whpName + Remove-AzWebApp -ResourceGroupName $rgname -Name $webName -Force + + $webappNames = (Get-AzWebApp -ResourceGroupName $rgname) | Select -Property Name + Assert-False { $webappNames -contains $webName } +} + +Invoke-LiveTestScenario -Name "Start, Stop and Restart WebApp" -Description "Test Stop-AzWebApp, Start-AzWebApp, Restart-AzWebApp" -ScenarioScript ` +{ + param ($rg) + + $rgName = $rg.ResourceGroupName + $webName = New-LiveTestResourceName + $webLocation = "westus" + $whpName = New-LiveTestResourceName + $tier = "Shared" + + $null = New-AzAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $webLocation -Tier $tier + $webApp = New-AzWebApp -ResourceGroupName $rgname -Name $webName -Location $webLocation -AppServicePlan $whpName + # Stop web app + $webApp = $webApp | Stop-AzWebApp + Assert-AreEqual "Stopped" $webApp.State + + # Start web app + $webApp = $webApp | Start-AzWebApp + Assert-AreEqual "Running" $webApp.State + + # Restart web app + $webApp = $webApp | Restart-AzWebApp + Assert-AreEqual "Running" $webApp.State + + # Stop web app + $webApp = Stop-AzWebApp -ResourceGroupName $rgname -Name $webName + Assert-AreEqual "Stopped" $webApp.State + + # Start web app + $webApp = Start-AzWebApp -ResourceGroupName $rgname -Name $webName + Assert-AreEqual "Running" $webApp.State + + # Retart web app + $webApp = Restart-AzWebApp -ResourceGroupName $rgname -Name $webName + Assert-AreEqual "Running" $webApp.State +} diff --git a/tools/TestFx/Assert.ps1 b/tools/TestFx/Assert.ps1 index f604184eea1f..a30933dfefb8 100644 --- a/tools/TestFx/Assert.ps1 +++ b/tools/TestFx/Assert.ps1 @@ -394,7 +394,7 @@ function Assert-Match { $message = "Assertion failed because the actual string '$actual' does not match the regular expression '$regex'." } - if (!($actual -match $regex)) { + if (!($actual -match $regex) > $null) { throw $message } @@ -418,7 +418,7 @@ function Assert-NotMatch { $message = "Assertion failed because the actual string '$actual' does match the regular expression '$regex'." } - if ($actual -Match $regex) { + if ($actual -match $regex) { throw $message } diff --git a/tools/TestFx/Live/ConnectLiveTestServicePrincipal.ps1 b/tools/TestFx/Live/ConnectLiveTestServicePrincipal.ps1 index 8a0794ec3e7b..ccfdd7bb0ef6 100644 --- a/tools/TestFx/Live/ConnectLiveTestServicePrincipal.ps1 +++ b/tools/TestFx/Live/ConnectLiveTestServicePrincipal.ps1 @@ -16,6 +16,11 @@ param ( [string] $ServicePrincipalSecret ) +$PreErrorActionPreference = $ErrorActionPreference +$ErrorActionPreference = "Stop" + $servicePrincipalSecureSecret = ConvertTo-SecureString -String $ServicePrincipalSecret -AsPlainText -Force $servicePrincipalCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ServicePrincipalId, $servicePrincipalSecureSecret Connect-AzAccount -SubscriptionId $SubscriptionId -TenantId $TenantId -Credential $servicePrincipalCredential -ServicePrincipal + +$ErrorActionPreference = $PreErrorActionPreference diff --git a/tools/TestFx/Live/DebugLocalLiveTestScenarios.ps1 b/tools/TestFx/Live/DebugLocalLiveTestScenarios.ps1 new file mode 100644 index 000000000000..a3edc91e234e --- /dev/null +++ b/tools/TestFx/Live/DebugLocalLiveTestScenarios.ps1 @@ -0,0 +1,68 @@ +param ( + [Parameter(Mandatory)] + [ValidateScript({ Test-Path -LiteralPath $_ -PathType Container })] + [string] $RepoLocation, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [string] $RunPlatform = "Windows" +) + +function ImportLocalAzModules { + param () + + $debugDirectory = Join-Path -Path $RepoLocation -ChildPath "artifacts" | Join-Path -ChildPath "Debug" + $accountsModuleDirectory = Join-Path -Path $debugDirectory -ChildPath "Az.Accounts" + Write-Host "Start to import Azure PowerShell modules from artifacts/Debug." -ForegroundColor Green + Write-Host "If you see module import issue, please restart the PowerShell host." -ForegroundColor Magenta + + Write-Host "Importing Az.Accounts" -ForegroundColor Green + Import-Module (Join-Path -Path $accountsModuleDirectory -ChildPath "Az.Accounts.psd1") + Get-ChildItem -Path $debugDirectory -Directory -Exclude "Az.Accounts" | Get-ChildItem -File -Filter "*.psd1" | Select-Object -ExpandProperty FullName | ForEach-Object { + Write-Host "Importing $_" -ForegroundColor Green + Import-Module $_ -Force + } + Write-Host "Successfully imported Azure PowerShell modules from artifacts/Debug" -ForegroundColor Green +} + +function InvokeLocalLiveTestScenarios { + param ( + [Parameter()] + [ValidateNotNullOrEmpty()] + [string[]] $TargetModules, + + [Parameter()] + [ValidateScript({ Test-Path -LiteralPath $_ -PathType Container })] + [string] $Output = (Get-Location) + ) + + $srcDir = Join-Path -Path $RepoLocation -ChildPath "src" + $liveScenarios = Get-ChildItem -Path $srcDir -Recurse -Directory -Filter "LiveTests" | Get-ChildItem -Filter "TestLiveScenarios.ps1" -File | Select-Object -ExpandProperty FullName + $liveScenarios | ForEach-Object { + $moduleName = [regex]::match($_, "[\\|\/]src[\\|\/](?[a-zA-Z]+)[\\|\/]").Groups["ModuleName"].Value + if (!$PSBoundParameters.ContainsKey("TargetModules") -or $moduleName -in $TargetModules) { + Write-Host "Executing live test scenarios for module $moduleName" -ForegroundColor Cyan + Import-Module "./tools/TestFx/Assert.ps1" -Force + Import-Module "./tools/TestFx/Live/LiveTestUtility.psd1" -ArgumentList $moduleName, $RunPlatform, $Output -Force + . $_ + } + } + + Write-Host "Waiting for all cleanup jobs to be completed." -ForegroundColor Green + while (Get-Job -State Running) { + Write-Host "Waiting for 10 seconds ..." -ForegroundColor Green + Start-Sleep -Seconds 10 + } + Write-Host "All cleanup jobs are completed." -ForegroundColor Green + + Write-Host "Cleanup jobs information." -ForegroundColor Green + + Write-Host + $cleanupJobs = Get-Job + $cleanupJobs | Select-Object Name, Command, State, PSBeginTime, PSEndTime, Output + Write-Host + + $cleanupJobs | Remove-Job +} + +ImportLocalAzModules diff --git a/tools/TestFx/Live/InitializeLiveTestEnvironment.ps1 b/tools/TestFx/Live/InitializeLiveTestEnvironment.ps1 index 55067633a78a..4f1df58cfb64 100644 --- a/tools/TestFx/Live/InitializeLiveTestEnvironment.ps1 +++ b/tools/TestFx/Live/InitializeLiveTestEnvironment.ps1 @@ -15,14 +15,14 @@ function InstallLiveTestDesiredPowerShell { [string] $DesiredVersion ) - Write-Host "Validating desired PowerShell version ..." + Write-Host "Validating desired PowerShell version." if ($isWinPSDesired) { powershell -NoLogo -NoProfile -NonInteractive -Command "(Get-Variable -Name PSVersionTable).Value" - Write-Host "Desired Windows Powershell version $DesiredVersion has been installed." + Write-Host "##[section]Desired Windows Powershell version $DesiredVersion has been installed." } else { - Write-Host "Installing PowerShell version $DesiredVersion ..." + Write-Host "##[section]Installing PowerShell version $DesiredVersion." dotnet --version dotnet new tool-manifest --force @@ -36,7 +36,7 @@ function InstallLiveTestDesiredPowerShell { dotnet tool run pwsh -Version - Write-Host "Desired PowerShell version $DesiredVersion has been installed." + Write-Host "##[section]Desired PowerShell version $DesiredVersion has been installed." } } diff --git a/tools/TestFx/Live/InstallLiveTestAzModules.ps1 b/tools/TestFx/Live/InstallLiveTestAzModules.ps1 index 445007018c54..879b06a51fc9 100644 --- a/tools/TestFx/Live/InstallLiveTestAzModules.ps1 +++ b/tools/TestFx/Live/InstallLiveTestAzModules.ps1 @@ -1,6 +1,6 @@ param ( [Parameter(Mandatory)] - [ValidateSet("PSGallery", "DailyBuild", IgnoreCase = $false)] + [ValidateSet("PSGallery", "DailyBuild", "Sign", IgnoreCase = $false)] [string] $Source, [Parameter()] @@ -11,9 +11,12 @@ switch ($Source) { "PSGallery" { Set-PSRepository -Name $Source -InstallationPolicy Trusted } - "DailyBuild" { + { "DailyBuild" -or "Sign" } { Register-PSRepository -Name $Source -SourceLocation $AzPackagesLocation -PackageManagementProvider NuGet -InstallationPolicy Trusted } } -Install-Module -Name Az -Repository $Source -Scope CurrentUser -AllowClobber -Force +Install-Module -Name AzPreview -Repository $Source -Scope CurrentUser -AllowClobber -Force + +Get-Module -Name Az +Get-Module -Name Az.* -ListAvailable diff --git a/tools/TestFx/Live/InvokeLiveTestCITask.ps1 b/tools/TestFx/Live/InvokeLiveTestCITask.ps1 index 9d2be07b79e4..be97031b9f26 100644 --- a/tools/TestFx/Live/InvokeLiveTestCITask.ps1 +++ b/tools/TestFx/Live/InvokeLiveTestCITask.ps1 @@ -14,14 +14,17 @@ param ( if ($UseWindowsPowerShell) { $process = "powershell" + Write-Host "##[section]Using Windows PowerShell" } else { $process = "dotnet tool run pwsh" + Write-Host "##[section]Using PowerShell" + dotnet tool run pwsh -NoLogo -NoProfile -NonInteractive -Version } switch ($PSCmdlet.ParameterSetName) { "ByScriptFile" { - Invoke-Expression "$process -NoLogo -NoProfile -NonInteractive -File '$ScriptFile'" + Invoke-Expression "$process -NoLogo -NoProfile -NonInteractive -File $ScriptFile" } "ByScriptBlock" { Invoke-Expression "$process -NoLogo -NoProfile -NonInteractive -Command $ScriptBlock" diff --git a/tools/TestFx/Live/InvokeLiveTestScenarios.ps1 b/tools/TestFx/Live/InvokeLiveTestScenarios.ps1 index 9ffe59ff4b63..923af1db78f2 100644 --- a/tools/TestFx/Live/InvokeLiveTestScenarios.ps1 +++ b/tools/TestFx/Live/InvokeLiveTestScenarios.ps1 @@ -1,78 +1,47 @@ param ( - [Parameter(Mandatory, Position = 0)] + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] - [string] $BuildId, + [string] $RunPlatform, - [Parameter(Mandatory, Position = 1)] - [ValidateNotNullOrEmpty()] - [string] $OSVersion, - - [Parameter(Mandatory, Position = 2)] - [ValidateNotNullOrEmpty()] - [string] $PSVersion, - - [Parameter(Mandatory, Position = 3)] + [Parameter(Mandatory)] [ValidateScript({ Test-Path -LiteralPath $_ -PathType Container })] [string] $RepoLocation, - [Parameter(Mandatory, Position = 4)] + [Parameter(Mandatory)] [ValidateScript({ Test-Path -LiteralPath $_ -PathType Container })] [string] $DataLocation ) -function FillLiveTestCoverageAdditionalInfo { - [CmdletBinding()] - param ( - [Parameter(Mandatory)] - [ValidateScript({ Test-Path -LiteralPath $_ -PathType Container })] - [string] $TestCoverageDataLocation, - - [Parameter(Mandatory)] - [ValidateNotNullOrEmpty()] - [string] $BuildId, +$srcDir = Join-Path -Path $RepoLocation -ChildPath "src" +$liveScenarios = Get-ChildItem -Path $srcDir -Directory -Exclude "Accounts" | Get-ChildItem -Directory -Filter "LiveTests" -Recurse | Get-ChildItem -File -Filter "TestLiveScenarios.ps1" | Select-Object -ExpandProperty FullName +$liveScenarios | ForEach-Object { + $moduleName = [regex]::match($_, "[\\|\/]src[\\|\/](?[a-zA-Z]+)[\\|\/]").Groups["ModuleName"].Value + Import-Module "./tools/TestFx/Assert.ps1" -Force + Import-Module "./tools/TestFx/Live/LiveTestUtility.psd1" -ArgumentList $moduleName, $RunPlatform, $DataLocation -Force + . $_ +} - [Parameter(Mandatory)] - [ValidateNotNullOrEmpty()] - [string] $OSVersion, +$accountsDir = Join-Path -Path $srcDir -ChildPath "Accounts" +$accountsLiveScenario = Get-ChildItem -Path $accountsDir -Directory -Filter "LiveTests" -Recurse | Get-ChildItem -File -Filter "TestLiveScenarios.ps1" | Select-Object -ExpandProperty FullName +if ($null -ne $accountsLiveScenario) { + Import-Module "./tools/TestFx/Assert.ps1" -Force + Import-Module "./tools/TestFx/Live/LiveTestUtility.psd1" -ArgumentList "Accounts", $RunPlatform, $DataLocation -Force + . $accountsLiveScenario +} - [Parameter(Mandatory)] - [ValidateNotNullOrEmpty()] - [string] $PSVersion, +Write-Host "##[section]Waiting for all cleanup jobs to be completed." -ForegroundColor Green +while (Get-Job -State Running) { + Start-Sleep -Seconds 30 +} +Write-Host "##[section]All cleanup jobs are completed." -ForegroundColor Green - [Parameter(Mandatory)] - [ValidateNotNullOrEmpty()] - [string] $ModuleName - ) +Write-Host "##[group]Cleanup jobs information." -ForegroundColor Magenta - $testCoverageUtility = $PSScriptRoot | Split-Path | Join-Path -ChildPath "Coverage" | Join-Path -ChildPath "TestCoverageUtility.psd1" - Import-Module $testCoverageUtility - $module = Get-Module -Name "Az.$ModuleName" -ListAvailable - $moduleDetails = Get-TestCoverageModuleDetails -Module $module +Write-Host +$cleanupJobs = Get-Job +$cleanupJobs | Select-Object Name, Command, State, PSBeginTime, PSEndTime, Output +Write-Host - $testCoverageRawCsv = Join-Path -Path $TestCoverageDataLocation -ChildPath "TestCoverageAnalysis" | Join-Path -ChildPath "Raw" | Join-Path -ChildPath "Az.$ModuleName.csv" - (Import-Csv -LiteralPath $testCoverageRawCsv) | - Select-Object @{ Name = "BuildId"; Expression = { "$BuildId" } }, ` - @{ Name = "OSVersion"; Expression = { "$OSVersion" } }, ` - @{ Name = "PSVersion"; Expression = { "$PSVersion" } }, ` - @{ Name = "Module"; Expression = { "$ModuleName" } }, ` - "CommandName", @{ Name = "TotalCommands"; Expression = { "$($moduleDetails['TotalCommands'])" } }, ` - "ParameterSetName", @{ Name = "TotalParameterSets"; Expression = { "$($moduleDetails['TotalParameterSets'])" } }, ` - "Parameters", @{ Name = "TotalParameters"; Expression = { "$($moduleDetails['TotalParameters'])" } }, ` - "SourceScript", "LineNumber", "StartDateTime", "EndDateTime", "IsSuccess" | - Export-Csv -LiteralPath $testCoverageRawCsv -Encoding utf8 -NoTypeInformation -Force -} +Write-Host "##[endgroup]" -ForegroundColor Magenta -$srcDir = Join-Path -Path $RepoLocation -ChildPath "src" -$liveScenarios = Get-ChildItem -LiteralPath $srcDir -Recurse -Directory -Filter "LiveTests" | ForEach-Object { - Get-ChildItem -Path (Join-Path -Path $_.FullName -ChildPath "TestLiveScenarios.ps1") -File -} -$liveScenarios | ForEach-Object { - $moduleName = [regex]::match($_.FullName, "[\\|\/]src[\\|\/](?[a-zA-Z]+)[\\|\/]").Groups["ModuleName"].Value - if ($PSVersion -eq "latest") { - $PSVersion = (Get-Variable -Name PSVersionTable).Value.PSVersion.ToString() - } - Import-Module "./tools/TestFx/Assert.ps1" -Force - Import-Module "./tools/TestFx/Live/LiveTestUtility.psd1" -ArgumentList $moduleName, $BuildId, $OSVersion, $PSVersion, $DataLocation -Force - . $_ - FillLiveTestCoverageAdditionalInfo -TestCoverageDataLocation $DataLocation -BuildId $BuildId -OSVersion $OSVersion -PSVersion $PSVersion -ModuleName $moduleName -} +$cleanupJobs | Remove-Job diff --git a/tools/TestFx/Live/LiveTestUtility.psd1 b/tools/TestFx/Live/LiveTestUtility.psd1 index a695e2594c89..117f77a88405 100644 --- a/tools/TestFx/Live/LiveTestUtility.psd1 +++ b/tools/TestFx/Live/LiveTestUtility.psd1 @@ -74,7 +74,7 @@ # NestedModules = @() # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. - FunctionsToExport = 'New-LiveTestRandomName', 'New-LiveTestResourceGroupName', 'New-LiveTestResourceName', 'New-LiveTestStorageAccountName', 'New-LiveTestResourceGroup', 'Clear-LiveTestResources', 'Invoke-LiveTestScenario' + FunctionsToExport = 'New-LiveTestRandomName', 'New-LiveTestResourceGroupName', 'New-LiveTestResourceName', 'New-LiveTestStorageAccountName', 'New-LiveTestResourceGroup', 'Clear-LiveTestResources', 'Invoke-LiveTestCommand', 'Invoke-LiveTestScenario' # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. CmdletsToExport = @() diff --git a/tools/TestFx/Live/LiveTestUtility.psm1 b/tools/TestFx/Live/LiveTestUtility.psm1 index eb7937f66e18..742b5608404a 100644 --- a/tools/TestFx/Live/LiveTestUtility.psm1 +++ b/tools/TestFx/Live/LiveTestUtility.psm1 @@ -18,60 +18,94 @@ param ( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] - [string] $BuildId, - - [Parameter(Mandatory)] - [ValidateNotNullOrEmpty()] - [string] $OSVersion, - - [Parameter(Mandatory)] - [ValidateNotNullOrEmpty()] - [string] $PSVersion, + [string] $RunPlatform, [Parameter()] [ValidateScript({ Test-Path -LiteralPath $_ -PathType Container })] [string] $DataLocation ) -New-Variable -Name ResourceGroupPrefix -Value "azpsliverg" -Scope Script -Option Constant -New-Variable -Name ResourcePrefix -Value "azpslive" -Scope Script -Option Constant -New-Variable -Name StorageAccountPrefix -Value "azpslivesa" -Scope Script -Option Constant +New-Variable -Name ResourceGroupPrefix -Value "azpslrg" -Scope Script -Option Constant +New-Variable -Name ResourcePrefix -Value "azpsl" -Scope Script -Option Constant +New-Variable -Name StorageAccountPrefix -Value "azpslsa" -Scope Script -Option Constant New-Variable -Name CommandMaxRetryCount -Value 3 -Scope Script -Option Constant New-Variable -Name CommandDelay -Value 10 -Scope Script -Option Constant -New-Variable -Name ScenarioMaxRetryCount -Value 5 -Scope Script -Option Constant -New-Variable -Name ScenarioMaxDelay -Value 60 -Scope Script -Option Constant +New-Variable -Name ScenarioMaxRetryCount -Value 3 -Scope Script -Option Constant +New-Variable -Name ScenarioMaxDelay -Value 20 -Scope Script -Option Constant New-Variable -Name ScenarioDelay -Value 5 -Scope Script -Option Constant New-Variable -Name LiveTestAnalysisDirectory -Value (Join-Path -Path $DataLocation -ChildPath "LiveTestAnalysis") -Scope Script -Option Constant New-Variable -Name LiveTestRawDirectory -Value (Join-Path -Path $script:LiveTestAnalysisDirectory -ChildPath "Raw") -Scope Script -Option Constant New-Variable -Name LiveTestRawCsvFile -Value (Join-Path -Path $script:LiveTestRawDirectory -ChildPath "Az.$ModuleName.csv") -Scope Script -Option Constant +New-Variable -Name PowerShellLatestVersion -Value "7.3" -Scope Script -Option Constant + function InitializeLiveTestModule { [CmdletBinding()] - param ( - [Parameter(Mandatory, Position = 0)] - [ValidateNotNullOrEmpty()] - [string] $ModuleName - ) + param () if (!(Test-Path -LiteralPath $script:LiveTestAnalysisDirectory -PathType Container)) { New-Item -Path $script:LiveTestAnalysisDirectory -ItemType Directory -Force New-Item -Path $script:LiveTestRawDirectory -ItemType Directory -Force } - ({} | Select-Object "BuildId", "OSVersion", "PSVersion", "Module", "Name", "Description", "StartDateTime", "EndDateTime", "IsSuccess", "Errors" | ConvertTo-Csv -NoTypeInformation)[0] | Out-File -LiteralPath $script:LiveTestRawCsvFile -Encoding utf8 -Force + ({} | Select-Object "PSVersion", "Module", "Name", "Description", "StartDateTime", "EndDateTime", "IsSuccess", "Errors" | ConvertTo-Csv -NoTypeInformation)[0] | Out-File -LiteralPath $script:LiveTestRawCsvFile -Encoding utf8 -Force } function New-LiveTestRandomName { [CmdletBinding()] [OutputType([string])] - param () + param ( + [Parameter()] + [ValidateSet("Alphanumerics", "AllNumbers", "AllLetters", "StartWithNumber", "StartWithLetter", IgnoreCase = $false)] + [string] $Option = "Alphanumerics", + + [Parameter()] + [ValidateRange(1, 20)] + [int] $MaxLength = 10 + ) $alphanumerics = "0123456789abcdefghijklmnopqrstuvwxyz" - $randomName = $alphanumerics[(Get-Random -Maximum 10)] - for ($i = 0; $i -lt 9; $i ++) { - $randomName += $alphanumerics[(Get-Random -Maximum $alphanumerics.Length)] + $numLast = 10 + $alphanumLast = $alphanumerics.Length + + switch ($Option) { + "Alphanumerics" { + $firstChar = "" + $maxLen = $MaxLength + $min = 0 + $max = $alphanumLast + } + "AllNumbers" { + $firstChar = "" + $maxLen = $MaxLength + $min = 0 + $max = $numLast + } + "AllLetters" { + $firstChar = "" + $maxLen = $MaxLength + $min = $numLast + $max = $alphanumLast + } + "StartWithNumber" { + $firstChar = $alphanumerics[(Get-Random -Maximum $numLast)] + $maxLen = $MaxLength - 1 + $min = 0 + $max = $alphanumLast + } + "StartWithLetter" { + $firstChar = $alphanumerics[(Get-Random -Minimum $numLast -Maximum $alphanumLast)] + $maxLen = $MaxLength - 1 + $min = 0 + $max = $alphanumLast + } + } + + $randomName += $firstChar + for ($i = 0; $i -lt $maxLen; $i ++) { + $randomName += $alphanumerics[(Get-Random -Minimum $min -Maximum $max)] } $randomName @@ -83,7 +117,7 @@ function New-LiveTestResourceGroupName { param () $rgPrefix = $script:ResourceGroupPrefix - $rgName = New-LiveTestRandomName + $rgName = New-LiveTestRandomName -Option StartWithNumber $rgFullName = "$rgPrefix$rgName" $rgFullName @@ -103,7 +137,7 @@ function New-LiveTestResourceGroup { [string] $Location = "westus" ) - $rg = Invoke-LiveTestCommand -Command "New-AzResourceGroup -Name $Name -Location $Location" + $rg = Invoke-LiveTestCommand -Command { New-AzResourceGroup -Name $Name -Location $Location -Force } $rg } @@ -113,7 +147,7 @@ function New-LiveTestResourceName { param () $rPrefix = $script:ResourcePrefix - $rName = New-LiveTestRandomName + $rName = New-LiveTestRandomName -Option StartWithNumber $rFullName = "$rPrefix$rName" $rFullName @@ -125,7 +159,7 @@ function New-LiveTestStorageAccountName { param () $saPrefix = $script:StorageAccountPrefix - $saName = New-LiveTestRandomName + $saName = New-LiveTestRandomName -Option StartWithNumber $saFullName = "$saPrefix$saName" $saFullName @@ -136,35 +170,39 @@ function Invoke-LiveTestCommand { param ( [Parameter(Mandatory, ValueFromPipeline)] [ValidateNotNullOrEmpty()] - [string] $Command + [scriptblock] $Command ) $cmdRetryCount = 0 do { try { - Write-Host "##[section]Start to execute the command '$Command'" -ForegroundColor Green - Write-Host "##[command]The command '$Command' is running" -ForegroundColor Cyan + Write-Host "##[section]Start executing the command `"$Command`"." -ForegroundColor Green + Write-Host "##[command]The command `"$Command`" is running." -ForegroundColor Cyan + + $cmdResult = $Command.InvokeWithContext($null, [psvariable]::new("ErrorActionPreference", "Stop")) - $cmdResult = Invoke-Expression -Command $Command -ErrorAction Stop + Write-Host "##[section]Finish executing the command `"$Command`"" -ForegroundColor Green - Write-Host "##[section]Successfully executed the command '$Command'" -ForegroundColor Green $cmdResult break } catch { - $cmdErrorMessage = $_.Exception.Message - if ($cmdRetryCount -le $script:CommandMaxRetryCount) { - Write-Warning "Error occurred when executing the command '$Command' with error message '$cmdErrorMessage'." - Write-Warning "Live test will retry automatically in $script:CommandDelay seconds." + $cmdErrorMessage = $_.Exception.InnerException.Message + if ($cmdRetryCount -lt $script:CommandMaxRetryCount) { + Write-Host "##[warning]Error occurred when executing the command `"$Command`" with error message `"$cmdErrorMessage`"." -ForegroundColor Yellow + Write-Host "##[warning]Live test will retry automatically in $script:CommandDelay seconds." -ForegroundColor Yellow Write-Host Start-Sleep -Seconds $script:CommandDelay $cmdRetryCount++ - Write-Warning "Retrying #$cmdRetryCount to execute the command '$Command'." + Write-Host "##[warning]Retry #$cmdRetryCount to execute the command `"$Command`"." -ForegroundColor Yellow } else { - throw "Failed to execute the command '$Command' after retrying for $script:CommandMaxRetryCount time(s) with error message '$cmdErrorMessage'." + $cmdFinalErrorMessage = "Failed to execute the command `"$Command`" after retrying for $script:CommandMaxRetryCount time(s) with error message `"$cmdErrorMessage`"." + Write-Host "##[error]$cmdFinalErrorMessage" -ForegroundColor Red + Write-Host + throw $cmdFinalErrorMessage } } } @@ -172,7 +210,7 @@ function Invoke-LiveTestCommand { } function Invoke-LiveTestScenario { - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = "HasDefaultResourceGroup")] [OutputType([bool])] param ( [Parameter(Mandatory, Position = 0)] @@ -184,115 +222,164 @@ function Invoke-LiveTestScenario { [string] $Description, [Parameter()] + [ValidateSet("Windows", "Linux", "MacOS", IgnoreCase = $false)] + [string[]] $Platform, + + [Parameter()] + [ValidateSet("5.1", "Latest")] + [string[]] $PowerShellVersion, + + [Parameter(ParameterSetName = "HasDefaulResourceGroup")] [ValidateNotNullOrEmpty()] [string] $ResourceGroupLocation, + [Parameter(ParameterSetName = "HasNoDefaultResourceGroup")] + [switch] $NoResourceGroup, + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [scriptblock] $ScenarioScript ) + $proceed = $true + + if ($PSBoundParameters.ContainsKey("Platform") -and $RunPlatform -notin $Platform) { + $proceed = $false + } + + $curPSVer = (Get-Variable -Name PSVersionTable -ValueOnly).PSVersion + if ($PSBoundParameters.ContainsKey("PowerShellVersion")) { + $psSimpleVer = $PowerShellVersion -replace "Latest", $script:PowerShellLatestVersion + $curMajorVer = $curPSVer.Major + $curMinorVer = $curPSVer.Minor + $curSimpleVer = "$curMajorVer.$curMinorVer" + if ($curSimpleVer -notin $psSimpleVer) { + $proceed = $false + } + } + if (!(Test-Path -LiteralPath $script:LiveTestRawCsvFile -PathType Leaf -ErrorAction SilentlyContinue)) { throw "Error occurred when initializing live tests. The csv file was not found." } - Write-Host "##[group]Start to execute the live scenario '$Name'." -ForegroundColor Green - - try { - $snrCsvData = [PSCustomObject]@{ - BuildId = $BuildId - OSVersion = $OSVersion - PSVersion = $PSVersion - Module = $ModuleName - Name = $Name - Description = $Description - StartDateTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss") - EndDateTime = $null - IsSuccess = $true - Errors = "" - } + if ($proceed) { + Write-Host "##[group]Start executing the live scenario `"$Name`"." -ForegroundColor Magenta - $snrResourceGroupName = New-LiveTestResourceGroupName - $snrResourceGroupLocation = "westus" - if ($PSBoundParameters.ContainsKey("ResourceGroupLocation")) { - $snrResourceGroupLocation = $ResourceGroupLocation + if ($curPSVer.Major -eq 5) { + $PSVersion = "5.1" + } + else { + $PSVersion = $curPSVer.ToString() } - Write-Host "##[section]Start to create a resource group." - Write-Host "##[section]Resource group name: $snrResourceGroupName" -ForegroundColor Green - Write-Host "##[section]Resource group location: $snrResourceGroupLocation" -ForegroundColor Green + try { + $snrCsvData = [PSCustomObject]@{ + PSVersion = $PSVersion + Module = $ModuleName + Name = $Name + Description = $Description + StartDateTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss") + EndDateTime = $null + IsSuccess = $true + Errors = $null + } - $snrResourceGroup = New-LiveTestResourceGroup -Name $snrResourceGroupName -Location $snrResourceGroupLocation + if (!$NoResourceGroup.IsPresent) { + $snrResourceGroupName = New-LiveTestResourceGroupName + $snrResourceGroupLocation = "westus" + if ($PSBoundParameters.ContainsKey("ResourceGroupLocation")) { + $snrResourceGroupLocation = $ResourceGroupLocation + } - Write-Host "##[section]Successfully created the resource group." + Write-Host "##[section]Start creating a resource group." -ForegroundColor Green + Write-Host "##[section]Resource group name: $snrResourceGroupName" -ForegroundColor Green + Write-Host "##[section]Resource group location: $snrResourceGroupLocation" -ForegroundColor Green - $snrRetryCount = 0 - $snrRetryErrors = @() + $snrResourceGroup = New-LiveTestResourceGroup -Name $snrResourceGroupName -Location $snrResourceGroupLocation - do { - try { - Invoke-Command -ScriptBlock $ScenarioScript -ArgumentList $snrResourceGroup -ErrorAction Stop - Write-Host "##[section]Successfully executed the live scenario '$Name'." -ForegroundColor Green - break + Write-Host "##[section]Finish creating the resource group." -ForegroundColor Green } - catch { - $snrErrorMessage = $_.Exception.Message - if ($snrRetryCount -eq 0) { - $snrErrorDetails = "Error occurred when executing the live scenario [$Name] with error message [$snrErrorMessage]" - } - else { - $snrErrorDetails = "Error occurred when retrying #$snrRetryCount of the live scenario with error message [$snrErrorMessage]" - } - $snrInvocationInfo = $_.Exception.CommandInvocation - if ($null -ne $snrInvocationInfo) { - $snrErrorDetails += " thrown at line:$($snrInvocationInfo.ScriptLineNumber) char:$($snrInvocationInfo.OffsetInLine) by cmdlet [$($snrInvocationInfo.InvocationName)] on [$($snrInvocationInfo.Line.ToString().Trim())]." - } + $snrRetryCount = 0 + $snrRetryErrors = @() - $snrRetryErrors += $snrErrorDetails + do { + try { + $prefs = @([psvariable]::new("ErrorActionPreference", "Stop"), [psvariable]::new("ConfirmPreference", "None")) + if ($snrRetryCount -eq $script:ScenarioMaxRetryCount) { + $prefs += [psvariable]::new("DebugPreference", "Continue") + } - if ($snrRetryCount -lt $script:ScenarioMaxRetryCount) { - $snrRetryCount++ - $exponentialDelay = [Math]::Min((1 -shl ($snrRetryCount - 1)) * [int](Get-Random -Minimum ($script:ScenarioDelay * 0.8) -Maximum ($script:ScenarioDelay * 1.2)), $script:ScenarioMaxDelay) - Write-Warning "Error occurred when executing the live scenario '$Name' with error message '$snrErrorMessage'." - Write-Warning "Live test will retry automatically in $exponentialDelay seconds." - Write-Host + $ScenarioScript.InvokeWithContext($null, $prefs, $snrResourceGroup) + + Write-Host "##[section]Finish executing the live scenario `"$Name`"." -ForegroundColor Green - Start-Sleep -Seconds $exponentialDelay - Write-Warning "Retrying #$snrRetryCount to execute live scenario '$Name'." - } - else { - $snrCsvData.IsSuccess = $false - $snrCsvData.Errors = ConvertToLiveTestJsonErrors -Errors $snrRetryErrors break } + catch { + $snrErrorRecord = $_.Exception.InnerException.ErrorRecord + $snrErrorMessage = $snrErrorRecord.Exception.Message + $snrErrorDetails = $snrErrorMessage + + $snrInvocationInfo = $snrErrorRecord.InvocationInfo + + if ($null -ne $snrInvocationInfo) { + $snrScriptName = Split-Path -Path $snrInvocationInfo.ScriptName -Leaf -ErrorAction SilentlyContinue + if ($snrScriptName -eq "Assert.ps1") { + Write-Host "##[error]Exception was thrown from the Assert.ps1. The stack trace is:" -ForegroundColor Red + Write-Host "##[error]$($snrErrorRecord.ScriptStackTrace)" -ForegroundColor Red + } + else { + $snrErrorDetails += " thrown at line:$($snrInvocationInfo.ScriptLineNumber) char:$($snrInvocationInfo.OffsetInLine) by cmdlet '$($snrInvocationInfo.MyCommand)' on '$($snrInvocationInfo.Line.ToString().Trim())'" + } + } + + $snrRetryErrors += $snrErrorDetails + + if ($snrRetryCount -lt $script:ScenarioMaxRetryCount) { + $snrRetryCount++ + $exponentialDelay = [Math]::Min((1 -shl ($snrRetryCount - 1)) * [int](Get-Random -Minimum ($script:ScenarioDelay * 0.8) -Maximum ($script:ScenarioDelay * 1.2)), $script:ScenarioMaxDelay) + Write-Host "##[warning]Error occurred when executing the live scenario `"$Name`" with error details `"$snrErrorDetails`"." -ForegroundColor Yellow + Write-Host "##[warning]Live test will retry automatically in $exponentialDelay seconds." -ForegroundColor Yellow + Write-Host + + Start-Sleep -Seconds $exponentialDelay + Write-Host "##[warning]Retry #$snrRetryCount to execute the live scenario `"$Name`"." -ForegroundColor Yellow + } + else { + Write-Host "##[error]Failed to execute the live scenario `"$Name`" with error details `"$snrErrorDetails`"." -ForegroundColor Red + Write-Host + $snrCsvData.IsSuccess = $false + $snrCsvData.Errors = ConvertToLiveTestJsonErrors -Errors $snrRetryErrors + break + } + } } + while ($true) } - while ($true) - } - catch { - $snrErrorMessage = $_.Exception.Message - Write-Warning "Error occurred when executing the live scenario '$Name' with error message '$snrErrorMessage'" - $snrCsvData.IsSuccess = $false - $snrCsvData.Errors = ConvertToLiveTestJsonErrors -Errors $snrErrorMessage - } - finally { - if ($null -ne $snrResourceGroup) { - try { - Write-Host "##[section]Start to clean up the resource group '$snrResourceGroupName'." -ForegroundColor Green - Clear-LiveTestResources -Name $snrResourceGroupName - Write-Host "##[section]Successfully cleaned up the resource group '$snrResourceGroupName'" -ForegroundColor Green - } - catch { - if ($snrCsvData.Errors -eq "") { - $snrCsvData.Errors = ConvertToLiveTestJsonErrors -Errors $_.Exception.Message + catch { + $snrErrorMessage = $_.Exception.Message + Write-Host "##[error]Error occurred when executing the live scenario `"$Name`" with error details `"$snrErrorDetails`"" -ForegroundColor Red + Write-Host + $snrCsvData.IsSuccess = $false + $snrCsvData.Errors = ConvertToLiveTestJsonErrors -Errors $snrErrorMessage + } + finally { + $snrCsvData.EndDateTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss") + $snrCsvData | Export-Csv -LiteralPath $script:LiveTestRawCsvFile -Encoding utf8 -NoTypeInformation -Append + + if (!$NoResourceGroup.IsPresent -and $null -ne $snrResourceGroup) { + try { + Write-Host "##[section]Start cleaning up the resource group `"$snrResourceGroupName`"." -ForegroundColor Green + Clear-LiveTestResources -Name $snrResourceGroupName + } + catch { + # Ignore exception for clean up } } - } - $snrCsvData.EndDateTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss") - Export-Csv -LiteralPath $script:LiveTestRawCsvFile -InputObject $snrCsvData -Encoding utf8 -NoTypeInformation -Append - Write-Host "##[endgroup]" + Write-Host "##[endgroup]" -ForegroundColor Magenta + } } } @@ -305,7 +392,7 @@ function Clear-LiveTestResources { [string] $Name ) - Invoke-LiveTestCommand -Command "Remove-AzResourceGroup -Name $Name -Force" + Invoke-LiveTestCommand -Command { Remove-AzResourceGroup -Name $Name -Force -AsJob | Out-Null } } function ConvertToLiveTestJsonErrors { @@ -326,4 +413,4 @@ function ConvertToLiveTestJsonErrors { (ConvertTo-Json $errorsObj -Compress) } -InitializeLiveTestModule -ModuleName $ModuleName +InitializeLiveTestModule diff --git a/tools/TestFx/Live/SaveLiveTestResult.ps1 b/tools/TestFx/Live/SaveLiveTestResult.ps1 index d72ea49f4e37..28212365268f 100644 --- a/tools/TestFx/Live/SaveLiveTestResult.ps1 +++ b/tools/TestFx/Live/SaveLiveTestResult.ps1 @@ -25,39 +25,51 @@ param ( [Parameter(Mandatory, Position = 6)] [ValidateNotNullOrEmpty()] - [string] $LiveTestTableName, + [string] $TableName, [Parameter(Mandatory, Position = 7)] [ValidateNotNullOrEmpty()] - [string] $TestCoverageTableName, + [string] $DataLocation, [Parameter(Mandatory, Position = 8)] [ValidateNotNullOrEmpty()] - [string] $DataLocation -) + [string] $BuildId, -Import-Module "./tools/TestFx/Utilities/KustoUtility.psd1" -Force + [Parameter(Mandatory, Position = 9)] + [ValidateNotNullOrEmpty()] + [string] $OSVersion, + + [Parameter(Position = 10)] + [string] $Tag = [string]::Empty +) $liveTestDir = Join-Path -Path $DataLocation -ChildPath "LiveTestAnalysis" | Join-Path -ChildPath "Raw" -if (Test-Path -LiteralPath $liveTestDir) { - $liveTestResults = Get-ChildItem -Path $liveTestDir -Filter "*.csv" -File | Select-Object -ExpandProperty FullName - Import-KustoDataFromCsv ` - -ServicePrincipalTenantId $ServicePrincipalTenantId ` - -ServicePrincipalId $ServicePrincipalId ` - -ServicePrincipalSecret $ServicePrincipalSecret ` - -ClusterName $ClusterName ` - -ClusterRegion $ClusterRegion ` - -DatabaseName $DatabaseName ` - -TableName $LiveTestTableName ` - -CsvFile $liveTestResults -} -else { - Write-Warning "No live test data generated." -} +$liveTestResults = Get-ChildItem -Path $liveTestDir -Filter "*.csv" -File -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName + +if (![string]::IsNullOrWhiteSpace($liveTestResults)) { + if (![string]::IsNullOrEmpty($Tag)) { + $exProps = @{ Tag = $Tag } | ConvertTo-Json -Compress + } -$testCoverageDir = Join-Path -Path $DataLocation -ChildPath "TestCoverageAnalysis" | Join-Path -ChildPath "Raw" -if (Test-Path -LiteralPath $testCoverageDir) { - $testCoverageResults = Get-ChildItem -Path $testCoverageDir -Filter "*.csv" -File | Select-Object -ExpandProperty FullName + $liveTestResults | ForEach-Object { + (Import-Csv -Path $_) | + Select-Object ` + @{ Name = "Source"; Expression = { "LiveTest" } }, ` + @{ Name = "BuildId"; Expression = { $BuildId } }, ` + @{ Name = "OSVersion"; Expression = { $OSVersion } }, ` + @{ Name = "PSVersion"; Expression = { $_.PSVersion } }, ` + @{ Name = "Module"; Expression = { $_.Module } }, ` + @{ Name = "Name"; Expression = { $_.Name } }, ` + @{ Name = "Description"; Expression = { $_.Description } }, ` + @{ Name = "StartDateTime"; Expression = { $_.StartDateTime } }, ` + @{ Name = "EndDateTime"; Expression = { $_.EndDateTime } }, ` + @{ Name = "IsSuccess"; Expression = { $_.IsSuccess } }, ` + @{ Name = "Errors"; Expression = { $_.Errors } }, ` + @{ Name = "ExtendedProperties"; Expression = { $exProps } } | + Export-Csv -Path $_ -Encoding utf8 -NoTypeInformation -Force + } + + Import-Module "./tools/TestFx/Utilities/KustoUtility.psd1" -Force Import-KustoDataFromCsv ` -ServicePrincipalTenantId $ServicePrincipalTenantId ` -ServicePrincipalId $ServicePrincipalId ` @@ -65,9 +77,9 @@ if (Test-Path -LiteralPath $testCoverageDir) { -ClusterName $ClusterName ` -ClusterRegion $ClusterRegion ` -DatabaseName $DatabaseName ` - -TableName $TestCoverageTableName ` - -CsvFile $testCoverageResults + -TableName $TableName ` + -CsvFile $liveTestResults } else { - Write-Warning "No test coverage data generated." + Write-Host "##[warning]No live test data was found." } diff --git a/tools/TestFx/Utilities/KustoUtility.psm1 b/tools/TestFx/Utilities/KustoUtility.psm1 index f01e33733696..8323ef629e73 100644 --- a/tools/TestFx/Utilities/KustoUtility.psm1 +++ b/tools/TestFx/Utilities/KustoUtility.psm1 @@ -122,9 +122,9 @@ function IngestDataFromCsv { $ingestionProps.IngestionMapping = $ingestionMapping $CsvFile | ForEach-Object { - Write-Host "##[section]Start to import the file $_." -ForegroundColor Green - $ingestClient.IngestFromStorageAsync($_, $ingestionProps).GetAwaiter().GetResult() - Write-Host "##[section]Successfully imported the file $_." -ForegroundColor Green + Write-Host "##[section]Start to import the file $_." + $ingestClient.IngestFromStorageAsync($_, $ingestionProps).GetAwaiter().GetResult() | Out-Null + Write-Host "##[section]Successfully imported the file $_." } } catch {