diff --git a/consul/acl_endpoint_test.go b/consul/acl_endpoint_test.go index 8f429e56df..9c03eae018 100644 --- a/consul/acl_endpoint_test.go +++ b/consul/acl_endpoint_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testrpc" + "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/net-rpc-msgpackrpc" ) @@ -471,7 +472,7 @@ func TestACLEndpoint_ReplicationStatus(t *testing.T) { dir1, s1 := testServerWithConfig(t, func(c *Config) { c.ACLDatacenter = "dc2" c.ACLReplicationToken = "secret" - c.ACLReplicationInterval = 0 + c.ACLReplicationInterval = 10 * time.Millisecond }) defer os.RemoveAll(dir1) defer s1.Shutdown() @@ -483,12 +484,15 @@ func TestACLEndpoint_ReplicationStatus(t *testing.T) { getR := structs.DCSpecificRequest{ Datacenter: "dc1", } - var status structs.ACLReplicationStatus - err := msgpackrpc.CallWithCodec(codec, "ACL.ReplicationStatus", &getR, &status) - if err != nil { - t.Fatalf("err: %v", err) - } - if !status.Enabled || !status.Running || status.SourceDatacenter != "dc2" { - t.Fatalf("bad: %#v", status) - } + + retry.Run("", t, func(r *retry.R) { + var status structs.ACLReplicationStatus + err := msgpackrpc.CallWithCodec(codec, "ACL.ReplicationStatus", &getR, &status) + if err != nil { + r.Fatalf("err: %v", err) + } + if !status.Enabled || !status.Running || status.SourceDatacenter != "dc2" { + r.Fatalf("bad: %#v", status) + } + }) } diff --git a/consul/acl_replication_test.go b/consul/acl_replication_test.go index 54328945e6..734f6f9b5f 100644 --- a/consul/acl_replication_test.go +++ b/consul/acl_replication_test.go @@ -331,7 +331,7 @@ func TestACLReplication(t *testing.T) { c.Datacenter = "dc2" c.ACLDatacenter = "dc1" c.ACLReplicationToken = "root" - c.ACLReplicationInterval = 0 + c.ACLReplicationInterval = 10 * time.Millisecond c.ACLReplicationApplyLimit = 1000000 }) defer os.RemoveAll(dir2) @@ -348,7 +348,7 @@ func TestACLReplication(t *testing.T) { // Create a bunch of new tokens. var id string - for i := 0; i < 1000; i++ { + for i := 0; i < 50; i++ { arg := structs.ACLRequest{ Datacenter: "dc1", Op: structs.ACLSet, @@ -402,7 +402,7 @@ func TestACLReplication(t *testing.T) { }) // Create more new tokens. - for i := 0; i < 1000; i++ { + for i := 0; i < 50; i++ { arg := structs.ACLRequest{ Datacenter: "dc1", Op: structs.ACLSet, diff --git a/consul/acl_test.go b/consul/acl_test.go index 415d30fbad..589f768d38 100644 --- a/consul/acl_test.go +++ b/consul/acl_test.go @@ -6,6 +6,7 @@ import ( "reflect" "strings" "testing" + "time" "github.com/hashicorp/consul/acl" "github.com/hashicorp/consul/consul/structs" @@ -632,7 +633,7 @@ func TestACL_Replication(t *testing.T) { c.ACLDefaultPolicy = "deny" c.ACLDownPolicy = "extend-cache" c.ACLReplicationToken = "root" - c.ACLReplicationInterval = 0 + c.ACLReplicationInterval = 10 * time.Millisecond c.ACLReplicationApplyLimit = 1000000 }) defer os.RemoveAll(dir2) @@ -643,7 +644,7 @@ func TestACL_Replication(t *testing.T) { c.ACLDatacenter = "dc1" c.ACLDownPolicy = "deny" c.ACLReplicationToken = "root" - c.ACLReplicationInterval = 0 + c.ACLReplicationInterval = 10 * time.Millisecond c.ACLReplicationApplyLimit = 1000000 }) defer os.RemoveAll(dir3)