From fcda3985a0d007d2c7a5d24182e453aa6c25152d Mon Sep 17 00:00:00 2001 From: Nick Ripley Date: Wed, 3 Jul 2024 06:09:44 -0700 Subject: [PATCH] internal/exectracetest: fix TestExecutionTraceSpans flakes (#2769) This test was sensitive to the order of map iteration, making it flaky. Whoops! --- internal/exectracetest/exectrace_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/exectracetest/exectrace_test.go b/internal/exectracetest/exectrace_test.go index 9a8799217f..6587397bce 100644 --- a/internal/exectracetest/exectrace_test.go +++ b/internal/exectracetest/exectrace_test.go @@ -22,6 +22,7 @@ import ( "regexp" "runtime/pprof" "runtime/trace" + "sort" "testing" "time" @@ -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)