Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(test-tooling): fix types of streams: use NodeJS.ReadableStream #3047

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/cactus-test-tooling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"@types/fs-extra": "9.0.13",
"@types/js-yaml": "4.0.3",
"@types/lodash": "4.14.172",
"@types/node": "18.11.9",
"@types/node-forge": "1.3.0",
"@types/ssh2": "0.5.47",
"@types/ssh2-streams": "0.1.9",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from "path";
import { Duplex, Stream } from "stream";
import { Duplex } from "stream";
import { IncomingMessage } from "http";
import throttle from "lodash/throttle";
import { Container, ContainerInfo } from "dockerode";
Expand Down Expand Up @@ -443,7 +443,10 @@ export class Containers {
log.debug(JSON.stringify(msg.progress || msg.status));
}, 1000);

const pullStreamStartedHandler = (pullError: unknown, stream: Stream) => {
const pullStreamStartedHandler = (
pullError: unknown,
stream: NodeJS.ReadableStream,
) => {
if (pullError) {
log.error(`Could not even start ${imageFqn} pull:`, pullError);
reject(pullError);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import isPortReachable from "is-port-reachable";
import Joi from "joi";
import { EventEmitter } from "events";
import { ITestLedger } from "../i-test-ledger";
import { Stream } from "stream";

const OPTS_SCHEMA: Joi.Schema = Joi.object().keys({
imageVersion: Joi.string().min(5).required(),
Expand Down Expand Up @@ -211,22 +210,25 @@ export class HttpEchoContainer implements ITestLedger {
private pullContainerImage(containerNameAndTag: string): Promise<unknown[]> {
return new Promise((resolve, reject) => {
const docker = new Docker();
docker.pull(containerNameAndTag, (pullError: unknown, stream: Stream) => {
if (pullError) {
reject(pullError);
} else {
docker.modem.followProgress(
stream,
(progressError: unknown, output: unknown[]) => {
if (progressError) {
reject(progressError);
} else {
resolve(output);
}
},
);
}
});
docker.pull(
containerNameAndTag,
(pullError: unknown, stream: NodeJS.ReadableStream) => {
if (pullError) {
reject(pullError);
} else {
docker.modem.followProgress(
stream,
(progressError: unknown, output: unknown[]) => {
if (progressError) {
reject(progressError);
} else {
resolve(output);
}
},
);
}
},
);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import { ITestLedger } from "../i-test-ledger";
import { Streams } from "../common/streams";
import { Containers } from "../common/containers";
import { Stream } from "stream";

/*
* Contains options for Postgres container
Expand Down Expand Up @@ -287,22 +286,25 @@ export class PostgresTestContainer implements ITestLedger {
private pullContainerImage(containerNameAndTag: string): Promise<unknown[]> {
return new Promise((resolve, reject) => {
const docker = new Docker();
docker.pull(containerNameAndTag, (pullError: unknown, stream: Stream) => {
if (pullError) {
reject(pullError);
} else {
docker.modem.followProgress(
stream,
(progressError: unknown, output: unknown[]) => {
if (progressError) {
reject(progressError);
} else {
resolve(output);
}
},
);
}
});
docker.pull(
containerNameAndTag,
(pullError: unknown, stream: NodeJS.ReadableStream) => {
if (pullError) {
reject(pullError);
} else {
docker.modem.followProgress(
stream,
(progressError: unknown, output: unknown[]) => {
if (progressError) {
reject(progressError);
} else {
resolve(output);
}
},
);
}
},
);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Stream } from "stream";
import { EventEmitter } from "events";
import axios from "axios";
import { v4 as uuidv4 } from "uuid";
Expand Down Expand Up @@ -415,22 +414,25 @@ export class QuorumTestLedger implements ITestLedger {
private pullContainerImage(containerNameAndTag: string): Promise<unknown[]> {
return new Promise((resolve, reject) => {
const docker = new Docker();
docker.pull(containerNameAndTag, (pullError: unknown, stream: Stream) => {
if (pullError) {
reject(pullError);
} else {
docker.modem.followProgress(
stream,
(progressError: unknown, output: unknown[]) => {
if (progressError) {
reject(progressError);
} else {
resolve(output);
}
},
);
}
});
docker.pull(
containerNameAndTag,
(pullError: unknown, stream: NodeJS.ReadableStream) => {
if (pullError) {
reject(pullError);
} else {
docker.modem.followProgress(
stream,
(progressError: unknown, output: unknown[]) => {
if (progressError) {
reject(progressError);
} else {
resolve(output);
}
},
);
}
},
);
});
}

Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9270,6 +9270,7 @@ __metadata:
"@types/fs-extra": "npm:9.0.13"
"@types/js-yaml": "npm:4.0.3"
"@types/lodash": "npm:4.14.172"
"@types/node": "npm:18.11.9"
"@types/node-forge": "npm:1.3.0"
"@types/ssh2": "npm:0.5.47"
"@types/ssh2-streams": "npm:0.1.9"
Expand Down
Loading