From 9a220f30103bdf3467f10ee7ad81f0501e52a4b8 Mon Sep 17 00:00:00 2001 From: Kit Patella Date: Thu, 6 Feb 2020 16:37:53 -0800 Subject: [PATCH] agent/consul server: fix LeaderTest_ChangeNodeID (#7236) * fix LeaderTest_ChangeNodeID to use StatusLeft and add waitForAnyLANLeave * unextract the waitFor... fn, simplify, and provide a more descriptive error --- agent/consul/leader_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/agent/consul/leader_test.go b/agent/consul/leader_test.go index e9abd55bd2..00e3e37f84 100644 --- a/agent/consul/leader_test.go +++ b/agent/consul/leader_test.go @@ -982,15 +982,15 @@ func TestLeader_ChangeNodeID(t *testing.T) { // Shut down a server, freeing up its address/port s3.Shutdown() - + // wait for s1.LANMembers() to show s3 as StatusFailed or StatusLeft on retry.Run(t, func(r *retry.R) { - failed := 0 + var gone bool for _, m := range s1.LANMembers() { - if m.Status == serf.StatusFailed { - failed++ + if m.Name == s3.config.NodeName && (m.Status == serf.StatusFailed || m.Status == serf.StatusLeft) { + gone = true } } - require.Equal(r, 1, failed) + require.True(r, gone, "s3 has not been detected as failed or left after shutdown") }) // Bring up a new server with s3's name that will get a different ID