Skip to content

Commit d8078d3

Browse files
committed
fix: removing docker-run.sh script
#407
1 parent 1cbedc5 commit d8078d3

2 files changed

Lines changed: 52 additions & 44 deletions

File tree

tests/bin/agent/start.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { runDescribeIfPlatforms, runTestIfPlatforms } from '../../utils';
1717
import { globalRootKeyPems } from '../../fixtures/globalRootKeyPems';
1818

1919
describe('start', () => {
20-
const logger = new Logger('start test', LogLevel.INFO, [new StreamHandler()]);
20+
const logger = new Logger('start test', LogLevel.WARN, [new StreamHandler()]);
2121
let dataDir: string;
2222
beforeEach(async () => {
2323
dataDir = await fs.promises.mkdtemp(
@@ -30,7 +30,7 @@ describe('start', () => {
3030
recursive: true,
3131
});
3232
});
33-
runTestIfPlatforms('linux', 'docker').only(
33+
runTestIfPlatforms('linux', 'docker')(
3434
'start in foreground',
3535
async () => {
3636
const password = 'abc123';

tests/bin/utils.ts

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,35 @@ const generateDockerArgs = (mountPath: string) => [
1919
'run',
2020
'--interactive',
2121
'--rm',
22-
'--network', 'host',
23-
'--pid', 'host',
24-
'--userns', 'host',
25-
`--user`, `${process.getuid()}`,
26-
'--mount', `type=bind,src=${mountPath},dst=${mountPath}`,
27-
'--env', 'PK_PASSWORD',
28-
'--env', 'PK_NODE_PATH',
29-
'--env', 'PK_RECOVERY_CODE',
30-
'--env', 'PK_TOKEN',
31-
'--env', 'PK_ROOT_KEY',
32-
'--env', 'PK_NODE_ID',
33-
'--env', 'PK_CLIENT_HOST',
34-
'--env', 'PK_CLIENT_PORT',
22+
'--network',
23+
'host',
24+
'--pid',
25+
'host',
26+
'--userns',
27+
'host',
28+
`--user`,
29+
`${process.getuid()}`,
30+
'--mount',
31+
`type=bind,src=${mountPath},dst=${mountPath}`,
32+
'--env',
33+
'PK_PASSWORD',
34+
'--env',
35+
'PK_NODE_PATH',
36+
'--env',
37+
'PK_RECOVERY_CODE',
38+
'--env',
39+
'PK_TOKEN',
40+
'--env',
41+
'PK_ROOT_KEY',
42+
'--env',
43+
'PK_NODE_ID',
44+
'--env',
45+
'PK_CLIENT_HOST',
46+
'--env',
47+
'PK_CLIENT_PORT',
3548
`${process.env.PK_TEST_DOCKER_IMAGE}`,
36-
'polykey'
37-
]
49+
'polykey',
50+
];
3851

3952
/**
4053
* Wrapper for execFile to make it asynchronous and non-blocking
@@ -283,7 +296,6 @@ async function pkSpawn(
283296
/**
284297
* Mimics the behaviour of `pkStdio` while running the command as a separate process.
285298
* Note that this is incompatible with jest mocking.
286-
* @param cmd - path to the target command relative to the project directory.
287299
* @param args - args to be passed to the command.
288300
* @param env - environment variables to be passed to the command.
289301
* @param cwd - the working directory the command will be executed in.
@@ -312,18 +324,16 @@ async function pkStdioTarget(
312324
...process.env,
313325
...env,
314326
};
315-
const command = global.testCmd === 'docker' ?
316-
'docker' :
317-
path.resolve(path.join(global.projectDir, global.testCmd!));
327+
const command =
328+
global.testCmd === 'docker'
329+
? 'docker'
330+
: path.resolve(path.join(global.projectDir, global.testCmd!));
318331
const dockerArgs = global.testCmd === 'docker' ? generateDockerArgs(cwd) : [];
319-
const subprocess = child_process.spawn(
320-
command,
321-
[...dockerArgs, ...args],
322-
{
323-
env,
324-
cwd,
325-
stdio: ['pipe', 'pipe', 'pipe'],
326-
windowsHide: true,
332+
const subprocess = child_process.spawn(command, [...dockerArgs, ...args], {
333+
env,
334+
cwd,
335+
stdio: ['pipe', 'pipe', 'pipe'],
336+
windowsHide: true,
327337
});
328338
const exitCodeProm = promise<number | null>();
329339
subprocess.on('exit', (code) => {
@@ -345,7 +355,6 @@ async function pkStdioTarget(
345355

346356
/**
347357
* Execs the target command spawning it as a seperate process
348-
* @param cmd - path to the target command relative to the project directory.
349358
* @param args - args to be passed to the command.
350359
* @param env Augments env for command execution
351360
* @param cwd Defaults to temporary directory
@@ -372,9 +381,10 @@ async function pkExecTarget(
372381
// (if not defined in the env) to ensure no attempted connections. A regular
373382
// PolykeyAgent is expected to initially connect to the mainnet seed nodes
374383
env['PK_SEED_NODES'] = env['PK_SEED_NODES'] ?? '';
375-
const command = global.testCmd === 'docker' ?
376-
'docker' :
377-
path.resolve(path.join(global.projectDir, global.testCmd!));
384+
const command =
385+
global.testCmd === 'docker'
386+
? 'docker'
387+
: path.resolve(path.join(global.projectDir, global.testCmd!));
378388
const dockerArgs = global.testCmd === 'docker' ? generateDockerArgs(cwd) : [];
379389
return new Promise((resolve, reject) => {
380390
child_process.execFile(
@@ -428,18 +438,16 @@ async function pkSpawnTarget(
428438
// (if not defined in the env) to ensure no attempted connections. A regular
429439
// PolykeyAgent is expected to initially connect to the mainnet seed nodes
430440
env['PK_SEED_NODES'] = env['PK_SEED_NODES'] ?? '';
431-
const command = global.testCmd === 'docker' ?
432-
'docker' :
433-
path.resolve(path.join(global.projectDir, global.testCmd!));
441+
const command =
442+
global.testCmd === 'docker'
443+
? 'docker'
444+
: path.resolve(path.join(global.projectDir, global.testCmd!));
434445
const dockerArgs = global.testCmd === 'docker' ? generateDockerArgs(cwd) : [];
435-
const subprocess = child_process.spawn(
436-
command,
437-
[...dockerArgs, ...args],
438-
{
439-
env,
440-
cwd,
441-
stdio: ['pipe', 'pipe', 'pipe'],
442-
windowsHide: true,
446+
const subprocess = child_process.spawn(command, [...dockerArgs, ...args], {
447+
env,
448+
cwd,
449+
stdio: ['pipe', 'pipe', 'pipe'],
450+
windowsHide: true,
443451
});
444452
// The readline library will trim newlines
445453
const rlOut = readline.createInterface(subprocess.stdout!);

0 commit comments

Comments
 (0)