Remove the need for `AbstractStartedContainer` wrappers in modules
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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tái cấu trúc
- Độ 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 the four packages/testcontainers/src/generic-*/ files listed under “Where,” then inspect module start() overrides and started classes under packages/modules/*/src/. First resolve the stated dependencies and coordinate with issues #1521 and #1538; account for Compose and reuse paths that construct StartedGenericContainer. Done means modules can declare their started type without forwarding wrappers or wrapper-only start() overrides, with the listed follow-up work coordinated.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What happens
Every module is two classes joined by a forwarding wrapper. Simplified from the redis module:
export class RedisContainer extends GenericContainer {
public override async start(): Promise<StartedRedisContainer> {
return new StartedRedisContainer(await super.start(), this.password);
}
}
export class StartedRedisContainer extends AbstractStartedContainer {
constructor(startedTestContainer: StartedTestContainer, private readonly password?: string) {
super(startedTestContainer);
}
}
AbstractStartedContainer holds a StartedTestContainer and forwards each of its 20 methods to it.
- 50 module classes extend it.
- 50 module files override
start(), and each override has to wrap the result ofsuper.start()in the module's started class. - Every method added to
StartedTestContainerhas to be written three times: on the interface, onStartedGenericContainerand as a forwarder onAbstractStartedContainer. - Forwarding has caused bugs: #1202, where
Symbol.asyncDisposecalled the innerstop()and skipped the subclass's. - There are two sets of stop hooks:
containerStopping/containerStoppedonAbstractStartedContainer, andcontainerIsStopping/containerIsStoppedonStartedGenericContainer, which nothing overrides. That class is not exported. AbstractStoppedContainerrepeats the pattern and is used once (selenium).- Overriding
start()to wrap is also where modules put configuration, which is whystart()is not repeatable (#1520).
Expected
A module author declares the started type once, with no forwarding class and no start() override just to wrap. Some directions:
- Make
GenericContainergeneric over its started type, with a protected factory that the basestart()calls. Configuration moves to a hook such asbeforeContainerCreated. - Export a started base class that module containers extend directly, and let the builder say which class to construct. Inheritance replaces forwarding.
- One class for both states, as Java and Go have.
Where
packages/testcontainers/src/generic-container/abstract-started-container.tspackages/testcontainers/src/generic-container/abstract-stopped-container.tspackages/testcontainers/src/generic-container/started-generic-container.ts- every
packages/modules/*/src/*-container.ts
Notes
- Java and Go use a single type for a configured and a running container. .NET splits builder and container like this repo, but the module container extends the base container directly (
PostgreSqlContainer : DockerContainer, IDatabaseContainer), with no forwarding layer. - Compose and the reuse path construct
StartedGenericContainerthemselves, so the design has to cover those. - Semver: labelled
majorfor removingAbstractStartedContainer. The replacement can ship first in aminor, with the wrapper deprecated.
Dependencies
- Blocked by #1520, #1554: modules configure themselves inside
start()and through protected hooks. Both need their replacement first. - Coordinate with #1521: hook semantics for reused containers.
- Coordinate with #1538: both edit every module's started class.
- Land after the started-container additions (#1544, #1545, #1546, #1547, #1548, #1549, #1541). They add forwarders that this removes.
- Ngôn ngữ chính
- TypeScript
- Star
- 2.6k
- Fork
- 274
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 44
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ự
-
Create/import wallet form shows raw "password must be at least 1 characters" instead of the translated messageCó thể đã có người làm @CapThunder19 đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
joinmarket-webui/jam#1538 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
t0ggles
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
nolimits4web/swiper#8240 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/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
modelcontextprotocol/inspector#2723 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
status:approved type:bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
egdev6/quorb#109 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày