LogMessageWaitStrategy misses the required log lines when multiple containers are started
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
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- devops, testing-qa
Hướng nghiên cứu
Bắt đầu với LogMessageWaitStrategy và tái hiện standaloneTest bằng Dockerfile và init script được cung cấp, tập trung vào hai container tuần tự với các workload khác nhau. Theo dõi cách mỗi strategy quan sát log của container và xác định là hoàn tất khi cả hai startup checks đều phát hiện đáng tin cậy “Initialization finished.” mà không xảy ra timeout ngắt quãng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I start a custom database container and then I run a second container which executes a bunch of SQL scripts to initialize the database (these scripts usually run in less than a second) and exits. For both of these containers I use LogMessageWaitStrategy to check that (a) the database is ready; (b) the initialization scripts finished running and the initialization was successful.
The problem: the second container almost always (but not absolutely every time) does not pass the startup check, though the required log line is printed to the log.
After a while I came up with a synthetic test case which does not depend on our custom images.
The Dockerfile:
FROM alpine
COPY init /
CMD ["/init"]
The init script:
#!/bin/sh
if [ "$HANG" = 'true' ]
then
echo 'I will start and work hard for a long while.'
else
echo 'I will perform some quick initialization and quit.'
fi
# Emulate some workload before the initialization finishes.
sleep 0.1
echo "Initialization finished."
# Hang to emulate some workload running after initialization.
[ "$HANG" = 'true' ] && sleep inf || true
After building the image with the tag test I run the following test case:
@Test
public void standaloneTest() {
new GenericContainer<>("test")
.withEnv("HANG", "true")
.waitingFor(new LogMessageWaitStrategy()
.withRegEx(".*Initialization finished.*"))
.start();
new GenericContainer<>("test")
.waitingFor(new LogMessageWaitStrategy()
.withRegEx(".*Initialization finished.*"))
.start();
}
The test hangs on the second start() for a while and then fails with Not ready yet exception, though I see the correct log lines reported by Testcontainers just before the exception (Log output from the failed container).
Few things to consider:
- a single container using the test image always passes the startup check successfully disregarding how quickly it starts and how quickly it exits;
- a problem appears only when both containers use
LogMessageWaitStrategy; - increasing the
sleepduration in the script decreases the chances of the issue:sleep 0.3makes the issue less frequent andsleep 1removes it almost completely; Thread.sleep(1000)inserted between thestart()s seems to be a workaround, but it is not reliable and the issue still reproduces, though rarely.
I use Testcontainers 1.14.3. The environment varies; on different machines (all running different flavors of Linux) the issue has a different chance to fire (it seems that the chances are higher on more powerful and fast hardware).
- Ngôn ngữ chính
- Java
- Star
- 8.7k
- Fork
- 1.9k
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 9
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-java
-
type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
testcontainers/testcontainers-java#11997 · 1 bình luận ·
-
[Enhancement]: Document why singleton containers are required under Spring's test context caching Đang mởtype/enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
testcontainers/testcontainers-java#11967 ·
-
type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
testcontainers/testcontainers-java#11941 ·
-
type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
testcontainers/testcontainers-java#11829 · 1 bình luận ·
-
type/enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
testcontainers/testcontainers-java#11578 ·
Tất cả issue của testcontainers/testcontainers-java
Issue tương tự
-
Bug Java Platform: Java
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
getsentry/sentry-java#6138 · 1 bình luận ·
-
bug needs triage p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
bug needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100