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

[Serverless] Increase time to wait for metric samples in tests. #32409

Merged
merged 1 commit into from
Dec 20, 2024
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
48 changes: 25 additions & 23 deletions pkg/serverless/logs/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,15 @@ func TestProcessMessageValid(t *testing.T) {

lc.processMessage(&message)

received, timed := demux.WaitForNumberOfSamples(7, 0, 100*time.Millisecond)
received, timed := demux.WaitForNumberOfSamples(7, 0, 125*time.Millisecond)
assert.Len(t, received, 7)
assert.Len(t, timed, 0)
demux.Reset()

lc.enhancedMetricsEnabled = false
lc.processMessage(&message)

received, timed = demux.WaitForSamples(100 * time.Millisecond)
received, timed = demux.WaitForSamples(125 * time.Millisecond)
assert.Len(t, received, 0, "we should NOT have received metrics")
assert.Len(t, timed, 0)
}
Expand Down Expand Up @@ -366,7 +366,7 @@ func TestProcessMessageShouldNotProcessArnNotSet(t *testing.T) {

go lc.processMessage(message)

received, timed := demux.WaitForSamples(100 * time.Millisecond)
received, timed := demux.WaitForSamples(125 * time.Millisecond)
assert.Len(t, received, 0, "We should NOT have received metrics")
assert.Len(t, timed, 0)
}
Expand Down Expand Up @@ -394,7 +394,7 @@ func TestProcessMessageShouldNotProcessLogsDropped(t *testing.T) {

go lc.processMessage(message)

received, timed := demux.WaitForSamples(100 * time.Millisecond)
received, timed := demux.WaitForSamples(125 * time.Millisecond)
assert.Len(t, received, 0, "We should NOT have received metrics")
assert.Len(t, timed, 0)
}
Expand Down Expand Up @@ -424,11 +424,13 @@ func TestProcessMessageShouldProcessLogTypeFunctionOutOfMemory(t *testing.T) {

go lc.processMessage(message)

received, timed := demux.WaitForNumberOfSamples(2, 0, 100*time.Millisecond)
received, timed := demux.WaitForNumberOfSamples(2, 0, 125*time.Millisecond)
assert.Len(t, received, 2)
assert.Len(t, timed, 0)
assert.Equal(t, serverlessMetrics.OutOfMemoryMetric, received[0].Name)
assert.Equal(t, serverlessMetrics.ErrorsMetric, received[1].Name)
if len(received) == 2 {
assert.Equal(t, serverlessMetrics.OutOfMemoryMetric, received[0].Name)
assert.Equal(t, serverlessMetrics.ErrorsMetric, received[1].Name)
}
}

