@gatling.io/cli 3.11.3-M1 → 3.11.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gatling.io/cli",
3
- "version": "3.11.3-M1",
3
+ "version": "3.11.3",
4
4
  "license": "Apache-2.0",
5
5
  "bin": {
6
6
  "gatling": "target/index.js"
@@ -1,2 +1,3 @@
1
1
  export declare const installCoursier: (gatlingHomeDir: string, downloadDir: string) => Promise<string>;
2
- export declare const resolveDependencies: (coursierPath: string, javaHome: string) => Promise<string>;
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.resolveDependencies = exports.installCoursier = void 0;
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 resolveDependencies = async (coursierPath, javaHome) => {
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
- const command = `"${coursierPath}" fetch --classpath ${gatlingDep} ${gatlingAdapterDep} ${graalvmJsDep}`;
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 installAll: (options: DependenciesOptions) => Promise<ResolvedDependencies>;
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.installAll = void 0;
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 installAll = async (options) => {
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.resolveDependencies)(coursierPath, graalvmHomePath);
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.installAll = installAll;
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;
@@ -8,7 +8,7 @@ exports.versions = {
8
8
  },
9
9
  coursier: "2.1.10",
10
10
  gatling: {
11
- core: "3.11.2",
12
- jsAdapter: "3.11.3-M1"
11
+ core: "3.11.3",
12
+ jsAdapter: "3.11.3"
13
13
  }
14
14
  };
package/target/index.js CHANGED
@@ -30,7 +30,7 @@ program
30
30
  .addOption(gatlingHomeOption)
31
31
  .action(async (options) => {
32
32
  const gatlingHome = gatlingHomeDirWithDefaults(options);
33
- const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installAll)({ gatlingHome });
33
+ const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome });
34
34
  log_1.logger.info(`graalvmHome=${graalvmHome}`);
35
35
  log_1.logger.info(`coursierBinary=${coursierBinary}`);
36
36
  log_1.logger.info(`jvmClasspath=${jvmClasspath}`);
@@ -63,7 +63,14 @@ program
63
63
  const bundleFile = options.bundleFile;
64
64
  const resourcesFolder = options.resourcesFolder;
65
65
  const resultsFolder = options.resultsFolder;
66
- await (0, run_1.run)({ graalvmHome, jvmClasspath, simulation: simulation, bundleFile, resourcesFolder, resultsFolder });
66
+ await (0, run_1.runSimulation)({
67
+ graalvmHome,
68
+ jvmClasspath,
69
+ simulation: simulation,
70
+ bundleFile,
71
+ resourcesFolder,
72
+ resultsFolder
73
+ });
67
74
  });
68
75
  program
69
76
  .command("run")
@@ -83,11 +90,29 @@ program
83
90
  const resourcesFolder = options.resourcesFolder;
84
91
  const resultsFolder = options.resultsFolder;
85
92
  const typescript = options.typescript;
86
- const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installAll)({ gatlingHome });
93
+ const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome });
87
94
  log_1.logger.debug(`graalvmHome=${graalvmHome}`);
88
95
  log_1.logger.debug(`coursierBinary=${coursierBinary}`);
89
96
  log_1.logger.debug(`jvmClasspath=${jvmClasspath}`);
90
97
  await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, typescript });
91
- await (0, run_1.run)({ graalvmHome, jvmClasspath, simulation, bundleFile, resourcesFolder, resultsFolder });
98
+ await (0, run_1.runSimulation)({ graalvmHome, jvmClasspath, simulation, bundleFile, resourcesFolder, resultsFolder });
99
+ });
100
+ program
101
+ .command("recorder")
102
+ .description("Run the Gatling recorder")
103
+ .addOption(gatlingHomeOption)
104
+ .addOption(sourcesFolderOption)
105
+ .addOption(typescriptOption)
106
+ .addOption(resourcesFolderOption)
107
+ .action(async (options) => {
108
+ const gatlingHome = gatlingHomeDirWithDefaults(options);
109
+ const sourcesFolder = options.sourcesFolder;
110
+ const resourcesFolder = options.resourcesFolder;
111
+ const typescript = options.typescript;
112
+ const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installRecorder)({ gatlingHome });
113
+ log_1.logger.debug(`graalvmHome=${graalvmHome}`);
114
+ log_1.logger.debug(`coursierBinary=${coursierBinary}`);
115
+ log_1.logger.debug(`jvmClasspath=${jvmClasspath}`);
116
+ await (0, run_1.runRecorder)({ graalvmHome, jvmClasspath, sourcesFolder, typescript, resourcesFolder });
92
117
  });
