@gatling.io/cli 3.11.3-M1 → 3.11.4-M1
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 +3 -1
- package/target/bundle.d.ts +2 -0
- package/target/bundle.js +4 -8
- package/target/dependencies/coursier.d.ts +2 -1
- package/target/dependencies/coursier.js +12 -4
- package/target/dependencies/index.d.ts +2 -1
- package/target/dependencies/index.js +17 -4
- package/target/dependencies/versions.js +2 -2
- package/target/enterprisePackage.d.ts +8 -0
- package/target/enterprisePackage.js +82 -0
- package/target/index.js +82 -15
- package/target/run.d.ts +9 -1
- package/target/run.js +46 -17
- package/target/simulations.d.ts +6 -0
- package/target/simulations.js +23 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gatling.io/cli",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.4-M1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"gatling": "target/index.js"
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"main": "target/index.js",
|
|
9
9
|
"types": "target/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"archiver": "7.0.1",
|
|
11
12
|
"axios": "1.6.8",
|
|
12
13
|
"commander": "12.0.0",
|
|
13
14
|
"decompress": "4.2.1",
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
"esbuild-plugin-tsc": "0.4.0"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
19
|
+
"@types/archiver": "6.0.2",
|
|
18
20
|
"@types/decompress": "4.2.7",
|
|
19
21
|
"@types/node": "20.12.12",
|
|
20
22
|
"prettier": "3.2.5",
|
package/target/bundle.d.ts
CHANGED
package/target/bundle.js
CHANGED
|
@@ -29,17 +29,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.bundle = void 0;
|
|
30
30
|
const esbuild = __importStar(require("esbuild"));
|
|
31
31
|
const esbuild_plugin_tsc_1 = __importDefault(require("esbuild-plugin-tsc"));
|
|
32
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
33
32
|
const log_1 = require("./log");
|
|
34
33
|
const bundle = async (options) => {
|
|
35
|
-
log_1.logger.info(`
|
|
34
|
+
log_1.logger.info(`Bundling a Gatling simulation with options:
|
|
36
35
|
- sourcesFolder: ${options.sourcesFolder}
|
|
37
|
-
- bundleFile: ${options.bundleFile}
|
|
38
|
-
|
|
39
|
-
const contents =
|
|
40
|
-
.filter((f) => (options.typescript ? f.endsWith(".gatling.ts") : f.endsWith(".gatling.js")))
|
|
41
|
-
.map((f) => `export { default as "${f.slice(0, -11)}" } from "./${f}";`)
|
|
42
|
-
.join("\n");
|
|
36
|
+
- bundleFile: ${options.bundleFile}
|
|
37
|
+
- typescript: ${options.typescript}`);
|
|
38
|
+
const contents = options.simulations.map((s) => `export { default as "${s.name}" } from "./${s.path}";`).join("\n");
|
|
43
39
|
const plugins = options.typescript ? [(0, esbuild_plugin_tsc_1.default)({ force: true })] : [];
|
|
44
40
|
await esbuild.build({
|
|
45
41
|
stdin: {
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare const installCoursier: (gatlingHomeDir: string, downloadDir: string) => Promise<string>;
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const resolveGatlingJsDependencies: (coursierPath: string, javaHome: string) => Promise<string>;
|
|
3
|
+
export declare const resolveRecorderDependencies: (coursierPath: string, javaHome: string) => Promise<string>;
|
|
@@ -3,7 +3,7 @@ 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.
|
|
6
|
+
exports.resolveRecorderDependencies = exports.resolveGatlingJsDependencies = exports.installCoursier = void 0;
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
9
|
const download_1 = require("./download");
|
|
@@ -46,15 +46,23 @@ const installCoursier = async (gatlingHomeDir, downloadDir) => {
|
|
|
46
46
|
return coursierPath;
|
|
47
47
|
};
|
|
48
48
|
exports.installCoursier = installCoursier;
|
|
49
|
-
const
|
|
49
|
+
const resolveGatlingJsDependencies = async (coursierPath, javaHome) => {
|
|
50
50
|
const gatlingDep = `"io.gatling.highcharts:gatling-charts-highcharts:${versions_1.versions.gatling.core}"`;
|
|
51
51
|
const gatlingAdapterDep = `"io.gatling:gatling-jvm-to-js-adapter:${versions_1.versions.gatling.jsAdapter}"`;
|
|
52
52
|
const graalvmJsDep = `"org.graalvm.polyglot:js-community:${versions_1.versions.graalvm.js}"`;
|
|
53
|
-
|
|
53
|
+
return await resolveDependencies(coursierPath, javaHome, gatlingDep, gatlingAdapterDep, graalvmJsDep);
|
|
54
|
+
};
|
|
55
|
+
exports.resolveGatlingJsDependencies = resolveGatlingJsDependencies;
|
|
56
|
+
const resolveRecorderDependencies = async (coursierPath, javaHome) => {
|
|
57
|
+
const recorderDep = `io.gatling:gatling-recorder:${versions_1.versions.gatling.core}`;
|
|
58
|
+
return await resolveDependencies(coursierPath, javaHome, recorderDep);
|
|
59
|
+
};
|
|
60
|
+
exports.resolveRecorderDependencies = resolveRecorderDependencies;
|
|
61
|
+
const resolveDependencies = async (coursierPath, javaHome, ...dependencies) => {
|
|
62
|
+
const command = `"${coursierPath}" fetch --classpath ${dependencies.join(" ")}`;
|
|
54
63
|
// TODO could add a timeout
|
|
55
64
|
log_1.logger.info(`Resolving dependencies with Coursier`);
|
|
56
65
|
const { stdout } = await execAsync(command, { env: { ...process.env, JAVA_HOME: javaHome } });
|
|
57
66
|
return stdout;
|
|
58
67
|
};
|
|
59
|
-
exports.resolveDependencies = resolveDependencies;
|
|
60
68
|
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
@@ -6,4 +6,5 @@ export interface ResolvedDependencies {
|
|
|
6
6
|
coursierBinary: string;
|
|
7
7
|
jvmClasspath: string;
|
|
8
8
|
}
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const installGatlingJs: (options: DependenciesOptions) => Promise<ResolvedDependencies>;
|
|
10
|
+
export declare const installRecorder: (options: DependenciesOptions) => Promise<ResolvedDependencies>;
|
|
@@ -3,20 +3,33 @@ 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.
|
|
6
|
+
exports.installRecorder = exports.installGatlingJs = 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
|
-
const
|
|
10
|
+
const installGatlingJs = async (options) => {
|
|
11
11
|
const downloadDir = `${options.gatlingHome}/tmp/download`;
|
|
12
12
|
await promises_1.default.mkdir(downloadDir, { recursive: true });
|
|
13
13
|
const graalvmHomePath = await (0, graalVm_1.installGraalVm)(options.gatlingHome, downloadDir);
|
|
14
14
|
const coursierPath = await (0, coursier_1.installCoursier)(options.gatlingHome, downloadDir);
|
|
15
|
-
const classpath = await (0, coursier_1.
|
|
15
|
+
const classpath = await (0, coursier_1.resolveGatlingJsDependencies)(coursierPath, graalvmHomePath);
|
|
16
16
|
return {
|
|
17
17
|
graalvmHome: graalvmHomePath,
|
|
18
18
|
coursierBinary: coursierPath,
|
|
19
19
|
jvmClasspath: classpath.trim()
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
exports.
|
|
22
|
+
exports.installGatlingJs = installGatlingJs;
|
|
23
|
+
const installRecorder = async (options) => {
|
|
24
|
+
const downloadDir = `${options.gatlingHome}/tmp/download`;
|
|
25
|
+
await promises_1.default.mkdir(downloadDir, { recursive: true });
|
|
26
|
+
const graalvmHomePath = await (0, graalVm_1.installGraalVm)(options.gatlingHome, downloadDir);
|
|
27
|
+
const coursierPath = await (0, coursier_1.installCoursier)(options.gatlingHome, downloadDir);
|
|
28
|
+
const classpath = await (0, coursier_1.resolveRecorderDependencies)(coursierPath, graalvmHomePath);
|
|
29
|
+
return {
|
|
30
|
+
graalvmHome: graalvmHomePath,
|
|
31
|
+
coursierBinary: coursierPath,
|
|
32
|
+
jvmClasspath: classpath.trim()
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.installRecorder = installRecorder;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SimulationFile } from "./simulations";
|
|
2
|
+
export interface EnterprisePackageOptions {
|
|
3
|
+
bundleFile: string;
|
|
4
|
+
resourcesFolder: string;
|
|
5
|
+
enterprisePackageFile: string;
|
|
6
|
+
simulations: SimulationFile[];
|
|
7
|
+
}
|
|
8
|
+
export declare const enterprisePackage: (options: EnterprisePackageOptions) => Promise<void>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.enterprisePackage = void 0;
|
|
7
|
+
const archiver_1 = __importDefault(require("archiver"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const promises_1 = require("stream/promises");
|
|
10
|
+
const zlib_1 = require("zlib");
|
|
11
|
+
const versions_1 = require("./dependencies/versions");
|
|
12
|
+
const log_1 = require("./log");
|
|
13
|
+
const enterprisePackage = async (options) => {
|
|
14
|
+
log_1.logger.info(`Packaging a Gatling simulation with options:
|
|
15
|
+
- bundleFile: ${options.bundleFile}
|
|
16
|
+
- enterprisePackageFile: ${options.enterprisePackageFile}`);
|
|
17
|
+
const manifest = generateManifest(options.simulations.map((s) => s.name));
|
|
18
|
+
const output = fs_1.default.createWriteStream(options.enterprisePackageFile);
|
|
19
|
+
const archive = (0, archiver_1.default)("zip", {
|
|
20
|
+
zlib: { level: zlib_1.constants.Z_MAX_LEVEL }
|
|
21
|
+
});
|
|
22
|
+
archive.on("warning", (err) => {
|
|
23
|
+
// The pipeline will rethrow errors but not warnings. We don't want to ignore warnings from the archiver, because
|
|
24
|
+
// they include things like 'no such file or directory'.
|
|
25
|
+
throw err;
|
|
26
|
+
});
|
|
27
|
+
archive.file(options.bundleFile, { name: "bundle.js" });
|
|
28
|
+
archive.append(Buffer.from(manifest), { name: "META-INF/MANIFEST.MF" });
|
|
29
|
+
archive.directory(options.resourcesFolder + "/", false);
|
|
30
|
+
archive.finalize();
|
|
31
|
+
await (0, promises_1.pipeline)(archive, output);
|
|
32
|
+
log_1.logger.info(`Package for Gatling Enterprise created at ${options.enterprisePackageFile}`);
|
|
33
|
+
};
|
|
34
|
+
exports.enterprisePackage = enterprisePackage;
|
|
35
|
+
const generateManifest = (simulationNames) => {
|
|
36
|
+
const utf8Encoder = new TextEncoder();
|
|
37
|
+
const eol = utf8Encoder.encode("\n");
|
|
38
|
+
const continuation = utf8Encoder.encode("\n ");
|
|
39
|
+
const lines = [
|
|
40
|
+
"Manifest-Version: 1.0",
|
|
41
|
+
"Implementation-Title: gatling-javascript",
|
|
42
|
+
`Implementation-Version: ${versions_1.versions.gatling.jsAdapter}`,
|
|
43
|
+
"Implementation-Vendor: GatlingCorp",
|
|
44
|
+
"Specification-Vendor: GatlingCorp",
|
|
45
|
+
"Gatling-Context: js",
|
|
46
|
+
`Gatling-Version: ${versions_1.versions.gatling.core}`,
|
|
47
|
+
"Gatling-Packager: javascript",
|
|
48
|
+
`Gatling-Packager-Version: ${versions_1.versions.gatling.jsAdapter}`,
|
|
49
|
+
`Gatling-Simulations: ${simulationNames.join(",")}`,
|
|
50
|
+
`Java-Version: ${versions_1.versions.graalvm.jdk.split(".")[0]}`
|
|
51
|
+
];
|
|
52
|
+
let totalLength = 0;
|
|
53
|
+
const buffer = [];
|
|
54
|
+
for (const line of lines) {
|
|
55
|
+
let lineLength = 0;
|
|
56
|
+
for (const char of line) {
|
|
57
|
+
const bytes = utf8Encoder.encode(char);
|
|
58
|
+
const byteLength = bytes.byteLength;
|
|
59
|
+
if (lineLength + byteLength > 71) {
|
|
60
|
+
buffer.push(continuation);
|
|
61
|
+
buffer.push(bytes);
|
|
62
|
+
// reset length for the new line (with +1 for leading space)
|
|
63
|
+
lineLength = byteLength + 1;
|
|
64
|
+
totalLength += byteLength + 2;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
buffer.push(bytes);
|
|
68
|
+
lineLength += byteLength;
|
|
69
|
+
totalLength += byteLength;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
buffer.push(eol);
|
|
73
|
+
totalLength += 1;
|
|
74
|
+
}
|
|
75
|
+
const manifest = new Uint8Array(totalLength);
|
|
76
|
+
let cursor = 0;
|
|
77
|
+
for (const elt of buffer) {
|
|
78
|
+
manifest.set(elt, cursor);
|
|
79
|
+
cursor += elt.byteLength;
|
|
80
|
+
}
|
|
81
|
+
return manifest;
|
|
82
|
+
};
|
package/target/index.js
CHANGED
|
@@ -8,6 +8,8 @@ const commander_1 = require("commander");
|
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const bundle_1 = require("./bundle");
|
|
10
10
|
const dependencies_1 = require("./dependencies");
|
|
11
|
+
const enterprisePackage_1 = require("./enterprisePackage");
|
|
12
|
+
const simulations_1 = require("./simulations");
|
|
11
13
|
const log_1 = require("./log");
|
|
12
14
|
const run_1 = require("./run");
|
|
13
15
|
const program = new commander_1.Command()
|
|
@@ -17,11 +19,30 @@ const program = new commander_1.Command()
|
|
|
17
19
|
const gatlingHomeOption = new commander_1.Option("--gatling-home <value>", 'The folder used to download and install Gatling components (default: "~/.gatling")');
|
|
18
20
|
const gatlingHomeDirWithDefaults = (options) => options.gatlingHome || `${os_1.default.homedir()}/.gatling`;
|
|
19
21
|
const sourcesFolderOption = new commander_1.Option("--sources-folder <value>", "The sources folder path").default("src");
|
|
20
|
-
const simulationOption = new commander_1.Option("--simulation <value>", "The simulation entry point function name
|
|
21
|
-
const
|
|
22
|
+
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)");
|
|
23
|
+
const simulationWithDefaults = (options, simulationsFound) => {
|
|
24
|
+
if (options.simulation !== undefined) {
|
|
25
|
+
return options.simulation;
|
|
26
|
+
}
|
|
27
|
+
else if (simulationsFound.length === 1) {
|
|
28
|
+
return simulationsFound[0].name;
|
|
29
|
+
}
|
|
30
|
+
else if (simulationsFound.length === 0) {
|
|
31
|
+
throw new Error("No simulation found, simulations must be defined in a <simulation name>.gatling.js or <simulation name>.gatling.ts file)");
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
throw new Error(`Several simulations found, specify one using the --simulation option (available simulations: ${simulationsFound.map((s) => s.name)})`);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const simulationRequiredOption = new commander_1.Option("--simulation <value>", "The simulation entry point function name").makeOptionMandatory(true);
|
|
38
|
+
const bundleFileOption = new commander_1.Option("--bundle-file <value>", "The target bundle file path when building simulations").default("target/bundle.js");
|
|
39
|
+
const enterprisePackageFileOption = new commander_1.Option("--enterprise-package-file <value>", "The target package file path when packaging simulations for Gatling Enterprise").default("target/package.jar");
|
|
22
40
|
const resourcesFolderOption = new commander_1.Option("--resources-folder <value>", "The resources folder path").default("resources");
|
|
23
41
|
const resultsFolderOption = new commander_1.Option("--results-folder <value>", "The results folder path").default("target/gatling");
|
|
24
|
-
const typescriptOption = new commander_1.Option("--typescript", "Use the typescript compiler to compile your code
|
|
42
|
+
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)");
|
|
43
|
+
const typescriptWithDefaults = (options, simulationsFound) => options.typescript !== undefined
|
|
44
|
+
? options.typescript
|
|
45
|
+
: simulationsFound.findIndex((s) => s.type === "typescript") >= 0;
|
|
25
46
|
const graalvmHomeMandatoryOption = new commander_1.Option("--graalvm-home <value>", "Path to the GraalVM home").makeOptionMandatory(true);
|
|
26
47
|
const jvmClasspathMandatoryOption = new commander_1.Option("--jvm-classpath <value>", "The classpath containing all Gatling JVM components").makeOptionMandatory(true);
|
|
27
48
|
program
|
|
@@ -30,29 +51,30 @@ program
|
|
|
30
51
|
.addOption(gatlingHomeOption)
|
|
31
52
|
.action(async (options) => {
|
|
32
53
|
const gatlingHome = gatlingHomeDirWithDefaults(options);
|
|
33
|
-
const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.
|
|
54
|
+
const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome });
|
|
34
55
|
log_1.logger.info(`graalvmHome=${graalvmHome}`);
|
|
35
56
|
log_1.logger.info(`coursierBinary=${coursierBinary}`);
|
|
36
57
|
log_1.logger.info(`jvmClasspath=${jvmClasspath}`);
|
|
37
58
|
});
|
|
38
59
|
program
|
|
39
60
|
.command("build")
|
|
40
|
-
.description("Build
|
|
61
|
+
.description("Build Gatling simulations")
|
|
41
62
|
.addOption(sourcesFolderOption)
|
|
42
63
|
.addOption(bundleFileOption)
|
|
43
64
|
.addOption(typescriptOption)
|
|
44
65
|
.action(async (options) => {
|
|
45
66
|
const sourcesFolder = options.sourcesFolder;
|
|
46
67
|
const bundleFile = options.bundleFile;
|
|
47
|
-
const
|
|
48
|
-
|
|
68
|
+
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
69
|
+
const typescript = typescriptWithDefaults(options, simulations);
|
|
70
|
+
await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, typescript, simulations });
|
|
49
71
|
});
|
|
50
72
|
program
|
|
51
73
|
.command("run-only")
|
|
52
|
-
.description("Run a Gatling simulation")
|
|
74
|
+
.description("Run a Gatling simulation from an already built bundle")
|
|
53
75
|
.addOption(graalvmHomeMandatoryOption)
|
|
54
76
|
.addOption(jvmClasspathMandatoryOption)
|
|
55
|
-
.addOption(
|
|
77
|
+
.addOption(simulationRequiredOption)
|
|
56
78
|
.addOption(bundleFileOption)
|
|
57
79
|
.addOption(resourcesFolderOption)
|
|
58
80
|
.addOption(resultsFolderOption)
|
|
@@ -63,7 +85,14 @@ program
|
|
|
63
85
|
const bundleFile = options.bundleFile;
|
|
64
86
|
const resourcesFolder = options.resourcesFolder;
|
|
65
87
|
const resultsFolder = options.resultsFolder;
|
|
66
|
-
await (0, run_1.
|
|
88
|
+
await (0, run_1.runSimulation)({
|
|
89
|
+
graalvmHome,
|
|
90
|
+
jvmClasspath,
|
|
91
|
+
simulation: simulation,
|
|
92
|
+
bundleFile,
|
|
93
|
+
resourcesFolder,
|
|
94
|
+
resultsFolder
|
|
95
|
+
});
|
|
67
96
|
});
|
|
68
97
|
program
|
|
69
98
|
.command("run")
|
|
@@ -78,16 +107,54 @@ program
|
|
|
78
107
|
.action(async (options) => {
|
|
79
108
|
const gatlingHome = gatlingHomeDirWithDefaults(options);
|
|
80
109
|
const sourcesFolder = options.sourcesFolder;
|
|
81
|
-
const simulation = options.simulation;
|
|
82
110
|
const bundleFile = options.bundleFile;
|
|
83
111
|
const resourcesFolder = options.resourcesFolder;
|
|
84
112
|
const resultsFolder = options.resultsFolder;
|
|
85
|
-
const
|
|
86
|
-
const
|
|
113
|
+
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
114
|
+
const typescript = typescriptWithDefaults(options, simulations);
|
|
115
|
+
const simulation = simulationWithDefaults(options, simulations);
|
|
116
|
+
const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome });
|
|
117
|
+
log_1.logger.debug(`graalvmHome=${graalvmHome}`);
|
|
118
|
+
log_1.logger.debug(`coursierBinary=${coursierBinary}`);
|
|
119
|
+
log_1.logger.debug(`jvmClasspath=${jvmClasspath}`);
|
|
120
|
+
await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, typescript, simulations });
|
|
121
|
+
await (0, run_1.runSimulation)({ graalvmHome, jvmClasspath, simulation, bundleFile, resourcesFolder, resultsFolder });
|
|
122
|
+
});
|
|
123
|
+
program
|
|
124
|
+
.command("recorder")
|
|
125
|
+
.description("Run the Gatling recorder")
|
|
126
|
+
.addOption(gatlingHomeOption)
|
|
127
|
+
.addOption(sourcesFolderOption)
|
|
128
|
+
.addOption(typescriptOption)
|
|
129
|
+
.addOption(resourcesFolderOption)
|
|
130
|
+
.action(async (options) => {
|
|
131
|
+
const gatlingHome = gatlingHomeDirWithDefaults(options);
|
|
132
|
+
const sourcesFolder = options.sourcesFolder;
|
|
133
|
+
const resourcesFolder = options.resourcesFolder;
|
|
134
|
+
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
135
|
+
const typescript = typescriptWithDefaults(options, simulations);
|
|
136
|
+
const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installRecorder)({ gatlingHome });
|
|
87
137
|
log_1.logger.debug(`graalvmHome=${graalvmHome}`);
|
|
88
138
|
log_1.logger.debug(`coursierBinary=${coursierBinary}`);
|
|
89
139
|
log_1.logger.debug(`jvmClasspath=${jvmClasspath}`);
|
|
90
|
-
await (0,
|
|
91
|
-
|
|
140
|
+
await (0, run_1.runRecorder)({ graalvmHome, jvmClasspath, sourcesFolder, typescript, resourcesFolder });
|
|
141
|
+
});
|
|
142
|
+
program
|
|
143
|
+
.command("enterprise-package")
|
|
144
|
+
.description("Build Gatling simulations and package them for Gatling Enterprise")
|
|
145
|
+
.addOption(sourcesFolderOption)
|
|
146
|
+
.addOption(resourcesFolderOption)
|
|
147
|
+
.addOption(bundleFileOption)
|
|
148
|
+
.addOption(enterprisePackageFileOption)
|
|
149
|
+
.addOption(typescriptOption)
|
|
150
|
+
.action(async (options) => {
|
|
151
|
+
const sourcesFolder = options.sourcesFolder;
|
|
152
|
+
const resourcesFolder = options.resourcesFolder;
|
|
153
|
+
const bundleFile = options.bundleFile;
|
|
154
|
+
const enterprisePackageFile = options.enterprisePackageFile;
|
|
155
|
+
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
156
|
+
const typescript = typescriptWithDefaults(options, simulations);
|
|
157
|
+
await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, typescript, simulations });
|
|
158
|
+
await (0, enterprisePackage_1.enterprisePackage)({ bundleFile, resourcesFolder, enterprisePackageFile, simulations });
|
|
92
159
|
});
|
|
93
160
|
program.parse(process.argv);
|
package/target/run.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
export interface RunOptions {
|
|
2
2
|
graalvmHome: string;
|
|
3
3
|
jvmClasspath: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RunSimulationOptions extends RunOptions {
|
|
4
6
|
simulation: string;
|
|
5
7
|
bundleFile: string;
|
|
6
8
|
resourcesFolder: string;
|
|
7
9
|
resultsFolder: string;
|
|
8
10
|
}
|
|
9
|
-
export
|
|
11
|
+
export interface RunRecorderOptions extends RunOptions {
|
|
12
|
+
sourcesFolder: string;
|
|
13
|
+
typescript: boolean;
|
|
14
|
+
resourcesFolder: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const runSimulation: (options: RunSimulationOptions) => Promise<void>;
|
|
17
|
+
export declare const runRecorder: (options: RunRecorderOptions) => Promise<void>;
|
package/target/run.js
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.runRecorder = exports.runSimulation = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const log_1 = require("./log");
|
|
6
6
|
const versions_1 = require("./dependencies/versions");
|
|
7
7
|
const os_1 = require("./dependencies/os");
|
|
8
|
-
const
|
|
8
|
+
const runSimulation = async (options) => {
|
|
9
9
|
log_1.logger.info(`Running a Gatling simulation with options:
|
|
10
10
|
- simulation: ${options.simulation}
|
|
11
|
-
- bundleFile: ${options.bundleFile}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
"-XX:+HeapDumpOnOutOfMemoryError",
|
|
17
|
-
"-XX:MaxInlineLevel=20",
|
|
18
|
-
"-XX:MaxTrivialSize=12",
|
|
19
|
-
"-Xmx1G",
|
|
20
|
-
"-classpath",
|
|
21
|
-
`${options.resourcesFolder}${classpathSeparator}${options.jvmClasspath}`,
|
|
11
|
+
- bundleFile: ${options.bundleFile}
|
|
12
|
+
- resourcesFolder: ${options.resourcesFolder}
|
|
13
|
+
- resultsFolder: ${options.resultsFolder}`);
|
|
14
|
+
const additionalClasspathElements = [options.resourcesFolder];
|
|
15
|
+
const javaArgs = [
|
|
22
16
|
`-Dgatling.js.bundle.filePath=${options.bundleFile}`,
|
|
23
|
-
`-Dgatling.js.simulation=${options.simulation}
|
|
24
|
-
|
|
17
|
+
`-Dgatling.js.simulation=${options.simulation}`
|
|
18
|
+
];
|
|
19
|
+
const simulationArgs = [
|
|
25
20
|
"--results-folder",
|
|
26
21
|
options.resultsFolder,
|
|
27
22
|
"--simulation",
|
|
@@ -31,7 +26,42 @@ const run = async (options) => {
|
|
|
31
26
|
"--build-tool-version",
|
|
32
27
|
versions_1.versions.gatling.jsAdapter
|
|
33
28
|
];
|
|
34
|
-
|
|
29
|
+
return run(options, "io.gatling.app.Gatling", additionalClasspathElements, javaArgs, simulationArgs);
|
|
30
|
+
};
|
|
31
|
+
exports.runSimulation = runSimulation;
|
|
32
|
+
const runRecorder = async (options) => {
|
|
33
|
+
log_1.logger.info(`Running the Gatling Recorder with options:
|
|
34
|
+
- sourcesFolder: ${options.sourcesFolder}
|
|
35
|
+
- resourcesFolder: ${options.resourcesFolder}
|
|
36
|
+
- typescript: ${options.typescript}`);
|
|
37
|
+
const recorderArgs = [
|
|
38
|
+
"--simulations-folder",
|
|
39
|
+
options.sourcesFolder,
|
|
40
|
+
"--resources-folder",
|
|
41
|
+
options.resourcesFolder,
|
|
42
|
+
"--format",
|
|
43
|
+
options.typescript ? "typescript" : "javascript"
|
|
44
|
+
];
|
|
45
|
+
return run(options, "io.gatling.recorder.GatlingRecorder", [], [], recorderArgs);
|
|
46
|
+
};
|
|
47
|
+
exports.runRecorder = runRecorder;
|
|
48
|
+
const run = (options, mainClass, additionalClasspathElements, javaArgs, mainClassArgs) => {
|
|
49
|
+
const command = `${options.graalvmHome}/bin/java`;
|
|
50
|
+
const classpathSeparator = os_1.osType === "Windows_NT" ? ";" : ":";
|
|
51
|
+
const classpath = [...additionalClasspathElements, options.jvmClasspath].join(classpathSeparator);
|
|
52
|
+
const allArgs = [
|
|
53
|
+
"-server",
|
|
54
|
+
"-XX:+HeapDumpOnOutOfMemoryError",
|
|
55
|
+
"-XX:MaxInlineLevel=20",
|
|
56
|
+
"-XX:MaxTrivialSize=12",
|
|
57
|
+
"-Xmx1G",
|
|
58
|
+
"-classpath",
|
|
59
|
+
classpath,
|
|
60
|
+
...javaArgs,
|
|
61
|
+
mainClass,
|
|
62
|
+
...mainClassArgs
|
|
63
|
+
];
|
|
64
|
+
const process = (0, child_process_1.spawn)(command, allArgs);
|
|
35
65
|
return new Promise((resolve, reject) => {
|
|
36
66
|
process.stdout.on("data", (data) => log_1.logger.info(data.toString()));
|
|
37
67
|
process.stderr.on("data", (data) => log_1.logger.error(data.toString()));
|
|
@@ -46,4 +76,3 @@ const run = async (options) => {
|
|
|
46
76
|
});
|
|
47
77
|
});
|
|
48
78
|
};
|
|
49
|
-
exports.run = run;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.findSimulations = void 0;
|
|
7
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
|
+
const findSimulations = async (sourcesFolder) => {
|
|
9
|
+
const children = await promises_1.default.readdir(sourcesFolder, { recursive: false });
|
|
10
|
+
const simulations = children
|
|
11
|
+
.filter((path) => path.endsWith(".gatling.js") || path.endsWith(".gatling.ts"))
|
|
12
|
+
.map((path) => ({
|
|
13
|
+
path,
|
|
14
|
+
name: path.slice(0, -11),
|
|
15
|
+
type: path.endsWith(".ts") ? "typescript" : "javascript"
|
|
16
|
+
}));
|
|
17
|
+
const duplicates = simulations.filter((value, index) => simulations.findIndex((other) => other.name === value.name) !== index);
|
|
18
|
+
if (duplicates.length > 0) {
|
|
19
|
+
throw Error(`Found ambiguous simulation name(s) ${duplicates.map((s) => s.name)}: found as both *.gatling.js and *.gatling.ts file(s)`);
|
|
20
|
+
}
|
|
21
|
+
return simulations;
|
|
22
|
+
};
|
|
23
|
+
exports.findSimulations = findSimulations;
|