Skip to content

Az.FileShares - Add Tests for fileshares#29256

Open
ankushbindlish2 wants to merge 8 commits intoAzure:mainfrom
ankushbindlish2:add-fileshares-test
Open

Az.FileShares - Add Tests for fileshares#29256
ankushbindlish2 wants to merge 8 commits intoAzure:mainfrom
ankushbindlish2:add-fileshares-test

Conversation

@ankushbindlish2
Copy link
Member

Add prerequisites documentation and installer script for TypeSpec-based FileShare development (PREREQUISITES-STATUS.md, check-and-install-prerequisites.ps1) and add eng package manifest to pull TypeSpec packages. Include generated Pester module files and related test assets for FileShare, plus test environment templates, test helpers, sample implementation, and a test plan/status. Update FileShare project metadata and docs (AssemblyInfo, Az.FileShare.psd1, Az.FileShare.md) and adjust several FileShare test scripts. Also remove obsolete EventGrid generate-info.json.

Description

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

Add prerequisites documentation and installer script for TypeSpec-based FileShare development (PREREQUISITES-STATUS.md, check-and-install-prerequisites.ps1) and add eng package manifest to pull TypeSpec packages. Include generated Pester module files and related test assets for FileShare, plus test environment templates, test helpers, sample implementation, and a test plan/status. Update FileShare project metadata and docs (AssemblyInfo, Az.FileShare.psd1, Az.FileShare.md) and adjust several FileShare test scripts. Also remove obsolete EventGrid generate-info.json.
Copilot AI review requested due to automatic review settings March 10, 2026 08:35
@azure-client-tools-bot-prd
Copy link

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

@NoriZC
Copy link
Contributor

NoriZC commented Mar 10, 2026

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds/activates FileShare Autorest Pester tests and introduces JSON-based test environment assets to support TypeSpec-based FileShare development and validation.

Changes:

  • Load test environment variables from JSON and optionally create the test resource group in setupEnv.
  • Un-skip multiple FileShare cmdlet Pester tests and implement live assertions.
  • Add JSON request/asset files for tests and include local/env templates.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
src/FileShare/FileShare.Autorest/test/utils.ps1 Loads env values from JSON and creates RG if needed; writes env back to disk
src/FileShare/FileShare.Autorest/test/test-snapshot-update.json Adds snapshot update request payload asset
src/FileShare/FileShare.Autorest/test/test-recommendation.json Adds provisioning recommendation request payload asset
src/FileShare/FileShare.Autorest/test/test-availability.json Adds name availability request payload asset
src/FileShare/FileShare.Autorest/test/localEnv.json Adds local live-test environment values
src/FileShare/FileShare.Autorest/test/env.json.template Adds template env file for non-local scenarios
src/FileShare/FileShare.Autorest/test/env.json Adds env file used by tests when not in live mode
src/FileShare/FileShare.Autorest/test/Update-AzFileShareSnapshot.Tests.ps1 Implements Update snapshot tests (expanded/json/identity variants)
src/FileShare/FileShare.Autorest/test/Update-AzFileShare.Tests.ps1 Implements Update file share tests (expanded/json/identity variants)
src/FileShare/FileShare.Autorest/test/Test-AzFileShareNameAvailability.Tests.ps1 Implements name availability tests (expanded/json/body/identity variants)
src/FileShare/FileShare.Autorest/test/Remove-AzFileShareSnapshot.Tests.ps1 Implements snapshot delete tests (expanded/identity variants)
src/FileShare/FileShare.Autorest/test/Remove-AzFileShare.Tests.ps1 Implements file share delete tests
src/FileShare/FileShare.Autorest/test/New-AzFileShareSnapshot.Tests.ps1 Implements snapshot create tests (expanded/json/identity variants)
src/FileShare/FileShare.Autorest/test/New-AzFileShare.Tests.ps1 Implements file share create tests (expanded/json variants)
src/FileShare/FileShare.Autorest/test/Get-AzFileShareUsageData.Tests.ps1 Implements usage data tests
src/FileShare/FileShare.Autorest/test/Get-AzFileShareSnapshot.Tests.ps1 Implements snapshot get/list tests
src/FileShare/FileShare.Autorest/test/Get-AzFileShareProvisioningRecommendation.Tests.ps1 Implements provisioning recommendation tests (expanded/json/body/identity variants)
src/FileShare/FileShare.Autorest/test/Get-AzFileShareLimit.Tests.ps1 Implements limit tests (expanded/identity variants)
src/FileShare/FileShare.Autorest/test/Get-AzFileShare.Tests.ps1 Implements file share get/list tests