93
118
  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 declare const run: (options: RunOptions) => Promise<void>;
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,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = void 0;
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 run = async (options) => {
8
+ const runSimulation = async (options) => {
9
9
  log_1.logger.info(`Running a Gatling simulation with options:
10
10
  - simulation: ${options.simulation}
11
11
  - bundleFile: ${options.bundleFile}`);
12
- const command = `${options.graalvmHome}/bin/java`;
13
- const classpathSeparator = os_1.osType === "Windows_NT" ? ";" : ":";
14
- const args = [
15
- "-server",
16
- "-XX:+HeapDumpOnOutOfMemoryError",
17
- "-XX:MaxInlineLevel=20",
18
- "-XX:MaxTrivialSize=12",
19
- "-Xmx1G",
20
- "-classpath",
21
- `${options.resourcesFolder}${classpathSeparator}${options.jvmClasspath}`,
12
+ const additionalClasspathElements = [options.resourcesFolder];
13
+ const javaArgs = [
22
14
  `-Dgatling.js.bundle.filePath=${options.bundleFile}`,
23
- `-Dgatling.js.simulation=${options.simulation}`,
24
- "io.gatling.app.Gatling",
15
+ `-Dgatling.js.simulation=${options.simulation}`
16
+ ];
17
+ const simulationArgs = [
25
18
  "--results-folder",
26
19
  options.resultsFolder,
27
20
  "--simulation",
@@ -31,7 +24,39 @@ const run = async (options) => {
31
24
  "--build-tool-version",
32
25
  versions_1.versions.gatling.jsAdapter
33
26
  ];
34
- const process = (0, child_process_1.spawn)(command, args);
27
+ return run(options, "io.gatling.app.Gatling", additionalClasspathElements, javaArgs, simulationArgs);
28
+ };
29
+ exports.runSimulation = runSimulation;
30
+ const runRecorder = async (options) => {
31
+ log_1.logger.info("Running the Gatling Recorder");
32
+ const recorderArgs = [
33
+ "--simulations-folder",
34
+ options.sourcesFolder,
35
+ "--resources-folder",
36
+ options.resourcesFolder,
37
+ "--format",
38
+ options.typescript ? "typescript" : "javascript"
39
+ ];
40
+ return run(options, "io.gatling.recorder.GatlingRecorder", [], [], recorderArgs);
41
+ };
42
+ exports.runRecorder = runRecorder;
43
+ const run = (options, mainClass, additionalClasspathElements, javaArgs, mainClassArgs) => {
44
+ const command = `${options.graalvmHome}/bin/java`;
45
+ const classpathSeparator = os_1.osType === "Windows_NT" ? ";" : ":";
46
+ const classpath = [...additionalClasspathElements, options.jvmClasspath].join(classpathSeparator);
47
+ const allArgs = [
48
+ "-server",
49
+ "-XX:+HeapDumpOnOutOfMemoryError",
50
+ "-XX:MaxInlineLevel=20",
51
+ "-XX:MaxTrivialSize=12",
52
+ "-Xmx1G",
53
+ "-classpath",
54
+ classpath,
55
+ ...javaArgs,
56
+ mainClass,
57
+ ...mainClassArgs
58
+ ];
59
+ const process = (0, child_process_1.spawn)(command, allArgs);
35
60
  return new Promise((resolve, reject) => {
36
61
  process.stdout.on("data", (data) => log_1.logger.info(data.toString()));
37
62
  process.stderr.on("data", (data) => log_1.logger.error(data.toString()));
@@ -46,4 +71,3 @@ const run = async (options) => {
46
71
  });
47
72
  });
48
73
  };
49
- exports.run = run;