Skip to content

Fix storage service-version gates for all-version tests - #50294

Open
browndav-msft wants to merge 1 commit into
Azure:mainfrom
browndav-msft:fix/storage-required-service-version-gate
Open

Fix storage service-version gates for all-version tests#50294
browndav-msft wants to merge 1 commit into
Azure:mainfrom
browndav-msft:fix/storage-required-service-version-gate

Conversation

@browndav-msft

@browndav-msft browndav-msft commented Aug 29, 2026

Copy link
Copy Markdown
Member

Description

Problem

RequiredServiceVersionExtension receives service versions in two different string representations:

  • The all-versions test matrix sets AZURE_LIVE_TEST_SERVICE_VERSION to an enum name such as V2021_06_08.
  • @RequiredServiceVersion annotations use the service wire value, such as "2026-02-06".

For example, QueueServiceAsyncApiTests.queueServiceGetUserDelegationKey, which requires "2026-02-06", while platform-matrix-all-versions.json includes runs configured with V2021_06_08.

The extension previously resolved both inputs by comparing them with String.valueOf(serviceVersion). Storage service-version enums do not override Enum.toString(), so that expression produces the enum name (V2026_02_06) rather than the wire value (2026-02-06).

Consequently, the required wire value could not be found and received ordinal -1 even though the value actual exists (see screenshots below):

image image image

The extension therefore enabled a test requiring service version 2026-02-06 during a V2021_06_08 matrix run instead of skipping it. Unknown versions also returned -1, allowing malformed annotations or configuration to fail open in the same way.

Fix

  • Resolve each service version by either its explicit wire value (ServiceVersion.getVersion()) or its exact enum name (Enum.name()).
  • Throw a descriptive exception for unknown minimum or configured versions instead of returning -1.
  • Use the latest version's wire value when no environment version is configured.
  • Add an injectable overload for deterministic unit testing while retaining the existing environment lookup for production test execution.

This does not change how x-ms-version is sent to Storage. The test infrastructure still converts the configured enum name to a ServiceVersion, and the client sends that enum's getVersion() value over the wire.

Testing

Added focused unit coverage for:

  • Configured versions older than, equal to, and newer than the required version.
  • Required wire values compared with configured enum names.
  • The latest-version fallback.
  • Unknown configured and minimum versions.

Validated with the focused RequiredServiceVersionExtensionTests, Spotless, and Checkstyle. The Maven test compilation covered both Java 8 and Java 21.

All SDK Contribution checklist

  • The pull request does not introduce breaking changes.
  • CHANGELOG is updated for new features, bug fixes or other significant changes. Not applicable because this only changes test infrastructure.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There is one commit with an informative message.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

The all-versions matrix configures AZURE_LIVE_TEST_SERVICE_VERSION using
enum names such as V2021_06_08, while @RequiredServiceVersion uses wire
values. For example, QueueServiceAsyncApiTests requires "2026-02-06".

The gate compared both values using Enum.toString(), so "2026-02-06" was
unresolved and returned ordinal -1. As a result, the 2026-only test ran
against the 2021 service version instead of being skipped.

Resolve enum names and wire values explicitly, and reject unknown versions
rather than failing open.
Copilot AI lite review requested due to automatic review settings August 29, 2026 18:09
@github-actions github-actions Bot added the Storage Storage Service (Queues, Blobs, Files) label Aug 29, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
34 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the Storage test gating logic in RequiredServiceVersionExtension so that minimum required service versions declared as wire values (e.g., "2026-02-06") are correctly compared against configured versions that may be provided as enum names (e.g., V2021_06_08) in all-version test matrix runs.

Changes:

  • Correctly resolve service versions by matching either ServiceVersion.getVersion() (wire value) or Enum.name() (enum name), rather than relying on toString().
  • Fail closed by throwing a descriptive IllegalArgumentException when configured or minimum versions are unknown, instead of returning -1 and potentially enabling tests incorrectly.
  • Add focused unit tests for ordering comparisons, latest-version fallback behavior, and unknown-version validation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
sdk/storage/azure-storage-common/src/test-shared/java/com/azure/storage/common/test/shared/extensions/RequiredServiceVersionExtension.java Fixes version resolution and comparison logic; adds injectable overload and throws on unknown versions.
sdk/storage/azure-storage-common/src/test/java/com/azure/storage/common/test/shared/extensions/RequiredServiceVersionExtensionTests.java Adds unit coverage validating correct skip behavior across wire values, enum names, fallback, and unknown inputs.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Storage Storage Service (Queues, Blobs, Files)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants