@rocket.chat/houston 0.27.0-next.3 → 2.1.8
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/LICENSE +1 -1
- package/README.md +108 -15
- package/bin/houston +62 -0
- package/data/docs/ARCHITECTURE.md +387 -0
- package/data/docs/automation.md +107 -0
- package/data/docs/e2ee.md +76 -0
- package/data/docs/eks.md +258 -0
- package/data/docs/gui.md +282 -0
- package/data/docs/guide.md +669 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/troubleshooting.md +193 -0
- package/data/docs/upgrading.md +84 -0
- package/data/docs/voice.md +253 -0
- package/data/iam/engineer-policy.json +11 -0
- package/data/iam/engineer-rbac.yaml +42 -0
- package/data/iam/operator-policy.json +211 -0
- package/data/loadtest/badbot.js +22 -0
- package/data/loadtest/common.js +168 -0
- package/data/loadtest/custom.js +20 -0
- package/data/loadtest/journey.js +58 -0
- package/data/loadtest/login.js +18 -0
- package/data/loadtest/messages.js +13 -0
- package/data/loadtest/mixed.js +39 -0
- package/data/loadtest/read.js +12 -0
- package/data/loadtest/webhook.js +20 -0
- package/data/monitoring/houston-logs.json +98 -0
- package/data/monitoring/k6-loadtest.json +610 -0
- package/data/monitoring/mongodb-exporter.json +3007 -0
- package/data/monitoring/node-exporter-full.json +16114 -0
- package/data/monitoring/rocketchat-metrics.json +6471 -0
- package/data/presets/airgapped.yaml +16 -0
- package/data/presets/default.yaml +9 -0
- package/data/seed/avatar-0.png +0 -0
- package/data/seed/avatar-1.png +0 -0
- package/data/seed/avatar-2.png +0 -0
- package/data/seed/avatar-3.png +0 -0
- package/data/seed/avatar-4.png +0 -0
- package/data/seed/avatar-5.png +0 -0
- package/data/seed/avatar-6.png +0 -0
- package/data/seed/avatar-7.png +0 -0
- package/data/seed/seed-metrics.csv +3 -0
- package/data/seed/seed-preview.png +0 -0
- package/data/seed/seed-report.pdf +32 -0
- package/data/seed/seed-runbook.txt +3 -0
- package/data/skill/SKILL.md +399 -0
- package/data/versions.yaml +55 -0
- package/data/voice/freeswitch/drachtio.xml +52 -0
- package/data/voice/freeswitch/public.xml +87 -0
- package/data/webui/app.css +2003 -0
- package/data/webui/index.html +678 -0
- package/data/webui/js/api.js +561 -0
- package/data/webui/js/boot.js +44 -0
- package/data/webui/js/clusters-tail.js +1377 -0
- package/data/webui/js/clusters.js +896 -0
- package/data/webui/js/create.js +276 -0
- package/data/webui/js/detail.js +507 -0
- package/data/webui/js/jobs.js +636 -0
- package/data/webui/js/logs.js +634 -0
- package/data/webui/js/main.js +14 -0
- package/data/webui/js/options.js +408 -0
- package/data/webui/js/people.js +438 -0
- package/data/webui/js/perf.js +303 -0
- package/data/webui/js/render.js +438 -0
- package/data/webui/js/shared.js +3 -0
- package/data/webui/js/state.js +583 -0
- package/data/webui/js/theme.js +123 -0
- package/data/webui/js/util.js +584 -0
- package/dist/cli/app.js +593 -0
- package/dist/cli/capabilities.js +76 -0
- package/dist/cli/cell-widths.js +495 -0
- package/dist/cli/entry.js +10 -0
- package/dist/cli/error-panel.js +492 -0
- package/dist/cli/handlers/actor.js +84 -0
- package/dist/cli/handlers/https.js +614 -0
- package/dist/cli/handlers/prompt.js +299 -0
- package/dist/cli/handlers/users.js +226 -0
- package/dist/cli/handlers.js +3678 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +810 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2593 -0
- package/dist/cli/spec-types.js +8 -0
- package/dist/cli/usage-error.js +520 -0
- package/dist/cli/wire.js +70 -0
- package/dist/core/audit.js +346 -0
- package/dist/core/backup-compat.js +85 -0
- package/dist/core/backup.js +1639 -0
- package/dist/core/cluster.js +1398 -0
- package/dist/core/configimport.js +344 -0
- package/dist/core/data.js +267 -0
- package/dist/core/database-of.js +82 -0
- package/dist/core/diagnose.js +159 -0
- package/dist/core/doctor.js +1518 -0
- package/dist/core/edge/acme.js +338 -0
- package/dist/core/edge/engine.js +500 -0
- package/dist/core/edge/networks.js +174 -0
- package/dist/core/edge/paths.js +107 -0
- package/dist/core/edge/routes.js +251 -0
- package/dist/core/edge/routeyml.js +195 -0
- package/dist/core/edge/runtime.js +493 -0
- package/dist/core/edge/spec.js +305 -0
- package/dist/core/edge/types.js +202 -0
- package/dist/core/eks-docs.js +135 -0
- package/dist/core/eks.js +2240 -0
- package/dist/core/envvars.js +562 -0
- package/dist/core/eventlog.js +541 -0
- package/dist/core/firstrun.js +153 -0
- package/dist/core/journal.js +691 -0
- package/dist/core/kube/ask.js +231 -0
- package/dist/core/kube/capabilities.js +269 -0
- package/dist/core/kube/certmanager.js +452 -0
- package/dist/core/kube/chart.js +413 -0
- package/dist/core/kube/cluster.js +196 -0
- package/dist/core/kube/context.js +545 -0
- package/dist/core/kube/endpoints.js +448 -0
- package/dist/core/kube/exec.js +195 -0
- package/dist/core/kube/forward.js +732 -0
- package/dist/core/kube/grafana-ingress.js +110 -0
- package/dist/core/kube/ingress.js +218 -0
- package/dist/core/kube/manifests.js +361 -0
- package/dist/core/kube/monitoring.js +768 -0
- package/dist/core/kube/names.js +237 -0
- package/dist/core/kube/namespace.js +678 -0
- package/dist/core/kube/operator.js +941 -0
- package/dist/core/kube/probe.js +202 -0
- package/dist/core/kube/reachability.js +163 -0
- package/dist/core/kube/release.js +439 -0
- package/dist/core/kube/replicaset.js +180 -0
- package/dist/core/kube/scale.js +398 -0
- package/dist/core/kube/status.js +633 -0
- package/dist/core/kube/tools.js +238 -0
- package/dist/core/kube/transfer.js +173 -0
- package/dist/core/kube/workspace.js +423 -0
- package/dist/core/lifecycle/admin.js +64 -0
- package/dist/core/lifecycle/create-docker.js +1533 -0
- package/dist/core/lifecycle/create-k8s.js +939 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +635 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +726 -0
- package/dist/core/lifecycle/ownership.js +313 -0
- package/dist/core/lifecycle/payload.js +401 -0
- package/dist/core/lifecycle/ports.js +388 -0
- package/dist/core/lifecycle/preconditions.js +367 -0
- package/dist/core/lifecycle/pruning.js +551 -0
- package/dist/core/lifecycle/ready.js +753 -0
- package/dist/core/lifecycle/request.js +525 -0
- package/dist/core/lifecycle/seeding.js +281 -0
- package/dist/core/lifecycle/sizing.js +392 -0
- package/dist/core/lifecycle/state.js +286 -0
- package/dist/core/lifecycle/tlsplan.js +704 -0
- package/dist/core/lifecycle/types.js +232 -0
- package/dist/core/loadtest.js +995 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +969 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1285 -0
- package/dist/core/recovery.js +75 -0
- package/dist/core/runner/engine.js +394 -0
- package/dist/core/runner/host.js +298 -0
- package/dist/core/runner/locks.js +129 -0
- package/dist/core/runner/paths.js +173 -0
- package/dist/core/runner/ports.js +172 -0
- package/dist/core/runner/queries.js +612 -0
- package/dist/core/runner/record.js +563 -0
- package/dist/core/scaleseed.js +271 -0
- package/dist/core/seed-db.js +208 -0
- package/dist/core/sessions.js +472 -0
- package/dist/core/skill.js +326 -0
- package/dist/core/sso-identities.js +172 -0
- package/dist/core/sso.js +703 -0
- package/dist/core/tls-local.js +311 -0
- package/dist/core/tls.js +878 -0
- package/dist/core/topology.js +482 -0
- package/dist/core/upgrade.js +868 -0
- package/dist/core/users.js +739 -0
- package/dist/lib/audit.js +100 -0
- package/dist/lib/close-matches.js +238 -0
- package/dist/lib/compose.js +672 -0
- package/dist/lib/config.js +1398 -0
- package/dist/lib/context.js +18 -0
- package/dist/lib/errors.js +305 -0
- package/dist/lib/events.js +208 -0
- package/dist/lib/float-text.js +126 -0
- package/dist/lib/format.js +1320 -0
- package/dist/lib/home.js +325 -0
- package/dist/lib/journal.js +122 -0
- package/dist/lib/json-text.js +733 -0
- package/dist/lib/jsonout.js +382 -0
- package/dist/lib/lock.js +516 -0
- package/dist/lib/login-name.js +202 -0
- package/dist/lib/map-limit.js +29 -0
- package/dist/lib/mkdir-parents.js +90 -0
- package/dist/lib/mongo-kernel.js +67 -0
- package/dist/lib/monitoring.js +492 -0
- package/dist/lib/platform-name.js +59 -0
- package/dist/lib/presets/common.js +390 -0
- package/dist/lib/presets/composite.js +326 -0
- package/dist/lib/presets/e2ee.js +143 -0
- package/dist/lib/presets/email.js +172 -0
- package/dist/lib/presets/guides.js +27 -0
- package/dist/lib/presets/index.js +490 -0
- package/dist/lib/presets/keycloak.js +369 -0
- package/dist/lib/presets/ldap.js +1285 -0
- package/dist/lib/presets/livechat.js +220 -0
- package/dist/lib/presets/multi-instance.js +124 -0
- package/dist/lib/presets/oidc.js +161 -0
- package/dist/lib/presets/public.js +496 -0
- package/dist/lib/presets/registry.js +64 -0
- package/dist/lib/presets/s3-minio.js +300 -0
- package/dist/lib/presets/saml.js +149 -0
- package/dist/lib/presets/scenario.js +51 -0
- package/dist/lib/presets/types.js +86 -0
- package/dist/lib/presets/voice-pbx.js +320 -0
- package/dist/lib/presets/voice.js +345 -0
- package/dist/lib/presets/webhooks.js +182 -0
- package/dist/lib/redact.js +106 -0
- package/dist/lib/seed-options.js +68 -0
- package/dist/lib/seed-profiles.js +59 -0
- package/dist/lib/targz.js +1383 -0
- package/dist/lib/teammode.js +25 -0
- package/dist/lib/tempdir.js +162 -0
- package/dist/lib/unicode-tables.js +2335 -0
- package/dist/lib/version-spec.js +357 -0
- package/dist/lib/versions.js +463 -0
- package/dist/lib/yaml-dump.js +1361 -0
- package/dist/perf/baseline.js +168 -0
- package/dist/perf/constrain.js +296 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +178 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +224 -0
- package/dist/perf/slo.js +111 -0
- package/dist/perf/timeline.js +187 -0
- package/dist/perf/timings.js +85 -0
- package/dist/perf/verdict.js +201 -0
- package/dist/seams/aws-cli.js +126 -0
- package/dist/seams/docker-cli.js +280 -0
- package/dist/seams/exec.js +861 -0
- package/dist/seams/fs/lock.js +528 -0
- package/dist/seams/kubectl.js +83 -0
- package/dist/seams/rc-http.js +921 -0
- package/dist/seed/apply.js +190 -0
- package/dist/seed/assets.js +76 -0
- package/dist/seed/check.js +391 -0
- package/dist/seed/client.js +172 -0
- package/dist/seed/executor.js +726 -0
- package/dist/seed/history.js +281 -0
- package/dist/seed/kinds.js +91 -0
- package/dist/seed/plan.js +432 -0
- package/dist/seed/receipt.js +339 -0
- package/dist/seed/repairs.js +75 -0
- package/dist/seed/verification.js +363 -0
- package/dist/seed/wording.js +248 -0
- package/dist/web/app.js +326 -0
- package/dist/web/jobs.js +510 -0
- package/dist/web/route-deps.js +211 -0
- package/dist/web/route-table.js +213 -0
- package/dist/web/routes/backup.js +244 -0
- package/dist/web/routes/clusters.js +303 -0
- package/dist/web/routes/data.js +187 -0
- package/dist/web/routes/edge.js +82 -0
- package/dist/web/routes/index.js +63 -0
- package/dist/web/routes/jobs.js +95 -0
- package/dist/web/routes/logs.js +297 -0
- package/dist/web/routes/meta.js +191 -0
- package/dist/web/routes/people.js +151 -0
- package/dist/web/routes/perf.js +95 -0
- package/dist/web/routes/repros.js +550 -0
- package/dist/web/routes/session.js +361 -0
- package/dist/web/routes/spa.js +198 -0
- package/dist/web/security.js +475 -0
- package/dist/web/signin.js +246 -0
- package/package.json +67 -32
- package/.eslintrc +0 -94
- package/.swcrc +0 -18
- package/dist/bin.js +0 -3
- package/dist/cli.js +0 -184
- package/dist/commands/createBranch.js +0 -194
- package/dist/outputCI.js +0 -59
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -28
- package/src/outputCI.ts +0 -12
- package/src-old/logs.js +0 -323
- package/src-old/md.js +0 -191
- package/src-old/release-table.js +0 -60
- package/src-old/set-version.js +0 -614
- package/src-old/utils.js +0 -15
|
@@ -0,0 +1,995 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DEFAULT_DEPS = exports.GUI_SCENARIOS = void 0;
|
|
37
|
+
exports.depsWith = depsWith;
|
|
38
|
+
exports.loadtestReq = loadtestReq;
|
|
39
|
+
exports.installJournalRepairs = installJournalRepairs;
|
|
40
|
+
exports.repairConstraints = repairConstraints;
|
|
41
|
+
exports.repairMetrics = repairMetrics;
|
|
42
|
+
exports.rcServicesIn = rcServicesIn;
|
|
43
|
+
exports.loadtestTarget = loadtestTarget;
|
|
44
|
+
exports.short = short;
|
|
45
|
+
exports.loginSeedUsers = loginSeedUsers;
|
|
46
|
+
exports.requireComposeForPerf = requireComposeForPerf;
|
|
47
|
+
exports.newLoadRun = newLoadRun;
|
|
48
|
+
exports.putEverythingBack = putEverythingBack;
|
|
49
|
+
exports.armAndRun = armAndRun;
|
|
50
|
+
exports.loadtestVerdict = loadtestVerdict;
|
|
51
|
+
exports.refuseABadDuration = refuseABadDuration;
|
|
52
|
+
exports.loadtestPreflight = loadtestPreflight;
|
|
53
|
+
exports.runLoadtest = runLoadtest;
|
|
54
|
+
exports.runPreparedLoadtest = runPreparedLoadtest;
|
|
55
|
+
exports.capacityReq = capacityReq;
|
|
56
|
+
exports.newCapacitySearch = newCapacitySearch;
|
|
57
|
+
exports.stepFloats = stepFloats;
|
|
58
|
+
exports.capacityVerdict = capacityVerdict;
|
|
59
|
+
exports.capacityPreflight = capacityPreflight;
|
|
60
|
+
exports.putTheWorkspaceBack = putTheWorkspaceBack;
|
|
61
|
+
exports.searchForCapacity = searchForCapacity;
|
|
62
|
+
exports.runCapacity = runCapacity;
|
|
63
|
+
exports.runPreparedCapacity = runPreparedCapacity;
|
|
64
|
+
/**
|
|
65
|
+
* Load-test service for the web GUI (a focused subset of the CLI `loadtest`).
|
|
66
|
+
*
|
|
67
|
+
* Supports the common options — scenario, vus, duration, users, slo, constrain, diag, stats,
|
|
68
|
+
* live — with the SAME safety-critical restore-in-`finally` as the CLI (rate limiter,
|
|
69
|
+
* Prometheus setting, resource caps, and the users.json token file are always
|
|
70
|
+
* restored/cleaned up, even on failure). Returns a structured result.
|
|
71
|
+
*
|
|
72
|
+
* The CLI reuses the same transaction through the prepared-run seams below, adding its
|
|
73
|
+
* ramp/spike/custom controls and post-run artifacts without duplicating restoration.
|
|
74
|
+
*
|
|
75
|
+
* THE DEPENDENCY BAG. The private steps take `constrain`, `k6`, `mongoprof`, the metrics
|
|
76
|
+
* sampler and the analysis modules as PARAMETERS, so a spec passes stand-ins through. This
|
|
77
|
+
* module keeps that shape as `LoadtestDeps`, which is also what lets a spec drive the
|
|
78
|
+
* restore ordering with scripted modules instead of containers.
|
|
79
|
+
*/
|
|
80
|
+
const fs = __importStar(require("node:fs/promises"));
|
|
81
|
+
const config = __importStar(require("../lib/config"));
|
|
82
|
+
const errors_1 = require("../lib/errors");
|
|
83
|
+
const events_1 = require("../lib/events");
|
|
84
|
+
const home_1 = require("../lib/home");
|
|
85
|
+
const format_1 = require("../lib/format");
|
|
86
|
+
const monitoring = __importStar(require("../lib/monitoring"));
|
|
87
|
+
const constrainModule = __importStar(require("../perf/constrain"));
|
|
88
|
+
const k6Module = __importStar(require("../perf/k6"));
|
|
89
|
+
const mongoprofModule = __importStar(require("../perf/mongoprof"));
|
|
90
|
+
const rcmetricsModule = __importStar(require("../perf/rcmetrics"));
|
|
91
|
+
const resourcesModule = __importStar(require("../perf/resources"));
|
|
92
|
+
const sloModule = __importStar(require("../perf/slo"));
|
|
93
|
+
const timelineModule = __importStar(require("../perf/timeline"));
|
|
94
|
+
const verdictModule = __importStar(require("../perf/verdict"));
|
|
95
|
+
const exec_1 = require("../seams/exec");
|
|
96
|
+
const admin_1 = require("./lifecycle/admin");
|
|
97
|
+
const inspect_1 = require("./lifecycle/inspect");
|
|
98
|
+
const naming_1 = require("./lifecycle/naming");
|
|
99
|
+
const preconditions_1 = require("./lifecycle/preconditions");
|
|
100
|
+
const journal = __importStar(require("./journal"));
|
|
101
|
+
const rcapi_1 = require("./rcapi");
|
|
102
|
+
const record_1 = require("./runner/record");
|
|
103
|
+
const paths = __importStar(require("./runner/paths"));
|
|
104
|
+
const queries_1 = require("./runner/queries");
|
|
105
|
+
const wording_1 = require("../seed/wording");
|
|
106
|
+
const topology = __importStar(require("./topology"));
|
|
107
|
+
exports.GUI_SCENARIOS = Object.freeze([
|
|
108
|
+
'messages',
|
|
109
|
+
'login',
|
|
110
|
+
'read',
|
|
111
|
+
'mixed',
|
|
112
|
+
'journey',
|
|
113
|
+
'badbot',
|
|
114
|
+
]);
|
|
115
|
+
exports.DEFAULT_DEPS = {
|
|
116
|
+
constrain: constrainModule,
|
|
117
|
+
k6: k6Module,
|
|
118
|
+
mongoprof: mongoprofModule,
|
|
119
|
+
monitoring,
|
|
120
|
+
resources: resourcesModule,
|
|
121
|
+
rcmetrics: rcmetricsModule,
|
|
122
|
+
slo: sloModule,
|
|
123
|
+
timeline: timelineModule,
|
|
124
|
+
verdict: verdictModule,
|
|
125
|
+
};
|
|
126
|
+
/** The default modules, any of them replaced by `overrides`. */
|
|
127
|
+
function depsWith(overrides = {}) {
|
|
128
|
+
return { ...exports.DEFAULT_DEPS, ...overrides };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A cap that could not be applied: the job's DockerError, or the CLI's plain error
|
|
132
|
+
* `could not apply --constrain: <why>` -- REPRO_ERROR, exit 1, and the flag's own name.
|
|
133
|
+
*/
|
|
134
|
+
function constrainFailure(cli, exc) {
|
|
135
|
+
return cli === null
|
|
136
|
+
? new errors_1.DockerError(`could not apply constrain: ${(0, errors_1.errorText)(exc)}`)
|
|
137
|
+
: new errors_1.ReproError(`could not apply --constrain: ${(0, errors_1.errorText)(exc)}`);
|
|
138
|
+
}
|
|
139
|
+
/** A request with the established defaults filled in. */
|
|
140
|
+
function loadtestReq(values) {
|
|
141
|
+
return {
|
|
142
|
+
scenario: 'messages',
|
|
143
|
+
vus: 10,
|
|
144
|
+
duration: '30s',
|
|
145
|
+
usersN: 10,
|
|
146
|
+
slo: '',
|
|
147
|
+
constrain: '',
|
|
148
|
+
diag: true,
|
|
149
|
+
stats: false,
|
|
150
|
+
live: false,
|
|
151
|
+
slowms: 100,
|
|
152
|
+
ramp: null,
|
|
153
|
+
spike: null,
|
|
154
|
+
extraEnv: null,
|
|
155
|
+
quiet: true,
|
|
156
|
+
setupWarnings: false,
|
|
157
|
+
...values,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/** Restore the profiler a killed run left armed — the note's own kind, not this file's. */
|
|
161
|
+
function installJournalRepairs() {
|
|
162
|
+
journal.registerRepair(journal.CONSTRAINTS_APPLIED, repairConstraints);
|
|
163
|
+
journal.registerRepair(journal.RC_METRICS_ON, repairMetrics);
|
|
164
|
+
}
|
|
165
|
+
async function repairConstraints(entry, _emit, _login) {
|
|
166
|
+
const applied = (Array.isArray(entry.detail.applied) ? entry.detail.applied : []).map((a) => ({ ...a }));
|
|
167
|
+
// `not restore(...)`, where restore returns a PROBLEM LIST: an array is always truthy
|
|
168
|
+
// here, so `!restore(...)` would report every failed restore as repaired.
|
|
169
|
+
return (await constrainModule.restore(applied)).length === 0;
|
|
170
|
+
}
|
|
171
|
+
async function repairMetrics(entry, _emit, login_) {
|
|
172
|
+
if (login_ === null || login_ === undefined)
|
|
173
|
+
return false;
|
|
174
|
+
const meta = await (0, record_1.readMeta)(entry.workspace);
|
|
175
|
+
const auth = await login_(meta);
|
|
176
|
+
if (auth === null || auth === undefined)
|
|
177
|
+
return false;
|
|
178
|
+
return await (0, rcapi_1.setSetting)(meta.rootUrl, auth, (0, record_1.adminPass)(meta), monitoring.RC_METRICS_SETTING, false);
|
|
179
|
+
}
|
|
180
|
+
function bagOf(value) {
|
|
181
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
182
|
+
return {};
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
function rcServicesIn(doc) {
|
|
186
|
+
return Object.keys(bagOf(doc.services)).filter((service) => service === 'rocketchat' || service.startsWith('rocketchat-'));
|
|
187
|
+
}
|
|
188
|
+
function loadtestTarget(doc) {
|
|
189
|
+
const svcs = bagOf(doc.services);
|
|
190
|
+
if ('traefik' in svcs)
|
|
191
|
+
return 'http://traefik:80';
|
|
192
|
+
const rc = rcServicesIn(doc);
|
|
193
|
+
if (rc.includes('rocketchat'))
|
|
194
|
+
return 'http://rocketchat:3000';
|
|
195
|
+
return rc.length > 0 ? `http://${rc[0]}:3000` : 'http://rocketchat:3000';
|
|
196
|
+
}
|
|
197
|
+
function short(full, reproName) {
|
|
198
|
+
const prefix = `${config.PROJECT_PREFIX}${reproName}-`;
|
|
199
|
+
const s = full.startsWith(prefix) ? full.slice(prefix.length) : full;
|
|
200
|
+
return s.replace(/-\d+$/u, '');
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Log in the seeded users so VUs carry real identity.
|
|
204
|
+
*
|
|
205
|
+
* This once posted to `/api/v1/login` directly — one of the three recorded `rcapi`
|
|
206
|
+
* bypasses — and now reaches the same endpoint through `rcapi`, which is where the
|
|
207
|
+
* dependency policy says HTTP lives.
|
|
208
|
+
*/
|
|
209
|
+
async function loginSeedUsers(rootUrl, count) {
|
|
210
|
+
const users = [];
|
|
211
|
+
for (let i = 0; i < count; i += 1) {
|
|
212
|
+
const uname = (0, wording_1.username)(i);
|
|
213
|
+
let entry;
|
|
214
|
+
try {
|
|
215
|
+
entry = await (0, rcapi_1.loginUser)(rootUrl, uname);
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
if (entry !== null && (0, format_1.isTruthy)(entry.authToken)) {
|
|
221
|
+
users.push({
|
|
222
|
+
username: uname,
|
|
223
|
+
password: uname,
|
|
224
|
+
token: entry.authToken,
|
|
225
|
+
uid: entry.userId,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return users;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Refuse a load test or capacity search on a Kubernetes workspace, and say why.
|
|
233
|
+
*
|
|
234
|
+
* Not merely "unimplemented". The number would be WRONG in a way that reads as a result:
|
|
235
|
+
* a Kubernetes workspace is reached through `kubectl port-forward`, which is a single
|
|
236
|
+
* userspace relay — it saturates, serialises and drops connections far below what
|
|
237
|
+
* Rocket.Chat itself would, so every figure the run produced would be a measurement of
|
|
238
|
+
* the forward. A plausible wrong number is the one failure mode this tool cannot afford
|
|
239
|
+
* in a report a support engineer sends to a customer.
|
|
240
|
+
*/
|
|
241
|
+
async function requireComposeForPerf(name, operation) {
|
|
242
|
+
const target = await (0, naming_1.resolveName)(name);
|
|
243
|
+
if ((await topology.ofRepro(target)) !== topology.KUBERNETES) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
let version = '';
|
|
247
|
+
try {
|
|
248
|
+
version = (await (0, record_1.readMeta)(target)).rcVersion;
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
// the refusal matters more than the example
|
|
252
|
+
}
|
|
253
|
+
throw new errors_1.ValidationError(`${operation} is Compose-only. A Kubernetes workspace is reached through a ` +
|
|
254
|
+
'`kubectl port-forward`, which is a single userspace relay: it saturates and ' +
|
|
255
|
+
'drops connections long before Rocket.Chat does, so every number this ' +
|
|
256
|
+
'produced would be measuring the forward. Run it against a Compose ' +
|
|
257
|
+
`workspace on the same version instead — \`houston up --version ` +
|
|
258
|
+
`${version || '<version>'} --name perf\` — where the client talks to the ` +
|
|
259
|
+
'container directly.');
|
|
260
|
+
}
|
|
261
|
+
function newLoadRun() {
|
|
262
|
+
return {
|
|
263
|
+
appliedConstraints: [],
|
|
264
|
+
limiterWasOff: true,
|
|
265
|
+
limiterNote: '',
|
|
266
|
+
constrainNote: '',
|
|
267
|
+
metricsNote: '',
|
|
268
|
+
mongoNote: '',
|
|
269
|
+
metricsChanged: false,
|
|
270
|
+
mongoPrior: null,
|
|
271
|
+
sampler: null,
|
|
272
|
+
mon: null,
|
|
273
|
+
resources: null,
|
|
274
|
+
summary: null,
|
|
275
|
+
rcmReport: {},
|
|
276
|
+
sinceMs: 0,
|
|
277
|
+
restartsBefore: -1,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Put a setting back, and say whether it went back.
|
|
282
|
+
*
|
|
283
|
+
* `setSetting` answers false rather than throwing, and that answer was dropped: the warning
|
|
284
|
+
* in the `catch` could never fire, and the journal note was cleared either way. The login,
|
|
285
|
+
* mixed and journey scenarios log the admin in hundreds of times, and Rocket.Chat keeps 50
|
|
286
|
+
* login tokens (MAX_RESUME_LOGIN_TOKENS) -- so the session this run started with was
|
|
287
|
+
* pruned before it ended, the restore was refused, and the rate limiter stayed OFF with
|
|
288
|
+
* nothing said. Every later run then read it as "was off" and left it. A refused restore
|
|
289
|
+
* logs in afresh and tries once more.
|
|
290
|
+
*/
|
|
291
|
+
async function restoreSetting(m, auth, settingId, value) {
|
|
292
|
+
if (await (0, rcapi_1.setSetting)(m.rootUrl, auth, (0, record_1.adminPass)(m), settingId, value))
|
|
293
|
+
return true;
|
|
294
|
+
let fresh;
|
|
295
|
+
try {
|
|
296
|
+
fresh = await (0, admin_1.login)(m);
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
if (error instanceof exec_1.Interrupted)
|
|
300
|
+
throw error;
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
return await (0, rcapi_1.setSetting)(m.rootUrl, fresh, (0, record_1.adminPass)(m), settingId, value);
|
|
304
|
+
}
|
|
305
|
+
/** Undo every side effect this run armed, whichever way it ended. */
|
|
306
|
+
async function putEverythingBack({ auth, cli = null, deps, emit, m, run, }) {
|
|
307
|
+
// The job's event, or the restore's warning in the CLI's words.
|
|
308
|
+
const restoreWarning = (job, words) => {
|
|
309
|
+
if (cli === null)
|
|
310
|
+
(0, events_1.warn)(emit, job, { phase: 'restore' });
|
|
311
|
+
else
|
|
312
|
+
cli.warn(words);
|
|
313
|
+
};
|
|
314
|
+
// users.json holds live seeded-user auth tokens — delete it FIRST, so no later restore
|
|
315
|
+
// step failing can leave credentials on disk.
|
|
316
|
+
await fs.rm((0, home_1.joinPath)(paths.workspace(m.name), 'loadtest', 'users.json'), { force: true });
|
|
317
|
+
if (run.sampler !== null) {
|
|
318
|
+
run.rcmReport = await run.sampler.stop();
|
|
319
|
+
}
|
|
320
|
+
if (run.mon !== null) {
|
|
321
|
+
run.resources = await run.mon.stop();
|
|
322
|
+
}
|
|
323
|
+
if (!run.limiterWasOff) {
|
|
324
|
+
if (await restoreSetting(m, auth, config.RC_RATE_LIMITER_SETTING, true)) {
|
|
325
|
+
journal.clear(run.limiterNote);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
restoreWarning('could not restore the API rate limiter setting', ' ⚠ could not restore the API rate limiter setting');
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (run.metricsChanged) {
|
|
332
|
+
if (await restoreSetting(m, auth, deps.monitoring.RC_METRICS_SETTING, false)) {
|
|
333
|
+
journal.clear(run.metricsNote);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
restoreWarning('could not restore the Prometheus metrics setting', ' ⚠ could not restore the Prometheus metrics setting');
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (run.mongoPrior !== null) {
|
|
340
|
+
// Wrapped like its neighbours: an exception here would skip the resource-cap restore
|
|
341
|
+
// below and leave the containers capped.
|
|
342
|
+
try {
|
|
343
|
+
await deps.mongoprof.stop(m.name, run.mongoPrior);
|
|
344
|
+
journal.clear(run.mongoNote);
|
|
345
|
+
}
|
|
346
|
+
catch {
|
|
347
|
+
restoreWarning('could not restore the Mongo profiler level', ' ⚠ could not restore the Mongo profiler level');
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
// CLEARED AFTER, like its three siblings above. Clearing first threw away the note on
|
|
351
|
+
// the one path it exists for: `restore` RETURNS problems rather than raising, and the
|
|
352
|
+
// loop below is there to report them — so a failed restore left the containers capped
|
|
353
|
+
// with the record of their prior values already deleted, which is precisely what
|
|
354
|
+
// CONSTRAINTS_APPLIED carries them for.
|
|
355
|
+
const capProblems = await deps.constrain.restore(run.appliedConstraints);
|
|
356
|
+
for (const problem of capProblems) {
|
|
357
|
+
restoreWarning(`could not restore resource limits - ${problem}`, ` ⚠ could not restore resource limits — ${problem}`);
|
|
358
|
+
}
|
|
359
|
+
if (capProblems.length === 0) {
|
|
360
|
+
journal.clear(run.constrainNote);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/** Constrain, disable the limiter, turn the diagnostics on, and run k6. */
|
|
364
|
+
async function armAndRun({ auth, cli = null, deps, emit, m, perService, rcServices, req, run, target, token, users, }) {
|
|
365
|
+
if (Object.keys(perService).length > 0) {
|
|
366
|
+
try {
|
|
367
|
+
run.appliedConstraints = await deps.constrain.apply(m.name, perService);
|
|
368
|
+
}
|
|
369
|
+
catch (exc) {
|
|
370
|
+
// `constrain.apply` signals its own failures with a plain Error, and those are what
|
|
371
|
+
// this answers; nothing else is expected from it, so wrapping every failure is no
|
|
372
|
+
// broader a net than the one intended.
|
|
373
|
+
throw constrainFailure(cli, exc);
|
|
374
|
+
}
|
|
375
|
+
// NOTED WITH THE PRIOR VALUES, so a killed run can be undone exactly rather than
|
|
376
|
+
// reset to "unlimited". `restore` runs in the `finally` below; this is what covers
|
|
377
|
+
// the run that never reaches it.
|
|
378
|
+
run.constrainNote = journal.record(journal.CONSTRAINTS_APPLIED, m.name, {
|
|
379
|
+
applied: run.appliedConstraints.map((a) => ({ ...a })),
|
|
380
|
+
});
|
|
381
|
+
run.restartsBefore = await (0, queries_1.rcRestartCount)(m.name);
|
|
382
|
+
if (cli === null) {
|
|
383
|
+
(0, events_1.info)(emit, `constrained: ${deps.constrain.human(perService)} (restored after)`, {
|
|
384
|
+
phase: 'k6',
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
cli.constrained?.(deps.constrain.human(perService));
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
run.limiterWasOff =
|
|
392
|
+
(await (0, rcapi_1.getSetting)(m.rootUrl, auth, (0, record_1.adminPass)(m), config.RC_RATE_LIMITER_SETTING)) === false;
|
|
393
|
+
if (!run.limiterWasOff) {
|
|
394
|
+
// JOURNALLED BEFORE IT IS TURNED OFF. The `finally` below turns it back on, and a
|
|
395
|
+
// daemon thread killed by a restart or an OOM runs no `finally` at all — so the note
|
|
396
|
+
// on disk is what survives to say the API rate limiter is off on this workspace and
|
|
397
|
+
// nobody meant to leave it that way.
|
|
398
|
+
run.limiterNote = journal.record(journal.RATE_LIMITER_OFF, m.name);
|
|
399
|
+
const changed = await (0, rcapi_1.setSetting)(m.rootUrl, auth, (0, record_1.adminPass)(m), config.RC_RATE_LIMITER_SETTING, false);
|
|
400
|
+
if (!changed) {
|
|
401
|
+
// NEVER TURNED OFF, so there is nothing to put back: restoring it anyway now says
|
|
402
|
+
// "could not restore" about a setting this run never changed.
|
|
403
|
+
run.limiterWasOff = true;
|
|
404
|
+
journal.clear(run.limiterNote);
|
|
405
|
+
run.limiterNote = '';
|
|
406
|
+
if (req.setupWarnings) {
|
|
407
|
+
const words = 'could not disable the API rate limiter — results may be throttled (429s)';
|
|
408
|
+
if (cli === null)
|
|
409
|
+
(0, events_1.warn)(emit, words, { phase: 'k6' });
|
|
410
|
+
else
|
|
411
|
+
cli.warn(` ⚠ ${words}`);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
// The banner: after the caps and the limiter, before the diagnostics are armed.
|
|
416
|
+
cli?.armed?.();
|
|
417
|
+
if (req.diag) {
|
|
418
|
+
if ((await (0, rcapi_1.getSetting)(m.rootUrl, auth, (0, record_1.adminPass)(m), deps.monitoring.RC_METRICS_SETTING)) !== true) {
|
|
419
|
+
// Journalled like its two neighbours. Both of these are restored in the `finally`
|
|
420
|
+
// below, which is precisely the block a SIGKILL does not run — so without a note a
|
|
421
|
+
// killed --diag run leaves Rocket.Chat's metrics endpoint open and the profiler
|
|
422
|
+
// armed, with nothing on disk saying so.
|
|
423
|
+
run.metricsNote = journal.record(journal.RC_METRICS_ON, m.name);
|
|
424
|
+
run.metricsChanged = await (0, rcapi_1.setSetting)(m.rootUrl, auth, (0, record_1.adminPass)(m), deps.monitoring.RC_METRICS_SETTING, true);
|
|
425
|
+
}
|
|
426
|
+
run.mongoPrior = await deps.mongoprof.start(m.name, req.slowms);
|
|
427
|
+
if (run.mongoPrior === null && req.setupWarnings) {
|
|
428
|
+
const words = 'Mongo slow-query capture unavailable (profiler could not be enabled)';
|
|
429
|
+
if (cli === null)
|
|
430
|
+
(0, events_1.warn)(emit, words, { phase: 'k6' });
|
|
431
|
+
else
|
|
432
|
+
cli.warn(` ⚠ ${words}`);
|
|
433
|
+
}
|
|
434
|
+
else if (run.mongoPrior !== null) {
|
|
435
|
+
// Carrying the PRIOR level, because `mongoprof.stop` restores to a value rather
|
|
436
|
+
// than to off, and a workspace that already had profiling on must keep it. Same
|
|
437
|
+
// distinction CONSTRAINTS_APPLIED already draws.
|
|
438
|
+
run.mongoNote = journal.record(journal.MONGO_PROFILER_ON, m.name, {
|
|
439
|
+
prior: run.mongoPrior,
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
run.mon = req.stats ? new deps.resources.ResourceMonitor(m.name).start() : null;
|
|
444
|
+
run.sinceMs = Date.now();
|
|
445
|
+
if (req.diag) {
|
|
446
|
+
run.sampler = new deps.rcmetrics.RCMetricsSampler(m.name, rcServices).start();
|
|
447
|
+
}
|
|
448
|
+
// The job's narration only: the CLI announced its own banner above, and an event would
|
|
449
|
+
// reach the event log's sink even with no emitter.
|
|
450
|
+
if (cli === null) {
|
|
451
|
+
const who = users.length > 0 ? `${String(users.length)} seeded users` : 'admin token';
|
|
452
|
+
(0, events_1.info)(emit, `running k6: ${req.scenario} @ ${String(req.vus)} VUs for ${req.duration} -> ${target}` +
|
|
453
|
+
` (${who})`, { phase: 'k6' });
|
|
454
|
+
}
|
|
455
|
+
run.summary = await deps.k6.run(m.name, req.scenario, {
|
|
456
|
+
vus: req.vus,
|
|
457
|
+
duration: req.duration,
|
|
458
|
+
ramp: req.ramp,
|
|
459
|
+
token,
|
|
460
|
+
uid: auth.userId,
|
|
461
|
+
target,
|
|
462
|
+
users: users.length > 0 ? [...users] : null,
|
|
463
|
+
password: (0, record_1.adminPass)(m),
|
|
464
|
+
...(req.extraEnv === null ? {} : { extraEnv: req.extraEnv }),
|
|
465
|
+
quiet: req.quiet,
|
|
466
|
+
timeline: req.diag || req.spike !== null,
|
|
467
|
+
spike: req.spike,
|
|
468
|
+
live: req.live,
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* What the run proved: the SLO, the diagnosis, and where to look at it.
|
|
473
|
+
*
|
|
474
|
+
* `timeline` and `mongo` are read from the workspace only here, after the run has been
|
|
475
|
+
* put back, so the point file that k6 wrote is consumed exactly once.
|
|
476
|
+
*/
|
|
477
|
+
async function loadtestVerdict({ cli = null, deps, emit, m, req, rules, run, }) {
|
|
478
|
+
const mongoSlow = req.diag && run.mongoPrior !== null ? await deps.mongoprof.collect(m.name, run.sinceMs) : null;
|
|
479
|
+
let tl = null;
|
|
480
|
+
if (req.diag || req.spike !== null) {
|
|
481
|
+
const points = (0, home_1.joinPath)(paths.workspace(m.name), 'loadtest', 'points.json');
|
|
482
|
+
tl = deps.timeline.parse(points);
|
|
483
|
+
await fs.rm(points, { force: true });
|
|
484
|
+
}
|
|
485
|
+
const sloResults = rules.length > 0 ? deps.slo.evaluate(rules, run.summary ?? {}) : [];
|
|
486
|
+
// An EMPTY resources object counts as none, and that is a real case: the sampler
|
|
487
|
+
// ran but the workspace had no container to sample. Reporting `{}` where the established
|
|
488
|
+
// answer is null would say "we measured nothing" in a different shape.
|
|
489
|
+
const shortStats = run.resources !== null && Object.keys(run.resources).length > 0
|
|
490
|
+
? Object.fromEntries(Object.entries(run.resources).map(([key, value]) => [short(key, m.name), value]))
|
|
491
|
+
: null;
|
|
492
|
+
const verdictLines = req.diag
|
|
493
|
+
? deps.verdict.analyze(run.summary ?? {}, {
|
|
494
|
+
rcmetrics: Object.keys(run.rcmReport).length > 0 ? run.rcmReport : null,
|
|
495
|
+
// The collectors' interfaces carry no index signature, which is a TypeScript
|
|
496
|
+
// shape rather than a data difference: both are plain JSON objects on the wire.
|
|
497
|
+
mongo: mongoSlow,
|
|
498
|
+
resources: shortStats,
|
|
499
|
+
timeline: tl,
|
|
500
|
+
})
|
|
501
|
+
: [];
|
|
502
|
+
const passed = sloResults.length === 0 || sloResults.every((r) => r.ok);
|
|
503
|
+
// A CAP THAT KILLED IT, said. Under a memory cap the kernel can restart Rocket.Chat while
|
|
504
|
+
// the load runs, and the run then measures the restart -- it reported 100% errors as a
|
|
505
|
+
// load result with no word about why.
|
|
506
|
+
if (run.restartsBefore >= 0) {
|
|
507
|
+
const restarts = (await (0, queries_1.rcRestartCount)(m.name)) - run.restartsBefore;
|
|
508
|
+
if (restarts > 0) {
|
|
509
|
+
const words = `Rocket.Chat restarted ${String(restarts)}x during the run under --constrain: ` +
|
|
510
|
+
'these numbers are its restart, not its load. Give it more memory.';
|
|
511
|
+
verdictLines.unshift(words);
|
|
512
|
+
if (cli === null)
|
|
513
|
+
(0, events_1.warn)(emit, words, { phase: 'k6' });
|
|
514
|
+
else
|
|
515
|
+
cli.warn(` ⚠ ${words}`);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
const grafana = req.live ? (0, inspect_1.grafanaUrlOf)(m) : null;
|
|
519
|
+
const summary = run.summary ?? {};
|
|
520
|
+
// The job's closing event. The CLI renders its own result, and the event would reach the
|
|
521
|
+
// event log's sink with `passed` redacted as a secret.
|
|
522
|
+
if (cli === null) {
|
|
523
|
+
(0, events_1.info)(emit, `done: p95 ${(0, format_1.formatFixed)(Number(summary.p95 ?? 0), 0)}ms at ` +
|
|
524
|
+
`${(0, format_1.formatFixed)(Number(summary.rps ?? 0), 1)} req/s, ` +
|
|
525
|
+
`${(0, format_1.formatFixed)(Number(summary.error_rate ?? 0) * 100, 2)}% errors` +
|
|
526
|
+
(passed ? '' : ' - SLO FAIL'),
|
|
527
|
+
// The detail is one key named `data` inside the event's data, so it nests; the wire
|
|
528
|
+
// keeps that shape.
|
|
529
|
+
{ phase: 'done', data: { data: { passed } } });
|
|
530
|
+
}
|
|
531
|
+
return { grafana, mongoSlow, passed, shortStats, sloResults, tl, verdictLines };
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* A duration k6 takes: a Go duration (`30s`, `1m30s`, `500ms`, `1.5h`) or a bare number of
|
|
535
|
+
* milliseconds. Checked here because houston passed any word to k6, which started and then
|
|
536
|
+
* failed: `loadtest --duration forever` ran, exited 1 and said why only in k6's own output.
|
|
537
|
+
*/
|
|
538
|
+
function refuseABadDuration(value, flag) {
|
|
539
|
+
if (/^(\d+(\.\d+)?|(\d+(\.\d+)?(ns|us|µs|ms|s|m|h))+)$/u.test(value.trim()))
|
|
540
|
+
return;
|
|
541
|
+
throw new errors_1.ValidationError(`bad ${flag}: '${value}' is not a duration (e.g. 30s, 2m, 1m30s)`);
|
|
542
|
+
}
|
|
543
|
+
async function loadtestPreflight(deps, req) {
|
|
544
|
+
await (0, preconditions_1.requireDocker)();
|
|
545
|
+
if (!exports.GUI_SCENARIOS.includes(req.scenario)) {
|
|
546
|
+
throw new errors_1.ValidationError(`scenario must be one of ${exports.GUI_SCENARIOS.join(', ')}`);
|
|
547
|
+
}
|
|
548
|
+
if (req.vus < 1) {
|
|
549
|
+
throw new errors_1.ValidationError('vus must be >= 1');
|
|
550
|
+
}
|
|
551
|
+
refuseABadDuration(req.duration, 'duration');
|
|
552
|
+
// Refused here rather than at the top, so a bad --scenario is still named before a bad
|
|
553
|
+
// --name: the request's own shape is cheaper to check and is what the caller most
|
|
554
|
+
// likely got wrong. But BEFORE `readCompose`, which threw a bare ENOENT
|
|
555
|
+
// naming a compose file a Kubernetes workspace does not have — outside the ReproError
|
|
556
|
+
// contract, so the GUI answered 500 to a request that is merely unsupported. The same
|
|
557
|
+
// defect the env tab had, in a second place.
|
|
558
|
+
await requireComposeForPerf(req.name, 'loadtest');
|
|
559
|
+
const m = await (0, record_1.readMeta)(await (0, naming_1.resolveName)(req.name));
|
|
560
|
+
const doc = await (0, record_1.readCompose)(m.name);
|
|
561
|
+
const target = loadtestTarget(doc);
|
|
562
|
+
const rcServices = rcServicesIn(doc);
|
|
563
|
+
const services = rcServices.length > 0 ? rcServices : ['rocketchat'];
|
|
564
|
+
if (req.live) {
|
|
565
|
+
if (!(0, format_1.isTruthy)(bagOf(m.extra).monitoring)) {
|
|
566
|
+
throw new errors_1.ValidationError('live streaming needs monitoring attached first');
|
|
567
|
+
}
|
|
568
|
+
const promCmd = bagOf(bagOf(doc.services).prometheus).command;
|
|
569
|
+
if (!(Array.isArray(promCmd) ? promCmd : []).some((c) => String(c).includes('remote-write-receiver'))) {
|
|
570
|
+
throw new errors_1.ValidationError('live needs Prometheus with remote-write - re-attach monitoring');
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
let rules;
|
|
574
|
+
try {
|
|
575
|
+
rules = (0, format_1.isTruthy)(req.slo) ? deps.slo.parse(req.slo) : [];
|
|
576
|
+
}
|
|
577
|
+
catch (exc) {
|
|
578
|
+
throw new errors_1.ValidationError(`bad slo: ${(0, errors_1.errorText)(exc)}`);
|
|
579
|
+
}
|
|
580
|
+
let perService = {};
|
|
581
|
+
if (req.constrain) {
|
|
582
|
+
try {
|
|
583
|
+
perService = deps.constrain.resolveServices(deps.constrain.parse(req.constrain), Object.keys(bagOf(doc.services)));
|
|
584
|
+
}
|
|
585
|
+
catch (exc) {
|
|
586
|
+
throw new errors_1.ValidationError(`bad constrain: ${(0, errors_1.errorText)(exc)}`);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
let auth;
|
|
590
|
+
let token;
|
|
591
|
+
try {
|
|
592
|
+
auth = await (0, admin_1.login)(m);
|
|
593
|
+
token = await (0, rcapi_1.generatePat)(m.rootUrl, auth, (0, record_1.adminPass)(m), {
|
|
594
|
+
tokenName: 'houston-loadtest',
|
|
595
|
+
bypass2fa: true,
|
|
596
|
+
workspace: m.name,
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
catch (exc) {
|
|
600
|
+
throw new errors_1.NotReadyError(`could not authenticate (ready?): ${(0, errors_1.errorText)(exc)}`);
|
|
601
|
+
}
|
|
602
|
+
const users = req.usersN > 0 ? await loginSeedUsers(m.rootUrl, req.usersN) : [];
|
|
603
|
+
return { auth, m, perService, rcServices: services, rules, target, token, users };
|
|
604
|
+
}
|
|
605
|
+
async function runLoadtest(req, emit = events_1.nullEmit, deps = exports.DEFAULT_DEPS) {
|
|
606
|
+
const prepared = await loadtestPreflight(deps, req);
|
|
607
|
+
const { m, perService, target, users } = prepared;
|
|
608
|
+
const { run, verdict } = await runPreparedLoadtest(req, prepared, emit, deps);
|
|
609
|
+
const { grafana, mongoSlow, passed, shortStats, sloResults, tl, verdictLines } = verdict;
|
|
610
|
+
return {
|
|
611
|
+
ctx: {
|
|
612
|
+
name: m.name,
|
|
613
|
+
scenario: req.scenario,
|
|
614
|
+
vus: req.vus,
|
|
615
|
+
duration: req.duration,
|
|
616
|
+
users: users.length,
|
|
617
|
+
target,
|
|
618
|
+
constrained: Object.keys(perService).length > 0 ? deps.constrain.human(perService) : '',
|
|
619
|
+
},
|
|
620
|
+
summary: run.summary,
|
|
621
|
+
slo: sloResults,
|
|
622
|
+
passed,
|
|
623
|
+
verdict: verdictLines,
|
|
624
|
+
diag: req.diag ? { rcmetrics: run.rcmReport, mongo: mongoSlow, timeline: tl } : null,
|
|
625
|
+
resources: shortStats !== null
|
|
626
|
+
? Object.fromEntries(Object.entries(shortStats).map(([key, value]) => [key, { ...value }]))
|
|
627
|
+
: null,
|
|
628
|
+
grafana_url: grafana,
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
async function runPreparedLoadtest(req, prepared, emit = events_1.nullEmit, deps = exports.DEFAULT_DEPS, cli = null) {
|
|
632
|
+
const { auth, m, perService, rcServices, rules, target, token, users } = prepared;
|
|
633
|
+
const run = newLoadRun();
|
|
634
|
+
try {
|
|
635
|
+
await armAndRun({
|
|
636
|
+
auth,
|
|
637
|
+
cli,
|
|
638
|
+
deps,
|
|
639
|
+
emit,
|
|
640
|
+
m,
|
|
641
|
+
perService,
|
|
642
|
+
rcServices,
|
|
643
|
+
req,
|
|
644
|
+
run,
|
|
645
|
+
target,
|
|
646
|
+
token,
|
|
647
|
+
users,
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
catch (exc) {
|
|
651
|
+
// The ReproError taxonomy passes through and anything else is converted; every
|
|
652
|
+
// failure `armAndRun` can raise on its own is a bad-input-or-engine one, and the
|
|
653
|
+
// deliberate refusals above keep their own types.
|
|
654
|
+
if (exc instanceof errors_1.ReproError)
|
|
655
|
+
throw exc;
|
|
656
|
+
if (cli === null)
|
|
657
|
+
throw new errors_1.DockerError((0, errors_1.errorText)(exc));
|
|
658
|
+
// The CLI's plain error: k6's unreadable or missing summary is REPRO_ERROR, exit 1. A
|
|
659
|
+
// request that failed is a transport failure, which is not converted, so it goes on to
|
|
660
|
+
// the contract's last line as it is.
|
|
661
|
+
if (exc instanceof Error && exc.name === 'RequestFailed')
|
|
662
|
+
throw exc;
|
|
663
|
+
throw new errors_1.ReproError((0, errors_1.errorText)(exc));
|
|
664
|
+
}
|
|
665
|
+
finally {
|
|
666
|
+
await putEverythingBack({ auth, cli, deps, emit, m, run });
|
|
667
|
+
}
|
|
668
|
+
const verdict = await loadtestVerdict({ cli, deps, emit, m, req, rules, run });
|
|
669
|
+
return { run, verdict };
|
|
670
|
+
}
|
|
671
|
+
function capacityReq(values) {
|
|
672
|
+
return {
|
|
673
|
+
scenario: 'journey',
|
|
674
|
+
usersN: 10,
|
|
675
|
+
slo: 'p95=500ms,error=2%',
|
|
676
|
+
start: 10,
|
|
677
|
+
maxVus: 640,
|
|
678
|
+
stepDuration: '20s',
|
|
679
|
+
constrain: '',
|
|
680
|
+
...values,
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
function newCapacitySearch() {
|
|
684
|
+
return {
|
|
685
|
+
applied: [],
|
|
686
|
+
limiterWasOff: true,
|
|
687
|
+
limiterNote: '',
|
|
688
|
+
constrainNote: '',
|
|
689
|
+
metricsNote: '',
|
|
690
|
+
metricsChanged: false,
|
|
691
|
+
steps: [],
|
|
692
|
+
lastPass: null,
|
|
693
|
+
firstFail: null,
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* The members of each capacity step that are held as FLOATS: `lag_max_s` always (`0.0`,
|
|
698
|
+
* or an RC metric read as a float), and `rps`, `p95` or `error_rate` where k6's summary had
|
|
699
|
+
* no such key and the row took the default `0.0`. A value the
|
|
700
|
+
* summary did carry is left as the summary spelled it.
|
|
701
|
+
*
|
|
702
|
+
* Kept BESIDE the row rather than in it, because the row is also the GUI job's result, which
|
|
703
|
+
* the web's serializer writes: only the CLI's envelope writer knows a `JsonFloat`.
|
|
704
|
+
*/
|
|
705
|
+
const STEP_FLOATS = new WeakMap();
|
|
706
|
+
function stepFloats(row) {
|
|
707
|
+
return STEP_FLOATS.get(row) ?? [];
|
|
708
|
+
}
|
|
709
|
+
/** Where the SLO broke, and what broke it. */
|
|
710
|
+
function capacityVerdict(emit, req, search) {
|
|
711
|
+
const { result, why } = capacityWords(req, search);
|
|
712
|
+
// Nested one level, a key named `data` inside the event's data, as it always has been.
|
|
713
|
+
(0, events_1.info)(emit, `capacity: ${result}`, {
|
|
714
|
+
phase: 'done',
|
|
715
|
+
data: { data: { capacity_vus: search.lastPass } },
|
|
716
|
+
});
|
|
717
|
+
return { result, why };
|
|
718
|
+
}
|
|
719
|
+
/** The verdict's words alone, for the CLI's run, which says nothing through events. */
|
|
720
|
+
function capacityWords(req, search) {
|
|
721
|
+
let result;
|
|
722
|
+
if (search.lastPass === null) {
|
|
723
|
+
result = `breaches the SLO even at ${String(req.start)} VUs - start lower`;
|
|
724
|
+
}
|
|
725
|
+
else if (search.firstFail === null) {
|
|
726
|
+
result = `holds the SLO up to ${String(search.lastPass)} VUs (never breached; raise max to push further)`;
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
result = `~${String(search.lastPass)} concurrent VUs (holds at ${String(search.lastPass)}, breaks at ${String(search.firstFail)})`;
|
|
730
|
+
}
|
|
731
|
+
const breach = search.firstFail !== null
|
|
732
|
+
? search.steps.find((r) => r.vus === search.firstFail)
|
|
733
|
+
: search.steps.find((r) => !(0, format_1.isTruthy)(r.ok));
|
|
734
|
+
let why = '';
|
|
735
|
+
if (breach !== undefined) {
|
|
736
|
+
const lag = Number(breach.lag_max_s ?? 0);
|
|
737
|
+
why =
|
|
738
|
+
lag >= 0.5
|
|
739
|
+
? `at ${String(breach.vus)} VUs the RC event loop saturated (lag peaked ` +
|
|
740
|
+
`at ${(0, format_1.formatFixed)(lag * 1000, 0)}ms)`
|
|
741
|
+
: `at ${String(breach.vus)} VUs: ${(Array.isArray(breach.breached) ? breach.breached : []).join('; ')}`;
|
|
742
|
+
}
|
|
743
|
+
return { result, why };
|
|
744
|
+
}
|
|
745
|
+
async function capacityPreflight(deps, req) {
|
|
746
|
+
await (0, preconditions_1.requireDocker)();
|
|
747
|
+
if (!exports.GUI_SCENARIOS.includes(req.scenario)) {
|
|
748
|
+
throw new errors_1.ValidationError(`scenario must be one of ${exports.GUI_SCENARIOS.join(', ')}`);
|
|
749
|
+
}
|
|
750
|
+
let rules;
|
|
751
|
+
try {
|
|
752
|
+
rules = deps.slo.parse(req.slo);
|
|
753
|
+
}
|
|
754
|
+
catch (exc) {
|
|
755
|
+
throw new errors_1.ValidationError(`bad slo: ${(0, errors_1.errorText)(exc)}`);
|
|
756
|
+
}
|
|
757
|
+
if (req.start < 1 || req.maxVus < req.start) {
|
|
758
|
+
throw new errors_1.ValidationError('start must be >= 1 and max >= start');
|
|
759
|
+
}
|
|
760
|
+
refuseABadDuration(req.stepDuration, 'step duration');
|
|
761
|
+
await requireComposeForPerf(req.name, 'capacity'); // see runLoadtest for the why
|
|
762
|
+
const m = await (0, record_1.readMeta)(await (0, naming_1.resolveName)(req.name));
|
|
763
|
+
const doc = await (0, record_1.readCompose)(m.name);
|
|
764
|
+
const target = loadtestTarget(doc);
|
|
765
|
+
const rcServices = rcServicesIn(doc);
|
|
766
|
+
const services = rcServices.length > 0 ? rcServices : ['rocketchat'];
|
|
767
|
+
let perService = {};
|
|
768
|
+
if (req.constrain) {
|
|
769
|
+
try {
|
|
770
|
+
perService = deps.constrain.resolveServices(deps.constrain.parse(req.constrain), Object.keys(bagOf(doc.services)));
|
|
771
|
+
}
|
|
772
|
+
catch (exc) {
|
|
773
|
+
throw new errors_1.ValidationError(`bad constrain: ${(0, errors_1.errorText)(exc)}`);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
let auth;
|
|
777
|
+
let token;
|
|
778
|
+
try {
|
|
779
|
+
auth = await (0, admin_1.login)(m);
|
|
780
|
+
token = await (0, rcapi_1.generatePat)(m.rootUrl, auth, (0, record_1.adminPass)(m), {
|
|
781
|
+
tokenName: 'houston-loadtest',
|
|
782
|
+
bypass2fa: true,
|
|
783
|
+
workspace: m.name,
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
catch (exc) {
|
|
787
|
+
throw new errors_1.NotReadyError(`could not authenticate (ready?): ${(0, errors_1.errorText)(exc)}`);
|
|
788
|
+
}
|
|
789
|
+
const users = req.usersN > 0 ? await loginSeedUsers(m.rootUrl, req.usersN) : [];
|
|
790
|
+
return { auth, m, perService, rcServices: services, rules, target, token, users };
|
|
791
|
+
}
|
|
792
|
+
/** Undo every side effect the search armed, whichever way it ended. */
|
|
793
|
+
async function putTheWorkspaceBack({ auth, cli = null, deps, emit, m, search, }) {
|
|
794
|
+
// The job's event, or the restore's warning line: its own words, with the lead and
|
|
795
|
+
// the em dash the service's line does not have.
|
|
796
|
+
const restoreWarning = (job, words) => {
|
|
797
|
+
if (cli === null)
|
|
798
|
+
(0, events_1.warn)(emit, job, { phase: 'restore' });
|
|
799
|
+
else
|
|
800
|
+
cli.warn(words);
|
|
801
|
+
};
|
|
802
|
+
if (!search.limiterWasOff) {
|
|
803
|
+
if (await restoreSetting(m, auth, config.RC_RATE_LIMITER_SETTING, true)) {
|
|
804
|
+
journal.clear(search.limiterNote);
|
|
805
|
+
}
|
|
806
|
+
else {
|
|
807
|
+
restoreWarning('could not restore the API rate limiter setting', ' ⚠ could not restore the API rate limiter setting');
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
if (search.metricsChanged) {
|
|
811
|
+
if (await restoreSetting(m, auth, deps.monitoring.RC_METRICS_SETTING, false)) {
|
|
812
|
+
journal.clear(search.metricsNote);
|
|
813
|
+
}
|
|
814
|
+
else {
|
|
815
|
+
restoreWarning('could not restore the Prometheus metrics setting', ' ⚠ could not restore the Prometheus metrics setting');
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
// See run_loadtest: cleared only when the restore actually succeeded.
|
|
819
|
+
const capProblems = await deps.constrain.restore(search.applied);
|
|
820
|
+
for (const problem of capProblems) {
|
|
821
|
+
restoreWarning(`could not restore resource limits - ${problem}`, ` ⚠ could not restore resource limits — ${problem}`);
|
|
822
|
+
}
|
|
823
|
+
if (capProblems.length === 0) {
|
|
824
|
+
journal.clear(search.constrainNote);
|
|
825
|
+
}
|
|
826
|
+
await fs.rm((0, home_1.joinPath)(paths.workspace(m.name), 'loadtest', 'users.json'), { force: true });
|
|
827
|
+
}
|
|
828
|
+
/** Double until the SLO breaks, then bisect between the last pass and the first fail. */
|
|
829
|
+
async function searchForCapacity({ auth, cli = null, deps, emit, m, perService, req, runStep, search, }) {
|
|
830
|
+
if (Object.keys(perService).length > 0) {
|
|
831
|
+
try {
|
|
832
|
+
search.applied = await deps.constrain.apply(m.name, perService);
|
|
833
|
+
}
|
|
834
|
+
catch (exc) {
|
|
835
|
+
throw constrainFailure(cli, exc);
|
|
836
|
+
}
|
|
837
|
+
// NOTED WITH THE PRIOR VALUES, so a killed run can be undone exactly rather than
|
|
838
|
+
// reset to "unlimited". `restore` runs in the `finally` below; this is what covers
|
|
839
|
+
// the run that never reaches it.
|
|
840
|
+
search.constrainNote = journal.record(journal.CONSTRAINTS_APPLIED, m.name, {
|
|
841
|
+
applied: search.applied.map((a) => ({ ...a })),
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
search.limiterWasOff =
|
|
845
|
+
(await (0, rcapi_1.getSetting)(m.rootUrl, auth, (0, record_1.adminPass)(m), config.RC_RATE_LIMITER_SETTING)) === false;
|
|
846
|
+
if (!search.limiterWasOff) {
|
|
847
|
+
search.limiterNote = journal.record(journal.RATE_LIMITER_OFF, m.name);
|
|
848
|
+
if (!(await (0, rcapi_1.setSetting)(m.rootUrl, auth, (0, record_1.adminPass)(m), config.RC_RATE_LIMITER_SETTING, false))) {
|
|
849
|
+
// Never turned off, so nothing to put back (as in `armAndRun`).
|
|
850
|
+
search.limiterWasOff = true;
|
|
851
|
+
journal.clear(search.limiterNote);
|
|
852
|
+
search.limiterNote = '';
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
if ((await (0, rcapi_1.getSetting)(m.rootUrl, auth, (0, record_1.adminPass)(m), deps.monitoring.RC_METRICS_SETTING)) !== true) {
|
|
856
|
+
search.metricsNote = journal.record(journal.RC_METRICS_ON, m.name);
|
|
857
|
+
search.metricsChanged = await (0, rcapi_1.setSetting)(m.rootUrl, auth, (0, record_1.adminPass)(m), deps.monitoring.RC_METRICS_SETTING, true);
|
|
858
|
+
}
|
|
859
|
+
// The CLI's header, once everything above is armed. An event would reach the event log's
|
|
860
|
+
// sink even with no emitter, where the CLI's search has never written one.
|
|
861
|
+
if (cli === null) {
|
|
862
|
+
(0, events_1.info)(emit, `capacity search: ${req.scenario}, SLO ${req.slo}, steps of ${req.stepDuration}`, {
|
|
863
|
+
phase: 'k6',
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
else {
|
|
867
|
+
cli.armed?.();
|
|
868
|
+
}
|
|
869
|
+
let n = req.start;
|
|
870
|
+
while (n <= req.maxVus) {
|
|
871
|
+
const row = await runStep(n);
|
|
872
|
+
if ((0, format_1.isTruthy)(row.ok)) {
|
|
873
|
+
search.lastPass = n;
|
|
874
|
+
n *= 2;
|
|
875
|
+
}
|
|
876
|
+
else {
|
|
877
|
+
search.firstFail = n;
|
|
878
|
+
break;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
if (search.firstFail !== null && search.lastPass !== null) {
|
|
882
|
+
let lo = search.lastPass;
|
|
883
|
+
let hi = search.firstFail;
|
|
884
|
+
for (let round = 0; round < 2; round += 1) {
|
|
885
|
+
const mid = Math.floor((lo + hi) / 2);
|
|
886
|
+
if (mid <= lo || mid >= hi) {
|
|
887
|
+
break;
|
|
888
|
+
}
|
|
889
|
+
const row = await runStep(mid, ' (bisect)');
|
|
890
|
+
if ((0, format_1.isTruthy)(row.ok)) {
|
|
891
|
+
lo = mid;
|
|
892
|
+
search.lastPass = mid;
|
|
893
|
+
}
|
|
894
|
+
else {
|
|
895
|
+
hi = mid;
|
|
896
|
+
search.firstFail = mid;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
async function runCapacity(req, emit = events_1.nullEmit, deps = exports.DEFAULT_DEPS) {
|
|
902
|
+
const prepared = await capacityPreflight(deps, req);
|
|
903
|
+
const { m, perService } = prepared;
|
|
904
|
+
const { search, result, why } = await runPreparedCapacity(req, prepared, emit, deps);
|
|
905
|
+
return {
|
|
906
|
+
ctx: {
|
|
907
|
+
name: m.name,
|
|
908
|
+
scenario: req.scenario,
|
|
909
|
+
slo: req.slo,
|
|
910
|
+
constrained: Object.keys(perService).length > 0 ? deps.constrain.human(perService) : '',
|
|
911
|
+
},
|
|
912
|
+
steps: search.steps,
|
|
913
|
+
capacity_vus: search.lastPass,
|
|
914
|
+
breach_vus: search.firstFail,
|
|
915
|
+
result,
|
|
916
|
+
why,
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
async function runPreparedCapacity(req, prepared, emit = events_1.nullEmit, deps = exports.DEFAULT_DEPS, cli = null) {
|
|
920
|
+
const { auth, m, perService, rcServices, rules, target, token, users } = prepared;
|
|
921
|
+
const search = newCapacitySearch();
|
|
922
|
+
const runStep = async (n, tag = '') => {
|
|
923
|
+
const sampler = new deps.rcmetrics.RCMetricsSampler(m.name, rcServices).start();
|
|
924
|
+
let s;
|
|
925
|
+
let rcm;
|
|
926
|
+
try {
|
|
927
|
+
s = await deps.k6.run(m.name, req.scenario, {
|
|
928
|
+
vus: n,
|
|
929
|
+
duration: req.stepDuration,
|
|
930
|
+
ramp: null,
|
|
931
|
+
token,
|
|
932
|
+
uid: auth.userId,
|
|
933
|
+
target,
|
|
934
|
+
users: users.length > 0 ? [...users] : null,
|
|
935
|
+
password: (0, record_1.adminPass)(m),
|
|
936
|
+
quiet: true,
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
finally {
|
|
940
|
+
rcm = await sampler.stop();
|
|
941
|
+
}
|
|
942
|
+
const res = deps.slo.evaluate(rules, s);
|
|
943
|
+
let lagMax = 0.0;
|
|
944
|
+
for (const sm of Object.values(rcm)) {
|
|
945
|
+
// The first key's summary wins even if its `max` is zero: the fallback is decided on
|
|
946
|
+
// the summary, not on the number.
|
|
947
|
+
const lag = sm.eventloop_lag_max_s ?? sm.eventloop_lag_s;
|
|
948
|
+
if (lag !== undefined && (0, format_1.isTruthy)(lag))
|
|
949
|
+
lagMax = Math.max(lagMax, Number(lag.max));
|
|
950
|
+
}
|
|
951
|
+
const row = {
|
|
952
|
+
vus: n,
|
|
953
|
+
rps: s.rps ?? 0.0,
|
|
954
|
+
p95: s.p95 ?? 0.0,
|
|
955
|
+
error_rate: s.error_rate ?? 0.0,
|
|
956
|
+
ok: res.every((r) => r.ok),
|
|
957
|
+
lag_max_s: lagMax,
|
|
958
|
+
breached: res
|
|
959
|
+
.filter((r) => !r.ok)
|
|
960
|
+
.map((r) => `${r.key} ${r.op} ${r.raw} (actual ${deps.slo.fmtActual(r.key, r.actual)})`),
|
|
961
|
+
};
|
|
962
|
+
STEP_FLOATS.set(row, [
|
|
963
|
+
...['rps', 'p95', 'error_rate'].filter((key) => s[key] === undefined),
|
|
964
|
+
'lag_max_s',
|
|
965
|
+
]);
|
|
966
|
+
search.steps.push(row);
|
|
967
|
+
if (cli === null) {
|
|
968
|
+
(0, events_1.info)(emit, `${String(n)} VUs${tag}: ${(0, format_1.formatFixed)(Number(row.rps), 1)} req/s, ` +
|
|
969
|
+
`p95 ${(0, format_1.formatFixed)(Number(row.p95), 0)}ms, ${(0, format_1.isTruthy)(row.ok) ? 'PASS' : 'FAIL'}`, { phase: 'k6' });
|
|
970
|
+
}
|
|
971
|
+
else {
|
|
972
|
+
// Each row is printed the moment it is measured, tag and all.
|
|
973
|
+
cli.step?.(row, tag);
|
|
974
|
+
}
|
|
975
|
+
return row;
|
|
976
|
+
};
|
|
977
|
+
try {
|
|
978
|
+
await searchForCapacity({
|
|
979
|
+
auth,
|
|
980
|
+
cli,
|
|
981
|
+
deps,
|
|
982
|
+
emit,
|
|
983
|
+
m,
|
|
984
|
+
perService,
|
|
985
|
+
req,
|
|
986
|
+
runStep,
|
|
987
|
+
search,
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
finally {
|
|
991
|
+
await putTheWorkspaceBack({ auth, cli, deps, emit, m, search });
|
|
992
|
+
}
|
|
993
|
+
const { result, why } = cli === null ? capacityVerdict(emit, req, search) : capacityWords(req, search);
|
|
994
|
+
return { search, result, why };
|
|
995
|
+
}
|