- Add CRUD operation tests
- Add edge case scenarios tests
- Add negative/error handling tests
- Add pipeline functionality tests
- Add private endpoint tests
- Add resource move tests
- Add complex scenario tests
- Add test utilities
@NoriZC
Copy link
Contributor

NoriZC commented Mar 10, 2026

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

- Add scenario tests: CRUD, ComplexScenarios, EdgeCases, Negative, NegativeTests, Pipeline, PrivateEndpoint
- Add recordings for all test scenarios (16 recording files)
- Update individual cmdlet tests with fixes
- Update env.json and localEnv.json with test configuration
- Remove obsolete test files (FileShare-ResourceMove, test-*.json)
- Rename PipelineTests and PrivateEndpointTests to standard naming

Test results: 159 passed, 0 failed, 31 skipped
Copilot AI review requested due to automatic review settings March 19, 2026 03:33
@NoriZC
Copy link
Contributor

NoriZC commented Mar 19, 2026

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Prevents temporary JSON files created during test execution from being committed:
- test-*.json (test-availability.json, test-recommendation.json, test-snapshot.json, etc.)
- *-Params.json (test output files)
- run-tests.ps1 (local helper script, not part of standard test framework)
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 43 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (7)

src/FileShare/FileShare.Autorest/test/localEnv.json:1

  • This file commits concrete Tenant and Subscription IDs. Even if not secret, these are environment-specific identifiers and typically should not be checked in. Replace them with placeholders (e.g., "00000000-0000-0000-0000-000000000000") and document that users must override via local, untracked settings (or rely on Get-AzContext in setupEnv).
    src/FileShare/FileShare.Autorest/test/localEnv.json:1
  • This file commits concrete Tenant and Subscription IDs. Even if not secret, these are environment-specific identifiers and typically should not be checked in. Replace them with placeholders (e.g., "00000000-0000-0000-0000-000000000000") and document that users must override via local, untracked settings (or rely on Get-AzContext in setupEnv).
    src/FileShare/FileShare.Autorest/test/utils.ps1:1
  • This introduces real ARM calls during environment setup for any mode. In playback (and often record), the harness typically must avoid unrecorded ARM calls like Get-AzResourceGroup/New-AzResourceGroup, otherwise tests can fail or unexpectedly mutate a subscription. Gate this block so it runs only when appropriate (commonly $TestMode -ne 'playback', or even only in live/record), and keep playback strictly off-network.
    src/FileShare/FileShare.Autorest/test/utils.ps1:1
  • Get-Content without -Raw returns an array of lines. ConvertFrom-Json can fail or behave inconsistently when fed a string array (especially if the JSON becomes multi-line or contains trailing whitespace). Use Get-Content -Raw for reliable JSON parsing.
    src/FileShare/FileShare.Autorest/test/Update-AzFileShareSnapshot.Tests.ps1:1
  • These tests update $env.snapshotName01 but the test file does not create (or verify existence of) that snapshot first. This makes the test order-dependent and can fail in live runs. Create the snapshot in a BeforeAll/BeforeEach within this Describe, then update it, and delete it in AfterAll to keep tests isolated.
    src/FileShare/FileShare.Autorest/test/Test-AzFileShareNameAvailability.Tests.ps1:1
  • These tests assert NameAvailable is $true for fixed names (e.g., testshare-available, testshare-json). In live/record mode this can legitimately become false if the name becomes unavailable, causing flaky CI. Use a randomized name (e.g., include a GUID suffix) for 'available' assertions, and keep recordings stable via the test framework's sanitization/replacement features if needed.
    src/FileShare/FileShare.Autorest/test/Test-AzFileShareNameAvailability.Recording.json:1
  • The recorded request body looks base64-encoded, but isContentBase64 is set to false. If the mocking framework uses this flag to decode/compare bodies, playback matching can break. Ensure recordings either store the plain JSON with isContentBase64: false, or set isContentBase64: true when the content is base64-encoded.

@NoriZC
Copy link
Contributor

NoriZC commented Mar 19, 2026

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

FileShare is a standalone service (Microsoft.FileShares) that does not use
Storage Accounts. Removed legacy storageAccountName configuration that was
not being used in any tests.

