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

[keyvault-keys] Browser support, with record and playback #4343

Merged
merged 19 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/keyvault/keyvault-keys/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignoring the core files since they're auto-generated. Eventually, the auto-generated code will be on par with our current eslint rules, but in the mean time we should ignore them.
src/core
128 changes: 128 additions & 0 deletions sdk/keyvault/keyvault-keys/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// https://github.com/karma-runner/karma-chrome-launcher
process.env.CHROME_BIN = require("puppeteer").executablePath();
require("dotenv").config({ path: "../.env" });

module.exports = function(config) {
config.set({
basePath: "./",
frameworks: ["mocha"],

plugins: [
"karma-mocha",
"karma-mocha-reporter",
"karma-chrome-launcher",
"karma-edge-launcher",
"karma-firefox-launcher",
"karma-ie-launcher",
"karma-env-preprocessor",
"karma-coverage",
"karma-remap-coverage",
"karma-junit-reporter",
"karma-json-to-file-reporter",
"karma-json-preprocessor"
],

files: [
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys
"https://cdn.polyfill.io/v2/polyfill.js?features=Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always",
"dist-test/index.browser.js",
"recordings/browsers/**/*.json"
],

exclude: [],

preprocessors: {
"**/*.js": ["env"],
"dist-test/index.browser.js": ["coverage"],
"recordings/browsers/**/*.json": ["json"]
},

envPreprocessor: [
"AZURE_CLIENT_ID",
"AZURE_CLIENT_SECRET",
"AZURE_TENANT_ID",
"KEYVAULT_NAME",
"TEST_MODE"
],

reporters: ["mocha", "coverage", "remap-coverage", "junit", "json-to-file"],

coverageReporter: { type: "in-memory" },

remapCoverageReporter: {
"text-summary": null,
html: "./coverage-browser",
cobertura: "./coverage-browser/cobertura-coverage.xml"
},

remapOptions: {
exclude: /node_modules|tests/g
},

junitReporter: {
outputDir: "",
outputFile: "test-results.browser.xml",
suite: "",
useBrowserName: false,
nameFormatter: undefined,
classNameFormatter: undefined,
properties: {}
},

jsonToFileReporter: {
filter: function(obj) {
if (obj.writeFile) {
const fs = require("fs-extra");
try {
// Stripping away the filename from the file path and retaining the directory structure
fs.ensureDirSync(obj.path.substring(0, obj.path.lastIndexOf("/") + 1));
} catch (err) {
if (err.code !== "EEXIST") throw err;
}
fs.writeFile(obj.path, JSON.stringify(obj.content, null, " "), (err) => {
if (err) {
throw err;
}
});
}
return false;
},
outputPath: "."
},

port: 9328,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,

// --no-sandbox allows our tests to run in Linux without having to change the system.
// --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex.
browsers: ["ChromeHeadlessNoSandbox"],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: "ChromeHeadless",
flags: ["--no-sandbox", "--disable-web-security"]
Copy link
Member

Choose a reason for hiding this comment

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

Why is this flag --no-sandbox required ?

Copy link
Contributor Author

@sadasant sadasant Jul 18, 2019

Choose a reason for hiding this comment

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

I haven't been able to make it work in my Linux machine without this.

Copy link
Member

@HarshaNalluru HarshaNalluru Jul 18, 2019

Choose a reason for hiding this comment

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

Is this the same situation for storage-queue for you?
I don't recall facing any such issues with storage packages when I executed the tests on my Ubuntu sometime before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is necessary for me on all libraries that use chrome headless 😅 I believe @daviwil knows an alternative, but I believe it changes the kernel or something.

}
},

singleRun: false,
concurrency: 1,

browserNoActivityTimeout: 600000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 3,
browserConsoleLogOptions: {
// IMPORTANT: COMMENT the following line if you want to print debug logs in your browsers in record mode!!
terminal: process.env.TEST_MODE !== "record"
},

client: {
mocha: {
// change Karma's debug.html to the mocha web reporter
reporter: "html",
timeout: "600000"
}
}
});
};
63 changes: 45 additions & 18 deletions sdk/keyvault/keyvault-keys/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,31 @@
"files": [
"LICENSE.txt",
"README.md",
"lib/",
"types/keyvault-keys.d.ts",
"dist/**/*.js",
"dist/**/*.js.map",
"dist/**/*.d.ts",
"dist/**/*.d.ts.map",
"dist-esm/**/*.js",
"dist-esm/**/*.js.map",
"dist-esm/**/*.d.ts",
"dist-esm/**/*.d.ts.map",
"src/**/*.ts",
"rollup.config.js",
"types/",
"dist/",
"dist-esm/",
"src/",
"tsconfig.json"
],
"browser": {
"./dist/index.js": "./browser/azure-keyvault-keys.min.js",
"os": false,
"process": false
},
"scripts": {
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
"build:minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js 2>&1",
"build:samples": "tsc samples/helloWorld.ts",
"build:test": "npm run build",
"build": "npm run extract-api && npm run build:samples && rollup -c rollup.config.js 2>&1",
"build:es6": "tsc -p tsconfig.json",
"build:nodebrowser": "rollup -c 2>&1",
"build:test": "npm run build:es6 && rollup -c rollup.test.config.js 2>&1",
"build": "npm run extract-api && npm run build:samples && npm run build:es6 && npm run build:nodebrowser",
"check-format": "prettier --list-different --config ../../.prettierrc.json \"src/**/*.ts\" \"tests/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist dist-esm test-dist types *.tgz *.log",
"clean": "rimraf dist dist-esm dist-test types *.tgz *.log browser statistics.html coverage && find src/ -type f -name '*.js' -exec rm {} + && find tests/ -type f -name '*.js' -exec rm {} +",
"extract-api": "tsc -p . && api-extractor run --local",
"format": "prettier --write --config ../../.prettierrc.json \"src/**/*.ts\" \"tests/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "echo skipped",
"integration-test:node": "ts-mocha -p tests/tsconfig.test.json tests/*.test.ts tests/**/*.test.ts --timeout 1200000 --reporter mocha-multi --reporter-options spec=-,mocha-junit-reporter=-",
"integration-test:browser": "karma start --single-run",
"integration-test:node": "nyc mocha --require source-map-support/register --reporter mocha-multi --timeout 1200000 --reporter-options spec=-,mocha-junit-reporter=- --full-trace dist-test/index.node.js",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint -c ../../.eslintrc.json src tests samples --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint -c ../../.eslintrc.json src tests samples --ext .ts -f node_modules/eslint-detailed-reporter/lib/detailed.js -o keyvault-keys-lintReport.html || exit 0",
Expand Down Expand Up @@ -81,10 +80,13 @@
"@types/dotenv": "^6.1.0",
"@types/fs-extra": "~7.0.0",
"@types/mocha": "^5.2.5",
"@types/nise": "^1.4.0",
"@types/nock": "^10.0.1",
"@types/node": "^8.0.0",
"@types/query-string": "6.2.0",
"@typescript-eslint/eslint-plugin": "^1.11.0",
"@typescript-eslint/parser": "^1.11.0",
"assert": "^1.4.1",
"chai": "^4.2.0",
"cross-env": "^5.2.0",
"dotenv": "^7.0.0",
Expand All @@ -95,14 +97,39 @@
"eslint-plugin-no-only-tests": "^2.3.0",
"eslint-plugin-promise": "^4.1.1",
"fs-extra": "~8.0.1",
"karma": "^4.0.1",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.2",
"karma-edge-launcher": "^0.4.2",
"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": "^1.2.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-coverage": "^0.1.5",
"mocha": "^5.2.0",
"mocha-junit-reporter": "^1.18.0",
"mocha-multi": "^1.0.1",
"nise": "^1.4.10",
"nock": "^10.0.6",
"nyc": "^14.0.0",
"prettier": "^1.16.4",
"puppeteer": "^1.11.0",
"query-string": "^5.0.0",
"rimraf": "^2.6.2",
"rollup": "^1.16.3",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-multi-entry": "^2.1.0",
"rollup-plugin-node-resolve": "^5.0.2",
"ts-mocha": "^6.0.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-shim": "^1.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-visualizer": "^2.0.0",
"source-map-support": "^0.5.9",
"typescript": "^3.2.2",
"uglify-js": "^3.4.9",
"url": "^0.11.0"
Expand Down
Loading