Fix storage service-version gates for all-version tests - #50294
Fix storage service-version gates for all-version tests#50294browndav-msft wants to merge 1 commit into
Conversation
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.
|
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. |
There was a problem hiding this comment.
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) orEnum.name()(enum name), rather than relying ontoString(). - Fail closed by throwing a descriptive
IllegalArgumentExceptionwhen configured or minimum versions are unknown, instead of returning-1and 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.
Isabelle (ibrandes)
left a comment
There was a problem hiding this comment.
overall looks good! just a couple of small comments. good catch though!
| environmentServiceVersion = getLatestServiceVersion(targetEnumClass).getVersion(); | ||
| } | ||
|
|
||
| int minOrdinal = getOrdinal(serviceVersions, minServiceVersion, "minimum"); |
There was a problem hiding this comment.
getOrdinal now throws IllegalArgumentException for both min and the configured version - throwing on min is good since it catches annotation typos. But we shouldn't throw on the configured version (AZURE_LIVE_TEST_SERVICE_VERSION), it's externally supplied and shared across services, so a name absent from one service's enum would turn every @RequiredServiceVersion test in that module into an error instead of running. we should keep the throw for min, but for the configured version fall back to "latest" (or skip) on an unknown value.
| } | ||
|
|
||
| private static int getOrdinal(ServiceVersion[] serviceVersions, String target) { | ||
| private static int getOrdinal(ServiceVersion[] serviceVersions, String target, String description) { |
There was a problem hiding this comment.
we might want to add a comment explaining that both getVersion() (wire value, e.g. 2026-02-06) and name() (enum name, e.g. V2026_02_06) are accepted here (future refactor could tighten it to one format and silently break skipping again)
Description
Problem
RequiredServiceVersionExtensionreceives service versions in two different string representations:AZURE_LIVE_TEST_SERVICE_VERSIONto an enum name such asV2021_06_08.@RequiredServiceVersionannotations use the service wire value, such as"2026-02-06".For example,
QueueServiceAsyncApiTests.queueServiceGetUserDelegationKey, which requires"2026-02-06", whileplatform-matrix-all-versions.jsonincludes runs configured withV2021_06_08.The extension previously resolved both inputs by comparing them with
String.valueOf(serviceVersion). Storage service-version enums do not overrideEnum.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
-1even though the value actual exists (see screenshots below):The extension therefore enabled a test requiring service version
2026-02-06during aV2021_06_08matrix run instead of skipping it. Unknown versions also returned-1, allowing malformed annotations or configuration to fail open in the same way.Fix
ServiceVersion.getVersion()) or its exact enum name (Enum.name()).-1.This does not change how
x-ms-versionis sent to Storage. The test infrastructure still converts the configured enum name to aServiceVersion, and the client sends that enum'sgetVersion()value over the wire.Testing
Added focused unit coverage for:
Validated with the focused
RequiredServiceVersionExtensionTests, Spotless, and Checkstyle. The Maven test compilation covered both Java 8 and Java 21.All SDK Contribution checklist
General Guidelines and Best Practices
Testing Guidelines