-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[App Config] Migrate the tests to use the new unified recorder #18896
Conversation
… harshan/issue/17042
… harshan/issue/17042
…u/azure-sdk-for-js into harshan/issue/17042
… harshan/issue/17042
… harshan/unified-recorder/migrate-app-config-way-2
// allow loading from a .env file as an alternative to defining the variable | ||
// in the environment |
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.
remove
// 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 |
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.
handle commented tests in this or a followup PR
/** | ||
* The HttpClient that will be used to send HTTP requests. | ||
*/ | ||
httpClient?: HttpClient; |
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.
API addition
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.
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; |
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.
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.
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.
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.
?
createAppConfigurationClientForTests(recorder.configureClientOptionsCoreV1({})) || | ||
this.skip(); |
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.
I'm a little confused by this || this.skip()
here. What is this for?
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.
This was retained from what was there before.
I can update it appropriately.
// syncTokens: syncTokens | ||
// }) || this.skip(); | ||
|
||
// nock.recorder.clear(); |
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.
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?
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.
Richard added those tests, I need to review them again to see if I should keep it or remove/update.
if (!(error instanceof Error)) { | ||
throw new Error("Error of unexpected kind is thrown"); | ||
} |
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.
In situations like this where you catch something you can't handle, IMO it's best to just re-throw it.
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()}`); |
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.
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?
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.
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)}`); |
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.
Didn't I see a getRandomNumber
function somewhere around?
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.
good point
const key = recorder.getUniqueName("noLabelTests"); | ||
|
||
recorder.variable("noLabelTests", `noLabelTests-${getRandomNumber()}`); | ||
key = recorder.variable("noLabelTests"); |
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.
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)}` |
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.
Is there something semantically different about this way of constructing a random and the getRandomNumber
function?
} | ||
} | ||
|
||
return { | ||
credential: new DefaultAzureCredential(), | ||
credential: createTestCredential(options), |
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.
How were we able to use DAC before, but were unable to use it in the implementation of createTestCredential
?
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.
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. |
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. |
[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
Follows #18817 and #19210 and migrates AppConfig tests to use the new unified recorder.