Skip to content

Commit

Permalink
Fix stdout TestStdoutTimestamp failure with sleep
Browse files Browse the repository at this point in the history
Ensure the test condition is valid by introducing minimal sleep
durations before and after a timestamp is measured.

Resolves open-telemetry#1571
  • Loading branch information
MrAlias committed Feb 23, 2021
1 parent b94cd4b commit c95e8fa
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions exporters/stdout/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func TestStdoutTimestamp(t *testing.T) {
}

before := time.Now()
// Ensure the timestamp is after before.
time.Sleep(time.Nanosecond)

checkpointSet := metrictest.NewCheckpointSet(testResource)

Expand All @@ -102,6 +104,8 @@ func TestStdoutTimestamp(t *testing.T) {
t.Fatal("Unexpected export error: ", err)
}

// Ensure the timestamp is before after.
time.Sleep(time.Nanosecond)
after := time.Now()

var printed []interface{}
Expand Down

0 comments on commit c95e8fa

Please sign in to comment.