Skip to content

Commit fefe0ae

Browse files
authored
[AGNTLOG-235] Add 10 second sleep to e2e container (#45503)
### What does this PR do? Adds a 10 second sleep to containers the agent is supposed to tail e2e tests. This allows the agent to detect the container before it gets killed by kubernetes. ### Motivation These tests were found to be flaky, the goal is this PR to is to fix the flakiness these tests were causing. The flakiness presents itself as the agent not detecting the container that it is supposed to collect logs from. ### Describe how you validated your changes I was able to replicate the issue reliably by forcing the agent container to restart immediately prior to running the ubuntu container here, causing the agent container to "miss" the ubuntu container before it had been killed by kubernetes. Adding the 10 second sleep was able to fix that issue. ### Additional Notes Co-authored-by: lucas.liseth <lucas.liseth@datadoghq.com>
1 parent 6d0fa91 commit fefe0ae

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

test/new-e2e/tests/agent-log-pipelines/k8s-logs/file_tailing_test.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ func (v *k8sSuite) TestSingleLogAndMetadata() {
4949
Spec: corev1.PodSpec{
5050
Containers: []corev1.Container{
5151
{
52-
Name: "query-job-1",
53-
Image: "ubuntu",
54-
Command: []string{"echo", testLogMessage},
52+
Name: "query-job-1",
53+
Image: "ubuntu",
54+
// Sleep is added here so k8s doesn't kill the container before
55+
// the agent container can detect it.
56+
Command: []string{"sh", "-c", "echo '" + testLogMessage + "' && sleep 10"},
5557
},
5658
},
5759
RestartPolicy: corev1.RestartPolicyNever,
@@ -107,9 +109,11 @@ func (v *k8sSuite) TestLongLogLine() {
107109
Spec: corev1.PodSpec{
108110
Containers: []corev1.Container{
109111
{
110-
Name: "long-line-job",
111-
Image: "ubuntu",
112-
Command: []string{"echo", longLineLog},
112+
Name: "long-line-job",
113+
Image: "ubuntu",
114+
// Sleep is added here so k8s doesn't kill the container before
115+
// the agent container can detect it.
116+
Command: []string{"sh", "-c", "echo '" + longLineLog + "' && sleep 10"},
113117
},
114118
},
115119
RestartPolicy: corev1.RestartPolicyNever,
@@ -170,9 +174,11 @@ func (v *k8sSuite) TestContainerExclude() {
170174
Spec: corev1.PodSpec{
171175
Containers: []corev1.Container{
172176
{
173-
Name: "exclude-job",
174-
Image: "alpine",
175-
Command: []string{"echo", testLogMessage},
177+
Name: "exclude-job",
178+
Image: "alpine",
179+
// Sleep is added here so k8s doesn't kill the container before
180+
// the agent container can detect it.
181+
Command: []string{"sh", "-c", "echo '" + testLogMessage + "' && sleep 10"},
176182
},
177183
},
178184
RestartPolicy: corev1.RestartPolicyNever,

0 commit comments

Comments
 (0)