@datadog/datadog-ci 2.40.0 → 2.40.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/cli.test.d.ts +1 -0
- package/dist/__tests__/cli.test.js +41 -0
- package/dist/__tests__/cli.test.js.map +1 -0
- package/dist/commands/cloud-run/__tests__/fixtures.d.ts +2 -0
- package/dist/commands/cloud-run/__tests__/fixtures.js +12 -0
- package/dist/commands/cloud-run/__tests__/fixtures.js.map +1 -0
- package/dist/commands/cloud-run/__tests__/flare.test.d.ts +1 -0
- package/dist/commands/cloud-run/__tests__/flare.test.js +557 -0
- package/dist/commands/cloud-run/__tests__/flare.test.js.map +1 -0
- package/dist/commands/deployment/__tests__/mark.test.d.ts +1 -0
- package/dist/commands/deployment/__tests__/mark.test.js +47 -0
- package/dist/commands/deployment/__tests__/mark.test.js.map +1 -0
- package/dist/commands/dora/__tests__/deployment.test.d.ts +1 -0
- package/dist/commands/dora/__tests__/deployment.test.js +201 -0
- package/dist/commands/dora/__tests__/deployment.test.js.map +1 -0
- package/dist/commands/dsyms/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/dsyms/__tests__/upload.test.js +346 -0
- package/dist/commands/dsyms/__tests__/upload.test.js.map +1 -0
- package/dist/commands/dsyms/__tests__/utils.test.d.ts +1 -0
- package/dist/commands/dsyms/__tests__/utils.test.js +100 -0
- package/dist/commands/dsyms/__tests__/utils.test.js.map +1 -0
- package/dist/commands/dsyms/upload.js +3 -3
- package/dist/commands/dsyms/upload.js.map +1 -1
- package/dist/commands/dsyms/utils.js +4 -2
- package/dist/commands/dsyms/utils.js.map +1 -1
- package/dist/commands/elf-symbols/__tests__/elf.test.d.ts +1 -0
- package/dist/commands/elf-symbols/__tests__/elf.test.js +813 -0
- package/dist/commands/elf-symbols/__tests__/elf.test.js.map +1 -0
- package/dist/commands/elf-symbols/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/elf-symbols/__tests__/upload.test.js +249 -0
- package/dist/commands/elf-symbols/__tests__/upload.test.js.map +1 -0
- package/dist/commands/elf-symbols/upload.js +2 -3
- package/dist/commands/elf-symbols/upload.js.map +1 -1
- package/dist/commands/flutter-symbols/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/flutter-symbols/__tests__/upload.test.js +617 -0
- package/dist/commands/flutter-symbols/__tests__/upload.test.js.map +1 -0
- package/dist/commands/flutter-symbols/upload.js +2 -2
- package/dist/commands/flutter-symbols/upload.js.map +1 -1
- package/dist/commands/gate/__tests__/evaluate.test.d.ts +1 -0
- package/dist/commands/gate/__tests__/evaluate.test.js +398 -0
- package/dist/commands/gate/__tests__/evaluate.test.js.map +1 -0
- package/dist/commands/gate/__tests__/scope.test.d.ts +1 -0
- package/dist/commands/gate/__tests__/scope.test.js +29 -0
- package/dist/commands/gate/__tests__/scope.test.js.map +1 -0
- package/dist/commands/git-metadata/__tests__/git.test.d.ts +1 -0
- package/dist/commands/git-metadata/__tests__/git.test.js +132 -0
- package/dist/commands/git-metadata/__tests__/git.test.js.map +1 -0
- package/dist/commands/git-metadata/__tests__/gitdb.test.d.ts +1 -0
- package/dist/commands/git-metadata/__tests__/gitdb.test.js +1386 -0
- package/dist/commands/git-metadata/__tests__/gitdb.test.js.map +1 -0
- package/dist/commands/git-metadata/__tests__/library.test.d.ts +1 -0
- package/dist/commands/git-metadata/__tests__/library.test.js +118 -0
- package/dist/commands/git-metadata/__tests__/library.test.js.map +1 -0
- package/dist/commands/git-metadata/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/git-metadata/__tests__/upload.test.js +52 -0
- package/dist/commands/git-metadata/__tests__/upload.test.js.map +1 -0
- package/dist/commands/junit/__tests__/id.test.d.ts +1 -0
- package/dist/commands/junit/__tests__/id.test.js +24 -0
- package/dist/commands/junit/__tests__/id.test.js.map +1 -0
- package/dist/commands/junit/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/junit/__tests__/upload.test.js +495 -0
- package/dist/commands/junit/__tests__/upload.test.js.map +1 -0
- package/dist/commands/junit/upload.js +5 -3
- package/dist/commands/junit/upload.js.map +1 -1
- package/dist/commands/lambda/__tests__/fixtures.d.ts +51 -0
- package/dist/commands/lambda/__tests__/fixtures.js +146 -0
- package/dist/commands/lambda/__tests__/fixtures.js.map +1 -0
- package/dist/commands/lambda/__tests__/flare.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/flare.test.js +730 -0
- package/dist/commands/lambda/__tests__/flare.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/functions/commons.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/commons.test.js +791 -0
- package/dist/commands/lambda/__tests__/functions/commons.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part1.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js +386 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part2.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js +721 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +513 -0
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/functions/versionChecker.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/versionChecker.test.js +33 -0
- package/dist/commands/lambda/__tests__/functions/versionChecker.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/instrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/instrument.test.js +1511 -0
- package/dist/commands/lambda/__tests__/instrument.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/loggroup.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/loggroup.test.js +340 -0
- package/dist/commands/lambda/__tests__/loggroup.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/prompt.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/prompt.test.js +206 -0
- package/dist/commands/lambda/__tests__/prompt.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/tags.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/tags.test.js +305 -0
- package/dist/commands/lambda/__tests__/tags.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/uninstrument.test.js +722 -0
- package/dist/commands/lambda/__tests__/uninstrument.test.js.map +1 -0
- package/dist/commands/measure/__tests__/measure.test.d.ts +1 -0
- package/dist/commands/measure/__tests__/measure.test.js +110 -0
- package/dist/commands/measure/__tests__/measure.test.js.map +1 -0
- package/dist/commands/react-native/__tests__/codepush.test.d.ts +1 -0
- package/dist/commands/react-native/__tests__/codepush.test.js +161 -0
- package/dist/commands/react-native/__tests__/codepush.test.js.map +1 -0
- package/dist/commands/react-native/__tests__/interfaces.test.d.ts +1 -0
- package/dist/commands/react-native/__tests__/interfaces.test.js +33 -0
- package/dist/commands/react-native/__tests__/interfaces.test.js.map +1 -0
- package/dist/commands/react-native/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/react-native/__tests__/upload.test.js +238 -0
- package/dist/commands/react-native/__tests__/upload.test.js.map +1 -0
- package/dist/commands/react-native/__tests__/utils.test.d.ts +1 -0
- package/dist/commands/react-native/__tests__/utils.test.js +27 -0
- package/dist/commands/react-native/__tests__/utils.test.js.map +1 -0
- package/dist/commands/react-native/__tests__/xcode.test.d.ts +1 -0
- package/dist/commands/react-native/__tests__/xcode.test.js +465 -0
- package/dist/commands/react-native/__tests__/xcode.test.js.map +1 -0
- package/dist/commands/sarif/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/sarif/__tests__/upload.test.js +228 -0
- package/dist/commands/sarif/__tests__/upload.test.js.map +1 -0
- package/dist/commands/sarif/upload.js +2 -2
- package/dist/commands/sarif/upload.js.map +1 -1
- package/dist/commands/sbom/__tests__/payload.test.d.ts +1 -0
- package/dist/commands/sbom/__tests__/payload.test.js +262 -0
- package/dist/commands/sbom/__tests__/payload.test.js.map +1 -0
- package/dist/commands/sbom/__tests__/validation.test.d.ts +1 -0
- package/dist/commands/sbom/__tests__/validation.test.js +41 -0
- package/dist/commands/sbom/__tests__/validation.test.js.map +1 -0
- package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/sourcemaps/__tests__/upload.test.js +270 -0
- package/dist/commands/sourcemaps/__tests__/upload.test.js.map +1 -0
- package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +1 -0
- package/dist/commands/sourcemaps/__tests__/utils.test.js +31 -0
- package/dist/commands/sourcemaps/__tests__/utils.test.js.map +1 -0
- package/dist/commands/sourcemaps/upload.js +2 -2
- package/dist/commands/sourcemaps/upload.js.map +1 -1
- package/dist/commands/stepfunctions/__tests__/awsCommands.test.d.ts +1 -0
- package/dist/commands/stepfunctions/__tests__/awsCommands.test.js +192 -0
- package/dist/commands/stepfunctions/__tests__/awsCommands.test.js.map +1 -0
- package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.d.ts +6 -0
- package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js +45 -0
- package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js.map +1 -0
- package/dist/commands/stepfunctions/__tests__/fixtures/cli.d.ts +5 -0
- package/dist/commands/stepfunctions/__tests__/fixtures/cli.js +19 -0
- package/dist/commands/stepfunctions/__tests__/fixtures/cli.js.map +1 -0
- package/dist/commands/stepfunctions/__tests__/helpers.test.d.ts +1 -0
- package/dist/commands/stepfunctions/__tests__/helpers.test.js +205 -0
- package/dist/commands/stepfunctions/__tests__/helpers.test.js.map +1 -0
- package/dist/commands/stepfunctions/__tests__/instrument.test.d.ts +1 -0
- package/dist/commands/stepfunctions/__tests__/instrument.test.js +431 -0
- package/dist/commands/stepfunctions/__tests__/instrument.test.js.map +1 -0
- package/dist/commands/stepfunctions/__tests__/uninstrument.test.d.ts +1 -0
- package/dist/commands/stepfunctions/__tests__/uninstrument.test.js +166 -0
- package/dist/commands/stepfunctions/__tests__/uninstrument.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/api.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/api.test.js +422 -0
- package/dist/commands/synthetics/__tests__/api.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/cli.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/cli.test.js +1325 -0
- package/dist/commands/synthetics/__tests__/cli.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/fixtures.d.ts +149 -0
- package/dist/commands/synthetics/__tests__/fixtures.js +507 -0
- package/dist/commands/synthetics/__tests__/fixtures.js.map +1 -0
- package/dist/commands/synthetics/__tests__/mobile.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/mobile.test.js +376 -0
- package/dist/commands/synthetics/__tests__/mobile.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/reporters/default.test.js +354 -0
- package/dist/commands/synthetics/__tests__/reporters/default.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/reporters/junit.test.js +353 -0
- package/dist/commands/synthetics/__tests__/reporters/junit.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js +232 -0
- package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/run-tests-lib.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/run-tests-lib.test.js +735 -0
- package/dist/commands/synthetics/__tests__/run-tests-lib.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/test.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/test.test.js +33 -0
- package/dist/commands/synthetics/__tests__/test.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/tunnel/crypto.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js +21 -0
- package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js +80 -0
- package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/tunnel/websocket.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js +109 -0
- package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/utils/internal.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/utils/internal.test.js +186 -0
- package/dist/commands/synthetics/__tests__/utils/internal.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/utils/public.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/utils/public.test.js +1526 -0
- package/dist/commands/synthetics/__tests__/utils/public.test.js.map +1 -0
- package/dist/commands/synthetics/api.d.ts +1 -1
- package/dist/commands/synthetics/api.js +10 -5
- package/dist/commands/synthetics/api.js.map +1 -1
- package/dist/commands/synthetics/run-tests-command.d.ts +1 -0
- package/dist/commands/synthetics/run-tests-command.js +3 -2
- package/dist/commands/synthetics/run-tests-command.js.map +1 -1
- package/dist/commands/synthetics/run-tests-lib.js +0 -4
- package/dist/commands/synthetics/run-tests-lib.js.map +1 -1
- package/dist/commands/synthetics/test.js +9 -1
- package/dist/commands/synthetics/test.js.map +1 -1
- package/dist/commands/synthetics/utils/public.js +3 -3
- package/dist/commands/synthetics/utils/public.js.map +1 -1
- package/dist/commands/tag/__tests__/tag.test.d.ts +1 -0
- package/dist/commands/tag/__tests__/tag.test.js +75 -0
- package/dist/commands/tag/__tests__/tag.test.js.map +1 -0
- package/dist/commands/trace/__tests__/trace.test.d.ts +1 -0
- package/dist/commands/trace/__tests__/trace.test.js +145 -0
- package/dist/commands/trace/__tests__/trace.test.js.map +1 -0
- package/dist/commands/trace/trace.js +1 -1
- package/dist/commands/trace/trace.js.map +1 -1
- package/dist/commands/unity-symbols/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/unity-symbols/__tests__/upload.test.js +369 -0
- package/dist/commands/unity-symbols/__tests__/upload.test.js.map +1 -0
- package/dist/commands/unity-symbols/upload.js +2 -2
- package/dist/commands/unity-symbols/upload.js.map +1 -1
- package/dist/helpers/__tests__/app.test.d.ts +1 -0
- package/dist/helpers/__tests__/app.test.js +31 -0
- package/dist/helpers/__tests__/app.test.js.map +1 -0
- package/dist/helpers/__tests__/ci.test.d.ts +1 -0
- package/dist/helpers/__tests__/ci.test.js +252 -0
- package/dist/helpers/__tests__/ci.test.js.map +1 -0
- package/dist/helpers/__tests__/fixtures.d.ts +33 -0
- package/dist/helpers/__tests__/fixtures.js +71 -0
- package/dist/helpers/__tests__/fixtures.js.map +1 -0
- package/dist/helpers/__tests__/flare.test.d.ts +1 -0
- package/dist/helpers/__tests__/flare.test.js +226 -0
- package/dist/helpers/__tests__/flare.test.js.map +1 -0
- package/dist/helpers/__tests__/fs.test.d.ts +1 -0
- package/dist/helpers/__tests__/fs.test.js +189 -0
- package/dist/helpers/__tests__/fs.test.js.map +1 -0
- package/dist/helpers/__tests__/plist.test.d.ts +1 -0
- package/dist/helpers/__tests__/plist.test.js +43 -0
- package/dist/helpers/__tests__/plist.test.js.map +1 -0
- package/dist/helpers/__tests__/prompt.test.d.ts +1 -0
- package/dist/helpers/__tests__/prompt.test.js +71 -0
- package/dist/helpers/__tests__/prompt.test.js.map +1 -0
- package/dist/helpers/__tests__/retry.test.d.ts +1 -0
- package/dist/helpers/__tests__/retry.test.js +99 -0
- package/dist/helpers/__tests__/retry.test.js.map +1 -0
- package/dist/helpers/__tests__/tags.test.d.ts +1 -0
- package/dist/helpers/__tests__/tags.test.js +71 -0
- package/dist/helpers/__tests__/tags.test.js.map +1 -0
- package/dist/helpers/__tests__/upload.test.d.ts +1 -0
- package/dist/helpers/__tests__/upload.test.js +231 -0
- package/dist/helpers/__tests__/upload.test.js.map +1 -0
- package/dist/helpers/__tests__/user-provided-git.test.d.ts +1 -0
- package/dist/helpers/__tests__/user-provided-git.test.js +119 -0
- package/dist/helpers/__tests__/user-provided-git.test.js.map +1 -0
- package/dist/helpers/__tests__/utils.test.d.ts +1 -0
- package/dist/helpers/__tests__/utils.test.js +429 -0
- package/dist/helpers/__tests__/utils.test.js.map +1 -0
- package/dist/helpers/__tests__/validation.test.d.ts +1 -0
- package/dist/helpers/__tests__/validation.test.js +25 -0
- package/dist/helpers/__tests__/validation.test.js.map +1 -0
- package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.d.ts +1 -0
- package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js +103 -0
- package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js.map +1 -0
- package/dist/helpers/git/__tests__/format-git-span-data.test.d.ts +1 -0
- package/dist/helpers/git/__tests__/format-git-span-data.test.js +121 -0
- package/dist/helpers/git/__tests__/format-git-span-data.test.js.map +1 -0
- package/dist/helpers/git/__tests__/get-git-data.test.d.ts +1 -0
- package/dist/helpers/git/__tests__/get-git-data.test.js +72 -0
- package/dist/helpers/git/__tests__/get-git-data.test.js.map +1 -0
- package/package.json +4 -6
|
@@ -0,0 +1,1325 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
35
|
+
var t = {};
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
37
|
+
t[p] = s[p];
|
|
38
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
39
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
40
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
41
|
+
t[p[i]] = s[p[i]];
|
|
42
|
+
}
|
|
43
|
+
return t;
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
const advanced_1 = require("clipanion/lib/advanced");
|
|
47
|
+
const fixtures_1 = require("../../../helpers/__tests__/fixtures");
|
|
48
|
+
const ciUtils = __importStar(require("../../../helpers/utils"));
|
|
49
|
+
const api = __importStar(require("../api"));
|
|
50
|
+
const interfaces_1 = require("../interfaces");
|
|
51
|
+
const run_tests_command_1 = require("../run-tests-command");
|
|
52
|
+
const upload_application_command_1 = require("../upload-application-command");
|
|
53
|
+
const internal_1 = require("../utils/internal");
|
|
54
|
+
const utils = __importStar(require("../utils/public"));
|
|
55
|
+
const fixtures_2 = require("./fixtures");
|
|
56
|
+
test('all option flags are supported', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
const options = [
|
|
58
|
+
'apiKey',
|
|
59
|
+
'appKey',
|
|
60
|
+
'config',
|
|
61
|
+
'datadogSite',
|
|
62
|
+
'deviceIds',
|
|
63
|
+
'failOnCriticalErrors',
|
|
64
|
+
'failOnMissingTests',
|
|
65
|
+
'failOnTimeout',
|
|
66
|
+
'files',
|
|
67
|
+
'jUnitReport',
|
|
68
|
+
'mobileApplicationVersion',
|
|
69
|
+
'mobileApplicationVersionFilePath',
|
|
70
|
+
'public-id',
|
|
71
|
+
'runName',
|
|
72
|
+
'search',
|
|
73
|
+
'subdomain',
|
|
74
|
+
'tunnel',
|
|
75
|
+
'variable',
|
|
76
|
+
];
|
|
77
|
+
const cli = new advanced_1.Cli();
|
|
78
|
+
cli.register(run_tests_command_1.RunTestsCommand);
|
|
79
|
+
const usage = cli.usage(run_tests_command_1.RunTestsCommand);
|
|
80
|
+
options.forEach((option) => expect(usage).toContain(`--${option}`));
|
|
81
|
+
}));
|
|
82
|
+
describe('run-test', () => {
|
|
83
|
+
beforeEach(() => {
|
|
84
|
+
process.env = {};
|
|
85
|
+
jest.restoreAllMocks();
|
|
86
|
+
});
|
|
87
|
+
describe('resolveConfig', () => {
|
|
88
|
+
beforeEach(() => {
|
|
89
|
+
process.env = {};
|
|
90
|
+
});
|
|
91
|
+
test('override from ENV', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
var _a;
|
|
93
|
+
const overrideEnv = {
|
|
94
|
+
DATADOG_API_KEY: 'fake_api_key',
|
|
95
|
+
DATADOG_APP_KEY: 'fake_app_key',
|
|
96
|
+
DATADOG_SITE: 'datadoghq.eu',
|
|
97
|
+
DATADOG_SUBDOMAIN: 'custom',
|
|
98
|
+
DATADOG_SYNTHETICS_BATCH_TIMEOUT: '1',
|
|
99
|
+
DATADOG_SYNTHETICS_CONFIG_PATH: 'path/to/config.json',
|
|
100
|
+
DATADOG_SYNTHETICS_FAIL_ON_CRITICAL_ERRORS: 'false',
|
|
101
|
+
DATADOG_SYNTHETICS_FAIL_ON_MISSING_TESTS: 'false',
|
|
102
|
+
DATADOG_SYNTHETICS_FAIL_ON_TIMEOUT: 'false',
|
|
103
|
+
DATADOG_SYNTHETICS_FILES: 'test-file1;test-file2;test-file3',
|
|
104
|
+
DATADOG_SYNTHETICS_JUNIT_REPORT: 'junit-report.xml',
|
|
105
|
+
DATADOG_SYNTHETICS_PUBLIC_IDS: 'a-public-id;another-public-id',
|
|
106
|
+
DATADOG_SYNTHETICS_SELECTIVE_RERUN: 'true',
|
|
107
|
+
DATADOG_SYNTHETICS_TEST_SEARCH_QUERY: 'a-search-query',
|
|
108
|
+
DATADOG_SYNTHETICS_TUNNEL: 'false',
|
|
109
|
+
DATADOG_SYNTHETICS_OVERRIDE_ALLOW_INSECURE_CERTIFICATES: 'true',
|
|
110
|
+
DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_PASSWORD: 'password',
|
|
111
|
+
DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_USERNAME: 'username',
|
|
112
|
+
DATADOG_SYNTHETICS_OVERRIDE_BODY: 'body',
|
|
113
|
+
DATADOG_SYNTHETICS_OVERRIDE_BODY_TYPE: 'bodyType',
|
|
114
|
+
DATADOG_SYNTHETICS_OVERRIDE_COOKIES: 'cookie1;cookie2;cookie3',
|
|
115
|
+
DATADOG_SYNTHETICS_OVERRIDE_COOKIES_APPEND: 'true',
|
|
116
|
+
DATADOG_SYNTHETICS_OVERRIDE_DEFAULT_STEP_TIMEOUT: '42',
|
|
117
|
+
DATADOG_SYNTHETICS_OVERRIDE_DEVICE_IDS: 'chrome.laptop_large',
|
|
118
|
+
DATADOG_SYNTHETICS_OVERRIDE_EXECUTION_RULE: 'BLOCKING',
|
|
119
|
+
DATADOG_SYNTHETICS_OVERRIDE_FOLLOW_REDIRECTS: 'true',
|
|
120
|
+
DATADOG_SYNTHETICS_OVERRIDE_HEADERS: "{'Content-Type': 'application/json', 'Authorization': 'Bearer token'}",
|
|
121
|
+
// TODO SYNTH-12989: Clean up `locations` that should only be part of the testOverrides
|
|
122
|
+
DATADOG_SYNTHETICS_LOCATIONS: 'Wonderland;FarFarAway',
|
|
123
|
+
DATADOG_SYNTHETICS_OVERRIDE_LOCATIONS: 'us-east-1;us-west-1',
|
|
124
|
+
DATADOG_SYNTHETICS_OVERRIDE_MOBILE_APPLICATION_VERSION: '00000000-0000-0000-0000-000000000000',
|
|
125
|
+
DATADOG_SYNTHETICS_OVERRIDE_RESOURCE_URL_SUBSTITUTION_REGEXES: 'regex1;regex2',
|
|
126
|
+
DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT: '5',
|
|
127
|
+
DATADOG_SYNTHETICS_OVERRIDE_RETRY_INTERVAL: '100',
|
|
128
|
+
DATADOG_SYNTHETICS_OVERRIDE_START_URL: 'startUrl',
|
|
129
|
+
DATADOG_SYNTHETICS_OVERRIDE_START_URL_SUBSTITUTION_REGEX: 'startUrlSubstitutionRegex',
|
|
130
|
+
DATADOG_SYNTHETICS_OVERRIDE_TEST_TIMEOUT: '42',
|
|
131
|
+
DATADOG_SYNTHETICS_OVERRIDE_VARIABLES: "{'var1': 'value1', 'var2': 'value2'}",
|
|
132
|
+
};
|
|
133
|
+
process.env = overrideEnv;
|
|
134
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
|
|
135
|
+
yield command['resolveConfig']();
|
|
136
|
+
expect(command['config']).toEqual(Object.assign(Object.assign({}, run_tests_command_1.DEFAULT_COMMAND_CONFIG), { apiKey: overrideEnv.DATADOG_API_KEY, appKey: overrideEnv.DATADOG_APP_KEY, batchTimeout: 1, configPath: overrideEnv.DATADOG_SYNTHETICS_CONFIG_PATH, datadogSite: overrideEnv.DATADOG_SITE, defaultTestOverrides: {
|
|
137
|
+
allowInsecureCertificates: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_ALLOW_INSECURE_CERTIFICATES),
|
|
138
|
+
basicAuth: {
|
|
139
|
+
password: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_PASSWORD,
|
|
140
|
+
username: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_USERNAME,
|
|
141
|
+
},
|
|
142
|
+
body: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BODY,
|
|
143
|
+
bodyType: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BODY_TYPE,
|
|
144
|
+
cookies: {
|
|
145
|
+
value: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_COOKIES,
|
|
146
|
+
append: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_COOKIES_APPEND),
|
|
147
|
+
},
|
|
148
|
+
defaultStepTimeout: (0, internal_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_DEFAULT_STEP_TIMEOUT),
|
|
149
|
+
deviceIds: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_DEVICE_IDS.split(';'),
|
|
150
|
+
executionRule: (0, internal_1.toExecutionRule)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_EXECUTION_RULE),
|
|
151
|
+
followRedirects: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_FOLLOW_REDIRECTS),
|
|
152
|
+
headers: (0, internal_1.toStringMap)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_HEADERS),
|
|
153
|
+
locations: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_LOCATIONS.split(';'),
|
|
154
|
+
mobileApplicationVersion: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_MOBILE_APPLICATION_VERSION,
|
|
155
|
+
pollingTimeout: 1,
|
|
156
|
+
resourceUrlSubstitutionRegexes: (_a = overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_RESOURCE_URL_SUBSTITUTION_REGEXES) === null || _a === void 0 ? void 0 : _a.split(';'),
|
|
157
|
+
retry: {
|
|
158
|
+
count: (0, internal_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT),
|
|
159
|
+
interval: (0, internal_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_RETRY_INTERVAL),
|
|
160
|
+
},
|
|
161
|
+
startUrl: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_START_URL,
|
|
162
|
+
startUrlSubstitutionRegex: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_START_URL_SUBSTITUTION_REGEX,
|
|
163
|
+
testTimeout: (0, internal_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_TEST_TIMEOUT),
|
|
164
|
+
variables: (0, internal_1.toStringMap)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_VARIABLES),
|
|
165
|
+
}, failOnCriticalErrors: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_CRITICAL_ERRORS), failOnMissingTests: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_MISSING_TESTS), failOnTimeout: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_TIMEOUT), files: overrideEnv.DATADOG_SYNTHETICS_FILES.split(';'), jUnitReport: overrideEnv.DATADOG_SYNTHETICS_JUNIT_REPORT, pollingTimeout: 1, publicIds: overrideEnv.DATADOG_SYNTHETICS_PUBLIC_IDS.split(';'), selectiveRerun: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_SELECTIVE_RERUN), subdomain: overrideEnv.DATADOG_SUBDOMAIN, testSearchQuery: overrideEnv.DATADOG_SYNTHETICS_TEST_SEARCH_QUERY, tunnel: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_TUNNEL) }));
|
|
166
|
+
}));
|
|
167
|
+
test('partial retryConfig override from ENV retains existing values', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
168
|
+
const overrideEnv = {
|
|
169
|
+
DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT: '5',
|
|
170
|
+
};
|
|
171
|
+
process.env = overrideEnv;
|
|
172
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
|
|
173
|
+
command['config'].defaultTestOverrides = Object.assign(Object.assign({}, command['config'].defaultTestOverrides), { retry: {
|
|
174
|
+
count: 1,
|
|
175
|
+
interval: 42,
|
|
176
|
+
} });
|
|
177
|
+
yield command['resolveConfig']();
|
|
178
|
+
expect(command['config'].defaultTestOverrides.retry).toEqual({
|
|
179
|
+
count: 5,
|
|
180
|
+
interval: 42,
|
|
181
|
+
});
|
|
182
|
+
}));
|
|
183
|
+
test('override from config file', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
184
|
+
const expectedConfig = {
|
|
185
|
+
apiKey: 'fake_api_key',
|
|
186
|
+
appKey: 'fake_app_key',
|
|
187
|
+
batchTimeout: 1,
|
|
188
|
+
configPath: 'src/commands/synthetics/__tests__/config-fixtures/config-with-all-keys.json',
|
|
189
|
+
datadogSite: 'datadoghq.eu',
|
|
190
|
+
failOnCriticalErrors: true,
|
|
191
|
+
failOnMissingTests: true,
|
|
192
|
+
failOnTimeout: false,
|
|
193
|
+
files: ['my-new-file'],
|
|
194
|
+
jUnitReport: 'junit-report.xml',
|
|
195
|
+
// TODO SYNTH-12989: Clean up deprecated `global` in favor of `defaultTestOverrides`
|
|
196
|
+
global: {
|
|
197
|
+
allowInsecureCertificates: true,
|
|
198
|
+
basicAuth: { username: 'test', password: 'test' },
|
|
199
|
+
body: '{"fakeContent":true}',
|
|
200
|
+
bodyType: 'application/json',
|
|
201
|
+
cookies: {
|
|
202
|
+
value: 'name1=value1;name2=value2;',
|
|
203
|
+
append: true,
|
|
204
|
+
},
|
|
205
|
+
defaultStepTimeout: 10000,
|
|
206
|
+
deviceIds: ['chrome.laptop_large'],
|
|
207
|
+
executionRule: interfaces_1.ExecutionRule.BLOCKING,
|
|
208
|
+
followRedirects: true,
|
|
209
|
+
headers: { '<NEW_HEADER>': '<NEW_VALUE>' },
|
|
210
|
+
locations: ['aws:us-west-1'],
|
|
211
|
+
mobileApplicationVersion: '00000000-0000-0000-0000-000000000000',
|
|
212
|
+
mobileApplicationVersionFilePath: './path/to/application.apk',
|
|
213
|
+
pollingTimeout: 2,
|
|
214
|
+
retry: { count: 2, interval: 300 },
|
|
215
|
+
startUrl: '{{URL}}?static_hash={{STATIC_HASH}}',
|
|
216
|
+
startUrlSubstitutionRegex: 's/(https://www.)(.*)/$1extra-$2/',
|
|
217
|
+
testTimeout: 200000,
|
|
218
|
+
variables: { titleVariable: 'new value' },
|
|
219
|
+
},
|
|
220
|
+
defaultTestOverrides: {
|
|
221
|
+
allowInsecureCertificates: true,
|
|
222
|
+
basicAuth: { username: 'test', password: 'test' },
|
|
223
|
+
body: '{"fakeContent":true}',
|
|
224
|
+
bodyType: 'application/json',
|
|
225
|
+
cookies: {
|
|
226
|
+
value: 'name1=value1;name2=value2;',
|
|
227
|
+
append: true,
|
|
228
|
+
},
|
|
229
|
+
defaultStepTimeout: 10000,
|
|
230
|
+
deviceIds: ['chrome.laptop_large'],
|
|
231
|
+
executionRule: interfaces_1.ExecutionRule.BLOCKING,
|
|
232
|
+
followRedirects: true,
|
|
233
|
+
headers: { '<NEW_HEADER>': '<NEW_VALUE>' },
|
|
234
|
+
locations: ['aws:us-west-1'],
|
|
235
|
+
mobileApplicationVersion: '00000000-0000-0000-0000-000000000000',
|
|
236
|
+
mobileApplicationVersionFilePath: './path/to/application.apk',
|
|
237
|
+
pollingTimeout: 1,
|
|
238
|
+
retry: { count: 2, interval: 300 },
|
|
239
|
+
startUrl: '{{URL}}?static_hash={{STATIC_HASH}}',
|
|
240
|
+
startUrlSubstitutionRegex: 's/(https://www.)(.*)/$1extra-$2/',
|
|
241
|
+
testTimeout: 200000,
|
|
242
|
+
variables: { titleVariable: 'new value' },
|
|
243
|
+
},
|
|
244
|
+
// TODO SYNTH-12989: Clean up `locations` that should only be part of test overrides
|
|
245
|
+
locations: [],
|
|
246
|
+
// TODO SYNTH-12989: Clean up `pollingTimeout` in favor of `batchTimeout`
|
|
247
|
+
pollingTimeout: 1,
|
|
248
|
+
proxy: {
|
|
249
|
+
protocol: 'https',
|
|
250
|
+
},
|
|
251
|
+
publicIds: ['ran-dom-id1'],
|
|
252
|
+
selectiveRerun: true,
|
|
253
|
+
subdomain: 'ppa',
|
|
254
|
+
testSearchQuery: 'a-search-query',
|
|
255
|
+
tunnel: true,
|
|
256
|
+
// TODO SYNTH-12989: Clean up deprecated `variableStrings` in favor of `variables` in `defaultTestOverrides`.
|
|
257
|
+
variableStrings: [],
|
|
258
|
+
};
|
|
259
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
|
|
260
|
+
command.configPath = 'src/commands/synthetics/__tests__/config-fixtures/config-with-all-keys.json';
|
|
261
|
+
yield command['resolveConfig']();
|
|
262
|
+
expect(command['config']).toEqual(expectedConfig);
|
|
263
|
+
}));
|
|
264
|
+
test('override from CLI', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
265
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
266
|
+
// TODO SYNTH-12989: Clean up deprecated `global` in favor of `defaultTestOverrides`
|
|
267
|
+
const overrideCLI = {
|
|
268
|
+
apiKey: 'fake_api_key',
|
|
269
|
+
appKey: 'fake_app_key',
|
|
270
|
+
batchTimeout: 1,
|
|
271
|
+
configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file.json',
|
|
272
|
+
datadogSite: 'datadoghq.eu',
|
|
273
|
+
failOnCriticalErrors: true,
|
|
274
|
+
failOnMissingTests: true,
|
|
275
|
+
failOnTimeout: false,
|
|
276
|
+
files: ['new-file'],
|
|
277
|
+
jUnitReport: 'junit-report.xml',
|
|
278
|
+
mobileApplicationVersionFilePath: './path/to/application.apk',
|
|
279
|
+
pollingTimeout: 2,
|
|
280
|
+
publicIds: ['ran-dom-id2'],
|
|
281
|
+
selectiveRerun: true,
|
|
282
|
+
subdomain: 'new-sub-domain',
|
|
283
|
+
testSearchQuery: 'a-search-query',
|
|
284
|
+
tunnel: true,
|
|
285
|
+
// TODO SYNTH-12989: Clean up deprecated `variableStrings` in favor of `variables` in `defaultTestOverrides`.
|
|
286
|
+
variableStrings: ['var3=value3', 'var4=value4'],
|
|
287
|
+
};
|
|
288
|
+
/** Values passed to `--override`. */
|
|
289
|
+
const defaultTestOverrides = {
|
|
290
|
+
allowInsecureCertificates: true,
|
|
291
|
+
basicAuth: {
|
|
292
|
+
password: 'password',
|
|
293
|
+
username: 'username',
|
|
294
|
+
},
|
|
295
|
+
body: 'a body',
|
|
296
|
+
bodyType: 'bodyType',
|
|
297
|
+
cookies: 'name1=value1;name2=value2;',
|
|
298
|
+
defaultStepTimeout: 42,
|
|
299
|
+
deviceIds: ['chrome.laptop_large', 'chrome.laptop_small', 'firefox.laptop_large'],
|
|
300
|
+
executionRule: interfaces_1.ExecutionRule.BLOCKING,
|
|
301
|
+
followRedirects: true,
|
|
302
|
+
headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' },
|
|
303
|
+
locations: ['us-east-1', 'us-west-1'],
|
|
304
|
+
mobileApplicationVersion: '00000000-0000-0000-0000-000000000000',
|
|
305
|
+
// TODO SYNTH-12989: Clean up `pollingTimeout` from `defaultTestOverrides`
|
|
306
|
+
pollingTimeout: 3,
|
|
307
|
+
resourceUrlSubstitutionRegexes: [
|
|
308
|
+
's/(https://www.)(.*)/$1extra-$2',
|
|
309
|
+
'https://example.com(.*)|http://subdomain.example.com$1',
|
|
310
|
+
],
|
|
311
|
+
retry: {
|
|
312
|
+
count: 5,
|
|
313
|
+
interval: 42,
|
|
314
|
+
},
|
|
315
|
+
startUrl: 'startUrl',
|
|
316
|
+
startUrlSubstitutionRegex: 'startUrlSubstitutionRegex',
|
|
317
|
+
testTimeout: 42,
|
|
318
|
+
variables: { var1: 'value1', var2: 'value2' },
|
|
319
|
+
};
|
|
320
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
|
|
321
|
+
command['apiKey'] = overrideCLI.apiKey;
|
|
322
|
+
command['appKey'] = overrideCLI.appKey;
|
|
323
|
+
// `command['batchTimeout']` not used in the first test case
|
|
324
|
+
command['configPath'] = overrideCLI.configPath;
|
|
325
|
+
command['datadogSite'] = overrideCLI.datadogSite;
|
|
326
|
+
// TODO SYNTH-12989: Clean up deprecated `--deviceIds` in favor of `--override deviceIds="dev1;dev2;..."`
|
|
327
|
+
command['deviceIds'] = ['my-old-device'];
|
|
328
|
+
command['failOnCriticalErrors'] = overrideCLI.failOnCriticalErrors;
|
|
329
|
+
command['failOnMissingTests'] = overrideCLI.failOnMissingTests;
|
|
330
|
+
command['failOnTimeout'] = overrideCLI.failOnTimeout;
|
|
331
|
+
command['files'] = overrideCLI.files;
|
|
332
|
+
command['jUnitReport'] = overrideCLI.jUnitReport;
|
|
333
|
+
command['mobileApplicationVersion'] = defaultTestOverrides.mobileApplicationVersion;
|
|
334
|
+
command['mobileApplicationVersionFilePath'] = overrideCLI.mobileApplicationVersionFilePath;
|
|
335
|
+
// TODO SYNTH-12989: Clean up `pollingTimeout` in favor of `batchTimeout`
|
|
336
|
+
command['pollingTimeout'] = overrideCLI.pollingTimeout;
|
|
337
|
+
command['publicIds'] = overrideCLI.publicIds;
|
|
338
|
+
command['selectiveRerun'] = overrideCLI.selectiveRerun;
|
|
339
|
+
command['subdomain'] = overrideCLI.subdomain;
|
|
340
|
+
command['tunnel'] = overrideCLI.tunnel;
|
|
341
|
+
command['testSearchQuery'] = overrideCLI.testSearchQuery;
|
|
342
|
+
// TODO SYNTH-12989: Clean up deprecated `variableStrings` in favor of `variables` in `defaultTestOverrides`.
|
|
343
|
+
command['variableStrings'] = overrideCLI.variableStrings;
|
|
344
|
+
command['overrides'] = [
|
|
345
|
+
`allowInsecureCertificates=${defaultTestOverrides.allowInsecureCertificates}`,
|
|
346
|
+
`basicAuth.password=${(_b = defaultTestOverrides.basicAuth) === null || _b === void 0 ? void 0 : _b.password}`,
|
|
347
|
+
`basicAuth.username=${(_c = defaultTestOverrides.basicAuth) === null || _c === void 0 ? void 0 : _c.username}`,
|
|
348
|
+
`body=${defaultTestOverrides.body}`,
|
|
349
|
+
`bodyType=${defaultTestOverrides.bodyType}`,
|
|
350
|
+
`cookies=${defaultTestOverrides.cookies}`,
|
|
351
|
+
`cookies.append=true`,
|
|
352
|
+
`defaultStepTimeout=${defaultTestOverrides.defaultStepTimeout}`,
|
|
353
|
+
`deviceIds=${(_d = defaultTestOverrides.deviceIds) === null || _d === void 0 ? void 0 : _d.join(';')}`,
|
|
354
|
+
`executionRule=${defaultTestOverrides.executionRule}`,
|
|
355
|
+
`followRedirects=${defaultTestOverrides.followRedirects}`,
|
|
356
|
+
`headers.Content-Type=${defaultTestOverrides.headers ? defaultTestOverrides.headers['Content-Type'] : ''}`,
|
|
357
|
+
`headers.Authorization=${(_e = defaultTestOverrides.headers) === null || _e === void 0 ? void 0 : _e.Authorization}`,
|
|
358
|
+
`locations=${(_f = defaultTestOverrides.locations) === null || _f === void 0 ? void 0 : _f.join(';')}`,
|
|
359
|
+
// TODO SYNTH-12989: Clean up `pollingTimeout` in favor of `batchTimeout`
|
|
360
|
+
`pollingTimeout=${defaultTestOverrides.pollingTimeout}`,
|
|
361
|
+
`retry.count=${(_g = defaultTestOverrides.retry) === null || _g === void 0 ? void 0 : _g.count}`,
|
|
362
|
+
`retry.interval=${(_h = defaultTestOverrides.retry) === null || _h === void 0 ? void 0 : _h.interval}`,
|
|
363
|
+
`startUrl=${defaultTestOverrides.startUrl}`,
|
|
364
|
+
`startUrlSubstitutionRegex=${defaultTestOverrides.startUrlSubstitutionRegex}`,
|
|
365
|
+
`testTimeout=${defaultTestOverrides.testTimeout}`,
|
|
366
|
+
`resourceUrlSubstitutionRegexes=${(_j = defaultTestOverrides.resourceUrlSubstitutionRegexes) === null || _j === void 0 ? void 0 : _j.join(';')}`,
|
|
367
|
+
`variables.var1=${(_k = defaultTestOverrides.variables) === null || _k === void 0 ? void 0 : _k.var1}`,
|
|
368
|
+
`variables.var2=${(_l = defaultTestOverrides.variables) === null || _l === void 0 ? void 0 : _l.var2}`,
|
|
369
|
+
];
|
|
370
|
+
yield command['resolveConfig']();
|
|
371
|
+
expect(command['config']).toEqual(Object.assign(Object.assign({}, run_tests_command_1.DEFAULT_COMMAND_CONFIG), { apiKey: 'fake_api_key', appKey: 'fake_app_key', batchTimeout: 2, configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file.json', datadogSite: 'datadoghq.eu', failOnCriticalErrors: true, failOnMissingTests: true, failOnTimeout: false, files: ['new-file'], jUnitReport: 'junit-report.xml', defaultTestOverrides: {
|
|
372
|
+
allowInsecureCertificates: true,
|
|
373
|
+
basicAuth: {
|
|
374
|
+
password: 'password',
|
|
375
|
+
username: 'username',
|
|
376
|
+
},
|
|
377
|
+
body: 'a body',
|
|
378
|
+
bodyType: 'bodyType',
|
|
379
|
+
cookies: {
|
|
380
|
+
value: 'name1=value1;name2=value2;',
|
|
381
|
+
append: true,
|
|
382
|
+
},
|
|
383
|
+
defaultStepTimeout: 42,
|
|
384
|
+
deviceIds: ['chrome.laptop_large', 'chrome.laptop_small', 'firefox.laptop_large'],
|
|
385
|
+
executionRule: interfaces_1.ExecutionRule.BLOCKING,
|
|
386
|
+
followRedirects: true,
|
|
387
|
+
headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' },
|
|
388
|
+
locations: ['us-east-1', 'us-west-1'],
|
|
389
|
+
mobileApplicationVersion: '00000000-0000-0000-0000-000000000000',
|
|
390
|
+
mobileApplicationVersionFilePath: './path/to/application.apk',
|
|
391
|
+
// TODO SYNTH-12989: Clean up `pollingTimeout` from `defaultTestOverrides`
|
|
392
|
+
pollingTimeout: 2,
|
|
393
|
+
resourceUrlSubstitutionRegexes: [
|
|
394
|
+
's/(https://www.)(.*)/$1extra-$2',
|
|
395
|
+
'https://example.com(.*)|http://subdomain.example.com$1',
|
|
396
|
+
],
|
|
397
|
+
retry: {
|
|
398
|
+
count: 5,
|
|
399
|
+
interval: 42,
|
|
400
|
+
},
|
|
401
|
+
startUrl: 'startUrl',
|
|
402
|
+
startUrlSubstitutionRegex: 'startUrlSubstitutionRegex',
|
|
403
|
+
testTimeout: 42,
|
|
404
|
+
variables: { var1: 'value1', var2: 'value2' },
|
|
405
|
+
}, publicIds: ['ran-dom-id2'],
|
|
406
|
+
// TODO SYNTH-12989: Clean up `pollingTimeout` in favor of `batchTimeout`
|
|
407
|
+
pollingTimeout: 2, selectiveRerun: true, subdomain: 'new-sub-domain', testSearchQuery: 'a-search-query', tunnel: true }));
|
|
408
|
+
// TODO SYNTH-12989: Merge those 2 test cases when `pollingTimeout` is removed
|
|
409
|
+
command['batchTimeout'] = overrideCLI.batchTimeout; // when both are used, `batchTimeout` takes precedence
|
|
410
|
+
yield command['resolveConfig']();
|
|
411
|
+
expect(command['config']).toEqual(Object.assign(Object.assign({}, run_tests_command_1.DEFAULT_COMMAND_CONFIG), { apiKey: 'fake_api_key', appKey: 'fake_app_key', batchTimeout: 1, configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file.json', datadogSite: 'datadoghq.eu', failOnCriticalErrors: true, failOnMissingTests: true, failOnTimeout: false, files: ['new-file'], jUnitReport: 'junit-report.xml', defaultTestOverrides: {
|
|
412
|
+
allowInsecureCertificates: true,
|
|
413
|
+
basicAuth: {
|
|
414
|
+
password: 'password',
|
|
415
|
+
username: 'username',
|
|
416
|
+
},
|
|
417
|
+
body: 'a body',
|
|
418
|
+
bodyType: 'bodyType',
|
|
419
|
+
cookies: {
|
|
420
|
+
value: 'name1=value1;name2=value2;',
|
|
421
|
+
append: true,
|
|
422
|
+
},
|
|
423
|
+
defaultStepTimeout: 42,
|
|
424
|
+
deviceIds: ['chrome.laptop_large', 'chrome.laptop_small', 'firefox.laptop_large'],
|
|
425
|
+
executionRule: interfaces_1.ExecutionRule.BLOCKING,
|
|
426
|
+
followRedirects: true,
|
|
427
|
+
headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' },
|
|
428
|
+
locations: ['us-east-1', 'us-west-1'],
|
|
429
|
+
mobileApplicationVersion: '00000000-0000-0000-0000-000000000000',
|
|
430
|
+
mobileApplicationVersionFilePath: './path/to/application.apk',
|
|
431
|
+
// TODO SYNTH-12989: Clean up `pollingTimeout` from `defaultTestOverrides`
|
|
432
|
+
pollingTimeout: 1,
|
|
433
|
+
resourceUrlSubstitutionRegexes: [
|
|
434
|
+
's/(https://www.)(.*)/$1extra-$2',
|
|
435
|
+
'https://example.com(.*)|http://subdomain.example.com$1',
|
|
436
|
+
],
|
|
437
|
+
retry: {
|
|
438
|
+
count: 5,
|
|
439
|
+
interval: 42,
|
|
440
|
+
},
|
|
441
|
+
startUrl: 'startUrl',
|
|
442
|
+
startUrlSubstitutionRegex: 'startUrlSubstitutionRegex',
|
|
443
|
+
testTimeout: 42,
|
|
444
|
+
variables: {
|
|
445
|
+
var1: 'value1',
|
|
446
|
+
var2: 'value2',
|
|
447
|
+
},
|
|
448
|
+
}, publicIds: ['ran-dom-id2'], pollingTimeout: 1, selectiveRerun: true, subdomain: 'new-sub-domain', testSearchQuery: 'a-search-query', tunnel: true }));
|
|
449
|
+
}));
|
|
450
|
+
// TODO SYNTH-12989: Clean up deprecated `--deviceIds` in favor of `--override deviceIds="dev1;dev2;..."`
|
|
451
|
+
test("CLI parameter '--deviceIds' still works (deprecated)", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
452
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
|
|
453
|
+
command['deviceIds'] = ['dev1', 'dev2'];
|
|
454
|
+
yield command['resolveConfig']();
|
|
455
|
+
expect(command['config']).toEqual(Object.assign(Object.assign({}, run_tests_command_1.DEFAULT_COMMAND_CONFIG), { defaultTestOverrides: {
|
|
456
|
+
pollingTimeout: run_tests_command_1.DEFAULT_POLLING_TIMEOUT,
|
|
457
|
+
deviceIds: ['dev1', 'dev2'],
|
|
458
|
+
} }));
|
|
459
|
+
}));
|
|
460
|
+
// TODO SYNTH-12989: Clean up deprecated `variableStrings` in favor of `variables` in `defaultTestOverrides`.
|
|
461
|
+
test("CLI parameter '--variable' still works (deprecated)", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
462
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
|
|
463
|
+
command['variableStrings'] = ['var1=value1', 'var2=value2'];
|
|
464
|
+
yield command['resolveConfig']();
|
|
465
|
+
expect(command['config']).toEqual(Object.assign(Object.assign({}, run_tests_command_1.DEFAULT_COMMAND_CONFIG), { defaultTestOverrides: {
|
|
466
|
+
pollingTimeout: run_tests_command_1.DEFAULT_POLLING_TIMEOUT,
|
|
467
|
+
variables: { var1: 'value1', var2: 'value2' },
|
|
468
|
+
} }));
|
|
469
|
+
}));
|
|
470
|
+
test("Root config file 'pollingTimeout' still works (deprecated)", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
471
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
|
|
472
|
+
command.configPath = 'src/commands/synthetics/__tests__/config-fixtures/config-with-global-polling-timeout.json';
|
|
473
|
+
yield command['resolveConfig']();
|
|
474
|
+
expect(command['config']).toEqual(Object.assign(Object.assign({}, run_tests_command_1.DEFAULT_COMMAND_CONFIG), { batchTimeout: 333, configPath: 'src/commands/synthetics/__tests__/config-fixtures/config-with-global-polling-timeout.json',
|
|
475
|
+
// TODO SYNTH-12989: Clean up deprecated `global` in favor of `defaultTestOverrides`
|
|
476
|
+
global: { followRedirects: false }, defaultTestOverrides: { followRedirects: false, pollingTimeout: 333 }, pollingTimeout: 333 }));
|
|
477
|
+
}));
|
|
478
|
+
// We have 2 code paths that handle different levels of configuration overrides:
|
|
479
|
+
// 1) config file (configuration of datadog-ci) < ENV (environment variables) < CLI (command flags)
|
|
480
|
+
// 2) global (global config object, aka. `config.global`) < ENV (environment variables) < test file (test configuration)
|
|
481
|
+
//
|
|
482
|
+
// First, 1) configures datadog-ci itself and `config.global`,
|
|
483
|
+
// Then, 2) configures the Synthetic tests to execute.
|
|
484
|
+
//
|
|
485
|
+
// So the bigger picture is:
|
|
486
|
+
//
|
|
487
|
+
// (config file < ENV < CLI < test file) => execute tests
|
|
488
|
+
describe('override precedence - config file < ENV < CLI < test file', () => {
|
|
489
|
+
const configFile = {
|
|
490
|
+
apiKey: 'config_file_api_key',
|
|
491
|
+
appKey: 'config_file_app_key',
|
|
492
|
+
datadogSite: 'us3.datadoghq.com',
|
|
493
|
+
failOnCriticalErrors: false,
|
|
494
|
+
failOnMissingTests: false,
|
|
495
|
+
failOnTimeout: false,
|
|
496
|
+
files: ['from_config_file.json'],
|
|
497
|
+
// TODO SYNTH-12989: Clean up deprecated `global` in favor of `defaultTestOverrides`
|
|
498
|
+
global: {},
|
|
499
|
+
defaultTestOverrides: {
|
|
500
|
+
allowInsecureCertificates: true,
|
|
501
|
+
basicAuth: {
|
|
502
|
+
username: 'config-file-username',
|
|
503
|
+
password: 'config-file-password',
|
|
504
|
+
},
|
|
505
|
+
body: '{"fakeContentFromConfigFile":true}',
|
|
506
|
+
bodyType: 'application/json-from-config-file',
|
|
507
|
+
cookies: {
|
|
508
|
+
value: 'cookie1-from-config-file=cookie1-value;cookie2-from-config-file=cookie2-value;',
|
|
509
|
+
append: true,
|
|
510
|
+
},
|
|
511
|
+
defaultStepTimeout: 10000,
|
|
512
|
+
deviceIds: ['chrome.laptop_large_from_config_file', 'chrome.laptop_small_from_config_file'],
|
|
513
|
+
executionRule: interfaces_1.ExecutionRule.BLOCKING,
|
|
514
|
+
followRedirects: true,
|
|
515
|
+
headers: { 'Config-File': 'This is a mess' },
|
|
516
|
+
mobileApplicationVersion: '00000000-0000-0000-0000-000000000000-config-file',
|
|
517
|
+
mobileApplicationVersionFilePath: './path/to/application-from-config-file.apk',
|
|
518
|
+
pollingTimeout: 2,
|
|
519
|
+
retry: { count: 2, interval: 300 },
|
|
520
|
+
resourceUrlSubstitutionRegexes: ['regex1-from-config-file', 'regex2-from-config-file'],
|
|
521
|
+
startUrl: '{{URL}}?static_hash={{STATIC_HASH}}',
|
|
522
|
+
startUrlSubstitutionRegex: 's/(https://www.)(.*)/$1extra-$2/',
|
|
523
|
+
testTimeout: 200000,
|
|
524
|
+
variables: { titleVariable: 'config file value' },
|
|
525
|
+
},
|
|
526
|
+
jUnitReport: 'junit-report-from-config-file.xml',
|
|
527
|
+
// TODO SYNTH-12989: Clean up `locations` that should only be part of the testOverrides
|
|
528
|
+
locations: ['location_1_from_config_file', 'location_2_from_config_file'],
|
|
529
|
+
pollingTimeout: run_tests_command_1.DEFAULT_POLLING_TIMEOUT,
|
|
530
|
+
proxy: { protocol: 'http' },
|
|
531
|
+
publicIds: ['public-id-from-config-file'],
|
|
532
|
+
selectiveRerun: false,
|
|
533
|
+
subdomain: 'subdomain_from_config_file',
|
|
534
|
+
testSearchQuery: 'a-search-query-from-config-file',
|
|
535
|
+
tunnel: false,
|
|
536
|
+
// TODO SYNTH-12989: Clean up deprecated `variableStrings` in favor of `variables` in `defaultTestOverrides`.
|
|
537
|
+
variableStrings: ['configVar1=configValue1', 'configVar2=configValue2'],
|
|
538
|
+
};
|
|
539
|
+
test('config file < ENV', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
540
|
+
var _a, _b, _c;
|
|
541
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementationOnce((baseConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
542
|
+
return (Object.assign(Object.assign({}, baseConfig), configFile));
|
|
543
|
+
}));
|
|
544
|
+
const overrideEnv = {
|
|
545
|
+
DATADOG_API_KEY: 'env_api_key',
|
|
546
|
+
DATADOG_APP_KEY: 'env_app_key',
|
|
547
|
+
DATADOG_SITE: 'us5.datadoghq.com',
|
|
548
|
+
DATADOG_SUBDOMAIN: 'subdomain_from_env',
|
|
549
|
+
DATADOG_SYNTHETICS_BATCH_TIMEOUT: '1',
|
|
550
|
+
DATADOG_SYNTHETICS_CONFIG_PATH: 'path/to/config_from_env.json',
|
|
551
|
+
DATADOG_SYNTHETICS_FAIL_ON_CRITICAL_ERRORS: 'true',
|
|
552
|
+
DATADOG_SYNTHETICS_FAIL_ON_MISSING_TESTS: 'true',
|
|
553
|
+
DATADOG_SYNTHETICS_FAIL_ON_TIMEOUT: 'true',
|
|
554
|
+
DATADOG_SYNTHETICS_FILES: '1_from_env.json;2_from_env.json',
|
|
555
|
+
DATADOG_SYNTHETICS_JUNIT_REPORT: 'junit-report-from-env.xml',
|
|
556
|
+
DATADOG_SYNTHETICS_PUBLIC_IDS: 'a-public-id-from-env;another-public-id-from-env',
|
|
557
|
+
DATADOG_SYNTHETICS_SELECTIVE_RERUN: 'true',
|
|
558
|
+
DATADOG_SYNTHETICS_TEST_SEARCH_QUERY: 'a-search-query-from-env',
|
|
559
|
+
DATADOG_SYNTHETICS_TUNNEL: 'true',
|
|
560
|
+
DATADOG_SYNTHETICS_OVERRIDE_ALLOW_INSECURE_CERTIFICATES: 'true',
|
|
561
|
+
DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_PASSWORD: 'password-from-env',
|
|
562
|
+
DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_USERNAME: 'username-from-env',
|
|
563
|
+
DATADOG_SYNTHETICS_OVERRIDE_BODY: 'body-from-env',
|
|
564
|
+
DATADOG_SYNTHETICS_OVERRIDE_BODY_TYPE: 'bodyType-from-env',
|
|
565
|
+
DATADOG_SYNTHETICS_OVERRIDE_COOKIES: 'cookie1-from-env;cookie2-from-env;cookie3-from-env',
|
|
566
|
+
DATADOG_SYNTHETICS_OVERRIDE_COOKIES_APPEND: 'true',
|
|
567
|
+
DATADOG_SYNTHETICS_OVERRIDE_DEFAULT_STEP_TIMEOUT: '42',
|
|
568
|
+
DATADOG_SYNTHETICS_OVERRIDE_DEVICE_IDS: 'chrome.laptop_large_from_env',
|
|
569
|
+
DATADOG_SYNTHETICS_OVERRIDE_EXECUTION_RULE: 'NON_BLOCKING',
|
|
570
|
+
DATADOG_SYNTHETICS_OVERRIDE_FOLLOW_REDIRECTS: 'false',
|
|
571
|
+
DATADOG_SYNTHETICS_OVERRIDE_HEADERS: "{'Content-Type': 'application/json', 'Authorization': 'Bearer token from env'}",
|
|
572
|
+
// TODO SYNTH-12989: Clean up `locations` that should only be part of the testOverrides
|
|
573
|
+
DATADOG_SYNTHETICS_LOCATIONS: 'Wonderland;FarFarAway',
|
|
574
|
+
DATADOG_SYNTHETICS_OVERRIDE_LOCATIONS: 'location_1_from_env;location_2_from_env',
|
|
575
|
+
DATADOG_SYNTHETICS_OVERRIDE_MOBILE_APPLICATION_VERSION: '00000000-0000-0000-0000-000000000000',
|
|
576
|
+
DATADOG_SYNTHETICS_OVERRIDE_RESOURCE_URL_SUBSTITUTION_REGEXES: 'regex1-from-env;regex2-from-env',
|
|
577
|
+
DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT: '5',
|
|
578
|
+
DATADOG_SYNTHETICS_OVERRIDE_RETRY_INTERVAL: '100',
|
|
579
|
+
DATADOG_SYNTHETICS_OVERRIDE_START_URL: 'startUrl',
|
|
580
|
+
DATADOG_SYNTHETICS_OVERRIDE_START_URL_SUBSTITUTION_REGEX: 'startUrlSubstitutionRegex',
|
|
581
|
+
DATADOG_SYNTHETICS_OVERRIDE_TEST_TIMEOUT: '42',
|
|
582
|
+
DATADOG_SYNTHETICS_OVERRIDE_VARIABLES: "{'var1': 'value1', 'var2': 'value2'}",
|
|
583
|
+
};
|
|
584
|
+
const expectedEnvOverrideResult = {
|
|
585
|
+
apiKey: overrideEnv.DATADOG_API_KEY,
|
|
586
|
+
appKey: overrideEnv.DATADOG_APP_KEY,
|
|
587
|
+
batchTimeout: (0, internal_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_BATCH_TIMEOUT),
|
|
588
|
+
configPath: overrideEnv.DATADOG_SYNTHETICS_CONFIG_PATH,
|
|
589
|
+
datadogSite: overrideEnv.DATADOG_SITE,
|
|
590
|
+
defaultTestOverrides: {
|
|
591
|
+
allowInsecureCertificates: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_ALLOW_INSECURE_CERTIFICATES),
|
|
592
|
+
basicAuth: {
|
|
593
|
+
password: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_PASSWORD,
|
|
594
|
+
username: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_USERNAME,
|
|
595
|
+
},
|
|
596
|
+
body: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BODY,
|
|
597
|
+
bodyType: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BODY_TYPE,
|
|
598
|
+
cookies: {
|
|
599
|
+
value: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_COOKIES,
|
|
600
|
+
append: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_COOKIES_APPEND),
|
|
601
|
+
},
|
|
602
|
+
defaultStepTimeout: (0, internal_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_DEFAULT_STEP_TIMEOUT),
|
|
603
|
+
deviceIds: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_DEVICE_IDS.split(';'),
|
|
604
|
+
executionRule: (0, internal_1.toExecutionRule)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_EXECUTION_RULE),
|
|
605
|
+
followRedirects: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_FOLLOW_REDIRECTS),
|
|
606
|
+
headers: (0, internal_1.toStringMap)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_HEADERS),
|
|
607
|
+
// TODO SYNTH-12989: Clean up `locations` that should only be part of the testOverrides
|
|
608
|
+
locations: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_LOCATIONS.split(';'),
|
|
609
|
+
mobileApplicationVersion: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_MOBILE_APPLICATION_VERSION,
|
|
610
|
+
pollingTimeout: (0, internal_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_BATCH_TIMEOUT),
|
|
611
|
+
resourceUrlSubstitutionRegexes: (_a = overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_RESOURCE_URL_SUBSTITUTION_REGEXES) === null || _a === void 0 ? void 0 : _a.split(';'),
|
|
612
|
+
retry: {
|
|
613
|
+
count: (0, internal_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT),
|
|
614
|
+
interval: (0, internal_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_RETRY_INTERVAL),
|
|
615
|
+
},
|
|
616
|
+
startUrl: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_START_URL,
|
|
617
|
+
startUrlSubstitutionRegex: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_START_URL_SUBSTITUTION_REGEX,
|
|
618
|
+
testTimeout: (0, internal_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_TEST_TIMEOUT),
|
|
619
|
+
variables: (0, internal_1.toStringMap)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_VARIABLES),
|
|
620
|
+
// Added to make the test work, should be changed in the future when cleaning up
|
|
621
|
+
mobileApplicationVersionFilePath: configFile.defaultTestOverrides.mobileApplicationVersionFilePath,
|
|
622
|
+
},
|
|
623
|
+
failOnCriticalErrors: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_CRITICAL_ERRORS),
|
|
624
|
+
failOnMissingTests: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_MISSING_TESTS),
|
|
625
|
+
failOnTimeout: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_TIMEOUT),
|
|
626
|
+
files: (_b = overrideEnv.DATADOG_SYNTHETICS_FILES) === null || _b === void 0 ? void 0 : _b.split(';'),
|
|
627
|
+
jUnitReport: overrideEnv.DATADOG_SYNTHETICS_JUNIT_REPORT,
|
|
628
|
+
publicIds: (_c = overrideEnv.DATADOG_SYNTHETICS_PUBLIC_IDS) === null || _c === void 0 ? void 0 : _c.split(';'),
|
|
629
|
+
selectiveRerun: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_SELECTIVE_RERUN),
|
|
630
|
+
subdomain: overrideEnv.DATADOG_SUBDOMAIN,
|
|
631
|
+
testSearchQuery: overrideEnv.DATADOG_SYNTHETICS_TEST_SEARCH_QUERY,
|
|
632
|
+
tunnel: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_TUNNEL),
|
|
633
|
+
// All the following variables should be removed in the future, as they are either deprecated or misaligned (no ENV variable for now)
|
|
634
|
+
// TODO SYNTH-12989: Clean up deprecated `global` in favor of `defaultTestOverrides`
|
|
635
|
+
global: {},
|
|
636
|
+
// TODO SYNTH-12989: Clean up `locations` that should only be part of the testOverrides
|
|
637
|
+
locations: configFile.locations,
|
|
638
|
+
pollingTimeout: (0, internal_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_BATCH_TIMEOUT),
|
|
639
|
+
proxy: configFile.proxy,
|
|
640
|
+
variableStrings: configFile.variableStrings,
|
|
641
|
+
};
|
|
642
|
+
process.env = overrideEnv;
|
|
643
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
|
|
644
|
+
yield command['resolveConfig']();
|
|
645
|
+
expect(command['config']).toEqual(expectedEnvOverrideResult);
|
|
646
|
+
}));
|
|
647
|
+
test('config file < CLI', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
648
|
+
var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
649
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementationOnce((baseConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
650
|
+
return (Object.assign(Object.assign({}, baseConfig), configFile));
|
|
651
|
+
}));
|
|
652
|
+
const overrideCLI = {
|
|
653
|
+
apiKey: 'cli_api_key',
|
|
654
|
+
appKey: 'cli_app_key',
|
|
655
|
+
batchTimeout: 1,
|
|
656
|
+
configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file-from-cli.json',
|
|
657
|
+
datadogSite: 'datadoghq.eu',
|
|
658
|
+
failOnCriticalErrors: true,
|
|
659
|
+
failOnMissingTests: true,
|
|
660
|
+
failOnTimeout: true,
|
|
661
|
+
files: ['new-file-from-cli'],
|
|
662
|
+
jUnitReport: 'junit-report-from-cli.xml',
|
|
663
|
+
mobileApplicationVersionFilePath: './path/to/application-from-cli.apk',
|
|
664
|
+
pollingTimeout: 10,
|
|
665
|
+
publicIds: ['public-id-from-cli'],
|
|
666
|
+
selectiveRerun: true,
|
|
667
|
+
subdomain: 'subdomain-from-cli',
|
|
668
|
+
testSearchQuery: 'a-search-query-from-cli',
|
|
669
|
+
tunnel: true,
|
|
670
|
+
// TODO SYNTH-12989: Clean up deprecated `variableStrings` in favor of `variables` in `defaultTestOverrides`.
|
|
671
|
+
variableStrings: ['cliVar3=value3', 'cliVar4=value4'],
|
|
672
|
+
};
|
|
673
|
+
const defaultTestOverrides = {
|
|
674
|
+
allowInsecureCertificates: false,
|
|
675
|
+
basicAuth: {
|
|
676
|
+
password: 'password-cli',
|
|
677
|
+
username: 'username-cli',
|
|
678
|
+
},
|
|
679
|
+
body: '{"fakeContentFromCLI":true}',
|
|
680
|
+
bodyType: 'application/json-from-cli',
|
|
681
|
+
cookies: {
|
|
682
|
+
value: 'cli1=value1;cli2=value2;',
|
|
683
|
+
append: false,
|
|
684
|
+
},
|
|
685
|
+
defaultStepTimeout: 11,
|
|
686
|
+
deviceIds: ['chrome.laptop_large_from_cli', 'chrome.laptop_small_from_cli', 'firefox.laptop_large_from_cli'],
|
|
687
|
+
executionRule: interfaces_1.ExecutionRule.NON_BLOCKING,
|
|
688
|
+
followRedirects: false,
|
|
689
|
+
headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token from cli' },
|
|
690
|
+
locations: ['cli-loc-1', 'cli-loc-2'],
|
|
691
|
+
mobileApplicationVersion: '00000000-0000-0000-0000-000000000000-cli',
|
|
692
|
+
pollingTimeout: 12,
|
|
693
|
+
resourceUrlSubstitutionRegexes: [
|
|
694
|
+
'cli-regex',
|
|
695
|
+
's/(https://www.)(.*)/$1extra-$2',
|
|
696
|
+
'https://example.com(.*)|http://subdomain.example.com$1',
|
|
697
|
+
],
|
|
698
|
+
retry: {
|
|
699
|
+
count: 13,
|
|
700
|
+
interval: 14,
|
|
701
|
+
},
|
|
702
|
+
startUrl: 'startUrl-from-cli',
|
|
703
|
+
startUrlSubstitutionRegex: 'startUrlSubstitutionRegex-from-cli',
|
|
704
|
+
testTimeout: 15,
|
|
705
|
+
variables: { cliVar1: 'value1', cliVar2: 'value2' },
|
|
706
|
+
};
|
|
707
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
|
|
708
|
+
command['apiKey'] = overrideCLI.apiKey;
|
|
709
|
+
command['appKey'] = overrideCLI.appKey;
|
|
710
|
+
command['batchTimeout'] = overrideCLI.batchTimeout;
|
|
711
|
+
command['configPath'] = overrideCLI.configPath;
|
|
712
|
+
command['datadogSite'] = overrideCLI.datadogSite;
|
|
713
|
+
// TODO SYNTH-12989: Clean up deprecated `--deviceIds` in favor of `--override deviceIds="dev1;dev2;..."`
|
|
714
|
+
command['deviceIds'] = ['my-old-device'];
|
|
715
|
+
command['failOnCriticalErrors'] = overrideCLI.failOnCriticalErrors;
|
|
716
|
+
command['failOnMissingTests'] = overrideCLI.failOnMissingTests;
|
|
717
|
+
command['failOnTimeout'] = overrideCLI.failOnTimeout;
|
|
718
|
+
command['files'] = overrideCLI.files;
|
|
719
|
+
command['jUnitReport'] = overrideCLI.jUnitReport;
|
|
720
|
+
command['mobileApplicationVersion'] = defaultTestOverrides.mobileApplicationVersion;
|
|
721
|
+
command['mobileApplicationVersionFilePath'] = overrideCLI.mobileApplicationVersionFilePath;
|
|
722
|
+
command['pollingTimeout'] = overrideCLI.pollingTimeout;
|
|
723
|
+
command['publicIds'] = overrideCLI.publicIds;
|
|
724
|
+
command['selectiveRerun'] = overrideCLI.selectiveRerun;
|
|
725
|
+
command['subdomain'] = overrideCLI.subdomain;
|
|
726
|
+
command['tunnel'] = overrideCLI.tunnel;
|
|
727
|
+
command['testSearchQuery'] = overrideCLI.testSearchQuery;
|
|
728
|
+
// TODO SYNTH-12989: Clean up deprecated `variableStrings` in favor of `variables` in `defaultTestOverrides`.
|
|
729
|
+
command['variableStrings'] = overrideCLI.variableStrings;
|
|
730
|
+
command['overrides'] = [
|
|
731
|
+
`allowInsecureCertificates=${defaultTestOverrides.allowInsecureCertificates}`,
|
|
732
|
+
`basicAuth.password=${(_d = defaultTestOverrides.basicAuth) === null || _d === void 0 ? void 0 : _d.password}`,
|
|
733
|
+
`basicAuth.username=${(_e = defaultTestOverrides.basicAuth) === null || _e === void 0 ? void 0 : _e.username}`,
|
|
734
|
+
`body=${defaultTestOverrides.body}`,
|
|
735
|
+
`bodyType=${defaultTestOverrides.bodyType}`,
|
|
736
|
+
`cookies=${defaultTestOverrides.cookies.value}`,
|
|
737
|
+
`cookies.append=${defaultTestOverrides.cookies.append}`,
|
|
738
|
+
`defaultStepTimeout=${defaultTestOverrides.defaultStepTimeout}`,
|
|
739
|
+
`deviceIds=${(_f = defaultTestOverrides.deviceIds) === null || _f === void 0 ? void 0 : _f.join(';')}`,
|
|
740
|
+
`executionRule=${defaultTestOverrides.executionRule}`,
|
|
741
|
+
`followRedirects=${defaultTestOverrides.followRedirects}`,
|
|
742
|
+
`headers.Content-Type=${defaultTestOverrides.headers ? defaultTestOverrides.headers['Content-Type'] : ''}`,
|
|
743
|
+
`headers.Authorization=${(_g = defaultTestOverrides.headers) === null || _g === void 0 ? void 0 : _g.Authorization}`,
|
|
744
|
+
`locations=${(_h = defaultTestOverrides.locations) === null || _h === void 0 ? void 0 : _h.join(';')}`,
|
|
745
|
+
`retry.count=${(_j = defaultTestOverrides.retry) === null || _j === void 0 ? void 0 : _j.count}`,
|
|
746
|
+
`retry.interval=${(_k = defaultTestOverrides.retry) === null || _k === void 0 ? void 0 : _k.interval}`,
|
|
747
|
+
`startUrl=${defaultTestOverrides.startUrl}`,
|
|
748
|
+
`startUrlSubstitutionRegex=${defaultTestOverrides.startUrlSubstitutionRegex}`,
|
|
749
|
+
`testTimeout=${defaultTestOverrides.testTimeout}`,
|
|
750
|
+
`resourceUrlSubstitutionRegexes=${(_l = defaultTestOverrides.resourceUrlSubstitutionRegexes) === null || _l === void 0 ? void 0 : _l.join(';')}`,
|
|
751
|
+
`variables.cliVar1=${(_m = defaultTestOverrides.variables) === null || _m === void 0 ? void 0 : _m.cliVar1}`,
|
|
752
|
+
`variables.cliVar2=${(_o = defaultTestOverrides.variables) === null || _o === void 0 ? void 0 : _o.cliVar2}`,
|
|
753
|
+
];
|
|
754
|
+
yield command['resolveConfig']();
|
|
755
|
+
// TODO SYNTH-12989: Clean up deprecated `global`, `location`, `variableStrings`, `mobileApplicationVersionFilePath`, `proxy`, etc.
|
|
756
|
+
// This fixes are only here for the test to run, and to maintain backward compatibility.
|
|
757
|
+
const { mobileApplicationVersionFilePath } = overrideCLI, filteredOverrideCLI = __rest(overrideCLI, ["mobileApplicationVersionFilePath"]);
|
|
758
|
+
const expectedCLIOverrideResult = Object.assign(Object.assign({}, filteredOverrideCLI), { locations: configFile.locations, global: {}, defaultTestOverrides: Object.assign(Object.assign({}, defaultTestOverrides), { mobileApplicationVersionFilePath, pollingTimeout: filteredOverrideCLI.batchTimeout }), pollingTimeout: filteredOverrideCLI.batchTimeout, proxy: configFile.proxy, variableStrings: configFile.variableStrings });
|
|
759
|
+
expect(command['config']).toEqual(expectedCLIOverrideResult);
|
|
760
|
+
}));
|
|
761
|
+
test('ENV < CLI', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
762
|
+
var _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
763
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementationOnce((baseConfig) => __awaiter(void 0, void 0, void 0, function* () { return baseConfig; }));
|
|
764
|
+
const overrideEnv = {
|
|
765
|
+
DATADOG_API_KEY: 'env_api_key',
|
|
766
|
+
DATADOG_APP_KEY: 'env_app_key',
|
|
767
|
+
DATADOG_SITE: 'us5.datadoghq.com',
|
|
768
|
+
DATADOG_SYNTHETICS_CONFIG_PATH: 'path/to/config_from_env.json',
|
|
769
|
+
DATADOG_SUBDOMAIN: 'subdomain_from_env',
|
|
770
|
+
DATADOG_SYNTHETICS_FAIL_ON_CRITICAL_ERRORS: 'true',
|
|
771
|
+
DATADOG_SYNTHETICS_FAIL_ON_MISSING_TESTS: 'true',
|
|
772
|
+
DATADOG_SYNTHETICS_FAIL_ON_TIMEOUT: 'true',
|
|
773
|
+
DATADOG_SYNTHETICS_FILES: '1_from_env.json;2_from_env.json',
|
|
774
|
+
DATADOG_SYNTHETICS_JUNIT_REPORT: 'junit-report-from-env.xml',
|
|
775
|
+
DATADOG_SYNTHETICS_PUBLIC_IDS: 'a-public-id-from-env;another-public-id-from-env',
|
|
776
|
+
DATADOG_SYNTHETICS_SELECTIVE_RERUN: 'true',
|
|
777
|
+
DATADOG_SYNTHETICS_TEST_SEARCH_QUERY: 'a-search-query-from-env',
|
|
778
|
+
DATADOG_SYNTHETICS_TUNNEL: 'false',
|
|
779
|
+
DATADOG_SYNTHETICS_OVERRIDE_ALLOW_INSECURE_CERTIFICATES: 'true',
|
|
780
|
+
DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_PASSWORD: 'password-from-env',
|
|
781
|
+
DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_USERNAME: 'username-from-env',
|
|
782
|
+
DATADOG_SYNTHETICS_OVERRIDE_BODY: 'body-from-env',
|
|
783
|
+
DATADOG_SYNTHETICS_OVERRIDE_BODY_TYPE: 'bodyType-from-env',
|
|
784
|
+
DATADOG_SYNTHETICS_OVERRIDE_COOKIES: 'cookie1-from-env;cookie2-from-env;cookie3-from-env',
|
|
785
|
+
DATADOG_SYNTHETICS_OVERRIDE_COOKIES_APPEND: 'true',
|
|
786
|
+
DATADOG_SYNTHETICS_OVERRIDE_DEFAULT_STEP_TIMEOUT: '42',
|
|
787
|
+
DATADOG_SYNTHETICS_OVERRIDE_DEVICE_IDS: 'chrome.laptop_large_from_env',
|
|
788
|
+
DATADOG_SYNTHETICS_OVERRIDE_EXECUTION_RULE: 'BLOCKING',
|
|
789
|
+
DATADOG_SYNTHETICS_OVERRIDE_FOLLOW_REDIRECTS: 'true',
|
|
790
|
+
DATADOG_SYNTHETICS_OVERRIDE_HEADERS: "{'Content-Type': 'application/json', 'Authorization': 'Bearer token from env'}",
|
|
791
|
+
// TODO SYNTH-12989: Clean up `locations` that should only be part of the testOverrides
|
|
792
|
+
DATADOG_SYNTHETICS_LOCATIONS: 'Wonderland;FarFarAway',
|
|
793
|
+
DATADOG_SYNTHETICS_OVERRIDE_LOCATIONS: 'location_1_from_env;location_2_from_env',
|
|
794
|
+
DATADOG_SYNTHETICS_OVERRIDE_MOBILE_APPLICATION_VERSION: 'env-00000000-0000-0000-0000-000000000000',
|
|
795
|
+
DATADOG_SYNTHETICS_OVERRIDE_RESOURCE_URL_SUBSTITUTION_REGEXES: 'env-regex1;env-regex2',
|
|
796
|
+
DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT: '5',
|
|
797
|
+
DATADOG_SYNTHETICS_OVERRIDE_RETRY_INTERVAL: '100',
|
|
798
|
+
DATADOG_SYNTHETICS_OVERRIDE_START_URL: 'startUrl-from-env',
|
|
799
|
+
DATADOG_SYNTHETICS_OVERRIDE_START_URL_SUBSTITUTION_REGEX: 'startUrlSubstitutionRegex-from-env',
|
|
800
|
+
DATADOG_SYNTHETICS_OVERRIDE_TEST_TIMEOUT: '42',
|
|
801
|
+
DATADOG_SYNTHETICS_OVERRIDE_VARIABLES: "{'envVar1': 'value1', 'envVar2': 'value2'}",
|
|
802
|
+
};
|
|
803
|
+
const overrideCLI = {
|
|
804
|
+
apiKey: 'cli_api_key',
|
|
805
|
+
appKey: 'cli_app_key',
|
|
806
|
+
batchTimeout: 1,
|
|
807
|
+
configPath: 'path/to/config_from_cli.json',
|
|
808
|
+
datadogSite: 'datadoghq.eu',
|
|
809
|
+
failOnCriticalErrors: false,
|
|
810
|
+
failOnMissingTests: false,
|
|
811
|
+
failOnTimeout: false,
|
|
812
|
+
files: ['file-from-cli-1;file-from-cli-2'],
|
|
813
|
+
jUnitReport: 'junit-report-from-cli.xml',
|
|
814
|
+
mobileApplicationVersionFilePath: './path/to/application-from-cli.apk',
|
|
815
|
+
pollingTimeout: 10,
|
|
816
|
+
publicIds: ['public-id-from-cli-1', 'public-id-from-cli-2'],
|
|
817
|
+
selectiveRerun: false,
|
|
818
|
+
subdomain: 'subdomain-from-cli',
|
|
819
|
+
testSearchQuery: 'a-search-query-from-cli',
|
|
820
|
+
tunnel: true,
|
|
821
|
+
// TODO SYNTH-12989: Clean up deprecated `variableStrings` in favor of `variables` in `defaultTestOverrides`.
|
|
822
|
+
variableStrings: ['cliVar3=value3', 'cliVar4=value4'],
|
|
823
|
+
};
|
|
824
|
+
const defaultTestOverrides = {
|
|
825
|
+
allowInsecureCertificates: false,
|
|
826
|
+
basicAuth: {
|
|
827
|
+
password: 'password-cli',
|
|
828
|
+
username: 'username-cli',
|
|
829
|
+
},
|
|
830
|
+
body: 'a body from cli',
|
|
831
|
+
bodyType: 'bodyType from cli',
|
|
832
|
+
cookies: {
|
|
833
|
+
value: 'cli1=value1;cli2=value2;',
|
|
834
|
+
append: false,
|
|
835
|
+
},
|
|
836
|
+
defaultStepTimeout: 11,
|
|
837
|
+
deviceIds: ['chrome.laptop_large_from_cli', 'chrome.laptop_small_from_cli', 'firefox.laptop_large_from_cli'],
|
|
838
|
+
executionRule: interfaces_1.ExecutionRule.NON_BLOCKING,
|
|
839
|
+
followRedirects: false,
|
|
840
|
+
headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token from cli' },
|
|
841
|
+
locations: ['cli-loc-1', 'cli-loc-2'],
|
|
842
|
+
mobileApplicationVersion: 'cli-00000000-0000-0000-0000-000000000000',
|
|
843
|
+
pollingTimeout: 12,
|
|
844
|
+
resourceUrlSubstitutionRegexes: [
|
|
845
|
+
'from-cli-regex1',
|
|
846
|
+
's/(https://www.)(.*)/$1extra-$2',
|
|
847
|
+
'https://example.com(.*)|http://subdomain.example.com$1',
|
|
848
|
+
],
|
|
849
|
+
retry: {
|
|
850
|
+
count: 13,
|
|
851
|
+
interval: 14,
|
|
852
|
+
},
|
|
853
|
+
startUrl: 'startUrl-from-cli',
|
|
854
|
+
startUrlSubstitutionRegex: 'startUrlSubstitutionRegex-from-cli',
|
|
855
|
+
testTimeout: 15,
|
|
856
|
+
variables: { cliVar1: 'value1', cliVar2: 'value2' },
|
|
857
|
+
};
|
|
858
|
+
process.env = overrideEnv;
|
|
859
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
|
|
860
|
+
command['apiKey'] = overrideCLI.apiKey;
|
|
861
|
+
command['appKey'] = overrideCLI.appKey;
|
|
862
|
+
command['batchTimeout'] = overrideCLI.batchTimeout;
|
|
863
|
+
command['configPath'] = overrideCLI.configPath;
|
|
864
|
+
command['datadogSite'] = overrideCLI.datadogSite;
|
|
865
|
+
// TODO SYNTH-12989: Clean up deprecated `--deviceIds` in favor of `--override deviceIds="dev1;dev2;..."`
|
|
866
|
+
command['deviceIds'] = ['my-old-device'];
|
|
867
|
+
command['failOnCriticalErrors'] = overrideCLI.failOnCriticalErrors;
|
|
868
|
+
command['failOnMissingTests'] = overrideCLI.failOnMissingTests;
|
|
869
|
+
command['failOnTimeout'] = overrideCLI.failOnTimeout;
|
|
870
|
+
command['files'] = overrideCLI.files;
|
|
871
|
+
command['jUnitReport'] = overrideCLI.jUnitReport;
|
|
872
|
+
command['mobileApplicationVersion'] = defaultTestOverrides.mobileApplicationVersion;
|
|
873
|
+
command['mobileApplicationVersionFilePath'] = overrideCLI.mobileApplicationVersionFilePath;
|
|
874
|
+
command['pollingTimeout'] = overrideCLI.pollingTimeout;
|
|
875
|
+
command['publicIds'] = overrideCLI.publicIds;
|
|
876
|
+
command['selectiveRerun'] = overrideCLI.selectiveRerun;
|
|
877
|
+
command['subdomain'] = overrideCLI.subdomain;
|
|
878
|
+
command['tunnel'] = overrideCLI.tunnel;
|
|
879
|
+
command['testSearchQuery'] = overrideCLI.testSearchQuery;
|
|
880
|
+
// TODO SYNTH-12989: Clean up deprecated `variableStrings` in favor of `variables` in `defaultTestOverrides`.
|
|
881
|
+
command['variableStrings'] = overrideCLI.variableStrings;
|
|
882
|
+
command['overrides'] = [
|
|
883
|
+
`allowInsecureCertificates=${defaultTestOverrides.allowInsecureCertificates}`,
|
|
884
|
+
`basicAuth.password=${(_p = defaultTestOverrides.basicAuth) === null || _p === void 0 ? void 0 : _p.password}`,
|
|
885
|
+
`basicAuth.username=${(_q = defaultTestOverrides.basicAuth) === null || _q === void 0 ? void 0 : _q.username}`,
|
|
886
|
+
`body=${defaultTestOverrides.body}`,
|
|
887
|
+
`bodyType=${defaultTestOverrides.bodyType}`,
|
|
888
|
+
`cookies=${defaultTestOverrides.cookies.value}`,
|
|
889
|
+
`cookies.append=${defaultTestOverrides.cookies.append}`,
|
|
890
|
+
`defaultStepTimeout=${defaultTestOverrides.defaultStepTimeout}`,
|
|
891
|
+
`deviceIds=${(_r = defaultTestOverrides.deviceIds) === null || _r === void 0 ? void 0 : _r.join(';')}`,
|
|
892
|
+
`executionRule=${defaultTestOverrides.executionRule}`,
|
|
893
|
+
`followRedirects=${defaultTestOverrides.followRedirects}`,
|
|
894
|
+
`headers.Content-Type=${defaultTestOverrides.headers ? defaultTestOverrides.headers['Content-Type'] : ''}`,
|
|
895
|
+
`headers.Authorization=${(_s = defaultTestOverrides.headers) === null || _s === void 0 ? void 0 : _s.Authorization}`,
|
|
896
|
+
`locations=${(_t = defaultTestOverrides.locations) === null || _t === void 0 ? void 0 : _t.join(';')}`,
|
|
897
|
+
`retry.count=${(_u = defaultTestOverrides.retry) === null || _u === void 0 ? void 0 : _u.count}`,
|
|
898
|
+
`retry.interval=${(_v = defaultTestOverrides.retry) === null || _v === void 0 ? void 0 : _v.interval}`,
|
|
899
|
+
`startUrl=${defaultTestOverrides.startUrl}`,
|
|
900
|
+
`startUrlSubstitutionRegex=${defaultTestOverrides.startUrlSubstitutionRegex}`,
|
|
901
|
+
`testTimeout=${defaultTestOverrides.testTimeout}`,
|
|
902
|
+
`resourceUrlSubstitutionRegexes=${(_w = defaultTestOverrides.resourceUrlSubstitutionRegexes) === null || _w === void 0 ? void 0 : _w.join(';')}`,
|
|
903
|
+
`variables.cliVar1=${(_x = defaultTestOverrides.variables) === null || _x === void 0 ? void 0 : _x.cliVar1}`,
|
|
904
|
+
`variables.cliVar2=${(_y = defaultTestOverrides.variables) === null || _y === void 0 ? void 0 : _y.cliVar2}`,
|
|
905
|
+
];
|
|
906
|
+
yield command['resolveConfig']();
|
|
907
|
+
// TODO SYNTH-12989: Clean up deprecated `global`, `location`, `variableStrings`, `mobileApplicationVersionFilePath`, `proxy` etc.
|
|
908
|
+
// This fixes are only here for the test to run, and to maintain backward compatibility.
|
|
909
|
+
const { mobileApplicationVersionFilePath } = overrideCLI, filteredOverrideCLI = __rest(overrideCLI, ["mobileApplicationVersionFilePath"]);
|
|
910
|
+
const expectedCLIOverrideResult = Object.assign(Object.assign({}, filteredOverrideCLI), { locations: [], global: {}, defaultTestOverrides: Object.assign(Object.assign({}, defaultTestOverrides), { mobileApplicationVersionFilePath, pollingTimeout: filteredOverrideCLI.batchTimeout }), pollingTimeout: filteredOverrideCLI.batchTimeout, proxy: { protocol: 'http' }, variableStrings: [] });
|
|
911
|
+
expect(command['config']).toEqual(expectedCLIOverrideResult);
|
|
912
|
+
}));
|
|
913
|
+
const overrideTestConfig = {
|
|
914
|
+
allowInsecureCertificates: false,
|
|
915
|
+
basicAuth: {
|
|
916
|
+
password: 'password-test-file',
|
|
917
|
+
username: 'username-test-file',
|
|
918
|
+
},
|
|
919
|
+
body: 'a body from test file',
|
|
920
|
+
bodyType: 'bodyType from test file',
|
|
921
|
+
cookies: {
|
|
922
|
+
value: 'test-file1=value1;test-file2=value2;',
|
|
923
|
+
append: false,
|
|
924
|
+
},
|
|
925
|
+
defaultStepTimeout: 31,
|
|
926
|
+
deviceIds: [
|
|
927
|
+
'chrome.laptop_large_from_test_file',
|
|
928
|
+
'chrome.laptop_small_from_test_file',
|
|
929
|
+
'firefox.laptop_large_from_test_file',
|
|
930
|
+
],
|
|
931
|
+
executionRule: interfaces_1.ExecutionRule.NON_BLOCKING,
|
|
932
|
+
followRedirects: false,
|
|
933
|
+
headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token from test file' },
|
|
934
|
+
locations: ['test-file-loc-1', 'test-file-loc-2'],
|
|
935
|
+
mobileApplicationVersion: 'test-file-00000000-0000-0000-0000-000000000000',
|
|
936
|
+
pollingTimeout: 32,
|
|
937
|
+
resourceUrlSubstitutionRegexes: [
|
|
938
|
+
'from-test-file-regex1',
|
|
939
|
+
's/(https://www.)(.*)/$1extra-$2',
|
|
940
|
+
'https://example.com(.*)|http://subdomain.example.com$1',
|
|
941
|
+
],
|
|
942
|
+
retry: {
|
|
943
|
+
count: 33,
|
|
944
|
+
interval: 34,
|
|
945
|
+
},
|
|
946
|
+
startUrl: 'startUrl-from-test-file',
|
|
947
|
+
startUrlSubstitutionRegex: 'startUrlSubstitutionRegex-from-test-file',
|
|
948
|
+
testTimeout: 35,
|
|
949
|
+
variables: { testFileVar1: 'value1', testFileVar2: 'value2' },
|
|
950
|
+
};
|
|
951
|
+
const triggerTests = jest.fn(() => {
|
|
952
|
+
throw (0, fixtures_2.getAxiosHttpError)(502, { message: 'Bad Gateway' });
|
|
953
|
+
});
|
|
954
|
+
const apiHelper = (0, fixtures_2.mockApi)({
|
|
955
|
+
getTest: jest.fn(() => __awaiter(void 0, void 0, void 0, function* () { return (Object.assign({}, (0, fixtures_2.getApiTest)('publicId'))); })),
|
|
956
|
+
triggerTests,
|
|
957
|
+
});
|
|
958
|
+
const getExpectedTestsToTriggerArguments = (testOverrides) => {
|
|
959
|
+
return [
|
|
960
|
+
// Parameters we care about.
|
|
961
|
+
apiHelper,
|
|
962
|
+
[{ suite: 'Suite 1', id: 'aaa-bbb-ccc', testOverrides }],
|
|
963
|
+
// Ignore the rest of the parameters.
|
|
964
|
+
expect.anything(),
|
|
965
|
+
expect.anything(),
|
|
966
|
+
expect.anything(),
|
|
967
|
+
expect.anything(),
|
|
968
|
+
];
|
|
969
|
+
};
|
|
970
|
+
const testFile = { name: 'Suite 1', content: { tests: [{ id: 'aaa-bbb-ccc', testOverrides: {} }] } };
|
|
971
|
+
test('config file < test file', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
972
|
+
const getTestsToTriggerMock = jest.spyOn(utils, 'getTestsToTrigger');
|
|
973
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
|
|
974
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementationOnce((baseConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
975
|
+
return Object.assign(Object.assign({}, baseConfig), { defaultTestOverrides: Object.assign(Object.assign({}, configFile.defaultTestOverrides), { mobileApplicationVersionFilePath: undefined }), testSearchQuery: undefined });
|
|
976
|
+
}));
|
|
977
|
+
jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
|
|
978
|
+
jest.spyOn(utils, 'getSuites').mockResolvedValue([testFile]);
|
|
979
|
+
testFile.content.tests[0].testOverrides = overrideTestConfig;
|
|
980
|
+
expect(yield command.execute()).toBe(0);
|
|
981
|
+
expect(getTestsToTriggerMock).toHaveBeenNthCalledWith(1, ...getExpectedTestsToTriggerArguments(overrideTestConfig));
|
|
982
|
+
}));
|
|
983
|
+
test('ENV < test file', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
984
|
+
const getTestsToTriggerMock = jest.spyOn(utils, 'getTestsToTrigger');
|
|
985
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
|
|
986
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, _) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
|
|
987
|
+
jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
|
|
988
|
+
jest.spyOn(utils, 'getSuites').mockResolvedValue([testFile]);
|
|
989
|
+
testFile.content.tests[0].testOverrides = overrideTestConfig;
|
|
990
|
+
const testOverrideEnv = {
|
|
991
|
+
DATADOG_SYNTHETICS_OVERRIDE_ALLOW_INSECURE_CERTIFICATES: 'true',
|
|
992
|
+
DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_PASSWORD: 'password-from-env',
|
|
993
|
+
DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_USERNAME: 'username-from-env',
|
|
994
|
+
DATADOG_SYNTHETICS_OVERRIDE_BODY: 'body-from-env',
|
|
995
|
+
DATADOG_SYNTHETICS_OVERRIDE_BODY_TYPE: 'bodyType-from-env',
|
|
996
|
+
DATADOG_SYNTHETICS_OVERRIDE_COOKIES: 'cookie1-from-env;cookie2-from-env;cookie3-from-env',
|
|
997
|
+
DATADOG_SYNTHETICS_OVERRIDE_COOKIES_APPEND: 'true',
|
|
998
|
+
DATADOG_SYNTHETICS_OVERRIDE_DEFAULT_STEP_TIMEOUT: '42',
|
|
999
|
+
DATADOG_SYNTHETICS_OVERRIDE_DEVICE_IDS: 'chrome.laptop_large_from_env',
|
|
1000
|
+
DATADOG_SYNTHETICS_OVERRIDE_EXECUTION_RULE: 'BLOCKING',
|
|
1001
|
+
DATADOG_SYNTHETICS_OVERRIDE_FOLLOW_REDIRECTS: 'true',
|
|
1002
|
+
DATADOG_SYNTHETICS_OVERRIDE_HEADERS: "{'Content-Type': 'application/json', 'Authorization': 'Bearer token from env'}",
|
|
1003
|
+
// TODO SYNTH-12989: Clean up `locations` that should only be part of the testOverrides
|
|
1004
|
+
DATADOG_SYNTHETICS_LOCATIONS: 'Wonderland;FarFarAway',
|
|
1005
|
+
DATADOG_SYNTHETICS_OVERRIDE_LOCATIONS: 'location_1_from_env;location_2_from_env',
|
|
1006
|
+
DATADOG_SYNTHETICS_OVERRIDE_MOBILE_APPLICATION_VERSION: 'env-00000000-0000-0000-0000-000000000000',
|
|
1007
|
+
DATADOG_SYNTHETICS_OVERRIDE_RESOURCE_URL_SUBSTITUTION_REGEXES: 'env-regex1;env-regex2',
|
|
1008
|
+
DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT: '5',
|
|
1009
|
+
DATADOG_SYNTHETICS_OVERRIDE_RETRY_INTERVAL: '100',
|
|
1010
|
+
DATADOG_SYNTHETICS_OVERRIDE_START_URL: 'startUrl-from-env',
|
|
1011
|
+
DATADOG_SYNTHETICS_OVERRIDE_START_URL_SUBSTITUTION_REGEX: 'startUrlSubstitutionRegex-from-env',
|
|
1012
|
+
DATADOG_SYNTHETICS_OVERRIDE_TEST_TIMEOUT: '42',
|
|
1013
|
+
DATADOG_SYNTHETICS_OVERRIDE_VARIABLES: "{'envVar1': 'value1', 'envVar2': 'value2'}",
|
|
1014
|
+
};
|
|
1015
|
+
process.env = testOverrideEnv;
|
|
1016
|
+
expect(yield command.execute()).toBe(0);
|
|
1017
|
+
expect(getTestsToTriggerMock).toHaveBeenNthCalledWith(1, ...getExpectedTestsToTriggerArguments(overrideTestConfig));
|
|
1018
|
+
}));
|
|
1019
|
+
test('CLI < test file', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1020
|
+
var _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
1021
|
+
const getTestsToTriggerMock = jest.spyOn(utils, 'getTestsToTrigger');
|
|
1022
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
|
|
1023
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, _) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
|
|
1024
|
+
jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
|
|
1025
|
+
jest.spyOn(utils, 'getSuites').mockResolvedValue([testFile]);
|
|
1026
|
+
const defaultTestOverrides = {
|
|
1027
|
+
allowInsecureCertificates: false,
|
|
1028
|
+
basicAuth: {
|
|
1029
|
+
password: 'password-cli',
|
|
1030
|
+
username: 'username-cli',
|
|
1031
|
+
},
|
|
1032
|
+
body: 'a body from cli',
|
|
1033
|
+
bodyType: 'bodyType from cli',
|
|
1034
|
+
cookies: {
|
|
1035
|
+
value: 'cli1=value1;cli2=value2;',
|
|
1036
|
+
append: false,
|
|
1037
|
+
},
|
|
1038
|
+
defaultStepTimeout: 11,
|
|
1039
|
+
deviceIds: ['chrome.laptop_large_from_cli', 'chrome.laptop_small_from_cli', 'firefox.laptop_large_from_cli'],
|
|
1040
|
+
executionRule: interfaces_1.ExecutionRule.NON_BLOCKING,
|
|
1041
|
+
followRedirects: false,
|
|
1042
|
+
headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token from cli' },
|
|
1043
|
+
locations: ['cli-loc-1', 'cli-loc-2'],
|
|
1044
|
+
mobileApplicationVersion: 'cli-00000000-0000-0000-0000-000000000000',
|
|
1045
|
+
pollingTimeout: 12,
|
|
1046
|
+
resourceUrlSubstitutionRegexes: [
|
|
1047
|
+
'from-cli-regex1',
|
|
1048
|
+
's/(https://www.)(.*)/$1extra-$2',
|
|
1049
|
+
'https://example.com(.*)|http://subdomain.example.com$1',
|
|
1050
|
+
],
|
|
1051
|
+
retry: {
|
|
1052
|
+
count: 13,
|
|
1053
|
+
interval: 14,
|
|
1054
|
+
},
|
|
1055
|
+
startUrl: 'startUrl-from-cli',
|
|
1056
|
+
startUrlSubstitutionRegex: 'startUrlSubstitutionRegex-from-cli',
|
|
1057
|
+
testTimeout: 15,
|
|
1058
|
+
variables: { cliVar1: 'value1', cliVar2: 'value2' },
|
|
1059
|
+
};
|
|
1060
|
+
// TODO SYNTH-12989: Clean up deprecated `--deviceIds` in favor of `--override deviceIds="dev1;dev2;..."`
|
|
1061
|
+
command['deviceIds'] = ['my-old-device'];
|
|
1062
|
+
command['mobileApplicationVersion'] = defaultTestOverrides.mobileApplicationVersion;
|
|
1063
|
+
command['overrides'] = [
|
|
1064
|
+
`allowInsecureCertificates=${defaultTestOverrides.allowInsecureCertificates}`,
|
|
1065
|
+
`basicAuth.password=${(_z = defaultTestOverrides.basicAuth) === null || _z === void 0 ? void 0 : _z.password}`,
|
|
1066
|
+
`basicAuth.username=${(_0 = defaultTestOverrides.basicAuth) === null || _0 === void 0 ? void 0 : _0.username}`,
|
|
1067
|
+
`body=${defaultTestOverrides.body}`,
|
|
1068
|
+
`bodyType=${defaultTestOverrides.bodyType}`,
|
|
1069
|
+
`cookies=${defaultTestOverrides.cookies.value}`,
|
|
1070
|
+
`cookies.append=${defaultTestOverrides.cookies.append}`,
|
|
1071
|
+
`defaultStepTimeout=${defaultTestOverrides.defaultStepTimeout}`,
|
|
1072
|
+
`deviceIds=${(_1 = defaultTestOverrides.deviceIds) === null || _1 === void 0 ? void 0 : _1.join(';')}`,
|
|
1073
|
+
`executionRule=${defaultTestOverrides.executionRule}`,
|
|
1074
|
+
`followRedirects=${defaultTestOverrides.followRedirects}`,
|
|
1075
|
+
`headers.Content-Type=${defaultTestOverrides.headers ? defaultTestOverrides.headers['Content-Type'] : ''}`,
|
|
1076
|
+
`headers.Authorization=${(_2 = defaultTestOverrides.headers) === null || _2 === void 0 ? void 0 : _2.Authorization}`,
|
|
1077
|
+
`locations=${(_3 = defaultTestOverrides.locations) === null || _3 === void 0 ? void 0 : _3.join(';')}`,
|
|
1078
|
+
`retry.count=${(_4 = defaultTestOverrides.retry) === null || _4 === void 0 ? void 0 : _4.count}`,
|
|
1079
|
+
`retry.interval=${(_5 = defaultTestOverrides.retry) === null || _5 === void 0 ? void 0 : _5.interval}`,
|
|
1080
|
+
`startUrl=${defaultTestOverrides.startUrl}`,
|
|
1081
|
+
`startUrlSubstitutionRegex=${defaultTestOverrides.startUrlSubstitutionRegex}`,
|
|
1082
|
+
`testTimeout=${defaultTestOverrides.testTimeout}`,
|
|
1083
|
+
`resourceUrlSubstitutionRegexes=${(_6 = defaultTestOverrides.resourceUrlSubstitutionRegexes) === null || _6 === void 0 ? void 0 : _6.join(';')}`,
|
|
1084
|
+
`variables.cliVar1=${(_7 = defaultTestOverrides.variables) === null || _7 === void 0 ? void 0 : _7.cliVar1}`,
|
|
1085
|
+
`variables.cliVar2=${(_8 = defaultTestOverrides.variables) === null || _8 === void 0 ? void 0 : _8.cliVar2}`,
|
|
1086
|
+
];
|
|
1087
|
+
yield command['resolveConfig']();
|
|
1088
|
+
expect(yield command.execute()).toBe(0);
|
|
1089
|
+
expect(getTestsToTriggerMock).toHaveBeenNthCalledWith(1, ...getExpectedTestsToTriggerArguments(overrideTestConfig));
|
|
1090
|
+
}));
|
|
1091
|
+
});
|
|
1092
|
+
});
|
|
1093
|
+
describe('exit code respects `failOnCriticalErrors`', () => {
|
|
1094
|
+
test('404 leading to `NO_TESTS_TO_RUN` never exits with 1', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1095
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: jest.fn() } });
|
|
1096
|
+
command['config'].failOnCriticalErrors = true;
|
|
1097
|
+
const apiHelper = (0, fixtures_2.mockApi)({
|
|
1098
|
+
getTest: jest.fn(() => {
|
|
1099
|
+
throw (0, fixtures_2.getAxiosHttpError)(404, { errors: ['Test not found'] });
|
|
1100
|
+
}),
|
|
1101
|
+
});
|
|
1102
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, _) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
|
|
1103
|
+
jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
|
|
1104
|
+
jest.spyOn(utils, 'getSuites').mockResolvedValue([(0, fixtures_2.getTestSuite)()]);
|
|
1105
|
+
expect(yield command.execute()).toBe(0);
|
|
1106
|
+
expect(apiHelper.getTest).toHaveBeenCalledTimes(1);
|
|
1107
|
+
}));
|
|
1108
|
+
describe.each([false, true])('%s', (failOnCriticalErrors) => {
|
|
1109
|
+
const cases = [['HTTP 4xx error', 403], ['HTTP 5xx error', 502], ['Unknown error']];
|
|
1110
|
+
const expectedExit = failOnCriticalErrors ? 1 : 0;
|
|
1111
|
+
describe.each(cases)('%s', (_, errorCode) => {
|
|
1112
|
+
test('unable to obtain test configurations', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1113
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: jest.fn() } });
|
|
1114
|
+
command['config'].failOnCriticalErrors = failOnCriticalErrors;
|
|
1115
|
+
command['testSearchQuery'] = 'test:search';
|
|
1116
|
+
const apiHelper = (0, fixtures_2.mockApi)({
|
|
1117
|
+
searchTests: jest.fn(() => {
|
|
1118
|
+
throw errorCode ? (0, fixtures_2.getAxiosHttpError)(errorCode, { message: 'Error' }) : new Error('Unknown error');
|
|
1119
|
+
}),
|
|
1120
|
+
});
|
|
1121
|
+
jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
|
|
1122
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, __) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
|
|
1123
|
+
expect(yield command.execute()).toBe(expectedExit);
|
|
1124
|
+
expect(apiHelper.searchTests).toHaveBeenCalledTimes(1);
|
|
1125
|
+
}));
|
|
1126
|
+
test('unavailable test config', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1127
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: jest.fn() } });
|
|
1128
|
+
command['config'].failOnCriticalErrors = failOnCriticalErrors;
|
|
1129
|
+
const apiHelper = (0, fixtures_2.mockApi)({
|
|
1130
|
+
getTest: jest.fn(() => {
|
|
1131
|
+
throw errorCode ? (0, fixtures_2.getAxiosHttpError)(errorCode, { message: 'Error' }) : new Error('Unknown error');
|
|
1132
|
+
}),
|
|
1133
|
+
});
|
|
1134
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, __) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
|
|
1135
|
+
jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
|
|
1136
|
+
jest.spyOn(utils, 'getSuites').mockResolvedValue([(0, fixtures_2.getTestSuite)()]);
|
|
1137
|
+
expect(yield command.execute()).toBe(expectedExit);
|
|
1138
|
+
expect(apiHelper.getTest).toHaveBeenCalledTimes(1);
|
|
1139
|
+
}));
|
|
1140
|
+
test('unable to trigger tests', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1141
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: jest.fn() } });
|
|
1142
|
+
command['config'].failOnCriticalErrors = failOnCriticalErrors;
|
|
1143
|
+
const apiHelper = (0, fixtures_2.mockApi)({
|
|
1144
|
+
getTest: () => __awaiter(void 0, void 0, void 0, function* () { return (0, fixtures_2.getApiTest)('123-456-789'); }),
|
|
1145
|
+
triggerTests: jest.fn(() => {
|
|
1146
|
+
throw errorCode ? (0, fixtures_2.getAxiosHttpError)(errorCode, { message: 'Error' }) : new Error('Unknown error');
|
|
1147
|
+
}),
|
|
1148
|
+
});
|
|
1149
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, __) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
|
|
1150
|
+
jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
|
|
1151
|
+
jest.spyOn(utils, 'getSuites').mockResolvedValue([(0, fixtures_2.getTestSuite)()]);
|
|
1152
|
+
expect(yield command.execute()).toBe(expectedExit);
|
|
1153
|
+
expect(apiHelper.triggerTests).toHaveBeenCalledTimes(1);
|
|
1154
|
+
}));
|
|
1155
|
+
test('unable to poll test results', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1156
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: jest.fn() } });
|
|
1157
|
+
command['config'].failOnCriticalErrors = failOnCriticalErrors;
|
|
1158
|
+
const apiHelper = (0, fixtures_2.mockApi)({
|
|
1159
|
+
getBatch: () => __awaiter(void 0, void 0, void 0, function* () { return ({ results: [], status: 'passed' }); }),
|
|
1160
|
+
getTest: () => __awaiter(void 0, void 0, void 0, function* () { return (0, fixtures_2.getApiTest)('123-456-789'); }),
|
|
1161
|
+
pollResults: jest.fn(() => {
|
|
1162
|
+
throw errorCode ? (0, fixtures_2.getAxiosHttpError)(errorCode, { message: 'Error' }) : new Error('Unknown error');
|
|
1163
|
+
}),
|
|
1164
|
+
triggerTests: () => __awaiter(void 0, void 0, void 0, function* () { return fixtures_2.mockTestTriggerResponse; }),
|
|
1165
|
+
});
|
|
1166
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, __) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
|
|
1167
|
+
jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
|
|
1168
|
+
jest.spyOn(utils, 'getSuites').mockResolvedValue([(0, fixtures_2.getTestSuite)()]);
|
|
1169
|
+
expect(yield command.execute()).toBe(expectedExit);
|
|
1170
|
+
expect(apiHelper.pollResults).toHaveBeenCalledTimes(1);
|
|
1171
|
+
}));
|
|
1172
|
+
});
|
|
1173
|
+
});
|
|
1174
|
+
});
|
|
1175
|
+
describe('exit code respects `failOnMissingTests`', () => {
|
|
1176
|
+
const cases = [
|
|
1177
|
+
['only missing tests', false, 0, ['mis-sin-ggg']],
|
|
1178
|
+
['only missing tests', true, 1, ['mis-sin-ggg']],
|
|
1179
|
+
['both missing and available tests', false, 0, ['mis-sin-ggg', 'abc-def-ghi']],
|
|
1180
|
+
['both missing and available tests', true, 1, ['mis-sin-ggg', 'abc-def-ghi']],
|
|
1181
|
+
];
|
|
1182
|
+
test.each(cases)('%s with failOnMissingTests=%s exits with %s', (_, failOnMissingTests, exitCode, tests) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1183
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: jest.fn() } });
|
|
1184
|
+
command['config'].failOnMissingTests = failOnMissingTests;
|
|
1185
|
+
const apiHelper = (0, fixtures_2.mockApi)({
|
|
1186
|
+
getTest: jest.fn((testId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1187
|
+
if (testId === 'mis-sin-ggg') {
|
|
1188
|
+
throw (0, fixtures_2.getAxiosHttpError)(404, { errors: ['Test not found'] });
|
|
1189
|
+
}
|
|
1190
|
+
return {};
|
|
1191
|
+
})),
|
|
1192
|
+
});
|
|
1193
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, __) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
|
|
1194
|
+
jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
|
|
1195
|
+
jest.spyOn(utils, 'getSuites').mockResolvedValue([
|
|
1196
|
+
{
|
|
1197
|
+
content: {
|
|
1198
|
+
tests: tests.map((testId) => ({ config: {}, id: testId })),
|
|
1199
|
+
},
|
|
1200
|
+
name: 'Suite 1',
|
|
1201
|
+
},
|
|
1202
|
+
]);
|
|
1203
|
+
expect(yield command.execute()).toBe(exitCode);
|
|
1204
|
+
expect(apiHelper.getTest).toHaveBeenCalledTimes(tests.length);
|
|
1205
|
+
}));
|
|
1206
|
+
});
|
|
1207
|
+
describe('API errors logging', () => {
|
|
1208
|
+
test('enough context is provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1209
|
+
const writeMock = jest.fn();
|
|
1210
|
+
const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: writeMock } });
|
|
1211
|
+
command['config'].failOnCriticalErrors = true;
|
|
1212
|
+
const apiHelper = (0, fixtures_2.mockApi)({
|
|
1213
|
+
getTest: jest.fn((testId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1214
|
+
if (testId === 'for-bid-den') {
|
|
1215
|
+
const serverError = (0, fixtures_2.getAxiosHttpError)(403, { errors: ['Forbidden'] });
|
|
1216
|
+
serverError.config.url = 'tests/for-bid-den';
|
|
1217
|
+
throw serverError;
|
|
1218
|
+
}
|
|
1219
|
+
return { name: testId };
|
|
1220
|
+
})),
|
|
1221
|
+
});
|
|
1222
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, __) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
|
|
1223
|
+
jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
|
|
1224
|
+
jest.spyOn(utils, 'getSuites').mockResolvedValue([
|
|
1225
|
+
{
|
|
1226
|
+
content: {
|
|
1227
|
+
tests: [
|
|
1228
|
+
{ testOverrides: {}, id: 'aaa-aaa-aaa' },
|
|
1229
|
+
{ testOverrides: { headers: {} }, id: 'bbb-bbb-bbb' },
|
|
1230
|
+
{ testOverrides: {}, id: 'for-bid-den' },
|
|
1231
|
+
],
|
|
1232
|
+
},
|
|
1233
|
+
name: 'Suite 1',
|
|
1234
|
+
},
|
|
1235
|
+
]);
|
|
1236
|
+
expect(yield command.execute()).toBe(1);
|
|
1237
|
+
expect(apiHelper.getTest).toHaveBeenCalledTimes(3);
|
|
1238
|
+
expect(writeMock).toHaveBeenCalledTimes(4);
|
|
1239
|
+
expect(writeMock).toHaveBeenCalledWith('[aaa-aaa-aaa] Found test "aaa-aaa-aaa"\n');
|
|
1240
|
+
expect(writeMock).toHaveBeenCalledWith('[bbb-bbb-bbb] Found test "bbb-bbb-bbb" (1 test override)\n');
|
|
1241
|
+
expect(writeMock).toHaveBeenCalledWith('\n ERROR: authorization error \nFailed to get test: query on https://app.datadoghq.com/tests/for-bid-den returned: "Forbidden"\n\n\n');
|
|
1242
|
+
expect(writeMock).toHaveBeenCalledWith('Credentials refused, make sure `apiKey`, `appKey` and `datadogSite` are correct.\n');
|
|
1243
|
+
}));
|
|
1244
|
+
});
|
|
1245
|
+
});
|
|
1246
|
+
describe('upload-application', () => {
|
|
1247
|
+
beforeEach(() => {
|
|
1248
|
+
process.env = {};
|
|
1249
|
+
jest.restoreAllMocks();
|
|
1250
|
+
});
|
|
1251
|
+
describe('resolveConfig', () => {
|
|
1252
|
+
beforeEach(() => {
|
|
1253
|
+
process.env = {};
|
|
1254
|
+
});
|
|
1255
|
+
test('override from ENV', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1256
|
+
const overrideEnv = {
|
|
1257
|
+
DATADOG_API_KEY: 'fake_api_key',
|
|
1258
|
+
DATADOG_APP_KEY: 'fake_app_key',
|
|
1259
|
+
DATADOG_SITE: 'datadoghq.eu',
|
|
1260
|
+
DATADOG_SYNTHETICS_CONFIG_PATH: 'path/to/config.json',
|
|
1261
|
+
DATADOG_SYNTHETICS_VERSION_NAME: 'new',
|
|
1262
|
+
DATADOG_SYNTHETICS_LATEST: 'true',
|
|
1263
|
+
};
|
|
1264
|
+
process.env = overrideEnv;
|
|
1265
|
+
const command = (0, fixtures_1.createCommand)(upload_application_command_1.UploadApplicationCommand);
|
|
1266
|
+
yield command['resolveConfig']();
|
|
1267
|
+
expect(command['config']).toEqual(Object.assign(Object.assign({}, upload_application_command_1.DEFAULT_UPLOAD_COMMAND_CONFIG), { apiKey: overrideEnv.DATADOG_API_KEY, appKey: overrideEnv.DATADOG_APP_KEY, configPath: overrideEnv.DATADOG_SYNTHETICS_CONFIG_PATH, datadogSite: overrideEnv.DATADOG_SITE, versionName: overrideEnv.DATADOG_SYNTHETICS_VERSION_NAME, latest: (0, internal_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_LATEST) }));
|
|
1268
|
+
}));
|
|
1269
|
+
test('override from config file', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1270
|
+
const expectedConfig = {
|
|
1271
|
+
apiKey: 'fake_api_key',
|
|
1272
|
+
appKey: 'fake_app_key',
|
|
1273
|
+
configPath: 'src/commands/synthetics/__tests__/config-fixtures/upload-app-config-with-all-keys.json',
|
|
1274
|
+
datadogSite: 'datadoghq.eu',
|
|
1275
|
+
proxy: { protocol: 'http' },
|
|
1276
|
+
mobileApplicationVersionFilePath: 'fake_path/fake_app.apk',
|
|
1277
|
+
mobileApplicationId: 'fake-abc',
|
|
1278
|
+
versionName: 'new',
|
|
1279
|
+
latest: true,
|
|
1280
|
+
};
|
|
1281
|
+
const command = (0, fixtures_1.createCommand)(upload_application_command_1.UploadApplicationCommand);
|
|
1282
|
+
command['configPath'] = 'src/commands/synthetics/__tests__/config-fixtures/upload-app-config-with-all-keys.json';
|
|
1283
|
+
yield command['resolveConfig']();
|
|
1284
|
+
expect(command['config']).toEqual(expectedConfig);
|
|
1285
|
+
}));
|
|
1286
|
+
test('override from CLI', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1287
|
+
const overrideCLI = {
|
|
1288
|
+
apiKey: 'fake_api_key_cli',
|
|
1289
|
+
appKey: 'fake_app_key_cli',
|
|
1290
|
+
configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file.json',
|
|
1291
|
+
datadogSite: 'datadoghq.cli',
|
|
1292
|
+
mobileApplicationVersionFilePath: 'fake_path/cli_fake_app.apk',
|
|
1293
|
+
mobileApplicationId: 'fake-abc-cli',
|
|
1294
|
+
versionName: 'new cli',
|
|
1295
|
+
latest: true,
|
|
1296
|
+
};
|
|
1297
|
+
const command = (0, fixtures_1.createCommand)(upload_application_command_1.UploadApplicationCommand);
|
|
1298
|
+
command['apiKey'] = overrideCLI.apiKey;
|
|
1299
|
+
command['appKey'] = overrideCLI.appKey;
|
|
1300
|
+
command['configPath'] = overrideCLI.configPath;
|
|
1301
|
+
command['datadogSite'] = overrideCLI.datadogSite;
|
|
1302
|
+
command['mobileApplicationVersionFilePath'] = overrideCLI.mobileApplicationVersionFilePath;
|
|
1303
|
+
command['mobileApplicationId'] = overrideCLI.mobileApplicationId;
|
|
1304
|
+
command['versionName'] = overrideCLI.versionName;
|
|
1305
|
+
command['latest'] = overrideCLI.latest;
|
|
1306
|
+
yield command['resolveConfig']();
|
|
1307
|
+
expect(command['config']).toEqual(Object.assign(Object.assign({}, upload_application_command_1.DEFAULT_UPLOAD_COMMAND_CONFIG), { apiKey: 'fake_api_key_cli', appKey: 'fake_app_key_cli', configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file.json', datadogSite: 'datadoghq.cli', mobileApplicationVersionFilePath: 'fake_path/cli_fake_app.apk', mobileApplicationId: 'fake-abc-cli', versionName: 'new cli', latest: true }));
|
|
1308
|
+
}));
|
|
1309
|
+
test('override from config file < ENV < CLI', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1310
|
+
jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementationOnce((baseConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1311
|
+
return (Object.assign(Object.assign({}, baseConfig), { apiKey: 'api_key_config_file', appKey: 'app_key_config_file', datadogSite: 'us5.datadoghq.com', mobileApplicationVersionFilePath: 'fake_path/fake_app.apk', mobileApplicationId: 'fake-abc', versionName: 'new', latest: true }));
|
|
1312
|
+
}));
|
|
1313
|
+
process.env = {
|
|
1314
|
+
DATADOG_API_KEY: 'api_key_env',
|
|
1315
|
+
DATADOG_APP_KEY: 'app_key_env',
|
|
1316
|
+
};
|
|
1317
|
+
const command = (0, fixtures_1.createCommand)(upload_application_command_1.UploadApplicationCommand);
|
|
1318
|
+
command['apiKey'] = 'api_key_cli';
|
|
1319
|
+
command['mobileApplicationVersionFilePath'] = './path/to/application_cli.apk';
|
|
1320
|
+
yield command['resolveConfig']();
|
|
1321
|
+
expect(command['config']).toEqual(Object.assign(Object.assign({}, upload_application_command_1.DEFAULT_UPLOAD_COMMAND_CONFIG), { apiKey: 'api_key_cli', appKey: 'app_key_env', datadogSite: 'us5.datadoghq.com', mobileApplicationVersionFilePath: './path/to/application_cli.apk', mobileApplicationId: 'fake-abc', versionName: 'new', latest: true }));
|
|
1322
|
+
}));
|
|
1323
|
+
});
|
|
1324
|
+
});
|
|
1325
|
+
//# sourceMappingURL=cli.test.js.map
|