Skip to content

Commit

Permalink
[Monitor-Query] Update monitor-query to use new recorder (#20178)
Browse files Browse the repository at this point in the history
This 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](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/test-utils/recorder/MIGRATION.md).
  • Loading branch information
JonathanCrd authored Feb 14, 2022
1 parent a927a8b commit 39e4830
Show file tree
Hide file tree
Showing 33 changed files with 15,331 additions and 2,189 deletions.
25 changes: 6 additions & 19 deletions sdk/monitor/monitor-query/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
// https://github.com/karma-runner/karma-chrome-launcher
process.env.CHROME_BIN = require("puppeteer").executablePath();
require("dotenv").config();
const {
jsonRecordingFilterFunction,
isPlaybackMode,
isSoftRecordMode,
isRecordMode,
} = require("@azure-tools/test-recorder");
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");

process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();

module.exports = function (config) {
config.set({
Expand All @@ -30,15 +27,13 @@ module.exports = function (config) {
"karma-env-preprocessor",
"karma-coverage",
"karma-junit-reporter",
"karma-json-to-file-reporter",
"karma-json-preprocessor",
],

// list of files / patterns to load in the browser
files: [
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true },
].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []),
],

// list of files / patterns to exclude
exclude: [],
Expand All @@ -47,7 +42,6 @@ module.exports = function (config) {
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"**/*.js": ["env"],
"recordings/browsers/**/*.json": ["json"],
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
// Preprocess source file to calculate code coverage, however this will make source file unreadable
//"dist-test/index.browser.js": ["coverage"]
Expand All @@ -62,12 +56,13 @@ module.exports = function (config) {
"AZURE_CLIENT_ID",
"AZURE_CLIENT_SECRET",
"AZURE_TENANT_ID",
"RECORDINGS_RELATIVE_PATH",
],

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["mocha", "coverage", "junit", "json-to-file"],
reporters: ["mocha", "coverage", "junit"],

coverageReporter: {
// specify a common output directory
Expand All @@ -85,11 +80,6 @@ module.exports = function (config) {
properties: {}, // key value pair of properties to add to the <properties> section of the report
},

jsonToFileReporter: {
filter: jsonRecordingFilterFunction,
outputPath: ".",
},

// web server port
port: 9876,

Expand Down Expand Up @@ -124,9 +114,6 @@ module.exports = function (config) {
browserNoActivityTimeout: 600000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 3,
browserConsoleLogOptions: {
terminal: !isRecordMode(),
},

client: {
mocha: {
Expand Down
15 changes: 7 additions & 8 deletions sdk/monitor/monitor-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@
"generate:client:metrics": "autorest --typescript swagger/metrics.md",
"generate:client:metrics-namespaces": "autorest --typescript swagger/metric-namespaces.md",
"generate:client:metrics-definitions": "autorest --typescript swagger/metric-definitions.md",
"integration-test:browser": "karma start --single-run",
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --slow 5000 --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace \"dist-esm/test/{,!(browser)/**/}/*.spec.js\"",
"integration-test:browser": "dev-tool run test:browser",
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js' 'dist-esm/test/**/**/*.spec.js'",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint package.json api-extractor.json src test --format unix --ext .ts",
"pack": "npm pack 2>&1",
"test:browser": "npm run build:test && npm run integration-test:browser",
"test:node": "npm run build:test && npm run integration-test:node",
"test": "npm run build:test && npm run integration-test",
"unit-test:browser": "karma start --single-run",
"unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"",
"unit-test:browser": "dev-tool run test:browser",
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/**/*.spec.ts' 'test/**/**/*.spec.ts'",
"unit-test": "npm run build:test && npm run unit-test:node && npm run unit-test:browser"
},
"files": [
Expand Down Expand Up @@ -111,7 +111,7 @@
"@azure/identity": "^2.0.1",
"@azure/monitor-opentelemetry-exporter": "1.0.0-beta.4",
"@azure/test-utils": "^1.0.0",
"@azure-tools/test-recorder": "^1.0.0",
"@azure-tools/test-recorder": "^2.0.0",
"@microsoft/api-extractor": "^7.18.11",
"@opentelemetry/api": "^1.0.1",
"@opentelemetry/node": "^0.24.0",
Expand All @@ -134,8 +134,6 @@
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^1.1.0",
"karma-ie-launcher": "^1.0.0",
"karma-json-preprocessor": "^0.3.3",
"karma-json-to-file-reporter": "^1.0.1",
"karma-junit-reporter": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-mocha": "^2.0.1",
Expand All @@ -146,7 +144,8 @@
"prettier": "^2.5.1",
"rimraf": "^3.0.0",
"source-map-support": "^0.5.9",
"typescript": "~4.2.0"
"typescript": "~4.2.0",
"@azure-tools/test-credential": "^1.0.0"
},
"//sampleConfiguration": {
"skipFolder": false,
Expand Down
Loading

0 comments on commit 39e4830

Please sign in to comment.