-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Az.FileShares - Add Tests for fileshares #29256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ankushbindlish2
wants to merge
8
commits into
Azure:main
Choose a base branch
from
ankushbindlish2:add-fileshares-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c08ff11
Add FileShare TypeSpec setup, tests & tooling
ankushbindlish2 70096c6
Add comprehensive FileShare test suite
ankushbindlish2 07dad3d
Add comprehensive FileShare test suite with recordings
ankushbindlish2 379cf2b
Add .gitignore for test directory to exclude temporary test files
ankushbindlish2 f244a1f
Remove unused storageAccountName from test configuration
ankushbindlish2 ff5e04a
Update tenant ID to use official Microsoft tenant
ankushbindlish2 395f55d
Revert "Update tenant ID to use official Microsoft tenant"
ankushbindlish2 48d6d25
Add Private Endpoint tests and cleanup duplicates
ankushbindlish2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Temporary test files created during test execution | ||
| test-*.json | ||
|
|
||
| # Test output files | ||
| *-Params.json | ||
|
|
||
| # Local helper scripts (not part of standard test framework) | ||
| run-tests.ps1 | ||
1,301 changes: 1,301 additions & 0 deletions
1,301
src/FileShare/FileShare.Autorest/test/FileShare-CRUD.Recording.json
Large diffs are not rendered by default.
Oops, something went wrong.
186 changes: 186 additions & 0 deletions
186
src/FileShare/FileShare.Autorest/test/FileShare-CRUD.Tests.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| if(($null -eq $TestName) -or ($TestName -contains 'FileShare-CRUD')) | ||
| { | ||
| $loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' | ||
| if (-Not (Test-Path -Path $loadEnvPath)) { | ||
| $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' | ||
| } | ||
| . ($loadEnvPath) | ||
| $TestRecordingFile = Join-Path $PSScriptRoot 'FileShare-CRUD.Recording.json' | ||
| $currentPath = $PSScriptRoot | ||
| while(-not $mockingPath) { | ||
| $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File | ||
| $currentPath = Split-Path -Path $currentPath -Parent | ||
| } | ||
| . ($mockingPath | Select-Object -First 1).FullName | ||
| } | ||
|
|
||
| Describe 'FileShare-CRUD' { | ||
|
|
||
| BeforeAll { | ||
| $script:crudShareName = "crud-share-fixed01" | ||
| $script:crudSnapshotName = "crud-snapshot-fixed01" | ||
| } | ||
|
|
||
| Context 'Complete CRUD Lifecycle - NFS Protocol' { | ||
|
|
||
| It 'CREATE: Should create a new NFS file share with all properties' { | ||
| { | ||
| $share = New-AzFileShare -ResourceName $script:crudShareName ` | ||
| -ResourceGroupName $env.resourceGroup ` | ||
| -Location $env.location ` | ||
| -MediaTier "SSD" ` | ||
| -Protocol "NFS" ` | ||
| -ProvisionedStorageGiB 1024 ` | ||
| -ProvisionedIoPerSec 4024 ` | ||
| -ProvisionedThroughputMiBPerSec 228 ` | ||
| -Redundancy "Local" ` | ||
| -PublicNetworkAccess "Enabled" ` | ||
| -NfProtocolPropertyRootSquash "NoRootSquash" ` | ||
| -Tag @{"lifecycle" = "crud"; "test" = "nfs"; "created" = (Get-Date -Format "yyyy-MM-dd")} | ||
|
|
||
| $share.Name | Should -Be $script:crudShareName | ||
| $share.ProvisioningState | Should -Be "Succeeded" | ||
| $share.Protocol | Should -Be "NFS" | ||
| $share.MediaTier | Should -Be "SSD" | ||
| $share.ProvisionedStorageGiB | Should -Be 1024 | ||
| $share.Tag.ContainsKey("lifecycle") | Should -Be $true | ||
| } | Should -Not -Throw | ||
| } | ||
|
|
||
| It 'READ: Should retrieve the created file share by name' { | ||
| { | ||
| $share = Get-AzFileShare -ResourceGroupName $env.resourceGroup -ResourceName $script:crudShareName | ||
|
|
||
| $share | Should -Not -BeNullOrEmpty | ||
| $share.Name | Should -Be $script:crudShareName | ||
| $share.Protocol | Should -Be "NFS" | ||
| $share.Tag["lifecycle"] | Should -Be "crud" | ||
| } | Should -Not -Throw | ||
| } | ||
|
|
||
| It 'READ: Should list file shares in resource group and find our share' { | ||
| { | ||
| $shares = Get-AzFileShare -ResourceGroupName $env.resourceGroup | ||
|
|
||
| $shares | Should -Not -BeNullOrEmpty | ||
| $shares.Count | Should -BeGreaterThan 0 | ||
| $ourShare = $shares | Where-Object { $_.Name -eq $script:crudShareName } | ||
| $ourShare | Should -Not -BeNullOrEmpty | ||
| } | Should -Not -Throw | ||
| } | ||
|
|
||
| It 'READ: Should retrieve file share via identity' { | ||
| { | ||
| $share = Get-AzFileShare -ResourceGroupName $env.resourceGroup -ResourceName $script:crudShareName | ||
| $shareViaIdentity = Get-AzFileShare -InputObject $share | ||
|
|
||
| $shareViaIdentity.Name | Should -Be $script:crudShareName | ||
| $shareViaIdentity.Id | Should -Be $share.Id | ||
| } | Should -Not -Throw | ||
| } | ||
|
|
||
| It 'UPDATE: Should update tags using expanded parameters' { | ||
| { | ||
| Start-TestSleep -Seconds 5 | ||
|
|
||
| $updated = Update-AzFileShare -ResourceGroupName $env.resourceGroup ` | ||
| -ResourceName $script:crudShareName ` | ||
| -Tag @{"lifecycle" = "crud"; "test" = "nfs"; "updated" = "true"; "version" = "2"} | ||
|
|
||
| $updated.Tag["updated"] | Should -Be "true" | ||
| $updated.Tag["version"] | Should -Be "2" | ||
| $updated.Tag["lifecycle"] | Should -Be "crud" | ||
| } | Should -Not -Throw | ||
| } | ||
|
|
||
| It 'UPDATE: Should update via identity' { | ||
| { | ||
| Start-TestSleep -Seconds 5 | ||
|
|
||
| $share = Get-AzFileShare -ResourceGroupName $env.resourceGroup -ResourceName $script:crudShareName | ||
| $updated = Update-AzFileShare -InputObject $share ` | ||
| -Tag @{"lifecycle" = "crud"; "test" = "nfs"; "method" = "identity"; "version" = "3"} | ||
|
|
||
| $updated.Tag["method"] | Should -Be "identity" | ||
| $updated.Tag["version"] | Should -Be "3" | ||
| } | Should -Not -Throw | ||
| } | ||
|
|
||
| It 'SNAPSHOT CREATE: Should create a snapshot of the file share' { | ||
| { | ||
| Start-TestSleep -Seconds 5 | ||
|
|
||
| $snapshot = New-AzFileShareSnapshot -ResourceGroupName $env.resourceGroup ` | ||
| -ResourceName $script:crudShareName ` | ||
| -Name $script:crudSnapshotName ` | ||
| -Metadata @{"purpose" = "testing"; "environment" = "test"} | ||
|
|
||
| $snapshot.Name | Should -Be $script:crudSnapshotName | ||
| $snapshot.SnapshotTime | Should -Not -BeNullOrEmpty | ||
| $snapshot.Metadata["purpose"] | Should -Be "testing" | ||
| } | Should -Not -Throw | ||
| } | ||
|
|
||
| It 'SNAPSHOT READ: Should retrieve snapshot' { | ||
| { | ||
| $snapshot = Get-AzFileShareSnapshot -ResourceGroupName $env.resourceGroup ` | ||
| -ResourceName $script:crudShareName ` | ||
| -Name $script:crudSnapshotName | ||
|
|
||
| $snapshot | Should -Not -BeNullOrEmpty | ||
| $snapshot.Name | Should -Be $script:crudSnapshotName | ||
| } | Should -Not -Throw | ||
| } | ||
|
|
||
| It 'SNAPSHOT UPDATE: Should update snapshot' { | ||
| { | ||
| Start-TestSleep -Seconds 5 | ||
|
|
||
| $updated = Update-AzFileShareSnapshot -ResourceGroupName $env.resourceGroup ` | ||
| -ResourceName $script:crudShareName ` | ||
| -Name $script:crudSnapshotName | ||
|
|
||
| $updated | Should -Not -BeNullOrEmpty | ||
| } | Should -Not -Throw | ||
| } | ||
|
|
||
| It 'SNAPSHOT DELETE: Should delete snapshot' { | ||
| { | ||
| Start-TestSleep -Seconds 5 | ||
|
|
||
| Remove-AzFileShareSnapshot -ResourceGroupName $env.resourceGroup ` | ||
| -ResourceName $script:crudShareName ` | ||
| -Name $script:crudSnapshotName ` | ||
| -PassThru | Should -Be $true | ||
|
|
||
| Start-TestSleep -Seconds 3 | ||
|
|
||
| $deleted = Get-AzFileShareSnapshot -ResourceGroupName $env.resourceGroup ` | ||
| -ResourceName $script:crudShareName ` | ||
| -Name $script:crudSnapshotName ` | ||
| -ErrorAction SilentlyContinue | ||
|
|
||
| $deleted | Should -BeNullOrEmpty | ||
| } | Should -Not -Throw | ||
| } | ||
|
|
||
| It 'DELETE: Should delete file share via identity' { | ||
| { | ||
| Start-TestSleep -Seconds 5 | ||
|
|
||
| $share = Get-AzFileShare -ResourceGroupName $env.resourceGroup -ResourceName $script:crudShareName | ||
| Remove-AzFileShare -InputObject $share -PassThru | Should -Be $true | ||
|
|
||
| Start-TestSleep -Seconds 3 | ||
|
|
||
| $deleted = Get-AzFileShare -ResourceGroupName $env.resourceGroup ` | ||
| -ResourceName $script:crudShareName ` | ||
| -ErrorAction SilentlyContinue | ||
|
|
||
| $deleted | Should -BeNullOrEmpty | ||
| } | Should -Not -Throw | ||
| } | ||
| } | ||
|
|
||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.