From aa7e5009e66e991b00f02ddca6fabe1fb205e394 Mon Sep 17 00:00:00 2001 From: Vincent Dai <23257217+vidai-msft@users.noreply.github.com> Date: Wed, 22 Mar 2023 06:56:47 -0700 Subject: [PATCH] Sync live test to main branch (#21275) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add a live test for AKS (#20618) * add live test for AKS * update description * Enabled live test and added new function for local debug * Enabled live test and added new function for local debug (#20656) * Updated artifacts name for daily build and set trigger to none * Fixed issues in live test * fix aks test case (#20684) * Updated the script for local test and added a new parameter to specify the desired test modules. (#20708) * Shared/livetest (#20714) * Modified error messages for easy troubleshooting locally and added ConfirmPreference to innter scriptblock. * Added one test case for network * Updated timeout from defatul to 180 mins * Added failure retry when error occurs during connecting az account * Shortened the random resource name to 15 in total * Shared/livetest: Create livetest, storage and VM (#20678) * add scenario test vm * add scenario test Storage * update scenario test Storage * update scenario test vm * update scenario test Storage * update scenario test vm * update scenario test vm * update scenario test vm * update scenario test vm * update scenario test storage * update scenario test vm, update the variable * Shortened the random resource name to 15 in total * update scenario test vm * update scenario test vm * update scenario test vm * update scenario test vm * update location Storage live test * update location Storage live test * delete scenario test Storage.Test * msg * update location Storage live test * update location Storage live test * update location Storage live test --------- Co-authored-by: Vincent Dai <23257217+vidai-msft@users.noreply.github.com> * [PS - LiveTest] Fix storage live test failure (#20815) * add scenario test vm * add scenario test Storage * update scenario test Storage * update scenario test vm * update scenario test Storage * update scenario test vm * update scenario test vm * update scenario test vm * update scenario test vm * update scenario test storage * update scenario test vm, update the variable * Shortened the random resource name to 15 in total * update scenario test vm * update scenario test vm * update scenario test vm * update scenario test vm * update location Storage live test * update location Storage live test * delete scenario test Storage.Test * msg * update location Storage live test * update location Storage live test * update location Storage live test * update scenario test Storage.Test --------- Co-authored-by: Vincent Dai <23257217+vidai-msft@users.noreply.github.com> * Exposed the cmdlet Invoke-LiveTestCommand used to retry a single cmdlet instead of the whole live scenario * Exposed the cmdlet Invoke-LiveTestCommand used to retry a single cmdlet instead of the whole live scenario (#20835) * Add live test cases for bot service. (#20830) * Add live test cases for bot service. * Commit after local test running * Add Invoke-LiveTestCommand for single retry and remove useless commands. * Shortened the retry count to 3 and installed all az modules including preview * Disabled the live test for BotService * Add live test for Az.SpringCloud (#20863) * Disable the live test for SpringCloud (#20879) * Removed some of the run instances for the time being * Removed some of the run instances for the time being (#20882) * Enabled debug log and added more debug info to Aks live test * Added debug info for Aks module (#20896) * Removed some of the run instances for the time being * Enabled debug log and added more debug info to Aks live test * Merged main to shared/livetest (#20918) * Fix example 1 in Set-AzVirtualNetworkPeering.md (#20588) * {EventHub} Fix #20562: Fix 'New-AzEventHubAuthorizationRuleSASToken' … (#20569) * {EventHub} Fix #20562: Fix 'New-AzEventHubAuthorizationRuleSASToken' returned token has wrong skn value Fixes https://github.com/Azure/azure-powershell/issues/20562 * Update ChangeLog.md * Update ChangeLog.md Co-authored-by: Jin Lei <54836179+msJinLei@users.noreply.github.com> * Revise common assembly doc (#20465) * [AKS] support AadProfile (#20596) * [AKS] support AadProfile * update changelog * add example in help markdown files * [Network] New-AzNetworkWatcherPacketCapture - TotalBytesPerSession with incorrect data type (#20504) * resolved the TotalBytesPerSession limit issue * suppress the warning messages of the breaking change analyzer by adding all the error in BreakingChangeIssues.csv file * Update ChangeLog.md Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * Move LoadTesting to main (#20622) * Move BillingBenefits to main (#20624) Co-authored-by: Jin Lei <54836179+msJinLei@users.noreply.github.com> * Update changelog as per PR#20426 (#20616) * Update changelog as per PR#20426 * Update ChangeLog.md Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * Fix the issue that CI will fail to when tools is updated in generation branch (#20626) * Domain name of online doc is changed from docs.microsoft.com to learn.microsoft.com. (#20288) * Domain name of online doc is changed from docs.microsoft.com to learn.microsoft.com. (#20271) * Domain name of online doc is changed from docs.microsoft.com to learn.microsoft.com. (#20275) Co-authored-by: Dingmeng Xue * Enabled to set perform snat to always when PrivateRange is set to 255.255.255.255/32 (#20497) Co-authored-by: Gizachew Eshetie * Rename the name to PhaseName (#20651) * Fix format issue of Remove-AzPostgreSqlFlexibleServerDatabase ref doc (#20635) Fix https://github.com/Azure/azure-powershell/issues/20551 * Fix Az.Accounts cannot be imported due to assembly not found (#20637) * fix accounts cannot be imported * Az.Accounts v2.11.1 * fixed type error in CheckAssemblies.ps1 * Add support for the case that psd1 and help are in the {module}.Manaement folder (#20652) * Add support for the case that psd1 and help are in the {module}.Management folder For normal cases, psd1 and help are in the {module} folder. But for storage, they are in Storeage.Management folder. And this PR is created to support case like storage. * Replace ternary operator with if-clause * Fixed the issue when support help and psd1 in {module}.Management folder (#20674) Assume help folder and psd1 are in the same folder * Update the check rules and update some exception files (#20647) * Mitryakh/nrp test fixes (#20612) * Added Test-PublicIpAddressZones fix * Added fixes for Test-PublicIpAddressZones, Test-PublicIpAddressVmss * Fixed several tests/recordings * Fixed test results * reverted change in older failed test recording * Fixed vnet test adding a catch block to prevent transient failures * Fixed failed test * Fixed 1 more recording * Fixed TestPublicIpAddressCRUDIdleTimeout and recording for that * Added skip tag for MultiIpConfigOnNicTests, which has transient failures for live testing * Fixed typo "resouce group"→"resource group" (#20664) https://learn.microsoft.com/en-us/powershell/module/az.dnsresolver/get-azdnsforwardingruleset?view=azps-9.3.0 https://github.com/Azure/azure-powershell/blob/main/src/DnsResolver/help/Get-AzDnsForwardingRuleset.md #PingMSFTDocs * [AppService]: doc-update #12181- AppSettingsOverrides in New-AzWebAppSlot are ignored (#20606) * [AppService]: doc-update #12181- AppSettingsOverrides in New-AzWebAppSlot are ignored * Review comments are addressed * Migrate MobileNetwork from generation to main (#20673) * Move MobileNetwork to main * create SignatureIssues.csv * create ExampleIssues.csv * update azure-powershell-modules.md * Rename Changelog.md to ChangeLog.md Co-authored-by: Jinpei Li (Wicresoft North America Ltd) Co-authored-by: Yunchi Wang <54880216+wyunchi-ms@users.noreply.github.com> * Change test coverage log to debug level (#20648) * Update TestCoverage.cs * Removed unnecessary debug info Co-authored-by: Vincent Dai <23257217+vidai-msft@users.noreply.github.com> * Added HAReplicaCount parameter to restore-AzSqlDatabase cmdlet (#20580) * Added HAReplicaCount parameter to restore-AzSqlDatabase cmdlet * updated changelog * Update ChangeLog.md Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * [Storage Dataplane] - Remove Validation Set and move to track2 SDK for accesstier (#20554) * [Storage Dataplane] - Remove Validation Set and move to track2 SDK for accesstier * Fix CI failure * Updated script to build TestFx environment as well as the document (#20592) * Updated script to build TestFx environment as well as the document * Update documentation/testing-docs/using-azure-test-framework.md Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * {AppServices} Update AccountName parameter description (#20607) * {AppServices} Update AccountName parameter description Update AccountName parameter and mount path parameter description * Update Parameter description Update Parameter description * modify parameter description * generate help * add param to New-AzRestorePoint (#20645) * update * changelog * update for fulltypename Co-authored-by: Theodore Chang * Move BillingBenefits to main (#20706) * BillingBenefits and LoadTesting OOB (#20629) Co-authored-by: msJinLei Co-authored-by: Jin Lei <54836179+msJinLei@users.noreply.github.com> * Domain name of online doc is changed from docs.microsoft.com to learn.microsoft.com. (#20265) * Domain name of online doc is changed from docs.microsoft.com to learn.microsoft.com. (#20264) * Domain name of online doc is changed from docs.microsoft.com to learn.microsoft.com. (#20269) * Domain name of online doc is changed from docs.microsoft.com to learn.microsoft.com. (#20268) * Domain name of online doc is changed from docs.microsoft.com to learn.microsoft.com. (#20277) Co-authored-by: dingmeng-xue * Domain name of online doc is changed from docs.microsoft.com to learn.microsoft.com. (#20266) * Domain name of online doc is changed from docs.microsoft.com to learn.microsoft.com. (#20267) * Domain name of online doc is changed from docs.microsoft.com to learn.microsoft.com. (#20274) * Microsoft mandatory file (#20737) Co-authored-by: microsoft-github-policy-service[bot] <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com> * Fill in empty Compute parameter descriptions (#20726) * descriptions filled * fix missing * changelog * Update StorageAccountType LRS values to correct _LRS format (#20727) * lrs fixed * changelog --------- Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * Remove the useless projects under tools folder (#20633) * Remove the useless projects under tools folder * Add back FormatPs1XmlGenerator * [CosmosDB] Modify Example 1 with the correct cmdlet (#20707) * update Compute .Net SDK version to 59 (#20524) * update net version * changelog * Update ChangeLog.md * {AzurePolicy} fixes Azure/azure-powershell#20654 fix the description (#20729) fix the description for the `Get-AzPolicyExemption` fixes Azure/azure-powershell#20654 * [SQL] umi support for auditing (#20750) * umi support for auditing * updated changelog * added null check * Update ChangeLog.md --------- Co-authored-by: Ilias Khan Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * Updated the max value for HAReplicaCount parameter (#20752) * Updated the max value for HAReplicaCount parameter * updated changelog * Fixed help message * [AppGW] Start-AzApplicationGateway docs example (#20699) * [AppGW] Start-AzApplicationGateway docs example Adding Get-AzApplicationGateway command to be consistent with https://github.com/Azure/azure-powershell/blob/main/src/Network/Network/help/Start-AzApplicationGateway.md * Update Start-AzApplicationGateway.md Consistency with https://github.com/Azure/azure-powershell/blob/main/src/Network/Network/help/Stop-AzApplicationGateway.md * {Sql} Fix #20703: Fix 'Set-AzSqlServerAudit' missing WorkSpaceResourceId para… (#20760) * {Sql} Fix #20703: Fix 'Set-AzSqlServerAudit' missing WorkSpaceId parameter Fixes https://github.com/Azure/azure-powershell/issues/20703 * {Sql} Fix #20703: Fix 'Set-AzSqlServerAudit' missing WorkspaceResourceId parameter * Fix the issue of wrong format of csv (#20765) * Fix the issue of wrong format of csv * Fix the issue of wrong format of csv * Suppress Az.Compute * [Redis] Update `Get-AzRedisCacheLink` and `New-AzRedisCacheLink` to print additional properties (#20704) * Update ps1xml file with linked server properties * Update output in help/Get-AzRedisCacheLink.md * Update output in New-AzRedisCacheLink.md * update changelog * update formatting in New-AzRedisCacheLink.md --------- Co-authored-by: Austin Tolani * Add Azure Firewall SKU Upgrade Example (#20686) example to upgrade firewall sku * [DataFactory]Updated ADF .Net SDK version to 9.0.0 (#20676) * Typo "resouce group"→"resource group" (#20713) https://learn.microsoft.com/en-us/powershell/module/az.dnsresolver/get-azdnsresolveroutboundendpoint?view=azps-9.3.0 https://github.com/Azure/azure-powershell/blob/main/src/DnsResolver/help/Get-AzDnsResolverOutboundEndpoint.md #PingMSFTDocs * [Storage] Add warning message for AllowBlobPublicAccess default behavior change (#20679) * Add warning for AllowBlobPublicAccess default behavior change * add changelog * update message * Update warning message --------- Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * Corrected disallowed html tags from docs build report (#20643) Co-authored-by: Mike F. Robbins * Corrected broken links from docs build report (#20642) Co-authored-by: Mike F. Robbins * Replace Get-InstalledModule with Get-Module -ListAvailable (#20632) * Migrate ApplicationInsights from generation to main (#20782) * Move ApplicationInsights to main * Update ChangeLog.md --------- Co-authored-by: Yabo Hu * Managed database cross subscription restore (#20735) * SDK generated from private branch, and added support for cross subscription restore * recording tests * help, changelog * split example in two * fixing * Removing positional parameter to fix pipeline * Use commit hash --------- Co-authored-by: Milan Brkic * Add module version to changelog (#20669) * Add module version in changelog * Update RunVersionController.ps1 * Update RunVersionController.ps1 * Update RunVersionController.ps1 * TargetExtendedLocation support for GalleryImageVersion (#20748) * update SDK version from 58 to 60 * add ExtendedTargetLocation to New and Update and add allowDeletionReplicedLocation param to Update * fix error * add parameters and test * changelog * add md and examples * change CRP common test with work with new --------- Co-authored-by: Theodore Chang * Migrate StackHCI from generation to main (#20785) * Move StackHCI to main * Update ChangeLog.md --------- Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * [Peering] Migrate to autorest and support API version 2022-10-01 (#20776) * delete module for peering in main * Migrate Peering from generation to feature/delete-peering-main (#20779) * Move Peering to feature/delete-peering-main * create exampleIssues.csv and SignatureIssues.csv update changelog --------- Co-authored-by: Jinpei Li (Wicresoft North America Ltd) * update AssemblyInfo.cs --------- Co-authored-by: Azure PowerShell <65331932+azure-powershell-bot@users.noreply.github.com> * [AKS] support HostGroupID (#20796) * [AKS] support HostGroupID * add test asserts * Migrate DataProtection from generation to main (#20786) * Move DataProtection to main * Update New-AzDataProtectionBackupVault.md * Update New-AzDataProtectionBackupVault.md * Update and rename Changelog.md to ChangeLog.md --------- Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * [Resources] Handle nested array changes in What-If formatter (#20689) * Handle nested array changes * Update changelog * Migrate Compute from generation to main (#20788) * Move Compute to main * Update ChangeLog.md --------- Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * win-arm64 support for WAM (#20797) * add msal runtime arm64 * Update ChangeLog.md * Add PDB for msalruntime_arm64 * [AppService]: fix #20746 New-AzWebAppCertificate -hostname indicates support for multiple hostnames (#20790) * Format changelog.md (#20800) * Format changelog.md * storage * Migrate VoiceServices from generation to main (#20798) * Move VoiceServices to main * Update Changelog.md --------- Co-authored-by: Lucas Yao <53558334+LucasYao93@users.noreply.github.com> Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * Add managed instance DTC cmdlets (#20805) * Added SDK updates and DTC cmdlets * Removed debugger line * Added tests and fixed input object parameter set * Updated help and tests * Updated help files * Fixed help files * Removed excess positions * Added a safeguard for the DTC model and modified the comment to better explain how the host name and dns suffix are related * Adressing comments --------- Co-authored-by: Stefan Krivokapic Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * Revert the UbuntuLTS image alias to use the version 16.04 instead of 20.04 (#20792) * Update Images.json * Update ChangeLog.md --------- Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * Fixed query issue when objectId in assignment is empty for Get-DenyAssignment (#20813) * changed domain name of online. (#20802) * Typo "udpate"→"update" (#20810) * Typo "udpate"→"update" https://learn.microsoft.com/en-us/powershell/module/az.recoveryservices/update-azrecoveryservicesasrprotectioncontainermapping?view=azps-9.3.0 https://github.com/Azure/azure-powershell/blob/main/src/RecoveryServices/RecoveryServices/help/Update-AzRecoveryServicesAsrProtectionContainerMapping.md #PingMSFTDocs * Update UpdateAzureRmRecoveryServicesAsrProtectionContainerMapping.cs --------- Co-authored-by: Beisi Zhou * [Compute] Added `-SkipIdentity`, `-PathUserIdentity`, `-IsTest` to `Set-AzVMAEMExtension` (#20597) * features: -PathUserIdentity, -SkipIdentity, IsTest * re-record tests and add tests for new properties * added description to and fixed null exception * revert ComputeTestRunner * add suppress messages * fixed comments, doc and paramPos as per #20597 * removed skip tests as requested --------- Co-authored-by: sedusch Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * [Az.RecoveryServices.Backup] Added support for Private Endpoints and Immutable Vaults (#20741) * Added support for enable/disable Public Network Access and PrivateEndpoints Added support for Immutable Vaults Added support for RetainRecoveryPointsAsPerPolicy in Disable-AzRecoveryServicesBackupProtection cmdlet. Now user can suspend backups and retain RPs as per policy Added List RP expiry time Added RecoveryServices, RecoveryServices.Backup, RecoveryServices.Backup.CrossRegionRestore management SDK Added changeLog * re-recorded failed tests Updated help files * re-record failed tests * added new tests and examples * resolved review comments * Move MobileNetwork to release-2023-02-07 (#20821) Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * Update the logic of get commit id in autorest generation (#20827) * Update the logic of get commit id in autorest generation * Update the logic of get commit id in autorest generation * Move Peering to release-2023-02-07 (#20833) * [AKS] fix a bug in zip on windows (#20832) * [AKS] fix a bug in zip on windows * update changelog * update changelog * Fix the bugs for AzKeyStore (#20768) * Fix AzKeyStore issues and optimize initialization and update * Enabled credential to be found only by applicationId while tenant was not matched when accquire token. [#20484] * When Az.Accounts ran in parallel, the waiters were allowed to wait infinitely to avoid throw exception in automation enviroment. [#20455] * Used Lazy load for AzKeyStore. * Used update on change mechanism for AzKeyStore and remove `Flush` interface. * Add parallel test case of Az.Accounts to smoke test * Address review comments Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> Address review comments * Fix failed test cases. * Fix an issue of AzKeyStore when context autosaving switching * Migrate Monitor from generation to release-2023-02-07 (#20841) * Move Monitor to release-2023-02-07 * Update ChangeLog.md --------- Co-authored-by: Yabo Hu Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * release-2023-02-07 (#20843) * Update Reference to latest swagger for Runbook Cmdlets (#20803) * Added test cases for RunBook Pattern changes as per public doc https://learn.microsoft.com/en-us/azure/automation/manage-runbooks * Update swagger to be from the main branch of Azure/azure-rest-api-specs repo * Updated Session record for Runbook Test * Update ChangeLog.MD * Update Automation ChangeLog.MD --------- Co-authored-by: Sushil Upadhyay * {AzureDataShare} fixes Azure/azure-powershell#20822 fix the description (#20840) * {AzureDataShare} fixes Azure/azure-powershell#20822 fix the description fixes Azure/azure-powershell#20822 fix the description The StorageAccountResourceId parameter in the "New-AzDataShareDataSetMapping" PowerShell cmdlet is used to specify the resource ID of the Azure storage account that is the source of the data being shared. This parameter is required when creating a new data set mapping for an Azure Data Share and is used to identify the storage account from which the data will be shared. The resource ID of the storage account can be obtained from the Azure portal or through Azure PowerShell. The AccountName parameter in the "New-AzDataShareDataSetMapping" PowerShell cmdlet is used to specify the name of the Azure storage account that is the source of the data being shared. This parameter is required when creating a new data set mapping for an Azure Data Share and is used to identify the storage account from which the data will be shared. The account name of the storage account must be unique within Azure and can be used to access the storage account and the data stored within it. The ResourceGroup parameter in the "New-AzDataShareDataSetMapping" PowerShell cmdlet is used to specify the name of the Azure resource group that contains the Azure storage account being shared. This parameter is required when creating a new data set mapping for an Azure Data Share and is used to identify the resource group that holds the storage account from which the data will be shared. The resource group can be used to manage the resources within it, such as the storage account and the data set mapping. * Update NewAzDataShareDataSetMapping.cs * Update NewAzDataShareDataSetMapping.cs * Update GetAzDataShareDataSetMapping.cs * Update RemoveAzDataShareDataSetMapping.cs * Update Get-AzDataShareDataSetMapping.md * Update Remove-AzDataShareDataSetMapping.md * {AzureSubscription} fixes Azure/azure-powershell#20812 fix the workload parameter (#20842) * {AzureSubscription} fixes Azure/azure-powershell#20812 fix the workload parameter fixes Azure/azure-powershell#20812 While we run the PS cmdlet `New-AzSubscriptionAlias` it fails with the error: New-AzSubscriptionAlias -AliasName MyTestAlias -BillingScope '/providers/Microsoft.Billing/billingAccounts/XXXXXX/enrollmentAccounts/XXXXXX' -SubscriptionName MysSubscription New-AzSubscriptionAlias: Operation returned an invalid status code 'BadRequest' Debug output: { "error": { "code": "InvalidWorkLoad", "message": "Invalid WorkLoad provided, Only Production or DevTest are allowed" }, "code": "InvalidWorkLoad", "message": "Invalid WorkLoad provided, Only Production or DevTest are allowed" } This PR makes the workload parameter mandatory to avoid the above error. * Update ChangeLog.md * Update src/Subscription/Subscription/ChangeLog.md Co-authored-by: Beisi Zhou * Updating the help docs for New-AzSubscriptionAlias * Update src/Subscription/Subscription/ChangeLog.md --------- Co-authored-by: Beisi Zhou * Fix daily smoke test error of ThreadJob installation (#20856) * Migrate DataMigration from generation to main (#20857) * Move DataMigration to main * Update ChangeLog.md --------- Co-authored-by: Beisi Zhou * [Az.Automanage] Az.Automanage General Available (#20860) * Update Az.psd1 * Update MinimalVersion.csv * [Storage] Fix help file format per static analysis result (#20774) * fix help * update formatting * format help examples * Update help example format * Fix example cmdlet usage * Add skip line * remove skip comment * Fix exmaple title typo by comments * Bug : classic fw private ranges reverts to default when doing get & set (#20855) * Bug : classic fw private ranges reverts to default when doing get & set * Added change log --------- Co-authored-by: Gizachew Eshetie Co-authored-by: Beisi Zhou * added support for windows 2022 server for service fabric cluster (#20825) * added support for windows 2022 server * updated changelog file based on comments * OOB release for Az.Automation (#20874) * Removed some of the run instances for the time being * add pipeline yml for syncing fabricbot.json aliases (#20772) * add pipeline yml for syncing fabricbot.json aliases * change git user name and email in script * change inline script to GetWiki2Json.ps1 file * remove unnecessary code * change wrong dir * change to my personal repo for test * change the usage of token * change CreatePR.ps1 for test * correct ParseWiki2Json.ps1 * remove unnecessary output * remove quote * finish test, change back to Azure repo * change branch name * change some names * remove the use of magic number * change commit message * remove redundant git pull * change the way of getting wiki content * change space to - * add md * set current dir * use space * use - * still use ADOToken * use a better wiki url * test purpose * test2 * test oauth * test3 * finish test * test again * test * finish test * test cron * test double pr * solve double pr * test * test * test * finish test * test * finish test * test restapi * te * finish test * test * finish test * filter pr * test * test * test * test * finish test --------- Co-authored-by: Hongtu Zhang (FA Talent) * [Policy Insights] Added cmdlets for policy attestations (#20696) * Added cmdlets for policy attestations * Addressed pipeline errors * Addressed PR comments * Subscription ID Changed * PR Comments 2 * Metadata Tests * PR Comments Updated Docs * [Security] Update Security module based on .NET SDK track1, using source code (#20164) * Add all files * Add all code to module * resolve changes * Record securitySettings tests * Record pricing tests * Record securityAssessment and metadata * Fix Alerts code and tests record and coverage * Record and fix JitNetworkAccessPolicy tests * Record assessments and metadata tests * Record settings tests * Add SubPlan support in pricing * Change SecurityContact page type to list * Fix and record SecurityContact tests * Add support in evidence, techniques and sub techniques * Pricings * changes * remove breaking changes * Update ChangeLog.md --------- Co-authored-by: Keren Damari Co-authored-by: Sulaiman Abu Rashed Co-authored-by: surashed <55134940+surashed@users.noreply.github.com> * Fix ThreadJob installation error of smoke test (#20867) * Fix ThreadJob installation error of smoke test * Address review comments * Fix unexpected recommendation message (#20880) * Update Azure.Core from 1.25.0 to 1.28.0 (#20889) Co-authored-by: Beisi Zhou * updata some old moudle metadata json file (#20892) Co-authored-by: Hongtu Zhang (FA Talent) * Enabled debug log and added more debug info to Aks live test * [DataFactory]Updated ADF .Net SDK version to 9.1.0 (#20875) * [DataFactory]Updated ADF .Net SDK version to 9.1.0 * update * Service Client Code generation for Redis Cache RP (#20894) * Nuget Update with Auto Rest * CS files updates * sln update * Change sync alias.yml (#20899) * Set up first CI try with Azure Pipelines description here! [skip ci] * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * commit me * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * remove test yml * rectify_git_url --------- Co-authored-by: Hongtu Zhang (FA Talent) * Correct help docs for *-AzCosmosDBAccount (#20891) * Sync fabricbot.json (#20831) * [Az.DataMigration] Change Azure Database Migration Service in documentation to Azure Database Migration Service (classic) (#20893) * Rename Azure Database migration Service to Azure Database Migration Service (classic) * fix PR comments * Corrected syntax for ConfirmAction (#20902) `-Confirm` in the examples were not in the correct format to override the confirmation prompt * Update New-AzSynapseRoleAssignment.md (#20905) * Update Remove-AzSynapseRoleAssignment.md (#20906) * Added note for scenario when an SPN role assignment is listed (#20907) * Use pwsh7.2.8 temporarily till 7.2.10 is available (#20911) * Fix the issue that CI doesn't check online version of help doc (#20901) * Fix the issue that CI doesn't check online version of help doc * Fix the online version in help docs * Fix the online version in help docs * Fix the example issue * Fix the example issue * Snat cmdlet fwp (#20854) * Added Snat parameter to firewall policy cmdlets * Generated help for new cmdlet and updated for the existing ones * fixed pipeline analyze issue * Removed SupportsShouldProcess * suppressed static analyzer * Updated help per PR review comments --------- Co-authored-by: Gizachew Eshetie * OOB of Az.ConnectedKubernetes (#20904) * Fix/connectedk8s ps5 (#20603) * Create RSAHelper.ps1 * Update New-AzConnectedKubernetes.ps1 * Add try-catch and update function parameters * Update New-AzConnectedKubernetes.ps1 * [Az.ConnectedKubernetes] Update ChangeLog (#20649) * Update RSAHelper.ps1 (coding style) * Update ChangeLog.md * upgrade Az.ConnectedKubernetes from 0.7.0 to 0.7.1 --------- Co-authored-by: Ann Lu <112682982+yinghsugn@users.noreply.github.com> --------- Co-authored-by: Arun Sabale Co-authored-by: RakeshMohanMSFT <49954584+RakeshMohanMSFT@users.noreply.github.com> Co-authored-by: Jin Lei <54836179+msJinLei@users.noreply.github.com> Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> Co-authored-by: Yan Xu Co-authored-by: v-sapanchal <117979452+v-sapanchal@users.noreply.github.com> Co-authored-by: Azure PowerShell <65331932+azure-powershell-bot@users.noreply.github.com> Co-authored-by: Siddharth Saklecha Co-authored-by: Yunchi Wang <54880216+wyunchi-ms@users.noreply.github.com> Co-authored-by: Lucas Yao <53558334+LucasYao93@users.noreply.github.com> Co-authored-by: Dingmeng Xue Co-authored-by: Giz Co-authored-by: Gizachew Eshetie Co-authored-by: Xiaogang Co-authored-by: Mikhail Co-authored-by: Hiroshi Yoshioka <40815708+hyoshioka0128@users.noreply.github.com> Co-authored-by: Kota Sudhakar Reddy <60102891+Kotasudhakarreddy@users.noreply.github.com> Co-authored-by: Jinpei Li (Wicresoft North America Ltd) Co-authored-by: rebeccaxu-ms <104461363+rebeccaxu-ms@users.noreply.github.com> Co-authored-by: Wei Wei Co-authored-by: SaurabhSharma-MSFT <38112130+SaurabhSharma-MSFT@users.noreply.github.com> Co-authored-by: Theodore Chang Co-authored-by: Theodore Chang Co-authored-by: msJinLei Co-authored-by: microsoft-github-policy-service[bot] <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com> Co-authored-by: Adam Sandor Co-authored-by: navba-MSFT <57353862+navba-MSFT@users.noreply.github.com> Co-authored-by: Ilias Co-authored-by: Ilias Khan Co-authored-by: Jack Stromberg Co-authored-by: Austin Tolani <46536757+austintolani@users.noreply.github.com> Co-authored-by: Austin Tolani Co-authored-by: Ben Eshed <105308016+bewatersmsft@users.noreply.github.com> Co-authored-by: Jingshu923 <52914166+Jingshu923@users.noreply.github.com> Co-authored-by: yifanz0 <100746763+yifanz0@users.noreply.github.com> Co-authored-by: Mike F. Robbins Co-authored-by: Mike F. Robbins Co-authored-by: Yabo Hu Co-authored-by: Milan Brkic Co-authored-by: Milan Brkic Co-authored-by: lijinpei2008 <31384087+lijinpei2008@users.noreply.github.com> Co-authored-by: Shenglong Li Co-authored-by: Stefan Krivokapic <51293916+krivi37@users.noreply.github.com> Co-authored-by: Stefan Krivokapic Co-authored-by: Beisi Zhou Co-authored-by: Michael Guss Co-authored-by: sedusch Co-authored-by: Himanshu Agarwal Co-authored-by: sushil490023 Co-authored-by: Sushil Upadhyay Co-authored-by: demodh <44214810+demodh@users.noreply.github.com> Co-authored-by: xtR0d666 <69706194+xtR0d666@users.noreply.github.com> Co-authored-by: Hongtu Zhang (FA Talent) Co-authored-by: samarthlakhotia <112656832+samarthlakhotia@users.noreply.github.com> Co-authored-by: yibirnba <52132191+yibirnba@users.noreply.github.com> Co-authored-by: Keren Damari Co-authored-by: Sulaiman Abu Rashed Co-authored-by: surashed <55134940+surashed@users.noreply.github.com> Co-authored-by: Rohit Anand <69732641+rohanand-MS@users.noreply.github.com> Co-authored-by: Ashish Shinde Co-authored-by: Brett Miller Co-authored-by: meenalsri <81656932+meenalsri@users.noreply.github.com> Co-authored-by: NanxiangLiu <33285578+Nickcandy@users.noreply.github.com> Co-authored-by: Ann Lu <112682982+yinghsugn@users.noreply.github.com> * Add back the spring cloud live test (#20919) * Fix the live test of developement (#20940) * Fix the live test of developement * Fix the live test of developement * [Az. ApplicationInsights] Add testcases for livetest (#20943) * Add ApplicationInsights livetest * Delete blanks * Added live test cases for KeyVault and Compute * Added live test for Network * Added live test cases for Network and DNS (#20988) * Add livetest for websites and remove list case in applicationinsights (#20995) * Add livetest for websites and remove list case in applicationinsights * Avoid hard code names * Added live test cases (#21011) * Added live test cases for Network and DNS * Added live test cases for modules Automation, Databricks and Functions Added more detailed error info and enabled Debug preference during the last retry * Add service plan parameter to get/delete web app test case. (#21017) * Add livetest for Analysis Services (#21043) * Shared/livetest (#21052) * Added live test cases for Network and DNS * Added live test cases for modules Automation, Databricks and Functions Added more detailed error info and enabled Debug preference during the last retry * Updated live test to make it support no built-in resource group * Added live test for ssh key (#21056) * Added live test cases for Network and DNS * Added live test cases for modules Automation, Databricks and Functions Added more detailed error info and enabled Debug preference during the last retry * Updated live test to make it support no built-in resource group * Added live test for ssh key * Livetest (#21044) * add live test * add live test for app and ContainerInstance * revise test * add live test * delete connectedkubernetes live test * Delete id_rsa * Delete id_rsa.pub * delete connectedkubernetes live test * revise live test * Updated live test to use jobs for resource cleanup (#21070) * Disable livetest cases for Analysis Services (#21072) * Add livetest for Analysis Services * Disable livetest cases for Analysis Services * Added live test for desktop virtualization (#21074) * Updated live test to use jobs for resource cleanup * Added live test for desktop virtualization and modified the debug script * Reverted cmdlet error check and added -Force for New-AzResourceGroup (#21087) * Delete TestLiveScenarios.ps1 * Removed $lastexitcode due to unexpected issues on non-windows systems (#21091) * Reverted cmdlet error check and added -Force for New-AzResourceGroup * Removed the $lastexitcode due to unexpected issues on non-windows system * Modified cleanup jobs info * Add livetest for sql (#21095) * Add livetest cases for Sql * Remove unnecessary process of sql server delete * Added live test for Synapse (#21109) * Add service plan when creating web app in all cases (#21113) * Disabled live test for Spring Cloud until the function to specify platform and ps version is ready (#21118) * Updated live test to support selected platform and ps version as well as run for rc build * Updated live test for testing * Updated live test to support specifying platform and ps version * Added back powershell host 7.0.x and re-enabled test case for Spring Cloud * Updated local debug script. Use current location instead of test coverage location. * Removed Invoke-Expression as it is not recommended by PS team and replaced with Invoke-Command * Fixed bug for Sign pipeline * Print out installed powershell modules * Updated live test for Network to follow best practices * Added new Windows-2022 platform for live test * Fixed assertion issue and replaced branch to main --------- Co-authored-by: Yan Xu Co-authored-by: Alex <108926104+Alex-wdy@users.noreply.github.com> Co-authored-by: NoriZC <110961157+NoriZC@users.noreply.github.com> Co-authored-by: Yunchi Wang <54880216+wyunchi-ms@users.noreply.github.com> Co-authored-by: Arun Sabale Co-authored-by: RakeshMohanMSFT <49954584+RakeshMohanMSFT@users.noreply.github.com> Co-authored-by: Jin Lei <54836179+msJinLei@users.noreply.github.com> Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> Co-authored-by: v-sapanchal <117979452+v-sapanchal@users.noreply.github.com> Co-authored-by: Azure PowerShell <65331932+azure-powershell-bot@users.noreply.github.com> Co-authored-by: Siddharth Saklecha Co-authored-by: Lucas Yao <53558334+LucasYao93@users.noreply.github.com> Co-authored-by: Dingmeng Xue Co-authored-by: Giz Co-authored-by: Gizachew Eshetie Co-authored-by: Xiaogang Co-authored-by: Mikhail Co-authored-by: Hiroshi Yoshioka <40815708+hyoshioka0128@users.noreply.github.com> Co-authored-by: Kota Sudhakar Reddy <60102891+Kotasudhakarreddy@users.noreply.github.com> Co-authored-by: Jinpei Li (Wicresoft North America Ltd) Co-authored-by: rebeccaxu-ms <104461363+rebeccaxu-ms@users.noreply.github.com> Co-authored-by: Wei Wei Co-authored-by: SaurabhSharma-MSFT <38112130+SaurabhSharma-MSFT@users.noreply.github.com> Co-authored-by: Theodore Chang Co-authored-by: Theodore Chang Co-authored-by: msJinLei Co-authored-by: microsoft-github-policy-service[bot] <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com> Co-authored-by: Adam Sandor Co-authored-by: navba-MSFT <57353862+navba-MSFT@users.noreply.github.com> Co-authored-by: Ilias Co-authored-by: Ilias Khan Co-authored-by: Jack Stromberg Co-authored-by: Austin Tolani <46536757+austintolani@users.noreply.github.com> Co-authored-by: Austin Tolani Co-authored-by: Ben Eshed <105308016+bewatersmsft@users.noreply.github.com> Co-authored-by: Jingshu923 <52914166+Jingshu923@users.noreply.github.com> Co-authored-by: yifanz0 <100746763+yifanz0@users.noreply.github.com> Co-authored-by: Mike F. Robbins Co-authored-by: Mike F. Robbins Co-authored-by: Yabo Hu Co-authored-by: Milan Brkic Co-authored-by: Milan Brkic Co-authored-by: lijinpei2008 <31384087+lijinpei2008@users.noreply.github.com> Co-authored-by: Shenglong Li Co-authored-by: Stefan Krivokapic <51293916+krivi37@users.noreply.github.com> Co-authored-by: Stefan Krivokapic Co-authored-by: Beisi Zhou Co-authored-by: Michael Guss Co-authored-by: sedusch Co-authored-by: Himanshu Agarwal Co-authored-by: sushil490023 Co-authored-by: Sushil Upadhyay Co-authored-by: demodh <44214810+demodh@users.noreply.github.com> Co-authored-by: xtR0d666 <69706194+xtR0d666@users.noreply.github.com> Co-authored-by: Hongtu Zhang (FA Talent) Co-authored-by: samarthlakhotia <112656832+samarthlakhotia@users.noreply.github.com> Co-authored-by: yibirnba <52132191+yibirnba@users.noreply.github.com> Co-authored-by: Keren Damari Co-authored-by: Sulaiman Abu Rashed Co-authored-by: surashed <55134940+surashed@users.noreply.github.com> Co-authored-by: Rohit Anand <69732641+rohanand-MS@users.noreply.github.com> Co-authored-by: Ashish Shinde Co-authored-by: Brett Miller Co-authored-by: meenalsri <81656932+meenalsri@users.noreply.github.com> Co-authored-by: NanxiangLiu <33285578+Nickcandy@users.noreply.github.com> Co-authored-by: Ann Lu <112682982+yinghsugn@users.noreply.github.com> --- .azure-pipelines/live-test.yml | 145 ++++- .azure-pipelines/util/live-test-steps.yml | 73 ++- .../LiveTests/TestLiveScenarios.ps1 | 20 + .../Aks.Test/LiveTests/TestLiveScenarios.ps1 | 155 +++++ .../LiveTests/TestLiveScenarios.disabled.ps1 | 89 +++ src/App/Livetests/TestLiveScenarios.ps1 | 45 ++ .../LiveTests/TestLiveScenarios.ps1 | 58 ++ .../LiveTests/TestLiveScenarios.ps1 | 64 ++ .../LiveTests/TestLiveScenarios_disabled.ps1 | 71 +++ .../LiveTests/TestLiveScenarios.ps1 | 174 ++++++ .../LiveTests/TestLiveScenarios.ps1 | 70 +++ .../LiveTests/TestLiveScenarios.ps1 | 60 ++ .../LiveTests/TestLiveScenarios.ps1 | 52 ++ .../LiveTests/TestLiveScenarios.ps1 | 75 +++ .../Dns.Test/LiveTests/TestLiveScenarios.ps1 | 66 ++ src/Functions/LiveTests/TestLiveScenarios.ps1 | 88 +++ .../LiveTests/TestLiveScenarios.ps1 | 208 +++++++ .../LiveTests/TestLiveScenarios.ps1 | 567 ++++++++++++++++++ .../LiveTests/TestLiveScenarios.ps1 | 45 ++ .../Sql.Test/LiveTests/TestLiveScenarios.ps1 | 98 +++ .../LiveTests/TestLiveScenarios.ps1 | 36 ++ .../LiveTests/TestLiveScenarios.ps1 | 80 +++ .../LiveTests/TestLiveScenarios.ps1 | 143 +++++ tools/TestFx/Assert.ps1 | 4 +- .../Live/ConnectLiveTestServicePrincipal.ps1 | 5 + .../Live/DebugLocalLiveTestScenarios.ps1 | 68 +++ .../Live/InitializeLiveTestEnvironment.ps1 | 8 +- .../TestFx/Live/InstallLiveTestAzModules.ps1 | 9 +- tools/TestFx/Live/InvokeLiveTestCITask.ps1 | 5 +- tools/TestFx/Live/InvokeLiveTestScenarios.ps1 | 93 +-- tools/TestFx/Live/LiveTestUtility.psd1 | 2 +- tools/TestFx/Live/LiveTestUtility.psm1 | 327 ++++++---- tools/TestFx/Live/SaveLiveTestResult.ps1 | 64 +- tools/TestFx/Utilities/KustoUtility.psm1 | 6 +- 34 files changed, 2797 insertions(+), 276 deletions(-) create mode 100644 src/Accounts/Accounts.Test/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/Aks/Aks.Test/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/AnalysisServices/AnalysisServices.Test/LiveTests/TestLiveScenarios.disabled.ps1 create mode 100644 src/App/Livetests/TestLiveScenarios.ps1 create mode 100644 src/ApplicationInsights/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/Automation/Automation.Test/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/BotService/LiveTests/TestLiveScenarios_disabled.ps1 create mode 100644 src/Compute/Compute.Test/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/ContainerInstance/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/ContainerRegistry/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/Databricks/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/DesktopVirtualization/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/Dns/Dns.Test/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/Functions/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/KeyVault/KeyVault.Test/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/Network/Network.Test/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/SpringCloud/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/Sql/Sql.Test/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/Storage/Storage.Management.Test/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/Synapse/Synapse.Test/LiveTests/TestLiveScenarios.ps1 create mode 100644 src/Websites/Websites.Test/LiveTests/TestLiveScenarios.ps1 create mode 100644 tools/TestFx/Live/DebugLocalLiveTestScenarios.ps1 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 {