Skip to content

Commit c8e5f62

Browse files
committed
test: added checks to debug random unit test failures in delayed spans
1 parent 6707702 commit c8e5f62

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

delayed_spans_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"net/http"
99
"net/http/httptest"
10+
"os"
1011
"sync"
1112
"sync/atomic"
1213
"testing"
@@ -50,6 +51,14 @@ func TestPartiallyFlushDelayedSpans(t *testing.T) {
5051

5152
generateSomeTraffic(s, maxDelayedSpans)
5253

54+
// serverless agent should not be present for this test to pass.
55+
// following check is added for debugging random failures in the unit tests of delayed spans
56+
// TODO: remove it once the issue is resolved.
57+
_, isURLPresent := os.LookupEnv("INSTANA_ENDPOINT_URL")
58+
_, isKeyPresent := os.LookupEnv("INSTANA_AGENT_KEY")
59+
assert.Equal(t, false, isURLPresent)
60+
assert.Equal(t, false, isKeyPresent)
61+
5362
assert.Len(t, delayed.spans, maxDelayedSpans)
5463

5564
notReadyAfter := maxDelayedSpans / 10
@@ -76,6 +85,14 @@ func TestFlushDelayedSpans(t *testing.T) {
7685

7786
generateSomeTraffic(s, maxDelayedSpans)
7887

88+
// serverless agent should not be present for this test to pass.
89+
// following check is added for debugging random failures in the unit tests of delayed spans
90+
// TODO: remove it once the issue is resolved.
91+
_, isURLPresent := os.LookupEnv("INSTANA_ENDPOINT_URL")
92+
_, isKeyPresent := os.LookupEnv("INSTANA_AGENT_KEY")
93+
assert.Equal(t, false, isURLPresent)
94+
assert.Equal(t, false, isKeyPresent)
95+
7996
assert.Len(t, delayed.spans, maxDelayedSpans)
8097

8198
sensor.agent = alwaysReadyClient{}
@@ -101,6 +118,14 @@ func TestParallelFlushDelayedSpans(t *testing.T) {
101118

102119
generateSomeTraffic(s, maxDelayedSpans*2)
103120

121+
// serverless agent should not be present for this test to pass.
122+
// following check is added for debugging random failures in the unit tests of delayed spans
123+
// TODO: remove it once the issue is resolved.
124+
_, isURLPresent := os.LookupEnv("INSTANA_ENDPOINT_URL")
125+
_, isKeyPresent := os.LookupEnv("INSTANA_AGENT_KEY")
126+
assert.Equal(t, false, isURLPresent)
127+
assert.Equal(t, false, isKeyPresent)
128+
104129
assert.Len(t, delayed.spans, maxDelayedSpans)
105130

106131
workers := 15

0 commit comments

Comments
 (0)