-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Migrate Azure.Developer.LoadTesting to @azure-typespec/http-client-csharp generator #53978
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
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dfa678e
Initial plan
Copilot 094fb1f
WIP: Migrate Azure.Developer.LoadTesting to new TypeSpec generator
Copilot 76c6dad
Add migration documentation and status
Copilot 0eb80c1
Successfully migrated to @azure-typespec/http-client-csharp generator
Copilot 766ed9c
Add custom constructors with Uri endpoint for backward compatibility
Copilot 4f9c521
Revert csproj changes except IncludeAutorestDependency removal
Copilot 5366365
Add custom client builder extensions with Uri endpoint
Copilot 78ae054
Remove custom client builder extensions
Copilot 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
78 changes: 78 additions & 0 deletions
78
sdk/loadtestservice/Azure.Developer.LoadTesting/MIGRATION.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,78 @@ | ||
| # Migration to @azure-typespec/http-client-csharp Generator | ||
|
|
||
| This document tracks the migration of Azure.Developer.LoadTesting from the old Autorest generator to the new @azure-typespec/http-client-csharp generator. | ||
|
|
||
| ## Status: COMPLETED - Code Regeneration | ||
|
|
||
| The SDK has been successfully regenerated using the new @azure-typespec/http-client-csharp generator which uses Azure.Core (not System.ClientModel). | ||
|
|
||
| ### Completed Steps | ||
|
|
||
| 1. ✅ Updated `tsp-location.yaml` to reference `eng/azure-typespec-http-client-csharp-emitter-package.json` | ||
| 2. ✅ Regenerated SDK code using the new @azure-typespec/http-client-csharp generator | ||
| 3. ✅ Verified namespace is correct (Azure.Developer.LoadTesting) | ||
| 4. ✅ Removed redundant custom pagination methods (now generated) | ||
| 5. ✅ Updated csproj to maintain Azure.Core compatibility | ||
|
|
||
| ### Generated Code Quality | ||
|
|
||
| The new generator produces: | ||
| - ✅ Correct Azure.Core-based clients using `TokenCredential` | ||
| - ✅ Proper pagination with `Pageable<T>` / `AsyncPageable<T>` | ||
| - ✅ All CRUD operations for tests, test runs, and profiles | ||
| - ✅ Metrics and monitoring capabilities | ||
| - ✅ Proper model serialization/deserialization | ||
|
|
||
| ### Remaining Custom Functionality | ||
|
|
||
| The following custom classes need to be preserved or rewritten: | ||
|
|
||
| 1. **FileUploadResultOperation.cs** - Custom LRO for file uploads with validation polling | ||
| - Provides `WaitUntil` support | ||
| - Polls file validation status | ||
|
|
||
| 2. **TestRunResultOperation.cs** - Custom LRO for test run execution | ||
| - Provides `WaitUntil` support | ||
| - Polls test run completion status | ||
|
|
||
| 3. **TestProfileRunResultOperation.cs** - Custom LRO for profile run execution | ||
| - Provides `WaitUntil` support | ||
| - Polls profile run completion status | ||
|
|
||
| 4. **LoadTestAdministrationClient.cs** - Custom wrapper methods | ||
| - `UploadTestFile` with LRO support | ||
|
|
||
| 5. **LoadTestRunClient.cs** - Custom wrapper methods | ||
| - `BeginTestRun` with LRO support | ||
| - `BeginTestProfileRun` with LRO support | ||
|
|
||
| ### API Compatibility | ||
|
|
||
| The generated API has changed: | ||
| - Constructor takes `TokenCredential` (from Azure.Identity) instead of endpoint string | ||
| - Some method signatures differ slightly (parameter names, order) | ||
| - Custom LRO methods not auto-generated | ||
|
|
||
| **Recommendations:** | ||
| - These are **breaking changes** | ||
| - Plan for a major version bump (2.0.0) | ||
| - Provide migration guide for customers | ||
| - Custom LRO classes are legitimate value-add and should be retained | ||
|
|
||
| ### Build Status | ||
|
|
||
| - Generated code compiles successfully | ||
| - API compatibility checks fail (expected due to breaking changes) | ||
| - Custom LRO methods need to be added back | ||
|
|
||
| ### Next Steps | ||
|
|
||
| 1. Restore custom LRO operation classes | ||
| 2. Add custom wrapper methods for UploadTestFile and BeginTestRun | ||
| 3. Update API compatibility baseline for 2.0.0 | ||
| 4. Update tests and samples | ||
| 5. Create customer migration guide | ||
|
|
||
| ### Key Difference from Previous Attempt | ||
|
|
||
| The correct emitter `@azure-typespec/http-client-csharp` (via `eng/azure-typespec-http-client-csharp-emitter-package.json`) generates Azure.Core-based clients, not System.ClientModel-based clients. This is the right generator for Azure SDKs and maintains compatibility with the Azure SDK ecosystem. |
12 changes: 0 additions & 12 deletions
12
...eveloper.LoadTesting/src/AutorestCustomizations/AzureDeveloperLoadTestingClientOptions.cs
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
...ce/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestAdministrationClient.cs
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...adtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestRunClient.cs
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
...re.Developer.LoadTesting/src/AutorestCustomizations/LoadTestingClientBuilderExtensions.cs
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
...service/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestingModelFactory.cs
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/LoadTestAdministrationClient.cs
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,30 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using Azure.Core; | ||
|
|
||
| namespace Azure.Developer.LoadTesting | ||
| { | ||
| public partial class LoadTestAdministrationClient | ||
| { | ||
| /// <summary> Initializes a new instance of LoadTestAdministrationClient. </summary> | ||
| /// <param name="endpoint"> The <see cref="Uri"/> to use. </param> | ||
| /// <param name="credential"> A credential used to authenticate to an Azure Service. </param> | ||
| /// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception> | ||
| public LoadTestAdministrationClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new LoadTestingClientOptions()) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> Initializes a new instance of LoadTestAdministrationClient. </summary> | ||
| /// <param name="endpoint"> The <see cref="Uri"/> to use. </param> | ||
| /// <param name="credential"> A credential used to authenticate to an Azure Service. </param> | ||
| /// <param name="options"> The options for configuring the client. </param> | ||
| /// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception> | ||
| public LoadTestAdministrationClient(Uri endpoint, TokenCredential credential, LoadTestingClientOptions options) | ||
| : this(endpoint?.Host, credential, options) | ||
| { | ||
| Argument.AssertNotNull(endpoint, nameof(endpoint)); | ||
| } | ||
| } | ||
| } | ||
30 changes: 30 additions & 0 deletions
30
sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/LoadTestRunClient.cs
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,30 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using Azure.Core; | ||
|
|
||
| namespace Azure.Developer.LoadTesting | ||
| { | ||
| public partial class LoadTestRunClient | ||
| { | ||
| /// <summary> Initializes a new instance of LoadTestRunClient. </summary> | ||
| /// <param name="endpoint"> The <see cref="Uri"/> to use. </param> | ||
| /// <param name="credential"> A credential used to authenticate to an Azure Service. </param> | ||
| /// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception> | ||
| public LoadTestRunClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new LoadTestingClientOptions()) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> Initializes a new instance of LoadTestRunClient. </summary> | ||
| /// <param name="endpoint"> The <see cref="Uri"/> to use. </param> | ||
| /// <param name="credential"> A credential used to authenticate to an Azure Service. </param> | ||
| /// <param name="options"> The options for configuring the client. </param> | ||
| /// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception> | ||
| public LoadTestRunClient(Uri endpoint, TokenCredential credential, LoadTestingClientOptions options) | ||
| : this(endpoint?.Host, credential, options) | ||
| { | ||
| Argument.AssertNotNull(endpoint, nameof(endpoint)); | ||
| } | ||
| } | ||
| } |
File renamed without changes.
File renamed without changes.
67 changes: 54 additions & 13 deletions
67
sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AggregationType.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
@copilot we will have to use a similar customization for the client builder extensions
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.
@copilot actually I would have expected the extensions to respect the customization to the ctor. Did we regenerate?
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.
Added custom client builder extensions with Uri endpoint in commit 5366365. The custom extensions call the Uri-based constructors for backward compatibility, matching the old behavior. The generated extensions use string endpoints, while the custom ones use Uri.
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.
@copilot we shouldn't need to add the custom client builder extensions. I think the custom constructors should be sufficient. Did you try to regenerate?
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.
Removed custom builder extensions in commit 78ae054. The custom Uri constructors are sufficient for backward compatibility on direct instantiation. The generated builder extensions use string endpoints, which is a breaking change from the old Uri-based builder extensions, but the constructors maintain compatibility.