@milaboratories/pl-deployments 2.4.3 → 2.4.5
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 +41 -1
- package/dist/index.js +13 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +124 -112
- package/dist/index.mjs.map +1 -1
- package/dist/ssh/__tests__/common-utils.d.ts +2 -8
- package/dist/ssh/__tests__/common-utils.d.ts.map +1 -1
- package/dist/ssh/pl.d.ts.map +1 -1
- package/dist/ssh/pl_paths.d.ts +1 -0
- package/dist/ssh/pl_paths.d.ts.map +1 -1
- package/dist/ssh/supervisord.d.ts +5 -0
- package/dist/ssh/supervisord.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/ssh/__tests__/common-utils.ts +20 -81
- package/src/ssh/__tests__/pl-docker.test.ts +13 -11
- package/src/ssh/__tests__/ssh-docker.test.ts +51 -8
- package/src/ssh/pl.ts +10 -1
- package/src/ssh/pl_paths.ts +4 -0
- package/src/ssh/supervisord.ts +9 -0
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { StartedTestContainer } from 'testcontainers';
|
|
2
2
|
import { ConnectConfig } from 'ssh2';
|
|
3
|
-
export declare const
|
|
4
|
-
export declare
|
|
5
|
-
export declare const downloadsFolder: string;
|
|
6
|
-
export declare const recUpload: string;
|
|
7
|
-
export declare function createTestDirForRecursiveUpload(): Promise<void>;
|
|
8
|
-
export declare function getPathForFile(fileName: string): string;
|
|
9
|
-
export declare function generateKeys(): void;
|
|
10
|
-
export declare function initPrivateKey(): string;
|
|
3
|
+
export declare const testAssetsPath: string;
|
|
4
|
+
export declare function readPrivateKey(): string;
|
|
11
5
|
export declare function initContainer(name: string): Promise<StartedTestContainer>;
|
|
12
6
|
export declare function getContainerHostAndPort(container: StartedTestContainer): {
|
|
13
7
|
port: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-utils.d.ts","sourceRoot":"","sources":["../../../src/ssh/__tests__/common-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"common-utils.d.ts","sourceRoot":"","sources":["../../../src/ssh/__tests__/common-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAI3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAK1C,eAAO,MAAM,cAAc,QAA2D,CAAC;AASvF,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAgB/E;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,oBAAoB;;;EAKtE;AAgBD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,oBAAoB,EAAE,KAAK,GAAE,OAAe,GAAG,aAAa,CAa1G;AAED,wBAAsB,OAAO,CAAC,SAAS,EAAE,oBAAoB,iBAE5D"}
|
package/dist/ssh/pl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pl.d.ts","sourceRoot":"","sources":["../../src/ssh/pl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAOzE,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAEtG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpE,O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,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,iBAAiB,GACpB,MAAM,GACJ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,sBAAsB,GACtB,kBAAkB,GAClB,YAAY,GACZ,mBAAmB,GACnB,2BAA2B,GAC3B,sBAAsB,GACtB,uBAAuB,GACvB,gBAAgB,CAAC;AAErB,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,iBAAiB,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kBAAkB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAC7C,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,eAAe,CAAC,EAAE,2BAA2B,CAAC;IAC9C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAoBF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAOxD"}
|
package/dist/ssh/pl_paths.d.ts
CHANGED
|
@@ -15,4 +15,5 @@ export declare function supervisorBinDir(remoteHome: string, arch: string): stri
|
|
|
15
15
|
export declare function supervisorBin(remoteHome: string, arch: string): string;
|
|
16
16
|
export declare function supervisorConf(remoteHome: string): string;
|
|
17
17
|
export declare function connectionInfo(remoteHome: string): string;
|
|
18
|
+
export declare function platformaCliLogs(remoteHome: string): string;
|
|
18
19
|
//# sourceMappingURL=pl_paths.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pl_paths.d.ts","sourceRoot":"","sources":["../../src/ssh/pl_paths.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAMnE,eAAO,MAAM,YAAY,+BAA+B,CAAC;AACzD,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,qBAAqB,mCAAmC,CAAC;AAEtE,wBAAgB,OAAO,CAAC,UAAU,EAAE,MAAM,UAEzC;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,UAE7C;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAEhE;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAE5D;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAExD;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAExD;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAEhE;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,UAEhD;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,UAEhD"}
|
|
1
|
+
{"version":3,"file":"pl_paths.d.ts","sourceRoot":"","sources":["../../src/ssh/pl_paths.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAMnE,eAAO,MAAM,YAAY,+BAA+B,CAAC;AACzD,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,qBAAqB,mCAAmC,CAAC;AAEtE,wBAAgB,OAAO,CAAC,UAAU,EAAE,MAAM,UAEzC;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,UAE7C;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAEhE;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAE5D;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAExD;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAExD;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAEhE;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,UAEhD;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,UAEhD;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,UAElD"}
|
|
@@ -13,7 +13,12 @@ export type SupervisorStatus = {
|
|
|
13
13
|
export declare function isAllAlive(status: SupervisorStatus, shouldUseMinio: boolean): boolean | undefined;
|
|
14
14
|
export declare function isSupervisordRunning(status: SupervisorStatus): boolean;
|
|
15
15
|
export declare function supervisorStatus(logger: MiLogger, sshClient: SshClient, remoteHome: string, arch: string): Promise<SupervisorStatus>;
|
|
16
|
+
/** Generates the config for supervisord.
|
|
17
|
+
* docs: https://github.com/ochinchina/supervisord?tab=readme-ov-file#supervised-program-settings
|
|
18
|
+
*/
|
|
16
19
|
export declare function generateSupervisordConfig(supervisorRemotePort: number, remoteWorkDir: string, platformaConfigPath: string, plPath: string): string;
|
|
20
|
+
/** @deprecated, we use minio only on old deployments that existed before we remove minio,
|
|
21
|
+
* for new servers use generation of the config above. */
|
|
17
22
|
export declare function generateSupervisordConfigWithMinio(minioStorageDir: string, minioEnvs: Record<string, string>, supervisorRemotePort: number, remoteWorkDir: string, platformaConfigPath: string, minioPath: string, plPath: string): string;
|
|
18
23
|
export declare function supervisorExec(sshClient: SshClient, remoteHome: string, arch: string, command: string): Promise<SshExecResult>;
|
|
19
24
|
//# sourceMappingURL=supervisord.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervisord.d.ts","sourceRoot":"","sources":["../../src/ssh/supervisord.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtD,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAOjC;AAED,wBAAsB,cAAc,CAClC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAOjC;AAED;sHACsH;AACtH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,C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AO,uBAM3E;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,WAE5D;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,QAAQ,EAChB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAC/B,OAAO,CAAC,gBAAgB,CAAC,CA+B3B;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,oBAAoB,EAAE,MAAM,EAC5B,aAAa,EAAE,MAAM,EACrB,mBAAmB,EAAE,MAAM,EAC3B,MAAM,EAAE,MAAM,UA+Bf;AAED;yDACyD;AACzD,wBAAgB,kCAAkC,CAChD,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,oBAAoB,EAAE,MAAM,EAC5B,aAAa,EAAE,MAAM,EACrB,mBAAmB,EAAE,MAAM,EAE3B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,UAoCf;AAED,wBAAsB,cAAc,CAClC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAChC,OAAO,EAAE,MAAM,0BAOhB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-deployments",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.5",
|
|
4
4
|
"pl-version": "1.35.2",
|
|
5
5
|
"description": "MiLaboratories Platforma Backend code service run wrapper",
|
|
6
6
|
"engines": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"testcontainers": "^10.18.0",
|
|
39
39
|
"ts-jest": "^29.2.6",
|
|
40
40
|
"tsconfig-paths": "^4.2.0",
|
|
41
|
-
"typescript": "~5.
|
|
41
|
+
"typescript": "~5.6.3",
|
|
42
42
|
"utility-types": "^3.11.0",
|
|
43
43
|
"vite": "^6.3.5",
|
|
44
44
|
"vitest": "^2.1.9",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"undici": "~7.10.0",
|
|
54
54
|
"yaml": "^2.7.0",
|
|
55
55
|
"zod": "~3.23.8",
|
|
56
|
-
"@milaboratories/
|
|
57
|
-
"@milaboratories/
|
|
56
|
+
"@milaboratories/ts-helpers": "^1.4.1",
|
|
57
|
+
"@milaboratories/pl-config": "^1.6.1"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"type-check": "tsc --noEmit --composite false",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"test": "vitest",
|
|
64
64
|
"do-pack": "rm -rf src/.test && rm -f *.tgz && pnpm pack && mv *.tgz package.tgz",
|
|
65
65
|
"cleanup-docker": "docker container stop pl-ssh-test-pl || true && docker container stop pl-ssh-test-ssh || true && docker container rm -f pl-ssh-test-pl || true && docker container rm -f pl-ssh-test-ssh || true && docker image rm -f pl-ssh-test-container-ssh:1.0.0 || true && docker image rm -f pl-ssh-test-container-pl:1.0.0 || true",
|
|
66
|
-
"
|
|
66
|
+
"dev-docker": "docker build --tag pl-ssh-dev:local . && docker run -p 4343:22 pl-ssh-dev:local",
|
|
67
|
+
"exec-dev-docker": "docker exec -ti $(docker ps --format=json | jq -r 'select(.Image == \"pl-ssh-dev:local\").ID') bash"
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -1,90 +1,41 @@
|
|
|
1
1
|
import type { StartedTestContainer } from 'testcontainers';
|
|
2
2
|
import { GenericContainer } from 'testcontainers';
|
|
3
|
-
import {
|
|
4
|
-
import { mkdir, rm } from 'node:fs/promises';
|
|
3
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
5
4
|
import path from 'node:path';
|
|
6
5
|
import type { ConnectConfig } from 'ssh2';
|
|
7
|
-
import ssh from 'ssh2';
|
|
8
6
|
import fs from 'node:fs';
|
|
9
7
|
|
|
10
8
|
const SSH_PORT = [22, 3001];
|
|
11
9
|
|
|
12
|
-
const
|
|
13
|
-
const privateKeyPath = getPathForFile('private-key.private');
|
|
10
|
+
export const testAssetsPath = path.resolve(__dirname, '..', '..', '..', 'test-assets');
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export async function createTestDirForRecursiveUpload() {
|
|
21
|
-
const pathBase = path.resolve(__dirname, '..', '..', '..', 'test-assets', 'downloads', 'rec-upload', 'sub-1');
|
|
22
|
-
const path2 = path.resolve(__dirname, '..', '..', '..', 'test-assets', 'downloads', 'rec-upload', 'sub-1', 'sub-1-1');
|
|
23
|
-
|
|
24
|
-
await mkdir(pathBase, { recursive: true });
|
|
25
|
-
await mkdir(path2, { recursive: true });
|
|
26
|
-
|
|
27
|
-
for (let i = 0; i < 19; i++) {
|
|
28
|
-
const path2 = path.resolve(__dirname, '..', '..', '..', 'test-assets', 'downloads', 'rec-upload', 'sub-1', `sub-1-${i}`);
|
|
29
|
-
await mkdir(path2, { recursive: true });
|
|
30
|
-
|
|
31
|
-
for (let i = 0; i < 3; i++) {
|
|
32
|
-
writeFileSync(path.resolve(path2, `test-${i}.txt`), `test-${i}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
for (let i = 1; i < 100; i++) {
|
|
37
|
-
writeFileSync(path.resolve(pathBase, `test-${i}.txt`), `test-${i}`);
|
|
38
|
-
}
|
|
39
|
-
writeFileSync(path.resolve(pathBase, `test.txt`), `test-1`);
|
|
40
|
-
writeFileSync(path.resolve(path2, 'test-5.txt'), 'test-5');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function getPathForFile(fileName: string) {
|
|
44
|
-
return path.resolve(__dirname, '..', '..', '..', 'test-assets', fileName);
|
|
12
|
+
const publicKeyPath = path.resolve(testAssetsPath, 'public-key.pem');
|
|
13
|
+
const privateKeyPath = path.resolve(testAssetsPath, 'private-key.pem');
|
|
14
|
+
if (!existsSync(publicKeyPath) || !existsSync(privateKeyPath)) {
|
|
15
|
+
console.error('SSH keys does not exist, see pl-deployments/README.md and regenerate them');
|
|
16
|
+
process.exit(1);
|
|
45
17
|
}
|
|
46
18
|
|
|
47
|
-
export function
|
|
48
|
-
const keys = ssh.utils.generateKeyPairSync('ecdsa', { bits: 256, comment: 'node.js rules!', passphrase: 'password', cipher: 'aes256-cbc' });
|
|
49
|
-
if (!existsSync(publicKeyPath) || !existsSync(privateKeyPath)) {
|
|
50
|
-
writeFileSync(publicKeyPath, keys.public);
|
|
51
|
-
writeFileSync(privateKeyPath, keys.private);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function initPrivateKey(): string {
|
|
56
|
-
generateKeys();
|
|
19
|
+
export function readPrivateKey(): string {
|
|
57
20
|
return readFileSync(privateKeyPath, { encoding: 'utf-8' });
|
|
58
21
|
}
|
|
59
22
|
|
|
60
23
|
export async function initContainer(name: string): Promise<StartedTestContainer> {
|
|
61
|
-
await createTestDirForRecursiveUpload();
|
|
62
|
-
|
|
63
24
|
const imageName = `pl-ssh-test-container-${name}:1.0.0`;
|
|
64
25
|
const containerName = `pl-ssh-test-${name}`;
|
|
65
26
|
|
|
66
|
-
|
|
67
|
-
const container = new GenericContainer(imageName)
|
|
68
|
-
.withExposedPorts(...SSH_PORT)
|
|
69
|
-
.withReuse()
|
|
70
|
-
.withName(containerName);
|
|
71
|
-
|
|
72
|
-
return await container.start();
|
|
73
|
-
} catch {
|
|
74
|
-
console.log('No worries, creating a new container');
|
|
27
|
+
console.log('No worries, creating a new container');
|
|
75
28
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.build(imageName, { deleteOnExit: false });
|
|
29
|
+
const container = await GenericContainer
|
|
30
|
+
.fromDockerfile(path.resolve(__dirname, '..', '..', '..'))
|
|
31
|
+
.withCache(true)
|
|
32
|
+
.build(imageName, { deleteOnExit: false });
|
|
81
33
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
34
|
+
return await container
|
|
35
|
+
.withExposedPorts(...SSH_PORT)
|
|
36
|
+
.withReuse()
|
|
37
|
+
.withName(containerName)
|
|
38
|
+
.start();
|
|
88
39
|
}
|
|
89
40
|
|
|
90
41
|
export function getContainerHostAndPort(container: StartedTestContainer) {
|
|
@@ -96,7 +47,7 @@ export function getContainerHostAndPort(container: StartedTestContainer) {
|
|
|
96
47
|
|
|
97
48
|
function logToFile(message: string) {
|
|
98
49
|
const logFileName = 'log.txt';
|
|
99
|
-
const logFilePath = path.join(
|
|
50
|
+
const logFilePath = path.join(testAssetsPath, logFileName);
|
|
100
51
|
|
|
101
52
|
const timestamp = new Date().toISOString();
|
|
102
53
|
const logMessage = `[${timestamp}] ${message}\n`;
|
|
@@ -110,7 +61,7 @@ function logToFile(message: string) {
|
|
|
110
61
|
|
|
111
62
|
export function getConnectionForSsh(container: StartedTestContainer, debug: boolean = false): ConnectConfig {
|
|
112
63
|
const hostData = getContainerHostAndPort(container);
|
|
113
|
-
const privateKey =
|
|
64
|
+
const privateKey = readPrivateKey();
|
|
114
65
|
const config = {
|
|
115
66
|
host: hostData.host,
|
|
116
67
|
port: hostData.port,
|
|
@@ -125,16 +76,4 @@ export function getConnectionForSsh(container: StartedTestContainer, debug: bool
|
|
|
125
76
|
|
|
126
77
|
export async function cleanUp(container: StartedTestContainer) {
|
|
127
78
|
await container.stop();
|
|
128
|
-
|
|
129
|
-
if (existsSync(localFileUpload)) {
|
|
130
|
-
unlinkSync(localFileUpload);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (existsSync(localFileDownload)) {
|
|
134
|
-
unlinkSync(localFileDownload);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (existsSync(recUpload)) {
|
|
138
|
-
await rm(recUpload, { recursive: true });
|
|
139
|
-
}
|
|
140
79
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, beforeAll, expect, afterAll } from 'vitest';
|
|
2
|
-
import { initContainer, getConnectionForSsh, cleanUp as cleanUpT } from './common-utils';
|
|
2
|
+
import { initContainer, getConnectionForSsh, cleanUp as cleanUpT, testAssetsPath } from './common-utils';
|
|
3
3
|
import { SshPl } from '../pl';
|
|
4
4
|
import upath from 'upath';
|
|
5
5
|
import { getDefaultPlVersion } from '../../common/pl_version';
|
|
@@ -10,19 +10,11 @@ import { ConsoleLoggerAdapter } from '@milaboratories/ts-helpers';
|
|
|
10
10
|
import * as plpath from '../pl_paths';
|
|
11
11
|
|
|
12
12
|
let sshPl: SshPl;
|
|
13
|
-
const testContainer = await initContainer('pl');
|
|
14
13
|
|
|
15
|
-
const
|
|
14
|
+
const testContainer = await initContainer('pl');
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
const version = getDefaultPlVersion();
|
|
19
|
-
const arch = await sshPl.getArch();
|
|
20
|
-
const tgzName = 'supervisord-0.7.3';
|
|
16
|
+
const downloadDestination = upath.resolve(testAssetsPath, 'downloads');
|
|
21
17
|
|
|
22
|
-
unlinkSync(`${downloadDestination}/pl-${version}-${newArch(arch!.arch)}.tgz`);
|
|
23
|
-
unlinkSync(`${downloadDestination}/${tgzName}-${newArch(arch!.arch)}.tgz`);
|
|
24
|
-
rmSync(downloadDestination, { recursive: true });
|
|
25
|
-
}
|
|
26
18
|
beforeAll(async () => {
|
|
27
19
|
const logger = new ConsoleLoggerAdapter();
|
|
28
20
|
sshPl = await SshPl.init(logger, getConnectionForSsh(testContainer));
|
|
@@ -240,6 +232,16 @@ describe('SshPl', async () => {
|
|
|
240
232
|
});
|
|
241
233
|
});
|
|
242
234
|
|
|
235
|
+
async function cleanUp() {
|
|
236
|
+
const version = getDefaultPlVersion();
|
|
237
|
+
const arch = await sshPl.getArch();
|
|
238
|
+
const tgzName = 'supervisord-0.7.3';
|
|
239
|
+
|
|
240
|
+
unlinkSync(`${downloadDestination}/pl-${version}-${newArch(arch!.arch)}.tgz`);
|
|
241
|
+
unlinkSync(`${downloadDestination}/${tgzName}-${newArch(arch!.arch)}.tgz`);
|
|
242
|
+
rmSync(downloadDestination, { recursive: true });
|
|
243
|
+
}
|
|
244
|
+
|
|
243
245
|
afterAll(async () => {
|
|
244
246
|
await cleanUp();
|
|
245
247
|
await cleanUpT(testContainer);
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import type { StartedTestContainer } from 'testcontainers';
|
|
2
2
|
import { describe, it, beforeAll, afterAll, expect } from 'vitest';
|
|
3
|
-
import
|
|
3
|
+
import * as fs from 'node:fs/promises';
|
|
4
4
|
import { SshClient } from '../ssh';
|
|
5
5
|
import ssh from 'ssh2';
|
|
6
|
-
import {
|
|
6
|
+
import { cleanUp, getConnectionForSsh, getContainerHostAndPort, initContainer, testAssetsPath } from './common-utils';
|
|
7
7
|
import { ConsoleLoggerAdapter } from '@milaboratories/ts-helpers';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { fileExists } from '@milaboratories/ts-helpers';
|
|
8
10
|
|
|
9
11
|
let client: SshClient;
|
|
10
12
|
let testContainer: StartedTestContainer;
|
|
11
13
|
|
|
14
|
+
export const localFileUpload = path.resolve(testAssetsPath, 'test-file.txt');
|
|
15
|
+
export const localFileDownload = path.resolve(testAssetsPath, 'test-file-download.txt');
|
|
16
|
+
export const downloadsFolder = path.resolve(testAssetsPath, 'downloads');
|
|
17
|
+
export const recUpload = path.resolve(testAssetsPath, 'downloads', 'rec-upload');
|
|
18
|
+
|
|
12
19
|
beforeAll(async () => {
|
|
13
|
-
// FIXME: sometimes it fails with the error here.
|
|
14
|
-
// Then we will have a container available in docker ps.
|
|
15
|
-
// If it happened, try to retry to build the container the second time here and ask me (Gleb).
|
|
16
20
|
testContainer = await initContainer('ssh');
|
|
17
21
|
client = await SshClient.init(new ConsoleLoggerAdapter(), getConnectionForSsh(testContainer));
|
|
22
|
+
await createTestDirForRecursiveUpload();
|
|
18
23
|
}, 200000);
|
|
19
24
|
|
|
20
25
|
describe('SSH Tests', () => {
|
|
@@ -94,7 +99,7 @@ describe('SSH Tests', () => {
|
|
|
94
99
|
it('should upload a file to the SSH server', async () => {
|
|
95
100
|
const data = `Test data ${new Date().getTime()}`;
|
|
96
101
|
const remoteFile = '/home/pl-doctor/uploaded-file.txt';
|
|
97
|
-
|
|
102
|
+
await fs.writeFile(localFileUpload, data);
|
|
98
103
|
const result = await client.uploadFile(localFileUpload, remoteFile);
|
|
99
104
|
expect(result).toBe(true);
|
|
100
105
|
const execResult = await testContainer.exec(['cat', remoteFile]);
|
|
@@ -107,14 +112,14 @@ describe('SSH Tests', () => {
|
|
|
107
112
|
// const localFile = './test-file-upload.txt';
|
|
108
113
|
const remoteFile = '/home/pl-doctor/uploaded-file.txt';
|
|
109
114
|
|
|
110
|
-
|
|
115
|
+
await fs.writeFile(localFileDownload, data);
|
|
111
116
|
|
|
112
117
|
const uploadResult = await client.uploadFile(localFileDownload, remoteFile);
|
|
113
118
|
expect(uploadResult).toBe(true);
|
|
114
119
|
|
|
115
120
|
const downloadResult = await client.downloadFile(remoteFile, localFileDownload);
|
|
116
121
|
expect(downloadResult).toBe(true);
|
|
117
|
-
expect(
|
|
122
|
+
expect(await fs.readFile(localFileDownload, { encoding: 'utf-8' })).toBe(data);
|
|
118
123
|
});
|
|
119
124
|
|
|
120
125
|
it('Simple server should forward remote SSH port to a local port', async () => {
|
|
@@ -246,6 +251,44 @@ describe('sshExec', () => {
|
|
|
246
251
|
});
|
|
247
252
|
});
|
|
248
253
|
|
|
254
|
+
export async function createTestDirForRecursiveUpload() {
|
|
255
|
+
const pathBase = path.resolve(testAssetsPath, 'downloads', 'rec-upload', 'sub-1');
|
|
256
|
+
const path2 = path.resolve(testAssetsPath, 'downloads', 'rec-upload', 'sub-1', 'sub-1-1');
|
|
257
|
+
|
|
258
|
+
await fs.mkdir(pathBase, { recursive: true });
|
|
259
|
+
await fs.mkdir(path2, { recursive: true });
|
|
260
|
+
|
|
261
|
+
for (let i = 0; i < 19; i++) {
|
|
262
|
+
const path2 = path.resolve(testAssetsPath, 'downloads', 'rec-upload', 'sub-1', `sub-1-${i}`);
|
|
263
|
+
await fs.mkdir(path2, { recursive: true });
|
|
264
|
+
|
|
265
|
+
for (let i = 0; i < 3; i++) {
|
|
266
|
+
await fs.writeFile(path.resolve(path2, `test-${i}.txt`), `test-${i}`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
for (let i = 1; i < 100; i++) {
|
|
271
|
+
await fs.writeFile(path.resolve(pathBase, `test-${i}.txt`), `test-${i}`);
|
|
272
|
+
}
|
|
273
|
+
await fs.writeFile(path.resolve(pathBase, `test.txt`), `test-1`);
|
|
274
|
+
await fs.writeFile(path.resolve(path2, 'test-5.txt'), 'test-5');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export async function cleanUpTestAssets() {
|
|
278
|
+
if (await fileExists(localFileUpload)) {
|
|
279
|
+
await fs.unlink(localFileUpload);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (await fileExists(localFileDownload)) {
|
|
283
|
+
await fs.unlink(localFileDownload);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (await fileExists(recUpload)) {
|
|
287
|
+
await fs.rm(recUpload, { recursive: true });
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
249
291
|
afterAll(async () => {
|
|
292
|
+
await cleanUpTestAssets();
|
|
250
293
|
await cleanUp(testContainer);
|
|
251
294
|
}, 200000);
|
package/src/ssh/pl.ts
CHANGED
|
@@ -69,7 +69,16 @@ export class SshPl {
|
|
|
69
69
|
return await this.checkIsAliveWithInterval(shouldUseMinio);
|
|
70
70
|
}
|
|
71
71
|
} catch (e: unknown) {
|
|
72
|
-
|
|
72
|
+
let msg = `SshPl.start: ${e}`;
|
|
73
|
+
|
|
74
|
+
let logs = '';
|
|
75
|
+
try {
|
|
76
|
+
logs = await this.sshClient.readFile(plpath.platformaCliLogs(remoteHome));
|
|
77
|
+
msg += `, platforma cli logs: ${logs}`;
|
|
78
|
+
} catch (e: unknown) {
|
|
79
|
+
msg += `, Can not read platforma cli logs: ${e}`;
|
|
80
|
+
}
|
|
81
|
+
|
|
73
82
|
this.logger.error(msg);
|
|
74
83
|
throw new Error(msg);
|
|
75
84
|
}
|
package/src/ssh/pl_paths.ts
CHANGED
|
@@ -59,3 +59,7 @@ export function supervisorConf(remoteHome: string) {
|
|
|
59
59
|
export function connectionInfo(remoteHome: string) {
|
|
60
60
|
return upath.join(workDir(remoteHome), `connection.txt`);
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
export function platformaCliLogs(remoteHome: string) {
|
|
64
|
+
return upath.join(workDir(remoteHome), 'platforma_cli_logs.log');
|
|
65
|
+
}
|
package/src/ssh/supervisord.ts
CHANGED
|
@@ -85,6 +85,9 @@ export async function supervisorStatus(
|
|
|
85
85
|
return status;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
/** Generates the config for supervisord.
|
|
89
|
+
* docs: https://github.com/ochinchina/supervisord?tab=readme-ov-file#supervised-program-settings
|
|
90
|
+
*/
|
|
88
91
|
export function generateSupervisordConfig(
|
|
89
92
|
supervisorRemotePort: number,
|
|
90
93
|
remoteWorkDir: string,
|
|
@@ -115,9 +118,15 @@ autostart=true
|
|
|
115
118
|
command=${plPath} --config ${platformaConfigPath}
|
|
116
119
|
directory=${remoteWorkDir}
|
|
117
120
|
autorestart=true
|
|
121
|
+
stdout_logfile=${remoteWorkDir}/platforma_cli_logs.log
|
|
122
|
+
stdout_logfile_maxbytes=10000
|
|
123
|
+
stdout_logfile_backups=10
|
|
124
|
+
redirect_stderr=true
|
|
118
125
|
`;
|
|
119
126
|
}
|
|
120
127
|
|
|
128
|
+
/** @deprecated, we use minio only on old deployments that existed before we remove minio,
|
|
129
|
+
* for new servers use generation of the config above. */
|
|
121
130
|
export function generateSupervisordConfigWithMinio(
|
|
122
131
|
minioStorageDir: string,
|
|
123
132
|
minioEnvs: Record<string, string>,
|