@gatling.io/cli 3.11.7 → 3.13.1
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/package.json +8 -6
- package/polyfills/crypto.js +87 -0
- package/polyfills/global.js +13 -0
- package/src/bundle/index.ts +43 -0
- package/src/bundle/polyfill.ts +91 -0
- package/src/commands/build.ts +34 -0
- package/src/commands/enterpriseDeploy.ts +97 -0
- package/src/commands/enterprisePackage.ts +45 -0
- package/src/commands/enterpriseStart.ts +122 -0
- package/src/commands/index.ts +25 -0
- package/src/commands/install.ts +19 -0
- package/src/commands/options.ts +308 -0
- package/src/commands/recorder.ts +41 -0
- package/src/commands/run.ts +82 -0
- package/src/commands/runOnly.ts +56 -0
- package/src/dependencies/coursier.ts +84 -0
- package/src/dependencies/download.ts +11 -0
- package/src/dependencies/graalVm.ts +74 -0
- package/src/dependencies/index.ts +45 -0
- package/src/dependencies/os.ts +24 -0
- package/src/dependencies/versions.ts +15 -0
- package/src/enterprise.ts +227 -0
- package/src/index.ts +5 -0
- package/src/java.ts +48 -0
- package/src/log.ts +19 -0
- package/src/readline.ts +39 -0
- package/src/run.ts +67 -0
- package/src/simulations.ts +29 -0
- package/target/{bundle.d.ts → bundle/index.d.ts} +2 -1
- package/target/{bundle.js → bundle/index.js} +7 -1
- package/target/bundle/polyfill.d.ts +2 -0
- package/target/bundle/polyfill.js +83 -0
- package/target/commands/build.d.ts +3 -0
- package/target/commands/build.js +22 -0
- package/target/commands/enterpriseDeploy.d.ts +3 -0
- package/target/commands/enterpriseDeploy.js +64 -0
- package/target/commands/enterprisePackage.d.ts +3 -0
- package/target/commands/enterprisePackage.js +28 -0
- package/target/commands/enterpriseStart.d.ts +3 -0
- package/target/commands/enterpriseStart.js +80 -0
- package/target/commands/index.d.ts +2 -0
- package/target/commands/index.js +28 -0
- package/target/commands/install.d.ts +3 -0
- package/target/commands/install.js +18 -0
- package/target/commands/options.d.ts +50 -0
- package/target/commands/options.js +214 -0
- package/target/commands/recorder.d.ts +3 -0
- package/target/commands/recorder.js +28 -0
- package/target/commands/run.d.ts +3 -0
- package/target/commands/run.js +53 -0
- package/target/commands/runOnly.d.ts +3 -0
- package/target/commands/runOnly.js +37 -0
- package/target/dependencies/coursier.d.ts +1 -1
- package/target/dependencies/coursier.js +11 -6
- package/target/dependencies/index.d.ts +2 -0
- package/target/dependencies/index.js +4 -2
- package/target/dependencies/versions.d.ts +3 -0
- package/target/dependencies/versions.js +9 -6
- package/target/enterprise.d.ts +2 -1
- package/target/enterprise.js +7 -6
- package/target/index.js +2 -337
- package/target/run.js +4 -2
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const options_1 = require("./options");
|
|
4
|
+
const run_1 = require("../run");
|
|
5
|
+
exports.default = (program) => {
|
|
6
|
+
program
|
|
7
|
+
.command("run-only")
|
|
8
|
+
.description("Run a Gatling simulation from an already built bundle")
|
|
9
|
+
.addOption(options_1.graalvmHomeMandatoryOption)
|
|
10
|
+
.addOption(options_1.jvmClasspathMandatoryOption)
|
|
11
|
+
.addOption(options_1.simulationMandatoryOption)
|
|
12
|
+
.addOption(options_1.bundleFileOption)
|
|
13
|
+
.addOption(options_1.resourcesFolderOption)
|
|
14
|
+
.addOption(options_1.resultsFolderOption)
|
|
15
|
+
.addOption(options_1.memoryOption)
|
|
16
|
+
.addArgument(options_1.runParametersArgument)
|
|
17
|
+
.action(async (args, options) => {
|
|
18
|
+
const graalvmHome = (0, options_1.graalvmHomeMandatoryOptionValue)(options);
|
|
19
|
+
const jvmClasspath = (0, options_1.jvmClasspathMandatoryOptionValue)(options);
|
|
20
|
+
const simulation = (0, options_1.simulationMandatoryOptionValue)(options);
|
|
21
|
+
const bundleFile = (0, options_1.bundleFileOptionValue)(options);
|
|
22
|
+
const resourcesFolder = (0, options_1.resourcesFolderOptionValue)(options);
|
|
23
|
+
const resultsFolder = (0, options_1.resultsFolderOptionValue)(options);
|
|
24
|
+
const memory = (0, options_1.memoryOptionValue)(options);
|
|
25
|
+
const runParameters = (0, options_1.parseRunParametersArgument)(args);
|
|
26
|
+
await (0, run_1.runSimulation)({
|
|
27
|
+
graalvmHome,
|
|
28
|
+
jvmClasspath,
|
|
29
|
+
simulation: simulation,
|
|
30
|
+
bundleFile,
|
|
31
|
+
resourcesFolder,
|
|
32
|
+
resultsFolder,
|
|
33
|
+
memory,
|
|
34
|
+
runParameters
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const installCoursier: (gatlingHomeDir: string, downloadDir: string) => Promise<string>;
|
|
2
|
-
export declare const resolveGatlingJsDependencies: (coursierPath: string, javaHome: string) => Promise<string>;
|
|
2
|
+
export declare const resolveGatlingJsDependencies: (coursierPath: string, javaHome: string, postmanVersion?: string) => Promise<string>;
|
|
3
3
|
export declare const resolveRecorderDependencies: (coursierPath: string, javaHome: string) => Promise<string>;
|
|
@@ -46,12 +46,17 @@ const installCoursier = async (gatlingHomeDir, downloadDir) => {
|
|
|
46
46
|
return coursierPath;
|
|
47
47
|
};
|
|
48
48
|
exports.installCoursier = installCoursier;
|
|
49
|
-
const resolveGatlingJsDependencies = async (coursierPath, javaHome) => {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
const resolveGatlingJsDependencies = async (coursierPath, javaHome, postmanVersion) => {
|
|
50
|
+
const dependencies = [
|
|
51
|
+
`"io.gatling.highcharts:gatling-charts-highcharts:${versions_1.versions.gatling.core}"`,
|
|
52
|
+
`"io.gatling:gatling-jvm-to-js-adapter:${versions_1.versions.gatling.jsAdapter}"`,
|
|
53
|
+
`"io.gatling:gatling-enterprise-plugin-commons:${versions_1.versions.gatling.enterprisePluginCommons}"`,
|
|
54
|
+
`"org.graalvm.polyglot:js-community:${versions_1.versions.graalvm.js}"`
|
|
55
|
+
];
|
|
56
|
+
if (postmanVersion !== undefined) {
|
|
57
|
+
dependencies.push(`"io.gatling:gatling-postman-jvm-to-js-adapter:${postmanVersion}"`);
|
|
58
|
+
}
|
|
59
|
+
return await resolveDependencies(coursierPath, javaHome, ...dependencies);
|
|
55
60
|
};
|
|
56
61
|
exports.resolveGatlingJsDependencies = resolveGatlingJsDependencies;
|
|
57
62
|
const resolveRecorderDependencies = async (coursierPath, javaHome) => {
|
|
@@ -3,16 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.installRecorder = exports.installGatlingJs = void 0;
|
|
6
|
+
exports.installRecorder = exports.installGatlingJs = exports.versions = void 0;
|
|
7
7
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
8
|
const coursier_1 = require("./coursier");
|
|
9
9
|
const graalVm_1 = require("./graalVm");
|
|
10
|
+
var versions_1 = require("./versions");
|
|
11
|
+
Object.defineProperty(exports, "versions", { enumerable: true, get: function () { return versions_1.versions; } });
|
|
10
12
|
const installGatlingJs = async (options) => {
|
|
11
13
|
const downloadDir = `${options.gatlingHome}/tmp/download`;
|
|
12
14
|
await promises_1.default.mkdir(downloadDir, { recursive: true });
|
|
13
15
|
const graalvmHomePath = await (0, graalVm_1.installGraalVm)(options.gatlingHome, downloadDir);
|
|
14
16
|
const coursierPath = await (0, coursier_1.installCoursier)(options.gatlingHome, downloadDir);
|
|
15
|
-
const classpath = await (0, coursier_1.resolveGatlingJsDependencies)(coursierPath, graalvmHomePath);
|
|
17
|
+
const classpath = await (0, coursier_1.resolveGatlingJsDependencies)(coursierPath, graalvmHomePath, options.postman);
|
|
16
18
|
return {
|
|
17
19
|
graalvmHome: graalvmHomePath,
|
|
18
20
|
coursierBinary: coursierPath,
|
|
@@ -3,13 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.versions = void 0;
|
|
4
4
|
exports.versions = {
|
|
5
5
|
graalvm: {
|
|
6
|
-
jdk: "
|
|
7
|
-
js: "24.
|
|
6
|
+
jdk: "23.0.0",
|
|
7
|
+
js: "24.1.1"
|
|
8
8
|
},
|
|
9
|
-
|
|
9
|
+
java: {
|
|
10
|
+
compilerRelease: "21"
|
|
11
|
+
},
|
|
12
|
+
coursier: "2.1.12",
|
|
10
13
|
gatling: {
|
|
11
|
-
core: "3.
|
|
12
|
-
enterprisePluginCommons: "1.9.
|
|
13
|
-
jsAdapter: "3.
|
|
14
|
+
core: "3.13.1",
|
|
15
|
+
enterprisePluginCommons: "1.9.8",
|
|
16
|
+
jsAdapter: "3.13.1"
|
|
14
17
|
}
|
|
15
18
|
};
|
package/target/enterprise.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ export interface EnterprisePluginOptions extends RunJavaProcessOptions {
|
|
|
11
11
|
bundleFile: string;
|
|
12
12
|
resourcesFolder: string;
|
|
13
13
|
resultsFolder: string;
|
|
14
|
-
|
|
14
|
+
apiUrl: string;
|
|
15
|
+
webAppUrl: string;
|
|
15
16
|
apiToken?: string;
|
|
16
17
|
controlPlaneUrl?: string;
|
|
17
18
|
nonInteractive: boolean;
|
package/target/enterprise.js
CHANGED
|
@@ -8,7 +8,7 @@ const archiver_1 = __importDefault(require("archiver"));
|
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const promises_1 = require("stream/promises");
|
|
10
10
|
const zlib_1 = require("zlib");
|
|
11
|
-
const
|
|
11
|
+
const dependencies_1 = require("./dependencies");
|
|
12
12
|
const java_1 = require("./java");
|
|
13
13
|
const log_1 = require("./log");
|
|
14
14
|
const enterprisePackage = async (options) => {
|
|
@@ -41,11 +41,11 @@ const generateManifest = (simulationNames) => {
|
|
|
41
41
|
"Manifest-Version: 1.0",
|
|
42
42
|
"Specification-Vendor: GatlingCorp",
|
|
43
43
|
"Gatling-Context: js",
|
|
44
|
-
`Gatling-Version: ${
|
|
44
|
+
`Gatling-Version: ${dependencies_1.versions.gatling.core}`,
|
|
45
45
|
"Gatling-Packager: js-cli",
|
|
46
|
-
`Gatling-Packager-Version: ${
|
|
46
|
+
`Gatling-Packager-Version: ${dependencies_1.versions.gatling.jsAdapter}`,
|
|
47
47
|
`Gatling-Simulations: ${simulationNames.join(",")}`,
|
|
48
|
-
`Java-Version: ${
|
|
48
|
+
`Java-Version: ${dependencies_1.versions.java.compilerRelease}`
|
|
49
49
|
];
|
|
50
50
|
const pkg = getPackageNameAndVersion();
|
|
51
51
|
lines.push(`Implementation-Title: ${pkg.name}`);
|
|
@@ -110,7 +110,8 @@ const getPackageNameAndVersion = () => {
|
|
|
110
110
|
const javaArgsFromPluginOptions = (options) => {
|
|
111
111
|
const javaArgs = [];
|
|
112
112
|
// Base
|
|
113
|
-
javaArgs.push(`-Dgatling.enterprise.
|
|
113
|
+
javaArgs.push(`-Dgatling.enterprise.apiUrl=${options.apiUrl}`);
|
|
114
|
+
javaArgs.push(`-Dgatling.enterprise.webAppUrl=${options.webAppUrl}`);
|
|
114
115
|
if (options.apiToken !== undefined) {
|
|
115
116
|
javaArgs.push(`-Dgatling.enterprise.apiToken=${options.apiToken}`);
|
|
116
117
|
}
|
|
@@ -119,7 +120,7 @@ const javaArgsFromPluginOptions = (options) => {
|
|
|
119
120
|
javaArgs.push(`-Dgatling.enterprise.controlPlaneUrl=${options.controlPlaneUrl}`);
|
|
120
121
|
}
|
|
121
122
|
javaArgs.push("-Dgatling.enterprise.buildTool=js-cli");
|
|
122
|
-
javaArgs.push(`-Dgatling.enterprise.pluginVersion=${
|
|
123
|
+
javaArgs.push(`-Dgatling.enterprise.pluginVersion=${dependencies_1.versions.gatling.jsAdapter}`);
|
|
123
124
|
if (options.nonInteractive) {
|
|
124
125
|
javaArgs.push(`-Dgatling.enterprise.batchMode=true`);
|
|
125
126
|
}
|
package/target/index.js
CHANGED
|
@@ -1,340 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const bundle_1 = require("./bundle");
|
|
10
|
-
const dependencies_1 = require("./dependencies");
|
|
11
|
-
const enterprise_1 = require("./enterprise");
|
|
12
|
-
const simulations_1 = require("./simulations");
|
|
13
|
-
const log_1 = require("./log");
|
|
14
|
-
const readline_1 = require("./readline");
|
|
15
|
-
const run_1 = require("./run");
|
|
16
|
-
const program = new commander_1.Command()
|
|
17
|
-
.name("gatling-js-cli")
|
|
18
|
-
.version("0.0.1")
|
|
19
|
-
.description("The Gatling Javascript run & packaging tool");
|
|
20
|
-
const gatlingHomeOption = new commander_1.Option("--gatling-home <value>", 'The folder used to download and install Gatling components (default: "~/.gatling")');
|
|
21
|
-
const gatlingHomeDirWithDefaults = (options) => options.gatlingHome || `${os_1.default.homedir()}/.gatling`;
|
|
22
|
-
const sourcesFolderOption = new commander_1.Option("--sources-folder <value>", "The sources folder path").default("src");
|
|
23
|
-
const simulationOption = new commander_1.Option("--simulation <value>", "The simulation entry point function name (default: if only one *.gatling.js or *.gatling.ts file is found, will execute that simulation)");
|
|
24
|
-
const simulationWithDefaults = (options, simulationsFound, interactive) => {
|
|
25
|
-
if (options.simulation !== undefined) {
|
|
26
|
-
return options.simulation;
|
|
27
|
-
}
|
|
28
|
-
else if (simulationsFound.length === 1) {
|
|
29
|
-
return simulationsFound[0].name;
|
|
30
|
-
}
|
|
31
|
-
else if (simulationsFound.length === 0) {
|
|
32
|
-
throw new Error("No simulation found, simulations must be defined in a <simulation name>.gatling.js or <simulation name>.gatling.ts file)");
|
|
33
|
-
}
|
|
34
|
-
else if (interactive) {
|
|
35
|
-
const idx = (0, readline_1.keyInSelectPaginated)(simulationsFound.map((s) => s.name).sort((a, b) => a.localeCompare(b)), "Choose a simulation to run");
|
|
36
|
-
if (idx >= 0) {
|
|
37
|
-
const simulation = simulationsFound[idx].name;
|
|
38
|
-
log_1.logger.info(`Simulation '${simulation}' was chosen.`);
|
|
39
|
-
return simulation;
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
throw new Error("Simulation choice was cancelled.");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
throw new Error(`Several simulations found, specify one using the --simulation option (available simulations: ${simulationsFound.map((s) => s.name)})`);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const simulationRequiredOption = new commander_1.Option("--simulation <value>", "The simulation entry point function name").makeOptionMandatory(true);
|
|
50
|
-
const bundleFileOption = new commander_1.Option("--bundle-file <value>", "The target bundle file path when building simulations (must have a .js extension)").default("target/bundle.js");
|
|
51
|
-
const validateBundleFile = (options) => {
|
|
52
|
-
if (!options.bundleFile.endsWith(".js")) {
|
|
53
|
-
throw Error(`'${options.bundleFile}' is not a valid bundle file path: should have a .js extension`);
|
|
54
|
-
}
|
|
55
|
-
return options.bundleFile;
|
|
56
|
-
};
|
|
57
|
-
const packageFileOption = new commander_1.Option("--package-file <value>", "The target package file path when packaging simulations for Gatling Enterprise (must have a .zip extension)").default("target/package.zip");
|
|
58
|
-
const validatePackageFile = (options) => {
|
|
59
|
-
if (!options.packageFile.endsWith(".zip")) {
|
|
60
|
-
throw Error(`'${options.packageFile}' is not a valid package file path: should have a .zip extension`);
|
|
61
|
-
}
|
|
62
|
-
return options.packageFile;
|
|
63
|
-
};
|
|
64
|
-
const resourcesFolderOption = new commander_1.Option("--resources-folder <value>", "The resources folder path").default("resources");
|
|
65
|
-
const resultsFolderOption = new commander_1.Option("--results-folder <value>", "The results folder path").default("target/gatling");
|
|
66
|
-
const typescriptOption = new commander_1.Option("--typescript", "Use the typescript compiler to compile your code (default: true if the sourcesFolder contains any *.gatling.ts file, false otherwise)");
|
|
67
|
-
const typescriptWithDefaults = (options, simulationsFound) => options.typescript !== undefined
|
|
68
|
-
? options.typescript
|
|
69
|
-
: simulationsFound.findIndex((s) => s.type === "typescript") >= 0;
|
|
70
|
-
const graalvmHomeMandatoryOption = new commander_1.Option("--graalvm-home <value>", "Path to the GraalVM home").makeOptionMandatory(true);
|
|
71
|
-
const jvmClasspathMandatoryOption = new commander_1.Option("--jvm-classpath <value>", "The classpath containing all Gatling JVM components").makeOptionMandatory(true);
|
|
72
|
-
const memoryOption = new commander_1.Option("--memory <value>", "Heap space memory size in MiB for Gatling. Half the total available memory is usually a good default, as the Gatling process will use more memory than just the heap space.").argParser((value) => {
|
|
73
|
-
const parsedValue = parseInt(value, 10);
|
|
74
|
-
if (isNaN(parsedValue)) {
|
|
75
|
-
throw new Error(`${value} is not a valid memory size, must be an integer number`);
|
|
76
|
-
}
|
|
77
|
-
return parsedValue;
|
|
78
|
-
});
|
|
79
|
-
const nonInteractiveOption = new commander_1.Option("--non-interactive", "Switch to non-interactive mode and fail if no simulation is explicitly specified").default(false);
|
|
80
|
-
const runParametersArgument = new commander_1.Argument("[optionKey=optionValue...]", "Specify one or more parameter which can be read in the simulation script with the getParameter() function; format must be key=value");
|
|
81
|
-
const parseRunParameters = (args) => {
|
|
82
|
-
const parsedParameters = {};
|
|
83
|
-
for (const arg of args) {
|
|
84
|
-
const i = arg.indexOf("=");
|
|
85
|
-
if (i < 0) {
|
|
86
|
-
throw Error(`Parameter '${arg}' is not valid: format should be key=value`);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
const key = arg.slice(0, i).trim();
|
|
90
|
-
parsedParameters[key] = arg.slice(i + 1);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return parsedParameters;
|
|
94
|
-
};
|
|
95
|
-
program
|
|
96
|
-
.command("install")
|
|
97
|
-
.description("Install all required components and dependencies for Gatling")
|
|
98
|
-
.addOption(gatlingHomeOption)
|
|
99
|
-
.action(async (options) => {
|
|
100
|
-
const gatlingHome = gatlingHomeDirWithDefaults(options);
|
|
101
|
-
const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome });
|
|
102
|
-
log_1.logger.info(`graalvmHome=${graalvmHome}`);
|
|
103
|
-
log_1.logger.info(`coursierBinary=${coursierBinary}`);
|
|
104
|
-
log_1.logger.info(`jvmClasspath=${jvmClasspath}`);
|
|
105
|
-
});
|
|
106
|
-
program
|
|
107
|
-
.command("build")
|
|
108
|
-
.description("Build Gatling simulations")
|
|
109
|
-
.addOption(sourcesFolderOption)
|
|
110
|
-
.addOption(bundleFileOption)
|
|
111
|
-
.addOption(typescriptOption)
|
|
112
|
-
.action(async (options) => {
|
|
113
|
-
const sourcesFolder = options.sourcesFolder;
|
|
114
|
-
const bundleFile = validateBundleFile(options);
|
|
115
|
-
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
116
|
-
const typescript = typescriptWithDefaults(options, simulations);
|
|
117
|
-
await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, typescript, simulations });
|
|
118
|
-
});
|
|
119
|
-
program
|
|
120
|
-
.command("run-only")
|
|
121
|
-
.description("Run a Gatling simulation from an already built bundle")
|
|
122
|
-
.addOption(graalvmHomeMandatoryOption)
|
|
123
|
-
.addOption(jvmClasspathMandatoryOption)
|
|
124
|
-
.addOption(simulationRequiredOption)
|
|
125
|
-
.addOption(bundleFileOption)
|
|
126
|
-
.addOption(resourcesFolderOption)
|
|
127
|
-
.addOption(resultsFolderOption)
|
|
128
|
-
.addOption(memoryOption)
|
|
129
|
-
.addArgument(runParametersArgument)
|
|
130
|
-
.action(async (args, options) => {
|
|
131
|
-
const graalvmHome = options.graalvmHome;
|
|
132
|
-
const jvmClasspath = options.jvmClasspath;
|
|
133
|
-
const simulation = options.simulation;
|
|
134
|
-
const bundleFile = validateBundleFile(options);
|
|
135
|
-
const resourcesFolder = options.resourcesFolder;
|
|
136
|
-
const resultsFolder = options.resultsFolder;
|
|
137
|
-
const memory = options.memory;
|
|
138
|
-
const runParameters = parseRunParameters(args);
|
|
139
|
-
await (0, run_1.runSimulation)({
|
|
140
|
-
graalvmHome,
|
|
141
|
-
jvmClasspath,
|
|
142
|
-
simulation: simulation,
|
|
143
|
-
bundleFile,
|
|
144
|
-
resourcesFolder,
|
|
145
|
-
resultsFolder,
|
|
146
|
-
memory,
|
|
147
|
-
runParameters
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
program
|
|
151
|
-
.command("run")
|
|
152
|
-
.description("Build and run a Gatling simulation, after installing all required components and dependencies for Gatling")
|
|
153
|
-
.addOption(sourcesFolderOption)
|
|
154
|
-
.addOption(simulationOption)
|
|
155
|
-
.addOption(typescriptOption)
|
|
156
|
-
.addOption(bundleFileOption)
|
|
157
|
-
.addOption(resourcesFolderOption)
|
|
158
|
-
.addOption(resultsFolderOption)
|
|
159
|
-
.addOption(gatlingHomeOption)
|
|
160
|
-
.addOption(memoryOption)
|
|
161
|
-
.addOption(nonInteractiveOption)
|
|
162
|
-
.addArgument(runParametersArgument)
|
|
163
|
-
.action(async (args, options) => {
|
|
164
|
-
const gatlingHome = gatlingHomeDirWithDefaults(options);
|
|
165
|
-
const sourcesFolder = options.sourcesFolder;
|
|
166
|
-
const bundleFile = validateBundleFile(options);
|
|
167
|
-
const resourcesFolder = options.resourcesFolder;
|
|
168
|
-
const resultsFolder = options.resultsFolder;
|
|
169
|
-
const memory = options.memory;
|
|
170
|
-
const nonInteractive = options.nonInteractive;
|
|
171
|
-
const runParameters = parseRunParameters(args);
|
|
172
|
-
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
173
|
-
const typescript = typescriptWithDefaults(options, simulations);
|
|
174
|
-
const simulation = simulationWithDefaults(options, simulations, !nonInteractive);
|
|
175
|
-
const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome });
|
|
176
|
-
log_1.logger.debug(`graalvmHome=${graalvmHome}`);
|
|
177
|
-
log_1.logger.debug(`coursierBinary=${coursierBinary}`);
|
|
178
|
-
log_1.logger.debug(`jvmClasspath=${jvmClasspath}`);
|
|
179
|
-
await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, typescript, simulations });
|
|
180
|
-
await (0, run_1.runSimulation)({
|
|
181
|
-
graalvmHome,
|
|
182
|
-
jvmClasspath,
|
|
183
|
-
simulation,
|
|
184
|
-
bundleFile,
|
|
185
|
-
resourcesFolder,
|
|
186
|
-
resultsFolder,
|
|
187
|
-
memory,
|
|
188
|
-
runParameters
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
program
|
|
192
|
-
.command("recorder")
|
|
193
|
-
.description("Run the Gatling recorder")
|
|
194
|
-
.addOption(gatlingHomeOption)
|
|
195
|
-
.addOption(sourcesFolderOption)
|
|
196
|
-
.addOption(typescriptOption)
|
|
197
|
-
.addOption(resourcesFolderOption)
|
|
198
|
-
.action(async (options) => {
|
|
199
|
-
const gatlingHome = gatlingHomeDirWithDefaults(options);
|
|
200
|
-
const sourcesFolder = options.sourcesFolder;
|
|
201
|
-
const resourcesFolder = options.resourcesFolder;
|
|
202
|
-
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
203
|
-
const typescript = typescriptWithDefaults(options, simulations);
|
|
204
|
-
const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installRecorder)({ gatlingHome });
|
|
205
|
-
log_1.logger.debug(`graalvmHome=${graalvmHome}`);
|
|
206
|
-
log_1.logger.debug(`coursierBinary=${coursierBinary}`);
|
|
207
|
-
log_1.logger.debug(`jvmClasspath=${jvmClasspath}`);
|
|
208
|
-
await (0, run_1.runRecorder)({ graalvmHome, jvmClasspath, sourcesFolder, typescript, resourcesFolder });
|
|
209
|
-
});
|
|
210
|
-
program
|
|
211
|
-
.command("enterprise-package")
|
|
212
|
-
.description("Build Gatling simulations and package them for Gatling Enterprise")
|
|
213
|
-
.addOption(sourcesFolderOption)
|
|
214
|
-
.addOption(resourcesFolderOption)
|
|
215
|
-
.addOption(bundleFileOption)
|
|
216
|
-
.addOption(packageFileOption)
|
|
217
|
-
.addOption(typescriptOption)
|
|
218
|
-
.action(async (options) => {
|
|
219
|
-
const sourcesFolder = options.sourcesFolder;
|
|
220
|
-
const resourcesFolder = options.resourcesFolder;
|
|
221
|
-
const bundleFile = validateBundleFile(options);
|
|
222
|
-
const packageFile = validatePackageFile(options);
|
|
223
|
-
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
224
|
-
const typescript = typescriptWithDefaults(options, simulations);
|
|
225
|
-
await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, typescript, simulations });
|
|
226
|
-
await (0, enterprise_1.enterprisePackage)({ bundleFile, resourcesFolder, packageFile, simulations });
|
|
227
|
-
});
|
|
228
|
-
const urlOption = new commander_1.Option("--url <value>", "URL of Gatling Enterprise")
|
|
229
|
-
.default("https://cloud.gatling.io")
|
|
230
|
-
.hideHelp();
|
|
231
|
-
const apiTokenOption = new commander_1.Option("--api-token <value>", "API Token on Gatling Enterprise. Prefer configuration using `GATLING_ENTERPRISE_API_TOKEN` environment variable.");
|
|
232
|
-
// Plugin configuration
|
|
233
|
-
const controlPlaneUrlOption = new commander_1.Option("--control-plane-url <value>", "URL of a control plane for Gatling Enterprise providing a private repository. If this parameter is provided, packages will be registered as private packages and uploaded through this private control plane.");
|
|
234
|
-
// Descriptor file
|
|
235
|
-
const packageDescriptorFilenameOption = new commander_1.Option("--package-descriptor-filename <value>", "Path to a package descriptor inside the .gatling folder").default("package.conf");
|
|
236
|
-
const enterpriseBundleAndPackage = async (options) => {
|
|
237
|
-
const gatlingHome = gatlingHomeDirWithDefaults(options);
|
|
238
|
-
const sourcesFolder = options.sourcesFolder;
|
|
239
|
-
const bundleFile = validateBundleFile(options);
|
|
240
|
-
const resourcesFolder = options.resourcesFolder;
|
|
241
|
-
const resultsFolder = options.resultsFolder;
|
|
242
|
-
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
243
|
-
const typescript = typescriptWithDefaults(options, simulations);
|
|
244
|
-
// Base
|
|
245
|
-
const url = options.url;
|
|
246
|
-
const apiToken = options.apiToken;
|
|
247
|
-
// Plugin configuration
|
|
248
|
-
const controlPlaneUrl = options.controlPlaneUrl;
|
|
249
|
-
const nonInteractive = options.nonInteractive;
|
|
250
|
-
// Descriptor file
|
|
251
|
-
const packageDescriptorFilename = options.packageDescriptorFilename;
|
|
252
|
-
// Deployment info
|
|
253
|
-
const packageFile = validatePackageFile(options);
|
|
254
|
-
const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome });
|
|
255
|
-
log_1.logger.debug(`graalvmHome=${graalvmHome}`);
|
|
256
|
-
log_1.logger.debug(`coursierBinary=${coursierBinary}`);
|
|
257
|
-
log_1.logger.debug(`jvmClasspath=${jvmClasspath}`);
|
|
258
|
-
await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, typescript, simulations });
|
|
259
|
-
await (0, enterprise_1.enterprisePackage)({ bundleFile, resourcesFolder, packageFile, simulations });
|
|
260
|
-
return {
|
|
261
|
-
graalvmHome,
|
|
262
|
-
jvmClasspath,
|
|
263
|
-
bundleFile,
|
|
264
|
-
resourcesFolder,
|
|
265
|
-
resultsFolder,
|
|
266
|
-
// Base
|
|
267
|
-
url,
|
|
268
|
-
apiToken,
|
|
269
|
-
// Plugin configuration
|
|
270
|
-
controlPlaneUrl,
|
|
271
|
-
nonInteractive,
|
|
272
|
-
// Descriptor file
|
|
273
|
-
packageDescriptorFilename,
|
|
274
|
-
// Deployment info
|
|
275
|
-
packageFile
|
|
276
|
-
};
|
|
277
|
-
};
|
|
278
|
-
program
|
|
279
|
-
.command("enterprise-deploy")
|
|
280
|
-
.description("Deploy a package and configured simulations")
|
|
281
|
-
.addOption(sourcesFolderOption)
|
|
282
|
-
.addOption(resourcesFolderOption)
|
|
283
|
-
.addOption(bundleFileOption)
|
|
284
|
-
.addOption(resultsFolderOption)
|
|
285
|
-
// Base
|
|
286
|
-
.addOption(urlOption)
|
|
287
|
-
.addOption(apiTokenOption)
|
|
288
|
-
// Plugin configuration
|
|
289
|
-
.addOption(controlPlaneUrlOption)
|
|
290
|
-
.addOption(nonInteractiveOption)
|
|
291
|
-
// Descriptor file
|
|
292
|
-
.addOption(packageDescriptorFilenameOption)
|
|
293
|
-
// Deployment info
|
|
294
|
-
.addOption(packageFileOption)
|
|
295
|
-
.action(async (options) => {
|
|
296
|
-
const deployOptions = await enterpriseBundleAndPackage(options);
|
|
297
|
-
await (0, enterprise_1.enterpriseDeploy)(deployOptions);
|
|
298
|
-
});
|
|
299
|
-
// Deployment info
|
|
300
|
-
const enterpriseSimulationOption = new commander_1.Option("--enterprise-simulation <value>", "Specify the simulation name directly to bypass the prompt using the following command.");
|
|
301
|
-
const runTitleOption = new commander_1.Option("--run-title <value>", "Allows setting a title for your run reports.");
|
|
302
|
-
const runDescriptionOption = new commander_1.Option("--run-description <value>", "Allows setting a description for your run reports summary.");
|
|
303
|
-
const waitForRunEndOption = new commander_1.Option("--wait-for-run-end", "Wait for the result after starting the simulation on Gatling Enterprise, and complete with an error if the simulation ends with any error status").default(false);
|
|
304
|
-
program
|
|
305
|
-
.command("enterprise-start")
|
|
306
|
-
.description("Start a simulation deployed with `enterprise-deploy`")
|
|
307
|
-
.addOption(sourcesFolderOption)
|
|
308
|
-
.addOption(resourcesFolderOption)
|
|
309
|
-
.addOption(bundleFileOption)
|
|
310
|
-
.addOption(resultsFolderOption)
|
|
311
|
-
// Base
|
|
312
|
-
.addOption(urlOption)
|
|
313
|
-
.addOption(apiTokenOption)
|
|
314
|
-
// Plugin configuration
|
|
315
|
-
.addOption(controlPlaneUrlOption)
|
|
316
|
-
.addOption(nonInteractiveOption)
|
|
317
|
-
// Descriptor file
|
|
318
|
-
.addOption(packageDescriptorFilenameOption)
|
|
319
|
-
// Deployment info
|
|
320
|
-
.addOption(packageFileOption)
|
|
321
|
-
// Start
|
|
322
|
-
.addOption(enterpriseSimulationOption)
|
|
323
|
-
.addOption(runTitleOption)
|
|
324
|
-
.addOption(runDescriptionOption)
|
|
325
|
-
.addOption(waitForRunEndOption)
|
|
326
|
-
.action(async (options) => {
|
|
327
|
-
const deployOptions = await enterpriseBundleAndPackage(options);
|
|
328
|
-
if (options.nonInteractive && options.enterpriseSimulation === undefined) {
|
|
329
|
-
throw new Error(`No simulation specified when using non-interactive mode`);
|
|
330
|
-
}
|
|
331
|
-
await (0, enterprise_1.enterpriseStart)({
|
|
332
|
-
...deployOptions,
|
|
333
|
-
// Start
|
|
334
|
-
enterpriseSimulation: options.enterpriseSimulation,
|
|
335
|
-
runTitle: options.runTitle,
|
|
336
|
-
runDescription: options.runDescription,
|
|
337
|
-
waitForRunEnd: options.waitForRunEnd
|
|
338
|
-
});
|
|
339
|
-
});
|
|
340
|
-
program.parse(process.argv);
|
|
4
|
+
const commands_1 = require("./commands");
|
|
5
|
+
commands_1.program.parse(process.argv);
|
package/target/run.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runRecorder = exports.runSimulation = void 0;
|
|
4
4
|
const log_1 = require("./log");
|
|
5
|
-
const
|
|
5
|
+
const dependencies_1 = require("./dependencies");
|
|
6
6
|
const java_1 = require("./java");
|
|
7
7
|
const runSimulation = async (options) => {
|
|
8
8
|
log_1.logger.info(`Running a Gatling simulation with options:
|
|
@@ -11,11 +11,13 @@ const runSimulation = async (options) => {
|
|
|
11
11
|
- resourcesFolder: ${options.resourcesFolder}
|
|
12
12
|
- resultsFolder: ${options.resultsFolder}`);
|
|
13
13
|
const additionalClasspathElements = [options.resourcesFolder];
|
|
14
|
+
const jitTuningArgs = ["-XX:JVMCINativeLibraryThreadFraction=0.8", "-Dgraal.MethodInlineBailoutLimit=500"];
|
|
14
15
|
const memoryArgs = options.memory !== undefined ? [`-Xms${options.memory}M`, `-Xmx${options.memory}M`] : [];
|
|
15
16
|
const javaArgs = [
|
|
16
17
|
...Object.entries(options.runParameters).map(([key, value]) => `-D${key}=${value}`),
|
|
17
18
|
`-Dgatling.js.bundle.filePath=${options.bundleFile}`,
|
|
18
19
|
`-Dgatling.js.simulation=${options.simulation}`,
|
|
20
|
+
...jitTuningArgs,
|
|
19
21
|
...memoryArgs
|
|
20
22
|
];
|
|
21
23
|
const simulationArgs = [
|
|
@@ -26,7 +28,7 @@ const runSimulation = async (options) => {
|
|
|
26
28
|
"--launcher",
|
|
27
29
|
"gatling-js-cli",
|
|
28
30
|
"--build-tool-version",
|
|
29
|
-
|
|
31
|
+
dependencies_1.versions.gatling.jsAdapter
|
|
30
32
|
];
|
|
31
33
|
return (0, java_1.runJavaProcess)(options, "io.gatling.app.Gatling", additionalClasspathElements, javaArgs, simulationArgs);
|
|
32
34
|
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": "./",
|
|
4
|
+
"rootDir": "src",
|
|
5
|
+
"outDir": "target",
|
|
6
|
+
"lib": ["es2021", "dom"],
|
|
7
|
+
"target": "es2021",
|
|
8
|
+
"module": "node16",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"moduleResolution": "node16",
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"resolveJsonModule": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/**/*.ts"],
|
|
17
|
+
"exclude": ["**/*.test.ts"]
|
|
18
|
+
}
|