Skip to content
This repository was archived by the owner on Nov 7, 2022. It is now read-only.

Commit 0a982f4

Browse files
author
Paulo Janotti
authored
Fix flaky test for Zipkin LOCAL_COMPONENT handling (#400)
Internally the function being tested uses a map to generate the slice with the translation results, however, the order is not deterministic and some runs fail. There are just two elements on the translated results but to make clear the expectation of the test this change uses sort.Slice function to achieve the desired order.
1 parent 0283713 commit 0a982f4

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

translator/trace/zipkinv1_thrift_to_protospan_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"encoding/json"
1919
"io/ioutil"
2020
"reflect"
21+
"sort"
2122
"testing"
2223

2324
"github.com/jaegertracing/jaeger/thrift-gen/zipkincore"
@@ -43,6 +44,11 @@ func TestZipkinThriftFallbackToLocalComponent(t *testing.T) {
4344
t.Fatalf("got %d trace service request(s), want 2", len(reqs))
4445
}
4546

47+
// Ensure the order of nodes
48+
sort.Slice(reqs, func(i, j int) bool {
49+
return reqs[i].Node.ServiceInfo.Name < reqs[j].Node.ServiceInfo.Name
50+
})
51+
4652
// First span didn't have a host/endpoint to give service name, use the local component.
4753
got := reqs[0].Node.ServiceInfo.Name
4854
want := "myLocalComponent"

translator/trace/zipkinv1_to_protospan_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ func TestZipkinJSONFallbackToLocalComponent(t *testing.T) {
145145
t.Fatalf("got %d trace service request(s), want 2", len(reqs))
146146
}
147147

148+
// Ensure the order of nodes
149+
sort.Slice(reqs, func(i, j int) bool {
150+
return reqs[i].Node.ServiceInfo.Name < reqs[j].Node.ServiceInfo.Name
151+
})
152+
148153
// First span didn't have a host/endpoint to give service name, use the local component.
149154
got := reqs[0].Node.ServiceInfo.Name
150155
want := "myLocalComponent"

0 commit comments

Comments
 (0)