test: Tweaks ACL replication tests to converge faster w/less spam.

This commit is contained in:
James Phillips 2017-05-04 15:35:33 -07:00 committed by Frank Schroeder
parent b9fb20d0cf
commit ffdfe2c201
No known key found for this signature in database
GPG Key ID: 4D65C6EAEC87DECD
3 changed files with 19 additions and 14 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/consul/structs"
"github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/lib"
"github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testrpc"
"github.com/hashicorp/consul/testutil/retry"
"github.com/hashicorp/net-rpc-msgpackrpc" "github.com/hashicorp/net-rpc-msgpackrpc"
) )
@ -471,7 +472,7 @@ func TestACLEndpoint_ReplicationStatus(t *testing.T) {
dir1, s1 := testServerWithConfig(t, func(c *Config) { dir1, s1 := testServerWithConfig(t, func(c *Config) {
c.ACLDatacenter = "dc2" c.ACLDatacenter = "dc2"
c.ACLReplicationToken = "secret" c.ACLReplicationToken = "secret"
c.ACLReplicationInterval = 0 c.ACLReplicationInterval = 10 * time.Millisecond
}) })
defer os.RemoveAll(dir1) defer os.RemoveAll(dir1)
defer s1.Shutdown() defer s1.Shutdown()
@ -483,12 +484,15 @@ func TestACLEndpoint_ReplicationStatus(t *testing.T) {
getR := structs.DCSpecificRequest{ getR := structs.DCSpecificRequest{
Datacenter: "dc1", Datacenter: "dc1",
} }
var status structs.ACLReplicationStatus
err := msgpackrpc.CallWithCodec(codec, "ACL.ReplicationStatus", &getR, &status) retry.Run("", t, func(r *retry.R) {
if err != nil { var status structs.ACLReplicationStatus
t.Fatalf("err: %v", err) err := msgpackrpc.CallWithCodec(codec, "ACL.ReplicationStatus", &getR, &status)
} if err != nil {
if !status.Enabled || !status.Running || status.SourceDatacenter != "dc2" { r.Fatalf("err: %v", err)
t.Fatalf("bad: %#v", status) }
} if !status.Enabled || !status.Running || status.SourceDatacenter != "dc2" {
r.Fatalf("bad: %#v", status)
}
})
} }

View File

@ -331,7 +331,7 @@ func TestACLReplication(t *testing.T) {
c.Datacenter = "dc2" c.Datacenter = "dc2"
c.ACLDatacenter = "dc1" c.ACLDatacenter = "dc1"
c.ACLReplicationToken = "root" c.ACLReplicationToken = "root"
c.ACLReplicationInterval = 0 c.ACLReplicationInterval = 10 * time.Millisecond
c.ACLReplicationApplyLimit = 1000000 c.ACLReplicationApplyLimit = 1000000
}) })
defer os.RemoveAll(dir2) defer os.RemoveAll(dir2)
@ -348,7 +348,7 @@ func TestACLReplication(t *testing.T) {
// Create a bunch of new tokens. // Create a bunch of new tokens.
var id string var id string
for i := 0; i < 1000; i++ { for i := 0; i < 50; i++ {
arg := structs.ACLRequest{ arg := structs.ACLRequest{
Datacenter: "dc1", Datacenter: "dc1",
Op: structs.ACLSet, Op: structs.ACLSet,
@ -402,7 +402,7 @@ func TestACLReplication(t *testing.T) {
}) })
// Create more new tokens. // Create more new tokens.
for i := 0; i < 1000; i++ { for i := 0; i < 50; i++ {
arg := structs.ACLRequest{ arg := structs.ACLRequest{
Datacenter: "dc1", Datacenter: "dc1",
Op: structs.ACLSet, Op: structs.ACLSet,

View File

@ -6,6 +6,7 @@ import (
"reflect" "reflect"
"strings" "strings"
"testing" "testing"
"time"
"github.com/hashicorp/consul/acl" "github.com/hashicorp/consul/acl"
"github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/consul/structs"
@ -632,7 +633,7 @@ func TestACL_Replication(t *testing.T) {
c.ACLDefaultPolicy = "deny" c.ACLDefaultPolicy = "deny"
c.ACLDownPolicy = "extend-cache" c.ACLDownPolicy = "extend-cache"
c.ACLReplicationToken = "root" c.ACLReplicationToken = "root"
c.ACLReplicationInterval = 0 c.ACLReplicationInterval = 10 * time.Millisecond
c.ACLReplicationApplyLimit = 1000000 c.ACLReplicationApplyLimit = 1000000
}) })
defer os.RemoveAll(dir2) defer os.RemoveAll(dir2)
@ -643,7 +644,7 @@ func TestACL_Replication(t *testing.T) {
c.ACLDatacenter = "dc1" c.ACLDatacenter = "dc1"
c.ACLDownPolicy = "deny" c.ACLDownPolicy = "deny"
c.ACLReplicationToken = "root" c.ACLReplicationToken = "root"
c.ACLReplicationInterval = 0 c.ACLReplicationInterval = 10 * time.Millisecond
c.ACLReplicationApplyLimit = 1000000 c.ACLReplicationApplyLimit = 1000000
}) })
defer os.RemoveAll(dir3) defer os.RemoveAll(dir3)