@elench/testkit 0.1.4 → 0.1.6
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/README.md +2 -1
- package/infra/fly-build.sh +3 -2
- package/lib/config.mjs +8 -19
- package/lib/runner.mjs +2 -1
- package/package.json +3 -2
- package/vendor/k6 +0 -0
package/README.md
CHANGED
|
@@ -51,7 +51,8 @@ npx @elench/testkit destroy
|
|
|
51
51
|
2. **Neon** — discovers or creates a `<service>-test` branch, truncates tables between runs
|
|
52
52
|
3. **Fly** — discovers or creates a machine on the service's test app, updates env vars
|
|
53
53
|
4. **k6** — runs matched test files with `BASE_URL` and `MACHINE_ID` injected
|
|
54
|
-
5. **
|
|
54
|
+
5. **DAL** — DAL tests use a bundled k6-sql binary (`vendor/k6`) — no external binary needed
|
|
55
|
+
6. **Cleanup** — stops the Fly machine (preserved for next run)
|
|
55
56
|
|
|
56
57
|
Multi-service products run all services in parallel. Each service gets its own Neon branch and Fly machine.
|
|
57
58
|
|
package/infra/fly-build.sh
CHANGED
|
@@ -6,7 +6,8 @@ set -eo pipefail
|
|
|
6
6
|
export PATH="$PATH:/snap/bin:$HOME/.fly/bin"
|
|
7
7
|
|
|
8
8
|
STATE_DIR="${STATE_DIR:-.state}"
|
|
9
|
-
API_DIR="$(cd "${API_DIR:?API_DIR required — set to the
|
|
9
|
+
API_DIR="$(cd "${API_DIR:?API_DIR required — set to the product directory}" && pwd)"
|
|
10
|
+
DOCKERFILE_DIR="$(cd "${DOCKERFILE_DIR:-$API_DIR}" && pwd)"
|
|
10
11
|
FLY_APP="${FLY_APP:?FLY_APP required}"
|
|
11
12
|
|
|
12
13
|
SHORT_SHA=$(git -C "$API_DIR" rev-parse --short HEAD)
|
|
@@ -44,7 +45,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
44
45
|
bash "$SCRIPT_DIR/fly-app-ensure.sh"
|
|
45
46
|
|
|
46
47
|
echo "Building image: $IMAGE"
|
|
47
|
-
docker build -t "$IMAGE" -f "$
|
|
48
|
+
docker build -t "$IMAGE" -f "$DOCKERFILE_DIR/Dockerfile" "$API_DIR"
|
|
48
49
|
|
|
49
50
|
echo "Pushing to Fly registry..."
|
|
50
51
|
fly auth docker
|
package/lib/config.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Parse a .env file into an object. Supports KEY=VALUE, KEY='VALUE', KEY="VALUE".
|
|
@@ -113,17 +114,13 @@ export function requireFlyToken(serviceName) {
|
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
/**
|
|
116
|
-
* Resolve the
|
|
117
|
+
* Resolve the bundled k6-sql binary for DAL tests. Returns the absolute path.
|
|
117
118
|
*/
|
|
118
|
-
export function resolveDalBinary(
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
if (!rel) {
|
|
122
|
-
throw new Error("testkit.dal.k6Binary is required for DAL tests");
|
|
123
|
-
}
|
|
124
|
-
const abs = path.resolve(productDir, rel);
|
|
119
|
+
export function resolveDalBinary() {
|
|
120
|
+
const thisFile = fileURLToPath(import.meta.url);
|
|
121
|
+
const abs = path.resolve(path.dirname(thisFile), "..", "vendor", "k6");
|
|
125
122
|
if (!fs.existsSync(abs)) {
|
|
126
|
-
throw new Error(`DAL k6 binary not found: ${abs}`);
|
|
123
|
+
throw new Error(`Bundled DAL k6 binary not found: ${abs}`);
|
|
127
124
|
}
|
|
128
125
|
return abs;
|
|
129
126
|
}
|
|
@@ -185,16 +182,8 @@ function validateService(name, svc, manifestPath) {
|
|
|
185
182
|
errors.push(`${ctx}: testkit.k6 must be an object`);
|
|
186
183
|
}
|
|
187
184
|
|
|
188
|
-
if (tk.dal !== undefined) {
|
|
189
|
-
|
|
190
|
-
errors.push(`${ctx}: testkit.dal must be an object`);
|
|
191
|
-
} else if (svc.suites?.dal) {
|
|
192
|
-
requireString(errors, tk.dal, `${ctx}: testkit.dal.k6Binary`, "k6Binary");
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (svc.suites?.dal && !tk.dal) {
|
|
197
|
-
errors.push(`${ctx}: testkit.dal is required when suites.dal exists`);
|
|
185
|
+
if (tk.dal !== undefined && !isObject(tk.dal)) {
|
|
186
|
+
errors.push(`${ctx}: testkit.dal must be an object`);
|
|
198
187
|
}
|
|
199
188
|
}
|
|
200
189
|
|
package/lib/runner.mjs
CHANGED
|
@@ -49,6 +49,7 @@ export async function build(config) {
|
|
|
49
49
|
FLY_APP: tk.fly.app,
|
|
50
50
|
FLY_ORG: tk.fly.org,
|
|
51
51
|
API_DIR: productDir,
|
|
52
|
+
DOCKERFILE_DIR: tk.dockerfile ? path.join(productDir, tk.dockerfile) : productDir,
|
|
52
53
|
STATE_DIR: stateDir,
|
|
53
54
|
});
|
|
54
55
|
}
|
|
@@ -156,7 +157,7 @@ export async function runTests(config, files) {
|
|
|
156
157
|
export async function runDalTests(config, files) {
|
|
157
158
|
const { productDir, stateDir, manifest } = config;
|
|
158
159
|
const tk = manifest.testkit;
|
|
159
|
-
const k6Binary = resolveDalBinary(
|
|
160
|
+
const k6Binary = resolveDalBinary();
|
|
160
161
|
|
|
161
162
|
// Read DATABASE_URL from neon state
|
|
162
163
|
const databaseUrl = fs.readFileSync(path.join(stateDir, "database_url"), "utf8").trim();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elench/testkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "CLI for running k6 tests against real, ephemeral infrastructure",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"bin/",
|
|
11
11
|
"lib/",
|
|
12
|
-
"infra/"
|
|
12
|
+
"infra/",
|
|
13
|
+
"vendor/"
|
|
13
14
|
],
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"cac": "^6.7.14",
|
package/vendor/k6
ADDED
|
Binary file
|