-
Notifications
You must be signed in to change notification settings - Fork 66
[Spector] Test case for ARM multiple services #3618
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
Merged
tadelesh
merged 15 commits into
Azure:release/december-2025
from
weidongxu-microsoft:specs_arm-multi-service
Dec 19, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
24f66bb
multi-service for arm
weidongxu-microsoft 2e9f418
Merge remote-tracking branch 'origin/main' into specs_arm-multi-service
129db26
update test
8a9d116
update
e8a69e2
Merge remote-tracking branch 'origin/release/december-2025' into spec…
29ccea9
Merge remote-tracking branch 'origin/release/december-2025' into spec…
235c99f
update spec and doc
8964587
changeset
50a9aca
fix api version
43fe203
Update packages/azure-http-specs/specs/azure/resource-manager/multi-s…
tadelesh fa745c9
Update packages/azure-http-specs/specs/azure/resource-manager/multi-s…
tadelesh 32bcbae
Update packages/azure-http-specs/specs/azure/resource-manager/multi-s…
tadelesh 32f0524
Update packages/azure-http-specs/specs/azure/resource-manager/multi-s…
tadelesh 4ca1dad
update doc
2c7fa07
Merge branch 'release/december-2025' into specs_arm-multi-service
tadelesh 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
7 changes: 7 additions & 0 deletions
7
.chronus/changes/specs_arm-multi-service-2025-11-18-17-31-26.md
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,7 @@ | ||
| --- | ||
| changeKind: feature | ||
| packages: | ||
| - "@azure-tools/azure-http-specs" | ||
| --- | ||
|
|
||
| Add ARM multiple services test case. |
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
16 changes: 16 additions & 0 deletions
16
packages/azure-http-specs/specs/azure/resource-manager/multi-service/client.tsp
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,16 @@ | ||
| import "./service1.tsp"; | ||
| import "./service2.tsp"; | ||
| import "@azure-tools/typespec-client-generator-core"; | ||
|
|
||
| using Versioning; | ||
| using Azure.Core; | ||
| using Azure.ResourceManager; | ||
| using Azure.ClientGenerator.Core; | ||
|
|
||
| @client({ | ||
| service: [ | ||
| Azure.ResourceManager.MultiService.Compute, | ||
| Azure.ResourceManager.MultiService.ComputeDisk | ||
| ], | ||
| }) | ||
| namespace Azure.ResourceManager.MultiService.Combined; | ||
111 changes: 111 additions & 0 deletions
111
packages/azure-http-specs/specs/azure/resource-manager/multi-service/mockapi.ts
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,111 @@ | ||
| import { json, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api"; | ||
|
|
||
| export const Scenarios: Record<string, ScenarioMockApi> = {}; | ||
|
|
||
| // Mock data for Compute (VirtualMachine) | ||
| const SUBSCRIPTION_ID = "00000000-0000-0000-0000-000000000000"; | ||
| const RESOURCE_GROUP = "test-rg"; | ||
| const LOCATION = "eastus"; | ||
|
|
||
| const virtualMachine = { | ||
| id: `/subscriptions/${SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.Compute/virtualMachines/vm1`, | ||
| name: "vm1", | ||
| type: "Microsoft.Compute/virtualMachines", | ||
| location: LOCATION, | ||
| properties: { | ||
| provisioningState: "Succeeded", | ||
| }, | ||
| }; | ||
|
|
||
| // Mock data for ComputeDisk (Disk) | ||
| const disk = { | ||
| id: `/subscriptions/${SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.Compute/disks/disk1`, | ||
| name: "disk1", | ||
| type: "Microsoft.Compute/disks", | ||
| location: LOCATION, | ||
| properties: { | ||
| provisioningState: "Succeeded", | ||
| }, | ||
| }; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another thing I suggest to verify is the common models/operations between 2 services. Can we add case for it? thanks
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| // Scenario: Get Virtual Machine | ||
| Scenarios.Azure_ResourceManager_MultiService_Compute_VirtualMachines_get = passOnSuccess([ | ||
| { | ||
| uri: `/subscriptions/${SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.Compute/virtualMachines/vm1`, | ||
| method: "get", | ||
| request: { | ||
| query: { | ||
| "api-version": "2025-04-01", | ||
| }, | ||
| }, | ||
| response: { | ||
| status: 200, | ||
| body: json(virtualMachine), | ||
| }, | ||
| kind: "MockApiDefinition", | ||
| }, | ||
| ]); | ||
|
|
||
| // Scenario: Create or Update Virtual Machine | ||
| Scenarios.Azure_ResourceManager_MultiService_Compute_VirtualMachines_createOrUpdate = passOnSuccess( | ||
| [ | ||
| { | ||
| uri: `/subscriptions/${SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.Compute/virtualMachines/vm1`, | ||
| method: "put", | ||
| request: { | ||
| query: { | ||
| "api-version": "2025-04-01", | ||
| }, | ||
| body: json({ | ||
| location: LOCATION, | ||
| properties: {}, | ||
| }), | ||
| }, | ||
| response: { | ||
| status: 200, | ||
| body: json(virtualMachine), | ||
| }, | ||
| kind: "MockApiDefinition", | ||
| }, | ||
| ], | ||
| ); | ||
|
|
||
| // Scenario: Get Disk | ||
| Scenarios.Azure_ResourceManager_MultiService_ComputeDisk_Disks_get = passOnSuccess([ | ||
| { | ||
| uri: `/subscriptions/${SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.Compute/disks/disk1`, | ||
| method: "get", | ||
| request: { | ||
| query: { | ||
| "api-version": "2025-01-02", | ||
| }, | ||
| }, | ||
| response: { | ||
| status: 200, | ||
| body: json(disk), | ||
| }, | ||
| kind: "MockApiDefinition", | ||
| }, | ||
| ]); | ||
|
|
||
| // Scenario: Create or Update Disk | ||
| Scenarios.Azure_ResourceManager_MultiService_ComputeDisk_Disks_createOrUpdate = passOnSuccess([ | ||
| { | ||
| uri: `/subscriptions/${SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.Compute/disks/disk1`, | ||
| method: "put", | ||
| request: { | ||
| query: { | ||
| "api-version": "2025-01-02", | ||
| }, | ||
| body: json({ | ||
| location: LOCATION, | ||
| properties: {}, | ||
| }), | ||
| }, | ||
| response: { | ||
| status: 200, | ||
| body: json(disk), | ||
| }, | ||
| kind: "MockApiDefinition", | ||
| }, | ||
| ]); | ||
109 changes: 109 additions & 0 deletions
109
packages/azure-http-specs/specs/azure/resource-manager/multi-service/service1.tsp
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,109 @@ | ||
| import "@typespec/versioning"; | ||
| import "@azure-tools/typespec-azure-resource-manager"; | ||
| import "@typespec/spector"; | ||
|
|
||
| using TypeSpec.Versioning; | ||
| using Spector; | ||
|
|
||
| /** | ||
| * Compute Client | ||
| */ | ||
| @armProviderNamespace("Microsoft.Compute") | ||
| @service(#{ title: "Azure Compute resource management API." }) | ||
| @versioned(Versions) | ||
| namespace Azure.ResourceManager.MultiService.Compute; | ||
|
|
||
| /** | ||
| * The available API versions. | ||
| */ | ||
| enum Versions { | ||
| /** | ||
| * The 2024-11-01 API version. | ||
| */ | ||
| @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3) | ||
| v2024_11_01: "2024-11-01", | ||
|
|
||
| /** | ||
| * The 2025-04-01 API version. | ||
| */ | ||
| @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3) | ||
| v2025_04_01: "2025-04-01", | ||
| } | ||
|
|
||
| /** | ||
| * Describes a Virtual Machine. | ||
| */ | ||
| model VirtualMachine is Azure.ResourceManager.TrackedResource<VirtualMachineProperties> { | ||
| ...ResourceNameParameter< | ||
| Resource = VirtualMachine, | ||
| KeyName = "vmName", | ||
| SegmentName = "virtualMachines", | ||
| NamePattern = "" | ||
| >; | ||
| } | ||
|
|
||
| model VirtualMachineProperties { | ||
| @visibility(Lifecycle.Read) | ||
| provisioningState?: ResourceProvisioningState; | ||
| } | ||
|
|
||
| @armResourceOperations | ||
| interface VirtualMachines { | ||
| /** | ||
| * Retrieves information about the model view or the instance view of a virtual machine. | ||
| */ | ||
| @scenario | ||
| @scenarioDoc(""" | ||
| Test that a client can expose operations from multiple services. This operaton should be called like this: `client.virtualMachines.get(...)`. | ||
|
|
||
| GET a Virtual Machine. | ||
| Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/vm1 | ||
| Expected query parameter: api-version=2025-04-01 | ||
|
|
||
| Expected response body: | ||
| ```json | ||
| { | ||
| "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/vm1", | ||
| "name": "vm1", | ||
| "type": "Microsoft.Compute/virtualMachines", | ||
| "location": "eastus", | ||
| "properties": { | ||
| "provisioningState": "Succeeded" | ||
| } | ||
| } | ||
| ``` | ||
| """) | ||
| get is ArmResourceRead<VirtualMachine>; | ||
|
|
||
| /** | ||
| * The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. | ||
| */ | ||
| @scenario | ||
| @scenarioDoc(""" | ||
| Test that a client can expose operations from multiple services. This operaton should be called like this: `client.virtualMachines.createOrUpdate(...)`. | ||
|
|
||
| PUT (create or update) a Virtual Machine. | ||
| Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/vm1 | ||
| Expected query parameter: api-version=2025-04-01 | ||
| Expected request body: | ||
| ```json | ||
| { | ||
| "location": "eastus", | ||
| "properties": {} | ||
| } | ||
| ``` | ||
| Expected response body: | ||
| ```json | ||
| { | ||
| "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/vm1", | ||
| "name": "vm1", | ||
| "type": "Microsoft.Compute/virtualMachines", | ||
| "location": "eastus", | ||
| "properties": { | ||
| "provisioningState": "Succeeded" | ||
| } | ||
| } | ||
| ``` | ||
| """) | ||
| createOrUpdate is ArmResourceCreateOrUpdateAsync<VirtualMachine>; | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add another case of selecting specific version of Compute/ComputeDisk?
I think this should be a supported scenario for compute service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3713