From 6d8d8a6dcb4fb901cc935c2c65f6602a02b8ccc5 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Sat, 31 Mar 2018 18:43:24 -0700 Subject: [PATCH] functional-tester/tester: test shuffled cases are equal when sorted Signed-off-by: Gyuho Lee --- tools/functional-tester/tester/cluster_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/functional-tester/tester/cluster_test.go b/tools/functional-tester/tester/cluster_test.go index 4822639d3..011d1e1ab 100644 --- a/tools/functional-tester/tester/cluster_test.go +++ b/tools/functional-tester/tester/cluster_test.go @@ -16,6 +16,7 @@ package tester import ( "reflect" + "sort" "testing" "github.com/coreos/etcd/tools/functional-tester/rpcpb" @@ -186,4 +187,16 @@ func Test_newCluster(t *testing.T) { if reflect.DeepEqual(fs2, fs3) { t.Fatalf("expected reshuffled failure cases from %q, got %q", fs2, fs3) } + + // shuffle ensures visit all exactly once + // so when sorted, failure cases must be equal + sort.Strings(fs1) + sort.Strings(fs2) + sort.Strings(fs3) + if !reflect.DeepEqual(fs1, fs2) { + t.Fatalf("expected %q, got %q", fs1, fs2) + } + if !reflect.DeepEqual(fs2, fs3) { + t.Fatalf("expected %q, got %q", fs2, fs3) + } }