@milaboratories/pl-deployments 2.15.7 → 2.15.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/README.md +18 -5
- package/dist/common/os_and_arch.cjs +19 -19
- package/dist/common/os_and_arch.cjs.map +1 -1
- package/dist/common/os_and_arch.js +19 -19
- package/dist/common/os_and_arch.js.map +1 -1
- package/dist/common/pl_binary.cjs +9 -9
- package/dist/common/pl_binary.cjs.map +1 -1
- package/dist/common/pl_binary.d.ts +6 -6
- package/dist/common/pl_binary.d.ts.map +1 -1
- package/dist/common/pl_binary.js +9 -9
- package/dist/common/pl_binary.js.map +1 -1
- package/dist/common/pl_binary_download.cjs +16 -16
- package/dist/common/pl_binary_download.cjs.map +1 -1
- package/dist/common/pl_binary_download.d.ts +6 -6
- package/dist/common/pl_binary_download.d.ts.map +1 -1
- package/dist/common/pl_binary_download.js +16 -16
- package/dist/common/pl_binary_download.js.map +1 -1
- package/dist/common/pl_version.cjs +1 -1
- package/dist/common/pl_version.cjs.map +1 -1
- package/dist/common/pl_version.js +1 -1
- package/dist/common/pl_version.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/local/options.d.ts +4 -4
- package/dist/local/pid.cjs +1 -1
- package/dist/local/pid.cjs.map +1 -1
- package/dist/local/pid.js +1 -1
- package/dist/local/pid.js.map +1 -1
- package/dist/local/pl.cjs +26 -26
- package/dist/local/pl.cjs.map +1 -1
- package/dist/local/pl.d.ts +8 -8
- package/dist/local/pl.d.ts.map +1 -1
- package/dist/local/pl.js +26 -26
- package/dist/local/pl.js.map +1 -1
- package/dist/local/process.cjs +16 -16
- package/dist/local/process.cjs.map +1 -1
- package/dist/local/process.d.ts +2 -2
- package/dist/local/process.js +16 -16
- package/dist/local/process.js.map +1 -1
- package/dist/local/trace.cjs.map +1 -1
- package/dist/local/trace.d.ts +1 -1
- package/dist/local/trace.js.map +1 -1
- package/dist/package.json.cjs +2 -1
- package/dist/package.json.cjs.map +1 -1
- package/dist/package.json.js +2 -1
- package/dist/package.json.js.map +1 -1
- package/dist/ssh/__tests__/common-utils.d.ts +2 -2
- package/dist/ssh/__tests__/common-utils.d.ts.map +1 -1
- package/dist/ssh/connection_info.cjs +13 -7
- package/dist/ssh/connection_info.cjs.map +1 -1
- package/dist/ssh/connection_info.d.ts +1 -1
- package/dist/ssh/connection_info.d.ts.map +1 -1
- package/dist/ssh/connection_info.js +13 -7
- package/dist/ssh/connection_info.js.map +1 -1
- package/dist/ssh/pl.cjs +79 -76
- package/dist/ssh/pl.cjs.map +1 -1
- package/dist/ssh/pl.d.ts +18 -18
- package/dist/ssh/pl.d.ts.map +1 -1
- package/dist/ssh/pl.js +79 -76
- package/dist/ssh/pl.js.map +1 -1
- package/dist/ssh/pl_paths.cjs +13 -13
- package/dist/ssh/pl_paths.cjs.map +1 -1
- package/dist/ssh/pl_paths.d.ts.map +1 -1
- package/dist/ssh/pl_paths.js +13 -13
- package/dist/ssh/pl_paths.js.map +1 -1
- package/dist/ssh/ssh.cjs +43 -40
- package/dist/ssh/ssh.cjs.map +1 -1
- package/dist/ssh/ssh.d.ts +9 -9
- package/dist/ssh/ssh.d.ts.map +1 -1
- package/dist/ssh/ssh.js +43 -40
- package/dist/ssh/ssh.js.map +1 -1
- package/dist/ssh/ssh_errors.cjs +7 -5
- package/dist/ssh/ssh_errors.cjs.map +1 -1
- package/dist/ssh/ssh_errors.d.ts.map +1 -1
- package/dist/ssh/ssh_errors.js +7 -5
- package/dist/ssh/ssh_errors.js.map +1 -1
- package/dist/ssh/supervisord.cjs +15 -13
- package/dist/ssh/supervisord.cjs.map +1 -1
- package/dist/ssh/supervisord.d.ts +2 -2
- package/dist/ssh/supervisord.d.ts.map +1 -1
- package/dist/ssh/supervisord.js +15 -13
- package/dist/ssh/supervisord.js.map +1 -1
- package/package.json +37 -36
- package/src/common/os_and_arch.ts +19 -19
- package/src/common/pl_binary.ts +30 -27
- package/src/common/pl_binary_download.ts +80 -59
- package/src/common/pl_version.ts +2 -2
- package/src/index.ts +5 -5
- package/src/local/config.test.yaml +19 -19
- package/src/local/options.ts +4 -4
- package/src/local/pid.ts +4 -4
- package/src/local/pl.test.ts +245 -253
- package/src/local/pl.ts +45 -50
- package/src/local/process.ts +21 -21
- package/src/local/trace.ts +1 -1
- package/src/ssh/__tests__/common-utils.ts +21 -19
- package/src/ssh/__tests__/pl-docker.test.ts +68 -59
- package/src/ssh/__tests__/ssh-docker.test.ts +152 -90
- package/src/ssh/__tests__/ssh-upload.test.ts +42 -31
- package/src/ssh/connection_info.ts +33 -27
- package/src/ssh/pl.test.ts +15 -13
- package/src/ssh/pl.ts +228 -143
- package/src/ssh/pl_paths.ts +22 -18
- package/src/ssh/ssh.ts +151 -74
- package/src/ssh/ssh_errors.test.ts +39 -39
- package/src/ssh/ssh_errors.ts +8 -6
- package/src/ssh/supervisord.ts +28 -28
package/src/local/pl.test.ts
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import { test, expect } from
|
|
2
|
-
import { localPlatformaInit } from
|
|
3
|
-
import { ConsoleLoggerAdapter, sleep } from
|
|
4
|
-
import * as fs from
|
|
5
|
-
import upath from
|
|
6
|
-
import { ProcessOptions, processStop } from
|
|
7
|
-
import * as yaml from
|
|
8
|
-
import * as os from
|
|
9
|
-
import { mergeDefaultOps } from
|
|
10
|
-
import type { LocalPlOptions, LocalPlOptionsFull } from
|
|
11
|
-
import { plProcessOps } from
|
|
12
|
-
import {
|
|
13
|
-
import { getPorts } from '@milaboratories/pl-config';
|
|
1
|
+
import { test, expect } from "vitest";
|
|
2
|
+
import { localPlatformaInit } from "./pl";
|
|
3
|
+
import { ConsoleLoggerAdapter, sleep } from "@milaboratories/ts-helpers";
|
|
4
|
+
import * as fs from "fs/promises";
|
|
5
|
+
import upath from "upath";
|
|
6
|
+
import { ProcessOptions, processStop } from "./process";
|
|
7
|
+
import * as yaml from "yaml";
|
|
8
|
+
import * as os from "os";
|
|
9
|
+
import { mergeDefaultOps } from "./pl";
|
|
10
|
+
import type { LocalPlOptions, LocalPlOptionsFull } from "./pl";
|
|
11
|
+
import { plProcessOps } from "./pl";
|
|
12
|
+
import { getPorts } from "@milaboratories/pl-config";
|
|
14
13
|
|
|
15
14
|
test(
|
|
16
|
-
|
|
15
|
+
"should start and stop platforma of the current version with hardcoded config",
|
|
17
16
|
{ timeout: 25000 },
|
|
18
17
|
async ({ expect }) => {
|
|
19
18
|
const logger = new ConsoleLoggerAdapter();
|
|
20
19
|
const config = await readTestConfig();
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
logger.info('Config:\n' + yaml.stringify(config));
|
|
21
|
+
logger.info("Config:\n" + yaml.stringify(config));
|
|
24
22
|
|
|
25
23
|
const dir = await prepareDirForTestConfig();
|
|
26
24
|
|
|
@@ -43,7 +41,7 @@ test(
|
|
|
43
41
|
);
|
|
44
42
|
|
|
45
43
|
test(
|
|
46
|
-
|
|
44
|
+
"should close old platforma when starting a new one if the option is set",
|
|
47
45
|
{ timeout: 35000 },
|
|
48
46
|
async ({ expect }) => {
|
|
49
47
|
const logger = new ConsoleLoggerAdapter();
|
|
@@ -74,7 +72,7 @@ test(
|
|
|
74
72
|
);
|
|
75
73
|
|
|
76
74
|
test(
|
|
77
|
-
|
|
75
|
+
"should restart platforma if restart option was provided",
|
|
78
76
|
{ timeout: 25000 },
|
|
79
77
|
async ({ expect }) => {
|
|
80
78
|
const logger = new ConsoleLoggerAdapter();
|
|
@@ -108,19 +106,19 @@ test(
|
|
|
108
106
|
);
|
|
109
107
|
|
|
110
108
|
async function readTestConfig() {
|
|
111
|
-
const testConfig = upath.join(__dirname,
|
|
109
|
+
const testConfig = upath.join(__dirname, "config.test.yaml");
|
|
112
110
|
const config = (await fs.readFile(testConfig)).toString();
|
|
113
111
|
|
|
114
112
|
const parsed = yaml.parse(config);
|
|
115
113
|
parsed.license.value = process.env.MI_LICENSE;
|
|
116
|
-
if ((parsed.license.value ??
|
|
114
|
+
if ((parsed.license.value ?? "") == "") {
|
|
117
115
|
parsed.license.file = process.env.MI_LICENSE_FILE;
|
|
118
|
-
if ((parsed.license.file ??
|
|
119
|
-
parsed.license.file = upath.join(os.homedir(),
|
|
116
|
+
if ((parsed.license.file ?? "") == "") {
|
|
117
|
+
parsed.license.file = upath.join(os.homedir(), ".pl.license");
|
|
120
118
|
}
|
|
121
119
|
}
|
|
122
120
|
|
|
123
|
-
const freePort = await getPorts({ type:
|
|
121
|
+
const freePort = await getPorts({ type: "pickFree" });
|
|
124
122
|
parsed.core.grpc.listen = `127.0.0.1:${freePort.grpc}`;
|
|
125
123
|
parsed.core.http.listen = `127.0.0.1:${freePort.http}`;
|
|
126
124
|
|
|
@@ -128,13 +126,13 @@ async function readTestConfig() {
|
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
async function prepareDirForTestConfig() {
|
|
131
|
-
const dir = upath.join(__dirname,
|
|
129
|
+
const dir = upath.join(__dirname, "..", "..", ".test");
|
|
132
130
|
await fs.rm(dir, { recursive: true, force: true });
|
|
133
131
|
await fs.mkdir(dir);
|
|
134
132
|
|
|
135
|
-
await fs.mkdir(upath.join(dir,
|
|
136
|
-
await fs.mkdir(upath.join(dir,
|
|
137
|
-
await fs.mkdir(upath.join(dir,
|
|
133
|
+
await fs.mkdir(upath.join(dir, "storages", "work"), { recursive: true });
|
|
134
|
+
await fs.mkdir(upath.join(dir, "storages", "main"), { recursive: true });
|
|
135
|
+
await fs.mkdir(upath.join(dir, "packages"), { recursive: true });
|
|
138
136
|
|
|
139
137
|
return dir;
|
|
140
138
|
}
|
|
@@ -147,148 +145,148 @@ const mergeDefaultOpsCases: {
|
|
|
147
145
|
};
|
|
148
146
|
expected: LocalPlOptionsFull;
|
|
149
147
|
}[] = [
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
},
|
|
158
|
-
numCpu: 4,
|
|
159
|
-
},
|
|
160
|
-
expected: {
|
|
161
|
-
workingDir: '/test',
|
|
162
|
-
config: 'config',
|
|
163
|
-
plBinary: { type: 'Download', version: '1.29.2' },
|
|
164
|
-
spawnOptions: {
|
|
165
|
-
env: {
|
|
166
|
-
GOMAXPROCS: '4',
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
closeOld: true,
|
|
148
|
+
{
|
|
149
|
+
name: "should set default values when minimal input is provided",
|
|
150
|
+
input: {
|
|
151
|
+
ops: {
|
|
152
|
+
workingDir: "/test",
|
|
153
|
+
config: "config",
|
|
154
|
+
plBinary: { type: "Download", version: "1.29.2" },
|
|
170
155
|
},
|
|
156
|
+
numCpu: 4,
|
|
171
157
|
},
|
|
172
|
-
{
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
plBinary: { type: 'Local', path: '/custom/binary' },
|
|
180
|
-
closeOld: false,
|
|
158
|
+
expected: {
|
|
159
|
+
workingDir: "/test",
|
|
160
|
+
config: "config",
|
|
161
|
+
plBinary: { type: "Download", version: "1.29.2" },
|
|
162
|
+
spawnOptions: {
|
|
163
|
+
env: {
|
|
164
|
+
GOMAXPROCS: "4",
|
|
181
165
|
},
|
|
182
|
-
numCpu: 2,
|
|
183
166
|
},
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
167
|
+
closeOld: true,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: "should override outermost options when provided",
|
|
172
|
+
input: {
|
|
173
|
+
ops: {
|
|
174
|
+
workingDir: "/test",
|
|
175
|
+
config: "config",
|
|
176
|
+
// we provided plBinary and closeOld, they should appear in the result
|
|
177
|
+
plBinary: { type: "Local", path: "/custom/binary" },
|
|
193
178
|
closeOld: false,
|
|
194
179
|
},
|
|
180
|
+
numCpu: 2,
|
|
195
181
|
},
|
|
196
|
-
{
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
plBinary: { type: 'Download', version: '1.29.2' },
|
|
203
|
-
spawnOptions: {
|
|
204
|
-
env: {
|
|
205
|
-
NODE_ENV: 'test',
|
|
206
|
-
DEBUG: 'true',
|
|
207
|
-
},
|
|
208
|
-
},
|
|
182
|
+
expected: {
|
|
183
|
+
workingDir: "/test",
|
|
184
|
+
config: "config",
|
|
185
|
+
spawnOptions: {
|
|
186
|
+
env: {
|
|
187
|
+
GOMAXPROCS: "2",
|
|
209
188
|
},
|
|
210
|
-
numCpu: 3,
|
|
211
189
|
},
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
190
|
+
plBinary: { type: "Local", path: "/custom/binary" },
|
|
191
|
+
closeOld: false,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "should merge env variables when provided",
|
|
196
|
+
input: {
|
|
197
|
+
ops: {
|
|
198
|
+
workingDir: "/test",
|
|
199
|
+
config: "config",
|
|
200
|
+
plBinary: { type: "Download", version: "1.29.2" },
|
|
216
201
|
spawnOptions: {
|
|
217
202
|
env: {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
DEBUG: 'true',
|
|
203
|
+
NODE_ENV: "test",
|
|
204
|
+
DEBUG: "true",
|
|
221
205
|
},
|
|
222
206
|
},
|
|
223
|
-
closeOld: true,
|
|
224
207
|
},
|
|
208
|
+
numCpu: 3,
|
|
225
209
|
},
|
|
226
|
-
{
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
detached: true,
|
|
236
|
-
},
|
|
210
|
+
expected: {
|
|
211
|
+
workingDir: "/test",
|
|
212
|
+
config: "config",
|
|
213
|
+
plBinary: { type: "Download", version: "1.29.2" },
|
|
214
|
+
spawnOptions: {
|
|
215
|
+
env: {
|
|
216
|
+
GOMAXPROCS: "3",
|
|
217
|
+
NODE_ENV: "test",
|
|
218
|
+
DEBUG: "true",
|
|
237
219
|
},
|
|
238
|
-
numCpu: 2,
|
|
239
220
|
},
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
221
|
+
closeOld: true,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: "should override other spawnOptions properties",
|
|
226
|
+
input: {
|
|
227
|
+
ops: {
|
|
228
|
+
workingDir: "/test",
|
|
229
|
+
config: "config",
|
|
230
|
+
plBinary: { type: "Download", version: "1.29.2" },
|
|
244
231
|
spawnOptions: {
|
|
245
|
-
|
|
246
|
-
GOMAXPROCS: '2',
|
|
247
|
-
},
|
|
248
|
-
stdio: 'inherit',
|
|
232
|
+
stdio: "inherit",
|
|
249
233
|
detached: true,
|
|
250
234
|
},
|
|
251
|
-
closeOld: true,
|
|
252
235
|
},
|
|
236
|
+
numCpu: 2,
|
|
253
237
|
},
|
|
254
|
-
{
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
closeOld: false,
|
|
262
|
-
spawnOptions: {
|
|
263
|
-
env: {
|
|
264
|
-
NODE_ENV: 'production',
|
|
265
|
-
LOG_LEVEL: 'debug',
|
|
266
|
-
},
|
|
267
|
-
cwd: '/custom/dir',
|
|
268
|
-
windowsHide: false,
|
|
269
|
-
},
|
|
238
|
+
expected: {
|
|
239
|
+
workingDir: "/test",
|
|
240
|
+
config: "config",
|
|
241
|
+
plBinary: { type: "Download", version: "1.29.2" },
|
|
242
|
+
spawnOptions: {
|
|
243
|
+
env: {
|
|
244
|
+
GOMAXPROCS: "2",
|
|
270
245
|
},
|
|
271
|
-
|
|
246
|
+
stdio: "inherit",
|
|
247
|
+
detached: true,
|
|
272
248
|
},
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
249
|
+
closeOld: true,
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "should handle complex case with multiple overrides",
|
|
254
|
+
input: {
|
|
255
|
+
ops: {
|
|
256
|
+
workingDir: "/test",
|
|
257
|
+
config: "config",
|
|
258
|
+
plBinary: { type: "Local", path: "/custom/binary" },
|
|
277
259
|
closeOld: false,
|
|
278
260
|
spawnOptions: {
|
|
279
261
|
env: {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
LOG_LEVEL: 'debug',
|
|
262
|
+
NODE_ENV: "production",
|
|
263
|
+
LOG_LEVEL: "debug",
|
|
283
264
|
},
|
|
284
|
-
cwd:
|
|
265
|
+
cwd: "/custom/dir",
|
|
285
266
|
windowsHide: false,
|
|
286
267
|
},
|
|
287
268
|
},
|
|
269
|
+
numCpu: 6,
|
|
288
270
|
},
|
|
289
|
-
|
|
271
|
+
expected: {
|
|
272
|
+
workingDir: "/test",
|
|
273
|
+
config: "config",
|
|
274
|
+
plBinary: { type: "Local", path: "/custom/binary" },
|
|
275
|
+
closeOld: false,
|
|
276
|
+
spawnOptions: {
|
|
277
|
+
env: {
|
|
278
|
+
GOMAXPROCS: "6",
|
|
279
|
+
NODE_ENV: "production",
|
|
280
|
+
LOG_LEVEL: "debug",
|
|
281
|
+
},
|
|
282
|
+
cwd: "/custom/dir",
|
|
283
|
+
windowsHide: false,
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
];
|
|
290
288
|
|
|
291
|
-
test.each(mergeDefaultOpsCases)(
|
|
289
|
+
test.each(mergeDefaultOpsCases)("mergeDefaultOps: $name", ({ input, expected }) => {
|
|
292
290
|
const result = mergeDefaultOps(input.ops, input.numCpu);
|
|
293
291
|
|
|
294
292
|
expect(result).toEqual(expected);
|
|
@@ -304,148 +302,142 @@ const plProcessOpsCases: {
|
|
|
304
302
|
};
|
|
305
303
|
expected: ProcessOptions;
|
|
306
304
|
}[] = [
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
},
|
|
319
|
-
workDir: '/work/dir',
|
|
320
|
-
},
|
|
321
|
-
expected: {
|
|
322
|
-
cmd: '/path/to/binary',
|
|
323
|
-
args: ['--config', '/path/to/config.yaml'],
|
|
324
|
-
opts: {
|
|
325
|
-
env: {},
|
|
326
|
-
cwd: '/work/dir',
|
|
327
|
-
stdio: ['pipe', 'ignore', 'inherit'],
|
|
328
|
-
windowsHide: true,
|
|
329
|
-
},
|
|
305
|
+
{
|
|
306
|
+
name: "should set basic options with minimal input",
|
|
307
|
+
input: {
|
|
308
|
+
binaryPath: "/path/to/binary",
|
|
309
|
+
configPath: "/path/to/config.yaml",
|
|
310
|
+
ops: {
|
|
311
|
+
workingDir: "/work/dir",
|
|
312
|
+
config: "config-content",
|
|
313
|
+
plBinary: { type: "Download", version: "1.29.2" },
|
|
314
|
+
spawnOptions: {},
|
|
315
|
+
closeOld: true,
|
|
330
316
|
},
|
|
317
|
+
workDir: "/work/dir",
|
|
331
318
|
},
|
|
332
|
-
{
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
plBinary: { type: 'Download', version: '1.29.2' },
|
|
341
|
-
spawnOptions: {
|
|
342
|
-
env: {
|
|
343
|
-
DEBUG: 'true',
|
|
344
|
-
LOG_LEVEL: 'info',
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
closeOld: true,
|
|
348
|
-
},
|
|
349
|
-
workDir: '/work',
|
|
319
|
+
expected: {
|
|
320
|
+
cmd: "/path/to/binary",
|
|
321
|
+
args: ["--config", "/path/to/config.yaml"],
|
|
322
|
+
opts: {
|
|
323
|
+
env: {},
|
|
324
|
+
cwd: "/work/dir",
|
|
325
|
+
stdio: ["pipe", "ignore", "inherit"],
|
|
326
|
+
windowsHide: true,
|
|
350
327
|
},
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
name: "should merge environment variables when provided",
|
|
332
|
+
input: {
|
|
333
|
+
binaryPath: "/path/to/binary",
|
|
334
|
+
configPath: "/config.yaml",
|
|
335
|
+
ops: {
|
|
336
|
+
workingDir: "/work",
|
|
337
|
+
config: "content",
|
|
338
|
+
plBinary: { type: "Download", version: "1.29.2" },
|
|
339
|
+
spawnOptions: {
|
|
355
340
|
env: {
|
|
356
|
-
DEBUG:
|
|
357
|
-
LOG_LEVEL:
|
|
341
|
+
DEBUG: "true",
|
|
342
|
+
LOG_LEVEL: "info",
|
|
358
343
|
},
|
|
359
|
-
cwd: '/work',
|
|
360
|
-
stdio: ['pipe', 'ignore', 'inherit'],
|
|
361
|
-
windowsHide: true,
|
|
362
344
|
},
|
|
345
|
+
closeOld: true,
|
|
363
346
|
},
|
|
347
|
+
workDir: "/work",
|
|
364
348
|
},
|
|
365
|
-
{
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
config: 'content',
|
|
373
|
-
plBinary: { type: 'Download', version: '1.29.2' },
|
|
374
|
-
spawnOptions: {
|
|
375
|
-
stdio: 'inherit',
|
|
376
|
-
detached: true,
|
|
377
|
-
shell: true,
|
|
378
|
-
},
|
|
379
|
-
closeOld: true,
|
|
349
|
+
expected: {
|
|
350
|
+
cmd: "/path/to/binary",
|
|
351
|
+
args: ["--config", "/config.yaml"],
|
|
352
|
+
opts: {
|
|
353
|
+
env: {
|
|
354
|
+
DEBUG: "true",
|
|
355
|
+
LOG_LEVEL: "info",
|
|
380
356
|
},
|
|
381
|
-
|
|
357
|
+
cwd: "/work",
|
|
358
|
+
stdio: ["pipe", "ignore", "inherit"],
|
|
359
|
+
windowsHide: true,
|
|
382
360
|
},
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "should override spawn options when provided",
|
|
365
|
+
input: {
|
|
366
|
+
binaryPath: "/binary",
|
|
367
|
+
configPath: "/config.yaml",
|
|
368
|
+
ops: {
|
|
369
|
+
workingDir: "/work",
|
|
370
|
+
config: "content",
|
|
371
|
+
plBinary: { type: "Download", version: "1.29.2" },
|
|
372
|
+
spawnOptions: {
|
|
373
|
+
stdio: "inherit",
|
|
390
374
|
detached: true,
|
|
391
375
|
shell: true,
|
|
392
|
-
windowsHide: true,
|
|
393
376
|
},
|
|
377
|
+
closeOld: true,
|
|
394
378
|
},
|
|
379
|
+
workDir: "/work",
|
|
395
380
|
},
|
|
396
|
-
{
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
env: {
|
|
407
|
-
PL_DEBUG: 'true',
|
|
408
|
-
PL_MODE: 'development',
|
|
409
|
-
GOMAXPROCS: '4',
|
|
410
|
-
},
|
|
411
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
412
|
-
detached: false,
|
|
413
|
-
windowsHide: false,
|
|
414
|
-
uid: 1000,
|
|
415
|
-
gid: 1000,
|
|
416
|
-
},
|
|
417
|
-
closeOld: true,
|
|
418
|
-
},
|
|
419
|
-
workDir: '/var/platforma/runtime',
|
|
381
|
+
expected: {
|
|
382
|
+
cmd: "/binary",
|
|
383
|
+
args: ["--config", "/config.yaml"],
|
|
384
|
+
opts: {
|
|
385
|
+
env: {},
|
|
386
|
+
cwd: "/work",
|
|
387
|
+
stdio: "inherit",
|
|
388
|
+
detached: true,
|
|
389
|
+
shell: true,
|
|
390
|
+
windowsHide: true,
|
|
420
391
|
},
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: "should handle complex case with multiple options",
|
|
396
|
+
input: {
|
|
397
|
+
binaryPath: "/bin/platforma",
|
|
398
|
+
configPath: "/etc/platforma/config.yaml",
|
|
399
|
+
ops: {
|
|
400
|
+
workingDir: "/var/platforma",
|
|
401
|
+
config: "yaml content",
|
|
402
|
+
plBinary: { type: "Download", version: "1.29.2" },
|
|
403
|
+
spawnOptions: {
|
|
425
404
|
env: {
|
|
426
|
-
PL_DEBUG:
|
|
427
|
-
PL_MODE:
|
|
428
|
-
GOMAXPROCS:
|
|
405
|
+
PL_DEBUG: "true",
|
|
406
|
+
PL_MODE: "development",
|
|
407
|
+
GOMAXPROCS: "4",
|
|
429
408
|
},
|
|
430
|
-
|
|
431
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
409
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
432
410
|
detached: false,
|
|
433
411
|
windowsHide: false,
|
|
434
412
|
uid: 1000,
|
|
435
413
|
gid: 1000,
|
|
436
414
|
},
|
|
415
|
+
closeOld: true,
|
|
437
416
|
},
|
|
417
|
+
workDir: "/var/platforma/runtime",
|
|
438
418
|
},
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
419
|
+
expected: {
|
|
420
|
+
cmd: "/bin/platforma",
|
|
421
|
+
args: ["--config", "/etc/platforma/config.yaml"],
|
|
422
|
+
opts: {
|
|
423
|
+
env: {
|
|
424
|
+
PL_DEBUG: "true",
|
|
425
|
+
PL_MODE: "development",
|
|
426
|
+
GOMAXPROCS: "4",
|
|
427
|
+
},
|
|
428
|
+
cwd: "/var/platforma/runtime",
|
|
429
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
430
|
+
detached: false,
|
|
431
|
+
windowsHide: false,
|
|
432
|
+
uid: 1000,
|
|
433
|
+
gid: 1000,
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
];
|
|
438
|
+
|
|
439
|
+
test.each(plProcessOpsCases)("plProcessOps: $name", ({ input, expected }) => {
|
|
440
|
+
const result = plProcessOps(input.binaryPath, input.configPath, input.ops, input.workDir, {});
|
|
449
441
|
|
|
450
442
|
expect(result).toEqual(expected);
|
|
451
443
|
});
|