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

[Monitor-Query] Update monitor-query to use new recorder #20178

Merged

Conversation

JonathanCrd
Copy link
Member

@JonathanCrd JonathanCrd commented Feb 1, 2022

Packages impacted by this PR

@azure/monitor-query

Issues associated with this PR

Describe the problem that is addressed by this PR

This PR migrate monitor query to use new recorder and discard any use of the old one. It also updates the recordings. For more information check out this migration guide.

Checklists

  • Added impacted package name to the issue description
  • Does this PR needs any fixes in the SDK Generator?** (If so, create an Issue in the Autorest/typescript repository and link it here)
  • Added a changelog (if necessary)

@JonathanCrd JonathanCrd self-assigned this Feb 1, 2022
@ghost ghost added the Monitor Monitor, Monitor Ingestion, Monitor Query label Feb 1, 2022
@JonathanCrd JonathanCrd changed the title [Monitor-Query] Migrate monitor query to new recorder [Monitor-Query] Update monitor-query to use new recorder Feb 11, 2022
@JonathanCrd JonathanCrd marked this pull request as ready for review February 11, 2022 19:20
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.

Thanks for doing this! Overall it's looking good, just had a couple small comments/questions :)

console.log(
`TODO: live tests skipped until test-resources + data population is set up (missing ${variableName} env var).`
);
mochaContext.skip();
// NOTE: This function should be throwing
Copy link
Member

Choose a reason for hiding this comment

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

Just wondering, what do you mean by this? If the function should throw we can use the assertEnvironmentVariable helper exposed by the recorder instead of defining this function.

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 a note that came out during a sync, I forgot to update the function to add a Throw new Error(... in case the environment variable is not defined (right now it is just skipping it).

Can you provide more info about the assertEnvironmentVariable helper and how it could be used?

Copy link
Member

Choose a reason for hiding this comment

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

We have an assertEnvironmentVariable function exported from the recorder package which either returns the value of the environment variable or throws an error if it's not set. Maybe you could use that instead of the helper that's here at the moment (and remove old the helper entirely).

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for the explanation, I also think that method can replace this function. So, since CI is green for this PR already and test are working, I'm going to file an issue with this suggestion, and see if this is the case for other packages.

sdk/monitor/monitor-query/test/public/shared/testShared.ts Outdated Show resolved Hide resolved
sdk/monitor/monitor-query/test/public/shared/testShared.ts Outdated Show resolved Hide resolved
.vscode/settings.json Outdated Show resolved Hide resolved
sdk/monitor/ci.yml Outdated Show resolved Hide resolved
} = require("@azure-tools/test-recorder");
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");

process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
Copy link
Member

Choose a reason for hiding this comment

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

A passing observation: this has absolutely nothing to do with your changes and you don't need to do anything about it, but it irks me slightly that the environment variable is RECORDINGS_RELATIVE_PATH ('recordings', then 'relative'), but the function is the other way around ('relative', then 'recordings').

sdk/monitor/monitor-query/test/public/shared/testShared.ts Outdated Show resolved Hide resolved
@HarshaNalluru
Copy link
Member

HarshaNalluru commented Feb 12, 2022

/azp run js - monitor-query - tests

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@HarshaNalluru HarshaNalluru left a comment

Choose a reason for hiding this comment

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

Looks like all the tests are not being run for @azure/monitor-query. 😢

New

[node-tests] 9 passing (389ms)
[node-tests] 2 pending

https://dev.azure.com/azure-sdk/public/_build/results?buildId=1363590&view=results

Old

25 passing (982ms)
2 pending
https://dev.azure.com/azure-sdk/public/_build/results?buildId=1360303&view=results

@JonathanCrd
Copy link
Member Author

Looks like all the tests are not being run for @azure/monitor-query. 😢

Update on this: Only windows is running the 25 tests. Investigating why the other OS are not running all the tests.

@@ -1,5 +0,0 @@
let nock = require('nock');

Copy link
Contributor

Choose a reason for hiding this comment

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

Any idea why is this file deleted? This comes from one of the tests right?

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 a generated file; it is no longer generated with the new recorder. File sdk/monitor/monitor-query/recordings/browsers/metricsclient_live_tests/recording_listnamespaces.json is being generated instead.

@JonathanCrd
Copy link
Member Author

Looks like all the tests are not being run for @azure/monitor-query. 😢

Fixed:
The reason why not all 25 tests were running on ubuntu/macOS was due to the structure of the test/ folder and the path specified on the packaje.json script:

test/
┣ internal/
┃ ┗ unit/
┃   ┣ logsQueryClient.unittest.spec.ts
┃   ┣ modelConverters.unittest.spec.ts
┃   ┗ utils.unittest.spec.ts
┣ public/
┃ ┣ shared/
┃ ┃ ┗ testShared.ts
┃ ┣ logsQueryClient.spec.ts
┃ ┗ metricsQueryClient.spec.ts
┗ setupOpenTelemetry.ts
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'"

As you can see, the internal/ directory has a unit/ folder inside, so the script was only specifying to run test in path 'test/**/*.spec.ts', and for Unix based OS this was not being done recursively.

💡To fix this, I added an extra path test/**/**/*.spec.ts', so it will reach the tests inside internal/unit/ all times.

Kudos to @joheredi for helping with this bug.👏 CC: @HarshaNalluru

@JonathanCrd
Copy link
Member Author

/azp run js - monitor-query - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

LGTM!

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 great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Monitor Monitor, Monitor Ingestion, Monitor Query
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants