@harperfast/integration-testing 0.5.0 → 0.5.2
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/dist/harperLifecycle.d.ts +262 -0
- package/dist/harperLifecycle.js +594 -0
- package/dist/harperLifecycle.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/loopbackAddressPool.d.ts +50 -0
- package/dist/loopbackAddressPool.js +421 -0
- package/dist/loopbackAddressPool.js.map +1 -0
- package/dist/portUtils.d.ts +26 -0
- package/dist/portUtils.js +47 -0
- package/dist/portUtils.js.map +1 -0
- package/dist/run.d.ts +2 -0
- package/dist/run.js +178 -0
- package/dist/run.js.map +1 -0
- package/dist/targz.d.ts +6 -0
- package/dist/targz.js +19 -0
- package/dist/targz.js.map +1 -0
- package/package.json +3 -2
package/dist/run.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { run } from 'node:test';
|
|
3
|
+
import { availableParallelism, tmpdir } from 'node:os';
|
|
4
|
+
import { spec } from 'node:test/reporters';
|
|
5
|
+
import { parseArgs } from 'node:util';
|
|
6
|
+
import { validateLoopbackAddressPool } from "./loopbackAddressPool.js";
|
|
7
|
+
import { LOG_DIR_MARKER_PREFIX } from "./harperLifecycle.js";
|
|
8
|
+
import { mkdtemp } from 'node:fs/promises';
|
|
9
|
+
import { join, resolve } from 'node:path';
|
|
10
|
+
import { readFileSync, rmSync, existsSync } from 'node:fs';
|
|
11
|
+
/**
|
|
12
|
+
* Important! This script should not be required to execute integration tests.
|
|
13
|
+
|
|
14
|
+
* Thus, it should not be responsible for any stateful management or setup/teardown logic.
|
|
15
|
+
* All such logic should be contained within the individual test suites or utility functions.
|
|
16
|
+
* Tests (individuals or multiples) should be executable directly via the Node.js Test Runner CLI and
|
|
17
|
+
* parallelization should still work.
|
|
18
|
+
*
|
|
19
|
+
* The main purpose of this script is to reduce the boilerplate required to run integration tests, or having
|
|
20
|
+
* developers manually specify CLI arguments each time.
|
|
21
|
+
*
|
|
22
|
+
* This script configures and runs the Node.js Test Runner with sensible defaults for Harper integration tests.
|
|
23
|
+
*
|
|
24
|
+
* It supports environment variables to override defaults, allowing flexibility for CI environments or specific use cases.
|
|
25
|
+
*
|
|
26
|
+
* Usage: harper-integration-test-run [options] <glob-pattern> [<glob-pattern> ...]
|
|
27
|
+
*
|
|
28
|
+
* At least one glob pattern positional argument is required.
|
|
29
|
+
*/
|
|
30
|
+
// Imitating the Node.js Test Runner CLI arguments for consistency except we drop the `test-` prefix
|
|
31
|
+
const { values, positionals } = parseArgs({
|
|
32
|
+
options: {
|
|
33
|
+
concurrency: { type: 'string' },
|
|
34
|
+
isolation: { type: 'string' },
|
|
35
|
+
shard: { type: 'string' },
|
|
36
|
+
only: { type: 'boolean' },
|
|
37
|
+
},
|
|
38
|
+
allowPositionals: true,
|
|
39
|
+
});
|
|
40
|
+
if (positionals.length === 0) {
|
|
41
|
+
console.error('Error: At least one glob pattern is required.\n' +
|
|
42
|
+
'Usage: harper-integration-test-run [options] <glob-pattern> [<glob-pattern> ...]\n' +
|
|
43
|
+
'Example: harper-integration-test-run "integrationTests/**/*.test.ts"');
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
// https://nodejs.org/docs/latest-v24.x/api/cli.html#--test-concurrency
|
|
47
|
+
const concurrencyOption = process.env.HARPER_INTEGRATION_TEST_CONCURRENCY || values.concurrency;
|
|
48
|
+
const CONCURRENCY = concurrencyOption
|
|
49
|
+
? parseInt(concurrencyOption, 10)
|
|
50
|
+
: Math.max(1, Math.floor(availableParallelism() / 2) + 1);
|
|
51
|
+
// https://nodejs.org/docs/latest-v24.x/api/cli.html#--test-isolationmode
|
|
52
|
+
const ISOLATION = process.env.HARPER_INTEGRATION_TEST_ISOLATION || values.isolation || 'process';
|
|
53
|
+
// https://nodejs.org/docs/latest-v24.x/api/cli.html#--test-shard
|
|
54
|
+
const [SHARD_INDEX, SHARD_TOTAL] = (process.env.HARPER_INTEGRATION_TEST_SHARD || values.shard || '1/1')
|
|
55
|
+
.split('/')
|
|
56
|
+
.map((v) => parseInt(v, 10));
|
|
57
|
+
// https://nodejs.org/docs/latest-v24.x/api/cli.html#--test-only
|
|
58
|
+
const ONLY = parseBoolean(process.env.HARPER_INTEGRATION_TEST_ONLY) ?? values.only ?? false;
|
|
59
|
+
// Number of trailing hdb.log lines to print per failed test. 0 (or any non-positive value) prints the entire log.
|
|
60
|
+
const LOG_TAIL_LINES = (() => {
|
|
61
|
+
const parsed = parseInt(process.env.HARPER_INTEGRATION_TEST_LOG_TAIL_LINES || '', 10);
|
|
62
|
+
return Number.isFinite(parsed) ? parsed : 200;
|
|
63
|
+
})();
|
|
64
|
+
const TEST_FILES = positionals;
|
|
65
|
+
// Loopback Address Check
|
|
66
|
+
if (ISOLATION !== 'none' && CONCURRENCY > 1) {
|
|
67
|
+
const result = await validateLoopbackAddressPool();
|
|
68
|
+
if (result.failed.length > 0) {
|
|
69
|
+
console.error('Failed to bind loopback address pool required for integration tests:');
|
|
70
|
+
for (const failure of result.failed) {
|
|
71
|
+
console.error(`- ${failure.loopbackAddress}: ${failure.error.message}`);
|
|
72
|
+
}
|
|
73
|
+
console.error('Run the setup script to configure loopback addresses:\n' +
|
|
74
|
+
' harper-integration-test-setup-loopback\n' +
|
|
75
|
+
'Or run integration tests sequentially using `--isolation=none` to avoid this requirement.');
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
let createdTempLogDir;
|
|
80
|
+
if (!process.env.HARPER_INTEGRATION_TEST_LOG_DIR) {
|
|
81
|
+
createdTempLogDir = await mkdtemp(join(tmpdir(), 'harper-integration-test-logs-'));
|
|
82
|
+
process.env.HARPER_INTEGRATION_TEST_LOG_DIR = createdTempLogDir;
|
|
83
|
+
}
|
|
84
|
+
const fileToLogDirs = new Map();
|
|
85
|
+
const failedFiles = new Set();
|
|
86
|
+
const runner = run({
|
|
87
|
+
concurrency: ISOLATION === 'none' ? undefined : CONCURRENCY,
|
|
88
|
+
// @ts-expect-error - ignore until we do better env var / cli arg handling/validation
|
|
89
|
+
isolation: ISOLATION,
|
|
90
|
+
globPatterns: TEST_FILES,
|
|
91
|
+
only: ONLY,
|
|
92
|
+
shard: {
|
|
93
|
+
index: SHARD_INDEX,
|
|
94
|
+
total: SHARD_TOTAL,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
const logDirMarkerPattern = new RegExp(`${LOG_DIR_MARKER_PREFIX.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} (.*)`);
|
|
98
|
+
runner.on('test:stdout', (data) => {
|
|
99
|
+
const match = typeof data.message === 'string' && data.message.match(logDirMarkerPattern);
|
|
100
|
+
if (match && data.file) {
|
|
101
|
+
const logDir = match[1].trim();
|
|
102
|
+
const normalizedFile = resolve(data.file);
|
|
103
|
+
let dirs = fileToLogDirs.get(normalizedFile);
|
|
104
|
+
if (!dirs) {
|
|
105
|
+
dirs = new Set();
|
|
106
|
+
fileToLogDirs.set(normalizedFile, dirs);
|
|
107
|
+
}
|
|
108
|
+
dirs.add(logDir);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
runner.on('test:fail', (data) => {
|
|
112
|
+
process.exitCode = 1;
|
|
113
|
+
if (data.file) {
|
|
114
|
+
failedFiles.add(resolve(data.file));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
runner.compose(new spec()).pipe(process.stdout);
|
|
118
|
+
process.on('exit', () => {
|
|
119
|
+
if (failedFiles.size > 0) {
|
|
120
|
+
console.log('\n\n' + '='.repeat(80));
|
|
121
|
+
console.log('--- TEST FAILURES DETECTED: HARPER LOGS ---');
|
|
122
|
+
console.log('='.repeat(80));
|
|
123
|
+
for (const file of failedFiles) {
|
|
124
|
+
const dirs = fileToLogDirs.get(file);
|
|
125
|
+
if (dirs && dirs.size > 0) {
|
|
126
|
+
for (const dir of dirs) {
|
|
127
|
+
const hdbLogPath = join(dir, 'hdb.log');
|
|
128
|
+
if (existsSync(hdbLogPath)) {
|
|
129
|
+
try {
|
|
130
|
+
const content = readFileSync(hdbLogPath, 'utf8');
|
|
131
|
+
let output;
|
|
132
|
+
let tailNote = '';
|
|
133
|
+
if (LOG_TAIL_LINES > 0) {
|
|
134
|
+
const lines = content.split('\n');
|
|
135
|
+
if (lines.length > LOG_TAIL_LINES) {
|
|
136
|
+
output = lines.slice(-LOG_TAIL_LINES).join('\n');
|
|
137
|
+
tailNote = ` (last ${LOG_TAIL_LINES} of ${lines.length} lines; set HARPER_INTEGRATION_TEST_LOG_TAIL_LINES=0 for full log)`;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
output = content;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
output = content;
|
|
145
|
+
}
|
|
146
|
+
console.log(`\n--- Log for instance in ${file}${tailNote} ---`);
|
|
147
|
+
console.log(`Directory: ${dir}`);
|
|
148
|
+
console.log('-'.repeat(80));
|
|
149
|
+
console.log(output);
|
|
150
|
+
console.log('-'.repeat(80));
|
|
151
|
+
}
|
|
152
|
+
catch (e) {
|
|
153
|
+
console.error(`Failed to read log file ${hdbLogPath}:`, e);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (createdTempLogDir) {
|
|
161
|
+
try {
|
|
162
|
+
rmSync(createdTempLogDir, { recursive: true, force: true });
|
|
163
|
+
}
|
|
164
|
+
catch (e) {
|
|
165
|
+
console.error(`Failed to clean up temporary log directory ${createdTempLogDir}:`, e);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
function parseBoolean(value) {
|
|
170
|
+
if (value === undefined)
|
|
171
|
+
return undefined;
|
|
172
|
+
if (value.toLowerCase() === 'true' || value === '1')
|
|
173
|
+
return true;
|
|
174
|
+
if (value.toLowerCase() === 'false' || value === '0')
|
|
175
|
+
return false;
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=run.js.map
|
package/dist/run.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE3D;;;;;;;;;;;;;;;;;;GAkBG;AAEH,oGAAoG;AACpG,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;IACzC,OAAO,EAAE;QACR,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC/B,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC7B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KACzB;IACD,gBAAgB,EAAE,IAAI;CACtB,CAAC,CAAC;AAEH,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IAC9B,OAAO,CAAC,KAAK,CACZ,iDAAiD;QAChD,oFAAoF;QACpF,sEAAsE,CACvE,CA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ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { pack } from 'tar-fs';
|
|
2
|
+
import { createGzip } from 'node:zlib';
|
|
3
|
+
import { pipeline } from 'node:stream/promises';
|
|
4
|
+
/**
|
|
5
|
+
* Packs and compresses a directory into a base64-encoded tar.gz string.
|
|
6
|
+
*
|
|
7
|
+
* @param dirPath path to directory to pack and compress
|
|
8
|
+
*/
|
|
9
|
+
export async function targz(dirPath) {
|
|
10
|
+
const chunks = [];
|
|
11
|
+
// pipeline() propagates errors from any stage (e.g. pack() failing on a missing dir) and
|
|
12
|
+
// destroys the whole chain on failure, so the returned promise always settles.
|
|
13
|
+
await pipeline(pack(dirPath), createGzip(), async (source) => {
|
|
14
|
+
for await (const chunk of source)
|
|
15
|
+
chunks.push(chunk);
|
|
16
|
+
});
|
|
17
|
+
return Buffer.concat(chunks).toString('base64');
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=targz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targz.js","sourceRoot":"","sources":["../src/targz.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAe;IAC1C,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,yFAAyF;IACzF,+EAA+E;IAC/E,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5D,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM;YAAE,MAAM,CAAC,IAAI,CAAC,KAAmB,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harperfast/integration-testing",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Integration testing utilities for Harper-based projects. Provides Harper instance lifecycle management, loopback address pooling, and a test runner script.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"check": "tsc",
|
|
25
25
|
"build": "tsc -p tsconfig.build.json",
|
|
26
|
-
"test": "node --test \"test/**/*.test.ts\""
|
|
26
|
+
"test": "node --test \"test/**/*.test.ts\"",
|
|
27
|
+
"prepack": "npm run build"
|
|
27
28
|
},
|
|
28
29
|
"engines": {
|
|
29
30
|
"node": ">=20"
|