Skip to content
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

[Recorder] configureClientOptions method on the recorder #20175

Merged
merged 33 commits into from
Feb 8, 2022

Conversation

HarshaNalluru
Copy link
Member

@HarshaNalluru HarshaNalluru commented Feb 1, 2022

Packages impacted by this PR

Anyone who's using the new recorder or the perf framework

Issues associated with this PR

#16876 #19859
Fixes #16876

Describe the problem that is addressed by this PR

Now that #19920 - "additionalPolicies array in the client options" is merged, this PR adds 725c2d9 (configureClientOptions method) for both the perf framework and the recorder.
Listing all the changes below.

  • configureClientOptions added to PerfTest (perf framework) - "adds test proxy policy to the additionalPolicies array in the client options"
  • configureClientOptions added to Recorder (recorder framework) - "adds recorder policy to the additionalPolicies array in the client options"
  • configureClient removed from perf framework - "used to modify the pipeline object directly to add the policy"
  • configureClient removed from recorder framework - "used to modify the pipeline object directly to add the policy"
  • Bug fix in attestation
    • Fixed a bug where the client options are ignored when passed along with an AAD credential.
    • changelog
  • Updated recorder migration guide
  • Recorder changelog
  • Perf framework changelog
  • Perf framework guide update
  • Fixed a type issue in recorder for the configureClientOptionsCoreV1 and configureClientOptions methods
  • Updated the following packages to consume the above the recorder change
    • iot-device-update-rest
    • attestation
    • ai-document-translator-rest
    • schema-registry
    • search-documents
    • synapse-access-control-rest
    • synapse-artifacts
    • template
    • recorder/tests
    • testing-recorder-new
    • mixed-reality-remote-rendering
  • Updated the following perf projects to consume the above the perf framework change
    • data-tables
    • perf/tests

Recordings should ideally not be impacted by these changes and should work fine as before.

@HarshaNalluru HarshaNalluru changed the title Harshan/issue/16876 [Recorder] configureClientOptions method on the recorder Feb 4, 2022
@check-enforcer
Copy link

check-enforcer bot commented Feb 4, 2022

This pull request is protected by Check Enforcer.

What is Check Enforcer?

Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass.

Why am I getting this message?

You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged.

What should I do now?

If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

What if I am onboarding a new service?

Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment:
/azp run prepare-pipelines
This will run a pipeline that analyzes the source tree and creates the pipelines necessary to build and validate your pull request. Once the pipeline has been created you can trigger the pipeline using the following comment:
/azp run js - [service] - ci

@Azure Azure deleted a comment from azure-sdk Feb 4, 2022
@@ -197,15 +197,15 @@ describe("[AAD] Attestation Client", function () {
const binaryRuntimeData = base64url.decodeString(_runtimeData);
const client = createRecordedClient(recorder, endpointType);

{
// You can't specify both runtimeData and runtimeJson.
await expect(
Copy link
Member Author

@HarshaNalluru HarshaNalluru Feb 4, 2022

Choose a reason for hiding this comment

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

expect wasn't capturing somehow.
Maybe a breaking change or something, hence updated to assert instead.

Copy link
Member

@xirzec xirzec left a comment

Choose a reason for hiding this comment

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

The changes to the test contract look perfect!

Just had some minor feedback on how to clean up the issue in attestationClient.

} else if (clientOptions !== undefined) {
}

// If arg3 is defined, it has to be clientOptions and arg2 has to be a token credential
Copy link
Member

Choose a reason for hiding this comment

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

I think we can also ditch the initial assignment to options, since clientOptions has a default value that isn't undefined

I think we can simplify everything in this constructor to something like

if(credentialsOrOptions && isTokenCredential(credentialsOrOptions)) {
    credential = credentialsOrOptions;
    credentialScopes = ["https://attest.azure.net/.default"];
    options  = clientOptions;
} else {
    options = credentialsOrOptions;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

perfect, updated as suggested

Copy link
Member

@xirzec xirzec left a comment

Choose a reason for hiding this comment

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

Changes look great! Nice that we landed on a sensible public API for this

* Renamed `AttestationResponse.value` to `AttestationResponse.body` to align with
API guidelines.
- Renamed `AttestationResponse.value` to `AttestationResponse.body` to align with
API guidelines.
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, are these changes necessary?

Copy link
Member Author

@HarshaNalluru HarshaNalluru Feb 7, 2022

Choose a reason for hiding this comment

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

prettier did this.

Leveraging the new option, `configureClientOptions` method is added to the `Recorder`.
[#20175](https://github.com/Azure/azure-sdk-for-js/pull/20175)

With the support from the new `Recorder#configureClientOptions` method, we no longer need the `Recorder#configureClient` that used to access the private "pipeline" object internal to the client to add/modify the policies. [#20175](https://github.com/Azure/azure-sdk-for-js/pull/20175) removes the `Recorder#configureClient` along with the new addition.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. I don’t think this indentation applies.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated all the changelog related indentations

Copy link
Contributor

@sadasant sadasant left a comment

Choose a reason for hiding this comment

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

Looks good! — Make sure to get another approval as well 🙂

options = clientOptions;
} else {
options = credentialsOrOptions || {};
Copy link
Member

Choose a reason for hiding this comment

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

nit: You can use ?? here. Not a big deal but it is semantically clearer.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't want to kick off another 100 builds again. 🥲

I'll consider the change if I am making any other significant commit 🙂

Copy link
Member

@joheredi joheredi left a comment

Choose a reason for hiding this comment

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

Looks great!

Copy link
Member

@timovv timovv left a comment

Choose a reason for hiding this comment

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

Looks good!

sdk/test-utils/recorder/src/recorder.ts Show resolved Hide resolved
Copy link
Member

@jeremymeng jeremymeng left a comment

Choose a reason for hiding this comment

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

Looks good! One minor question

const client = new TableServiceClient(
assertEnvironmentVariable("TABLES_URL"),
credential,
recorder.configureClientOptions({})
Copy link
Member

Choose a reason for hiding this comment

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

nit: is it possible to also accept undefined? I am thinking of the case where I already have an options? of the original client options type and pass it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can do.
I didn't want to do that, just to force the users to pass something..
to not have any confusion when they actually want to pass options.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you feel strongly, I can allow undefined.

Copy link
Member

Choose a reason for hiding this comment

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

Either way is fine.

@HarshaNalluru HarshaNalluru merged commit c9dcb43 into Azure:main Feb 8, 2022
@HarshaNalluru HarshaNalluru deleted the harshan/issue/16876 branch February 8, 2022 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose httpClient for core-v1 and pipeline for core-v2 SDKs <-> Followup of #16518
6 participants