func TestProcessMessageShouldProcessLogTypePlatformReportOutOfMemory(t *testing.T) {
Expand Down Expand Up @@ -465,7 +467,7 @@ func TestProcessMessageShouldProcessLogTypePlatformReportOutOfMemory(t *testing.

go lc.processMessage(message)

received, timed := demux.WaitForNumberOfSamples(2, 0, 100*time.Millisecond)
received, timed := demux.WaitForNumberOfSamples(2, 0, 125*time.Millisecond)
assert.Len(t, received, 8)
assert.Len(t, timed, 0)
assert.Equal(t, serverlessMetrics.OutOfMemoryMetric, received[6].Name)
Expand Down Expand Up @@ -497,7 +499,7 @@ func TestProcessMessageShouldSendFailoverMetric(t *testing.T) {

lc.processMessage(&message)

received, timed := demux.WaitForNumberOfSamples(1, 0, 100*time.Millisecond)
received, timed := demux.WaitForNumberOfSamples(1, 0, 125*time.Millisecond)
assert.Len(t, received, 1)
assert.Len(t, timed, 0)
demux.Reset()
Expand All @@ -507,7 +509,7 @@ func TestProcessMessageShouldSendFailoverMetric(t *testing.T) {
message.stringRecord = "{\"DD_EXTENSION_FALLBACK_REASON\":\"test-reason\"}" // add again bc processing empties it
lc.processMessage(&message)

received, timed = demux.WaitForNumberOfSamples(1, 0, 100*time.Millisecond)
received, timed = demux.WaitForNumberOfSamples(1, 0, 125*time.Millisecond)
assert.Len(t, received, 1)
assert.Len(t, timed, 0)
}
Expand Down Expand Up @@ -549,7 +551,7 @@ func TestProcessLogMessageLogsEnabled(t *testing.T) {
assert.NotNil(t, received)
assert.Equal(t, "my-arn", received.Lambda.ARN)
assert.Equal(t, "myRequestID", received.Lambda.RequestID)
case <-time.After(100 * time.Millisecond):
case <-time.After(125 * time.Millisecond):
assert.Fail(t, "We should have received logs")
}
}
Expand Down Expand Up @@ -597,7 +599,7 @@ func TestProcessLogMessageLogsEnabledForMixedUnorderedMessages(t *testing.T) {
assert.NotNil(t, received)
assert.Equal(t, "my-arn", received.Lambda.ARN)
assert.Equal(t, expectedRequestIDs[i], received.Lambda.RequestID)
case <-time.After(100 * time.Millisecond):
case <-time.After(125 * time.Millisecond):
assert.Fail(t, "We should have received logs")
}
}
Expand Down Expand Up @@ -628,7 +630,7 @@ func TestProcessLogMessageNoStringRecordPlatformLog(t *testing.T) {
select {
case <-logChannel:
assert.Fail(t, "We should not have received logs")
case <-time.After(100 * time.Millisecond):
case <-time.After(125 * time.Millisecond):
// nothing to do here
}
}
Expand Down Expand Up @@ -663,7 +665,7 @@ func TestProcessLogMessageNoStringRecordFunctionLog(t *testing.T) {
assert.NotNil(t, received)
assert.Equal(t, "my-arn", received.Lambda.ARN)
assert.Equal(t, "myRequestID", received.Lambda.RequestID)
case <-time.After(100 * time.Millisecond):
case <-time.After(125 * time.Millisecond):
assert.Fail(t, "We should have received logs")
}
}
Expand Down Expand Up @@ -700,7 +702,7 @@ func TestProcessLogMessageLogsNotEnabled(t *testing.T) {
select {
case <-logChannel:
assert.Fail(t, "We should not have received logs")
case <-time.After(100 * time.Millisecond):
case <-time.After(125 * time.Millisecond):
// nothing to do here
}
}
Expand Down Expand Up @@ -763,7 +765,7 @@ func TestProcessLogMessagesTimeoutLogFromReportLog(t *testing.T) {
assert.Equal(t, "myRequestID", received.Lambda.RequestID)
assert.Equal(t, expectedStringRecord[i], string(received.Content))
assert.Equal(t, expectedErrors[i], received.IsError)
case <-time.After(100 * time.Millisecond):
case <-time.After(125 * time.Millisecond):
assert.Fail(t, "We should have received logs")
}
}
Expand Down Expand Up @@ -858,7 +860,7 @@ func TestProcessMultipleLogMessagesTimeoutLogFromReportLog(t *testing.T) {
} else {
assert.False(t, received.IsError)
}
case <-time.After(100 * time.Millisecond):
case <-time.After(125 * time.Millisecond):
assert.Fail(t, "We should have received logs")
}
}
Expand Down Expand Up @@ -904,7 +906,7 @@ func TestProcessLogMessagesOutOfMemoryError(t *testing.T) {
assert.Equal(t, "my-arn", received.Lambda.ARN)
assert.Equal(t, "myRequestID", received.Lambda.RequestID)
assert.Equal(t, true, received.IsError)
case <-time.After(100 * time.Millisecond):
case <-time.After(125 * time.Millisecond):
assert.Fail(t, "We should have received logs")
}
}
Expand Down Expand Up @@ -943,7 +945,7 @@ func TestProcessLogMessageLogsNoRequestID(t *testing.T) {
select {
case <-logChannel:
assert.Fail(t, "We should not have received logs")
case <-time.After(100 * time.Millisecond):
case <-time.After(125 * time.Millisecond):
// nothing to do here
}

Expand All @@ -952,7 +954,7 @@ func TestProcessLogMessageLogsNoRequestID(t *testing.T) {
for _, msg := range received {
assert.Equal(t, "", msg.objectRecord.requestID)
}
case <-time.After(100 * time.Millisecond):
case <-time.After(125 * time.Millisecond):
assert.Fail(t, "We should have received logs")
}
}
Expand Down Expand Up @@ -1228,7 +1230,7 @@ func TestRuntimeMetricsMatchLogs(t *testing.T) {
lc.processMessage(doneMessage)
lc.processMessage(reportMessage)

generatedMetrics, timedMetrics := demux.WaitForNumberOfSamples(10, 0, 100*time.Millisecond)
generatedMetrics, timedMetrics := demux.WaitForNumberOfSamples(10, 0, 125*time.Millisecond)
postRuntimeMetricTimestamp := float64(reportLogTime.UnixNano()) / float64(time.Second)
runtimeMetricTimestamp := float64(endTime.UnixNano()) / float64(time.Second)
assert.Equal(t, generatedMetrics[0], metrics.MetricSample{
Expand Down Expand Up @@ -1314,7 +1316,7 @@ func TestRuntimeMetricsMatchLogsProactiveInit(t *testing.T) {
lc.processMessage(doneMessage)
lc.processMessage(reportMessage)

generatedMetrics, timedMetrics := demux.WaitForNumberOfSamples(10, 0, 100*time.Millisecond)
generatedMetrics, timedMetrics := demux.WaitForNumberOfSamples(10, 0, 125*time.Millisecond)
postRuntimeMetricTimestamp := float64(reportLogTime.UnixNano()) / float64(time.Second)
runtimeMetricTimestamp := float64(endTime.UnixNano()) / float64(time.Second)
assert.Equal(t, generatedMetrics[0], metrics.MetricSample{
Expand Down Expand Up @@ -1416,7 +1418,7 @@ func TestRuntimeMetricsOnTimeout(t *testing.T) {
assert.Nil(t, restoreErr)
lc.processMessage(reportMessage)

generatedMetrics, timedMetrics := demux.WaitForNumberOfSamples(10, 0, 100*time.Millisecond)
generatedMetrics, timedMetrics := demux.WaitForNumberOfSamples(10, 0, 125*time.Millisecond)
postRuntimeMetricTimestamp := float64(reportLogTime.UnixNano()) / float64(time.Second)
runtimeMetricTimestamp := float64(endTime.UnixNano()) / float64(time.Second)
assert.Equal(t, generatedMetrics[0], metrics.MetricSample{
Expand Down
Loading
Loading