testing: fix flaky test TestDNS_NonExistentDC_RPC

I saw this test flake locally, and it was easy to reproduce with -count=10.

The failure was: 'TestAgent.dns: rpc error: error=No known Consul servers'.

Waiting for the agent seems to fix it.
This commit is contained in:
Daniel Nephin 2020-08-13 18:03:04 -04:00
parent 512a523a3e
commit 6b0ac22c1b
1 changed files with 1 additions and 5 deletions

View File

@ -5829,16 +5829,12 @@ func TestDNS_NonExistentDC_RPC(t *testing.T) {
server = false
`)
defer c.Shutdown()
testrpc.WaitForLeader(t, s.RPC, "dc1")
// Join LAN cluster
addr := fmt.Sprintf("127.0.0.1:%d", s.Config.SerfPortLAN)
_, err := c.JoinLAN([]string{addr})
require.NoError(t, err)
retry.Run(t, func(r *retry.R) {
require.Len(r, s.LANMembers(), 2)
require.Len(r, c.LANMembers(), 2)
})
testrpc.WaitForTestAgent(t, c.RPC, "dc1")
m := new(dns.Msg)
m.SetQuestion("consul.service.dc2.consul.", dns.TypeANY)