Skip to content

Commit

Permalink
internal/exectracetest: fix TestExecutionTraceSpans flakes (#2769)
Browse files Browse the repository at this point in the history
This test was sensitive to the order of map iteration, making it flaky.
Whoops!
  • Loading branch information
nsrip-dd authored Jul 3, 2024
1 parent 3a1e562 commit fcda398
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/exectracetest/exectrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"regexp"
"runtime/pprof"
"runtime/trace"
"sort"
"testing"
"time"

Expand Down Expand Up @@ -185,13 +186,14 @@ func TestExecutionTraceSpans(t *testing.T) {
}

want := []traceSpan{
{name: "root", spanID: root.Context().SpanID()},
{name: "child", parent: "root", spanID: child.Context().SpanID()},
{name: "root", spanID: root.Context().SpanID()},
}
var got []traceSpan
for _, v := range spans {
got = append(got, *v)
}
sort.Slice(got, func(i, j int) bool { return got[i].name < got[j].name })

if !reflect.DeepEqual(want, got) {
t.Errorf("wanted spans %+v, got %+v", want, got)
Expand Down

0 comments on commit fcda398

Please sign in to comment.