datagrok-tools 4.14.67 → 4.14.69
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/bin/commands/stress-tests.js +66 -0
- package/bin/grok.js +1 -0
- package/bin/utils/test-utils.js +17 -13
- package/package.json +1 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.stressTests = stressTests;
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
var _child_process = require("child_process");
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var utils = _interopRequireWildcard(require("../utils/utils"));
|
|
12
|
+
var _testUtils = _interopRequireWildcard(require("../utils/test-utils"));
|
|
13
|
+
var testUtils = _testUtils;
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
|
+
const cwd = process.cwd();
|
|
16
|
+
async function stressTests(args) {
|
|
17
|
+
const pkgPath = _path.default.join(cwd, 'package.json');
|
|
18
|
+
if (!_fs.default.existsSync(pkgPath)) {
|
|
19
|
+
console.error('❌ Error: This command must be executed from the ApiTests package folder (package.json not found).');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
let pkg;
|
|
23
|
+
try {
|
|
24
|
+
pkg = JSON.parse(_fs.default.readFileSync(pkgPath, 'utf8'));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error('❌ Error: Failed to read package.json. Make sure it is valid JSON.');
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
if (pkg.name !== '@datagrok/api-tests') {
|
|
30
|
+
console.error(`❌ Error: This command must be executed from the ApiTests package folder. Found package name: '${pkg.name ?? 'undefined'}'`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
const config = (0, _testUtils.getDevKey)(args.host);
|
|
34
|
+
await testUtils.loadPackage('', 'ApiTests', args.host, args['skip-publish'], args['skip-build'], false, true);
|
|
35
|
+
process.stdout.write(`Building node...`);
|
|
36
|
+
await utils.runScript(`npm run build-node`, '');
|
|
37
|
+
process.stdout.write(` success!\n`);
|
|
38
|
+
try {
|
|
39
|
+
await run(config, args);
|
|
40
|
+
return true;
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.error(`❌ Error: Something went wrong: ${e}`);
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function run(config, args) {
|
|
47
|
+
const processArgs = [];
|
|
48
|
+
processArgs.push('-r');
|
|
49
|
+
processArgs.push('./tsconfig-paths-bootstrap.js');
|
|
50
|
+
processArgs.push('dist-node/package-test-node.js');
|
|
51
|
+
processArgs.push(`--apiUrl=${config.url}`);
|
|
52
|
+
processArgs.push(`--devKey=${config.key}`);
|
|
53
|
+
if (args["concurrent-runs"]) processArgs.push(`--concurrentRuns=${args["concurrent-runs"]}`);
|
|
54
|
+
if (args['loop']) processArgs.push(`--loop`);
|
|
55
|
+
if (args['concurrency-range']) processArgs.push(`--concurrencyRange=${args["concurrency-range"]}`);
|
|
56
|
+
if (args['step']) processArgs.push(`--step=${args["step"]}`);
|
|
57
|
+
const child = (0, _child_process.spawn)('node', processArgs, {
|
|
58
|
+
cwd: '',
|
|
59
|
+
stdio: ['inherit', 'inherit', 'inherit']
|
|
60
|
+
});
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
62
|
+
child.on('exit', code => {
|
|
63
|
+
if (code === 0) resolve(code);else reject(new Error(`Stress tests exited with code ${code}`));
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
package/bin/grok.js
CHANGED
|
@@ -16,6 +16,7 @@ const commands = {
|
|
|
16
16
|
publish: require('./commands/publish').publish,
|
|
17
17
|
test: require('./commands/test').test,
|
|
18
18
|
testall: require('./commands/test-all').testAll,
|
|
19
|
+
stresstest: require('./commands/stress-tests').stressTests
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
const onPackageCommandNames = ['api', 'check', 'link', 'publish', 'test'];
|
package/bin/utils/test-utils.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.getBrowserPage = getBrowserPage;
|
|
|
14
14
|
exports.getDevKey = getDevKey;
|
|
15
15
|
exports.getToken = getToken;
|
|
16
16
|
exports.getWebUrl = getWebUrl;
|
|
17
|
+
exports.loadPackage = loadPackage;
|
|
17
18
|
exports.loadPackages = loadPackages;
|
|
18
19
|
exports.loadTestsList = loadTestsList;
|
|
19
20
|
exports.mergeBrowsersResults = mergeBrowsersResults;
|
|
@@ -181,6 +182,20 @@ const recorderConfig = exports.recorderConfig = {
|
|
|
181
182
|
}
|
|
182
183
|
// aspectRatio: '16:9',
|
|
183
184
|
};
|
|
185
|
+
async function loadPackage(packageDir, dirName, hostString, skipPublish, skipBuild, linkPackage, release) {
|
|
186
|
+
try {
|
|
187
|
+
if (skipPublish != true) {
|
|
188
|
+
process.stdout.write(`Building and publishing ${dirName}...`);
|
|
189
|
+
await utils.runScript(`npm install`, packageDir);
|
|
190
|
+
if (linkPackage) await utils.runScript(`grok link`, packageDir);
|
|
191
|
+
if (skipBuild != true) await utils.runScript(`npm run build`, packageDir);
|
|
192
|
+
await utils.runScript(`grok publish ${hostString}${release ? ' --release' : ''}`, packageDir);
|
|
193
|
+
process.stdout.write(` success!\n`);
|
|
194
|
+
}
|
|
195
|
+
} catch (e) {
|
|
196
|
+
process.stdout.write(` failed to load package ${dirName}!\n`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
184
199
|
async function loadPackages(packagesDir, packagesToLoad, host, skipPublish, skipBuild, linkPackage, release) {
|
|
185
200
|
const packagesToRun = new Map();
|
|
186
201
|
const hostString = host === undefined ? `` : `${host}`;
|
|
@@ -198,19 +213,8 @@ async function loadPackages(packagesDir, packagesToLoad, host, skipPublish, skip
|
|
|
198
213
|
}));
|
|
199
214
|
const packageFriendlyName = packagesToRun.get((0, _utils.spaceToCamelCase)(packageJsonData['friendlyName'] ?? packageJsonData['name'].split('/')[1] ?? packageJsonData['name'] ?? '').toLocaleLowerCase() ?? '') ?? packagesToRun.get(dirName);
|
|
200
215
|
if (utils.isPackageDir(packageDir) && (packageFriendlyName !== undefined || packagesToLoad === 'all')) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (skipPublish != true) {
|
|
204
|
-
await utils.runScript(`npm install`, packageDir);
|
|
205
|
-
if (linkPackage) await utils.runScript(`grok link`, packageDir);
|
|
206
|
-
if (skipBuild != true) await utils.runScript(`npm run build`, packageDir);
|
|
207
|
-
await utils.runScript(`grok publish ${hostString}${release ? ' --release' : ''}`, packageDir);
|
|
208
|
-
}
|
|
209
|
-
packagesToRun.set(dirName, true);
|
|
210
|
-
process.stdout.write(` success!\n`);
|
|
211
|
-
} catch (e) {
|
|
212
|
-
process.stdout.write(` fail!\n`);
|
|
213
|
-
}
|
|
216
|
+
await loadPackage(packageDir, dirName, hostString, skipPublish, skipBuild, linkPackage, release);
|
|
217
|
+
packagesToRun.set(dirName, true);
|
|
214
218
|
}
|
|
215
219
|
} catch (e) {
|
|
216
220
|
if (utils.isPackageDir(packageDir) && (packagesToRun.get((0, _utils.spaceToCamelCase)(dirName).toLocaleLowerCase()) !== undefined || packagesToLoad === 'all')) console.log(`Couldn't read package.json ${dirName}`);
|
package/package.json
CHANGED