Fix server command test (#5407)

The addition of CheckMigration to the server startup process means
that physical backends in this test need to be able to respond to Get() without error.
This commit is contained in:
Jim Kalafut 2018-09-26 14:52:11 -07:00 committed by GitHub
parent e8c06e6a74
commit d9d93e42a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 23 deletions

View File

@ -20,10 +20,8 @@ import (
"time"
"github.com/hashicorp/vault/physical"
physInmem "github.com/hashicorp/vault/physical/inmem"
"github.com/mitchellh/cli"
physConsul "github.com/hashicorp/vault/physical/consul"
physFile "github.com/hashicorp/vault/physical/file"
)
func testRandomPort(tb testing.TB) int {
@ -56,31 +54,23 @@ func testBaseHCL(tb testing.TB) string {
}
const (
consulHCL = `
backend "consul" {
prefix = "foo/"
inmemHCL = `
backend "inmem_ha" {
advertise_addr = "http://127.0.0.1:8200"
disable_registration = "true"
}
`
haConsulHCL = `
ha_backend "consul" {
prefix = "bar/"
haInmemHCL = `
ha_backend "inmem_ha" {
redirect_addr = "http://127.0.0.1:8200"
disable_registration = "true"
}
`
badHAConsulHCL = `
ha_backend "file" {
path = "/dev/null"
}
badHAInmemHCL = `
ha_backend "inmem" {}
`
reloadHCL = `
backend "file" {
path = "/dev/null"
}
backend "inmem" {}
disable_mlock = true
listener "tcp" {
address = "127.0.0.1:8203"
@ -101,8 +91,8 @@ func testServerCommand(tb testing.TB) (*cli.MockUi, *ServerCommand) {
ShutdownCh: MakeShutdownCh(),
SighupCh: MakeSighupCh(),
PhysicalBackends: map[string]physical.Factory{
"file": physFile.NewFileBackend,
"consul": physConsul.NewConsulBackend,
"inmem": physInmem.NewInmem,
"inmem_ha": physInmem.NewInmemHA,
},
// These prevent us from random sleep guessing...
@ -216,19 +206,19 @@ func TestServer(t *testing.T) {
}{
{
"common_ha",
testBaseHCL(t) + consulHCL,
testBaseHCL(t) + inmemHCL,
"(HA available)",
0,
},
{
"separate_ha",
testBaseHCL(t) + consulHCL + haConsulHCL,
testBaseHCL(t) + inmemHCL + haInmemHCL,
"HA Storage:",
0,
},
{
"bad_separate_ha",
testBaseHCL(t) + consulHCL + badHAConsulHCL,
testBaseHCL(t) + inmemHCL + badHAInmemHCL,
"Specified HA storage does not support HA",
1,
},