From 573500dc51391f5adf8df381ad3b8ff10449061c Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Wed, 21 Feb 2018 12:48:53 -0600 Subject: [PATCH] Unit test that calls revokeLeadership twice to make sure its idempotent --- agent/consul/server_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/agent/consul/server_test.go b/agent/consul/server_test.go index d65e2c7d7..74dbf726e 100644 --- a/agent/consul/server_test.go +++ b/agent/consul/server_test.go @@ -761,3 +761,22 @@ func TestServer_TLSToFullVerify(t *testing.T) { t.Fatalf("bad: %v", success) } } + +func TestServer_RevokeLeadershipIdempotent(t *testing.T) { + t.Parallel() + dir1, s1 := testServer(t) + defer os.RemoveAll(dir1) + defer s1.Shutdown() + + + testrpc.WaitForLeader(t, s1.RPC, "dc1") + + err:= s1.revokeLeadership() + if err != nil { + t.Fatal(err) + } + err = s1.revokeLeadership() + if err != nil { + t.Fatal(err) + } +}