Extend `exec`: reject on failure, stdin, streaming output and a timeout
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- docker, node.js, typescript
Hướng nghiên cứu
Read ExecOptions in packages/testcontainers/src/types.ts and the two exec implementations in packages/testcontainers/src/generic-container/started-generic-container.ts and packages/testcontainers/src/container-runtime/clients/container/docker-container-client.ts. Check the dependency issues #1525, #1531, and #1532, then trace existing exec tests and callers. Done means the four optional behaviors work while defaults stay unchanged; the issue says the work can be split by option.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What happens
exec runs a command and resolves with { output, stdout, stderr, exitCode } once it finishes. Its options are workingDir, user and env. Four things are missing.
It never rejects on failure, so callers who expect success check every time:
const result = await container.exec(["psql", "-c", sql]);
if (result.exitCode !== 0) {
throw new Error(`Command failed with exit code ${result.exitCode}: ${result.output}`);
}
Seven module files carry this check, nine times in total, each with its own message. In tests it is easy to forget, and a failed setup command then surfaces later as an unrelated assertion failure.
It cannot be given input. Piping a SQL file or a dump into a command means copying the file into the container first.
Output is buffered in full and returned at the end. A long-running command shows nothing until it exits, and a large output is held in memory.
It has no timeout. A command that never exits never resolves.
Expected
await container.exec(["psql", "-U", "test"], {
throwOnError: true,
stdin: fs.createReadStream("./seed.sql"),
onOutput: (chunk, stream) => process.stdout.write(chunk),
timeout: 30_000,
});
throwOnErrorrejects on a non-zero exit code, with an error that carries the command, exit code, stdout and stderr.stdinaccepts a string,BufferorReadable.onOutputreceives output as it arrives.timeoutrejects and stops waiting for the command.
The defaults stay as they are.
Where
execinpackages/testcontainers/src/generic-container/started-generic-container.tsexecinpackages/testcontainers/src/container-runtime/clients/container/docker-container-client.tsExecOptionsinpackages/testcontainers/src/types.ts
Notes
- Java and Go return the exit code and leave the check to the caller, as this library does today. Go's
exec.ProcessOptioncovers user, working directory and environment. This goes further than either. - Can be split into one change per option.
Dependencies
- Stack on #1525, #1531: same function, and both change
ExecOptions. - Coordinate with #1532: for the error class.
- Ngôn ngữ chính
- TypeScript
- Star
- 2.6k
- Fork
- 277
- Merge trung bình
- 1 ngày 53 phút
- Pull request đã merge (30 ngày)
- 58
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của testcontainers/testcontainers-node
-
enhancement minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
testcontainers/testcontainers-node#1539 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
testcontainers/testcontainers-node#1533 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
testcontainers/testcontainers-node#1531 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
testcontainers/testcontainers-node#1529 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
testcontainers/testcontainers-node#1528 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của testcontainers/testcontainers-node
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
source-cooperative/docs.source.coop#41 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Nimblesite/SharpLsp#468 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
solidjs-community/solid-primitives#1082 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày