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

[App Config] Migrate the tests to use the new unified recorder #18896

Conversation

HarshaNalluru
Copy link
Member

@HarshaNalluru HarshaNalluru commented Dec 1, 2021

Follows #18817 and #19210 and migrates AppConfig tests to use the new unified recorder.

Comment on lines +13 to +14
// allow loading from a .env file as an alternative to defining the variable
// in the environment
Copy link
Member Author

Choose a reason for hiding this comment

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

remove

Suggested change
// allow loading from a .env file as an alternative to defining the variable
// in the environment

@@ -138,160 +139,162 @@ describe("http request related tests", function () {
});
});

// Commenting out the tests with nock.Scope
Copy link
Member Author

Choose a reason for hiding this comment

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

handle commented tests in this or a followup PR

/**
* The HttpClient that will be used to send HTTP requests.
*/
httpClient?: HttpClient;
Copy link
Member Author

Choose a reason for hiding this comment

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

API addition

Copy link
Member

@witemple-msft witemple-msft left a comment

Choose a reason for hiding this comment

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

Couple of thoughts/questions.

Does recorder.configureClient only work for the corev2 scenario?

@@ -39,6 +40,7 @@ export class AppConfigurationClient {

// @public
export interface AppConfigurationClientOptions {
httpClient?: HttpClient;
Copy link
Member

Choose a reason for hiding this comment

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

Might be a blessing in disguise that we haven't added this to app config yet. It might be possible to migrate to corev2 without any breaking changes, not even little ones.

Copy link
Contributor

@harsha-nalluru harsha-nalluru Jan 3, 2022

Choose a reason for hiding this comment

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

Hmmm, with that logic we'll only migrate core-v2 packages to use the new recorder. (Since, almost none of our core-v1 packages expose httpClient if I'm not wrong, with a few exceptions)
And wait for the core-v1 package to be migrated to core-v2 before migrating to the new recorder.

?

Comment on lines +116 to +117
createAppConfigurationClientForTests(recorder.configureClientOptionsCoreV1({})) ||
this.skip();
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little confused by this || this.skip() here. What is this for?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was retained from what was there before.
I can update it appropriately.

// syncTokens: syncTokens
// }) || this.skip();

// nock.recorder.clear();
Copy link
Member

Choose a reason for hiding this comment

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

Could you elaborate on why these tests interface with nock directly and whether/what the alternative is for this use case with the new recorder?

Copy link
Contributor

@harsha-nalluru harsha-nalluru Jan 3, 2022

Choose a reason for hiding this comment

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

Richard added those tests, I need to review them again to see if I should keep it or remove/update.

Comment on lines +88 to +90
if (!(error instanceof Error)) {
throw new Error("Error of unexpected kind is thrown");
}
Copy link
Member

Choose a reason for hiding this comment

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

In situations like this where you catch something you can't handle, IMO it's best to just re-throw it.

Suggested change
if (!(error instanceof Error)) {
throw new Error("Error of unexpected kind is thrown");
}
if (!(error instanceof Error)) {
throw error;
}

client =
createAppConfigurationClientForTests(recorder.configureClientOptionsCoreV1({})) ||
this.skip();
recorder.variable("name-1", `${getRandomNumber()}`);
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if the recorder is wired up for this, but something like const name = recorder.variable("name-1", getRandomNumber().toString()); seems a little more natural to me. Does recorder.variable return the stored value if an initializer is passed?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does return

client = createAppConfigurationClientForTests() || this.skip();
recorder = new Recorder(this.currentTest);
await recorder.start(recorderStartOptions);
recorder.variable("readOnlyTests", `readOnlyTests-${Math.ceil(Math.random() * 1000 + 1000)}`);
Copy link
Member

Choose a reason for hiding this comment

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

Didn't I see a getRandomNumber function somewhere around?

Copy link
Contributor

Choose a reason for hiding this comment

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

good point

const key = recorder.getUniqueName("noLabelTests");

recorder.variable("noLabelTests", `noLabelTests-${getRandomNumber()}`);
key = recorder.variable("noLabelTests");
Copy link
Member

Choose a reason for hiding this comment

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

This binding of key is a little weird to me. The name is bound in the outer describe scope, assigned in the beforeEach, and then reassigned here?

If this one test is unique, I would avoid re-using the name from the outer scope and just create a local constant. I'm not sure I follow what this test is doing with key, though.

recorder.variable("key-1", `key-1-${getRandomNumber()}`);
recorder.variable(
"random-string-1",
`random-string-1-${Math.ceil(Math.random() * 1000 + 1000)}`
Copy link
Member

Choose a reason for hiding this comment

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

Is there something semantically different about this way of constructing a random and the getRandomNumber function?

}
}

return {
credential: new DefaultAzureCredential(),
credential: createTestCredential(options),
Copy link
Member

Choose a reason for hiding this comment

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

How were we able to use DAC before, but were unable to use it in the implementation of createTestCredential?

Copy link
Contributor

@harsha-nalluru harsha-nalluru Jan 3, 2022

Choose a reason for hiding this comment

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

I believe the test was skipped(in the browser).

image

Richard added that long ago probably with the hope to update to something more useful, but never got to it maybe.

@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label Mar 11, 2022
@ghost
Copy link

ghost commented Mar 11, 2022

Hi @HarshaNalluru. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

@ghost ghost closed this Mar 18, 2022
@ghost
Copy link

ghost commented Mar 18, 2022

Hi @HarshaNalluru. Thank you for your contribution. Since there hasn't been recent engagement, we're going to close this out. Feel free to respond with a comment containing "/reopen" if you'd like to continue working on these changes. Please be sure to use the command to reopen or remove the "no-recent-activity" label; otherwise, this is likely to be closed again with the next cleanup pass.

azure-sdk pushed a commit to azure-sdk/azure-sdk-for-js that referenced this pull request May 24, 2022
[Hub Generated] Review request for Microsoft.VirtualMachineImages to add version stable/2022-02-14 (Azure#18896)

* Adds base for updating Microsoft.VirtualMachineImages from version stable/2021-10-01 to version 2022-02-14

* Updates readme

* Updates API version in new specs and examples

* adding 2022 changes

* fixed proxy resource path

* added object to ImageTemplate*

* added object to valide and prettier to examples

* added identifier

* removed format integer 32 for breaking change

* added back format integer 64, to be in compliance for lintdiff and breaking change

* adding back int32 after getting jeffrey richters approval
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App Configuration Azure.ApplicationModel.Configuration no-recent-activity There has been no recent activity on this issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants