mirror of https://github.com/status-im/consul.git
server: ensure the primary dc and ACL dc match (#6634)
This is mostly a sanity check for server tests that skip the normal config builder equivalent fixup.
This commit is contained in:
parent
3aeb740430
commit
de6ce5b1d9
|
@ -327,6 +327,10 @@ func NewServerLogger(config *Config, logger *log.Logger, tokens *token.Store, tl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.PrimaryDatacenter != "" {
|
||||||
|
config.ACLDatacenter = config.PrimaryDatacenter
|
||||||
|
}
|
||||||
|
|
||||||
// Create the tombstone GC.
|
// Create the tombstone GC.
|
||||||
gc, err := state.NewTombstoneGC(config.TombstoneTTL, config.TombstoneTTLGranularity)
|
gc, err := state.NewTombstoneGC(config.TombstoneTTL, config.TombstoneTTLGranularity)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -247,6 +247,48 @@ func TestServer_StartStop(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestServer_fixupACLDatacenter(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
dir1, s1 := testServerWithConfig(t, func(c *Config) {
|
||||||
|
c.Datacenter = "aye"
|
||||||
|
c.PrimaryDatacenter = "aye"
|
||||||
|
c.ACLsEnabled = true
|
||||||
|
})
|
||||||
|
defer os.RemoveAll(dir1)
|
||||||
|
defer s1.Shutdown()
|
||||||
|
|
||||||
|
dir2, s2 := testServerWithConfig(t, func(c *Config) {
|
||||||
|
c.Datacenter = "bee"
|
||||||
|
c.PrimaryDatacenter = "aye"
|
||||||
|
c.ACLsEnabled = true
|
||||||
|
})
|
||||||
|
defer os.RemoveAll(dir2)
|
||||||
|
defer s2.Shutdown()
|
||||||
|
|
||||||
|
// Try to join
|
||||||
|
joinWAN(t, s2, s1)
|
||||||
|
retry.Run(t, func(r *retry.R) {
|
||||||
|
if got, want := len(s1.WANMembers()), 2; got != want {
|
||||||
|
r.Fatalf("got %d s1 WAN members want %d", got, want)
|
||||||
|
}
|
||||||
|
if got, want := len(s2.WANMembers()), 2; got != want {
|
||||||
|
r.Fatalf("got %d s2 WAN members want %d", got, want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
testrpc.WaitForLeader(t, s1.RPC, "aye")
|
||||||
|
testrpc.WaitForLeader(t, s2.RPC, "bee")
|
||||||
|
|
||||||
|
require.Equal(t, "aye", s1.config.Datacenter)
|
||||||
|
require.Equal(t, "aye", s1.config.ACLDatacenter)
|
||||||
|
require.Equal(t, "aye", s1.config.PrimaryDatacenter)
|
||||||
|
|
||||||
|
require.Equal(t, "bee", s2.config.Datacenter)
|
||||||
|
require.Equal(t, "aye", s2.config.ACLDatacenter)
|
||||||
|
require.Equal(t, "aye", s2.config.PrimaryDatacenter)
|
||||||
|
}
|
||||||
|
|
||||||
func TestServer_JoinLAN(t *testing.T) {
|
func TestServer_JoinLAN(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
dir1, s1 := testServer(t)
|
dir1, s1 := testServer(t)
|
||||||
|
|
Loading…
Reference in New Issue