- Removed from env.json
- Removed from localEnv.json
- Removed from env.json.template
Changed from: 70a036f6-8e4d-4615-bad6-149c02e7720d
Changed to:   72f988bf-86f1-41af-91ab-2d7cd011db47

This is the well-known Microsoft tenant ID used across Azure PowerShell
test configurations, ensuring consistency with other modules in the repository.
Copilot AI review requested due to automatic review settings March 20, 2026 06:10
@NoriZC
Copy link
Contributor

NoriZC commented Mar 20, 2026

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 43 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (8)

src/FileShare/FileShare.Autorest/test/utils.ps1:1

  • Get-Content without -Raw pipes the JSON file line-by-line into ConvertFrom-Json, which will fail for multi-line JSON (e.g., { on the first line). Use Get-Content -Raw -Path $envFilePath | ConvertFrom-Json (or Get-Content -Raw assigned to a string) so the entire JSON document is parsed correctly.
    src/FileShare/FileShare.Autorest/test/utils.ps1:1
  • In non-live modes this selects env.json and then overwrites it at the end of setupEnv(). If env.json is intended to be a checked-in playback asset, writing to it during test runs will dirty the working tree and can destabilize playback consistency. Consider (mandatory) writing only to localEnv.json (or a temp file) and treating env.json as read-only, or gating the Set-Content write so it only happens in live mode.
    src/FileShare/FileShare.Autorest/test/utils.ps1:1
  • In non-live modes this selects env.json and then overwrites it at the end of setupEnv(). If env.json is intended to be a checked-in playback asset, writing to it during test runs will dirty the working tree and can destabilize playback consistency. Consider (mandatory) writing only to localEnv.json (or a temp file) and treating env.json as read-only, or gating the Set-Content write so it only happens in live mode.
    src/FileShare/FileShare.Autorest/test/localEnv.json:1
  • This file appears to include real SubscriptionId/Tenant GUIDs. Even if these are non-secret, committing real tenant/subscription identifiers is generally treated as sensitive (and also makes the repo less portable). Replace these with placeholders (e.g., 00000000-0000-0000-0000-000000000000) and document how contributors should populate local values (and ensure the real local file is ignored).
    src/FileShare/FileShare.Autorest/test/localEnv.json:1
  • This file appears to include real SubscriptionId/Tenant GUIDs. Even if these are non-secret, committing real tenant/subscription identifiers is generally treated as sensitive (and also makes the repo less portable). Replace these with placeholders (e.g., 00000000-0000-0000-0000-000000000000) and document how contributors should populate local values (and ensure the real local file is ignored).
    src/FileShare/FileShare.Autorest/test/env.json:1
  • env.json is checked in and includes subscription/tenant identifiers. If this file is used as a playback/record baseline, it should be sanitized to non-identifying placeholder values (or removed and generated) to avoid leaking tenant metadata and to keep recordings portable across environments.
    src/FileShare/FileShare.Autorest/test/env.json.template:1
  • The template should not embed real subscription/tenant IDs. Use clear placeholder values and add brief guidance for users to fill these in locally. This also avoids copy/paste of real IDs into repos downstream.
    src/FileShare/FileShare.Autorest/test/Get-AzFileShare.Recording.json:1
  • The recording content includes systemData.createdBy with what appears to be a real email address (PII). Recordings should be sanitized (e.g., replace with [Filtered]/00000000-.../user@contoso.com) via the test framework's sanitizers before committing.
{

- Add FileShare-PrivateEndpoint tests with full recording (12 tests passing)
  - Fixed GroupId from 'share' to 'fileshare' for Microsoft.FileShares provider
  - Tests skip gracefully when Az.Network unavailable (playback mode compatible)
  - Recording includes VNet, Subnet, FileShare, and Private Endpoint operations

- Remove duplicate FileShare-NegativeTests files
  - Kept FileShare-Negative.Tests.ps1 as single negative test suite
  - Eliminates test interference and reduces execution time

- Fix Get-AzFileShareSnapshot InputObject parameter binding
  - Cast hashtable to FileShareIdentity model type before passing to -InputObject
  - Aligns with other test patterns for reliable parameter binding

- Remove localEnv.json from tracking
  - Local environment file should not be committed
@NoriZC
Copy link
Contributor

NoriZC commented Mar 20, 2026

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@ankushbindlish2 ankushbindlish2 changed the title [DO NOT MERGE] Add FileShare TypeSpec setup, tests & tooling Az.FileShares - Add Tests for fileshares Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants