Skip to content

Commit

Permalink
Fail test if the expected and actual traces differ (#777) (#781)
Browse files Browse the repository at this point in the history
Use pretty.Diff(expected, actual) instead of reflect.DeepEqual(expected, actual) to check for equality between given and received trace. Also, if there is a difference, set the test to fail instead of only logging the failed trace.

Signed-off-by: Michael Burman <miburman@redhat.com>
  • Loading branch information
burmanm authored and yurishkuro committed Apr 24, 2018
1 parent 210fc0b commit 2325502
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Makefile
@@ -1,5 +1,6 @@
PROJECT_ROOT=github.com/jaegertracing/jaeger
TOP_PKGS := $(shell glide novendor | grep -v -e ./thrift-gen/... -e swagger-gen... -e ./examples/... -e ./scripts/...)
STORAGE_PKGS = ./plugin/storage/integration/...

# all .go files that don't exist in hidden directories
ALL_SRC := $(shell find . -name "*.go" | grep -v -e vendor -e thrift-gen -e swagger-gen -e examples -e doc.go \
Expand Down Expand Up @@ -77,7 +78,7 @@ integration-test: go-gen

.PHONY: storage-integration-test
storage-integration-test: go-gen
$(GOTEST) ./plugin/storage/integration/...
bash -c "set -e; set -o pipefail; $(GOTEST) $(STORAGE_PKGS) | $(COLORIZE)"

all-pkgs:
@echo $(ALL_PKGS) | tr ' ' '\n' | sort
Expand Down
8 changes: 5 additions & 3 deletions plugin/storage/integration/domain_trace_compare_test.go
Expand Up @@ -50,13 +50,15 @@ func CompareTraces(t *testing.T, expected *model.Trace, actual *model.Trace) {
model.SortTrace(expected)
model.SortTrace(actual)
checkSize(t, expected, actual)
if !assert.EqualValues(t, expected, actual) {
for _, err := range pretty.Diff(expected, actual) {
t.Log(err)

if diff := pretty.Diff(expected, actual); len(diff) > 0 {
for _, d := range diff {
t.Logf("Expected and actual differ: %v\n", d)
}
out, err := json.Marshal(actual)
assert.NoError(t, err)
t.Logf("Actual trace: %s", string(out))
t.Fail()
}
}

Expand Down

0 comments on commit 2325502

Please sign in to comment.