Skip to content

Commit

Permalink
[ai-metrics-advisor] Migrate to test proxy and temporarily disable te…
Browse files Browse the repository at this point in the history
…sts (Azure#26330)

### Packages impacted by this PR

`@azure/ai-metrics-advisor`

### Issues associated with this PR

Closes Azure#18001

### Describe the problem that is addressed by this PR

This PR migrates `ai-metrics-advisor` to the latest version of the test
recorder so we can fully deprecate the 1.0 version. Due to the tests not
currently passing in live (as they require static resources that are
difficult to maintain), the tests are disabled for now until we can
figure out how to address this issue prior to a future release.
  • Loading branch information
xirzec authored Jun 27, 2023
1 parent c979e82 commit 59fe745
Show file tree
Hide file tree
Showing 446 changed files with 190 additions and 28,694 deletions.
25 changes: 6 additions & 19 deletions sdk/metricsadvisor/ai-metrics-advisor/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 @@ -29,15 +26,13 @@ module.exports = function (config) {
"karma-coverage",
"karma-sourcemap-loader",
"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 @@ -46,7 +41,6 @@ module.exports = function (config) {
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"**/*.js": ["sourcemap", "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 Down Expand Up @@ -74,12 +68,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 @@ -102,11 +97,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 @@ -141,9 +131,6 @@ module.exports = function (config) {
browserNoActivityTimeout: 600000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 3,
browserConsoleLogOptions: {
terminal: !isRecordMode(),
},

client: {
mocha: {
Expand Down
17 changes: 10 additions & 7 deletions sdk/metricsadvisor/ai-metrics-advisor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,21 @@
"extract-api": "tsc -p . && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"generate:client": "autorest --typescript ./swagger/README.md",
"integration-test:browser": "karma start --single-run",
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace -t 300000 \"dist-esm/test/internal/*.spec.js\" \"dist-esm/test/public/*.spec.js\" \"dist-esm/test/public/node/*.spec.js\" \"dist-esm/test/internal/node/*.spec.js\"",
"integration-test:browser": "echo skipped",
"integration-test:browser:real": "dev-tool run test:browser",
"integration-test:node": "echo skipped",
"integration-test:node:real": "dev-tool run test:node-js-input -- --timeout 5000000 '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 README.md src test --ext .ts,.javascript,.js --fix --fix-type [problem,suggestion]",
"lint": "eslint package.json api-extractor.json README.md src test --ext .ts,.javascript,.js",
"pack": "npm pack 2>&1",
"test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
"test": "npm run build:test && npm run unit-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 120000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"",
"unit-test:browser": "echo skipped",
"unit-test:browser:real": "dev-tool run test:browser",
"unit-test:node": "echo skipped",
"unit-test:node:real": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
},
"sideEffects": false,
Expand All @@ -94,7 +98,8 @@
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/identity": "^2.0.1",
"@azure/test-utils": "^1.0.0",
"@azure-tools/test-recorder": "^1.0.0",
"@azure-tools/test-credential": "^1.0.0",
"@azure-tools/test-recorder": "^3.0.0",
"@microsoft/api-extractor": "^7.31.1",
"@types/chai": "^4.1.6",
"@types/mocha": "^7.0.2",
Expand All @@ -110,8 +115,6 @@
"karma-coverage": "^2.0.0",
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^1.1.0",
"karma-json-preprocessor": "^0.3.3",
"karma-json-to-file-reporter": "^1.0.1",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 59fe745

Please sign in to comment.