mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 09:42:25 +00:00
Remove CE-only warning from shared tests (#26052)
* Remove CE-only warning from shared tests * Add tests for all warnings emitted during raft config parsing * Unmark warnings as CE only that are universal
This commit is contained in:
@@ -238,7 +238,7 @@ func parseRaftBackendConfig(conf map[string]string, logger log.Logger) (*RaftBac
|
||||
}
|
||||
|
||||
c.AutopilotRedundancyZone = conf["autopilot_redundancy_zone"]
|
||||
if c.AutopilotRedundancyZone == "" {
|
||||
if c.AutopilotRedundancyZone != "" {
|
||||
emitEntWarning(logger, "autopilot_redundancy_zone")
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,17 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/constants"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func ceOnlyWarnings(warns ...string) []string {
|
||||
if !constants.IsEnterprise {
|
||||
return warns
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestRaft_ParseConfig(t *testing.T) {
|
||||
// Note some of these can be parallel tests but since we need to setEnv in
|
||||
// some we can't make them all parallel so it's don inside the loop. We assume
|
||||
@@ -50,6 +58,7 @@ func TestRaft_ParseConfig(t *testing.T) {
|
||||
cfg.RaftLogVerifierEnabled = true
|
||||
cfg.RaftLogVerificationInterval = defaultRaftLogVerificationInterval
|
||||
},
|
||||
wantWarns: []string{"raft_log_verification_interval is less than the minimum allowed"},
|
||||
},
|
||||
{
|
||||
name: "WAL verifier interval, one",
|
||||
@@ -63,6 +72,7 @@ func TestRaft_ParseConfig(t *testing.T) {
|
||||
// Below min so should get default
|
||||
cfg.RaftLogVerificationInterval = defaultRaftLogVerificationInterval
|
||||
},
|
||||
wantWarns: []string{"raft_log_verification_interval is less than the minimum allowed"},
|
||||
},
|
||||
{
|
||||
name: "WAL verifier interval, nothing",
|
||||
@@ -74,6 +84,7 @@ func TestRaft_ParseConfig(t *testing.T) {
|
||||
cfg.RaftLogVerifierEnabled = true
|
||||
cfg.RaftLogVerificationInterval = defaultRaftLogVerificationInterval
|
||||
},
|
||||
wantWarns: []string{"raft_log_verification_interval is less than the minimum allowed"},
|
||||
},
|
||||
{
|
||||
name: "WAL verifier interval, valid",
|
||||
@@ -104,6 +115,18 @@ func TestRaft_ParseConfig(t *testing.T) {
|
||||
wantErr: "does not parse",
|
||||
},
|
||||
|
||||
// AUTOPILOT Redundancy Zone ---------------------------------------------
|
||||
{
|
||||
name: "Autopilot redundancy zone, ok",
|
||||
conf: map[string]string{
|
||||
"autopilot_redundancy_zone": "us-east-1a",
|
||||
},
|
||||
wantMutation: func(cfg *RaftBackendConfig) {
|
||||
cfg.AutopilotRedundancyZone = "us-east-1a"
|
||||
},
|
||||
wantWarns: ceOnlyWarnings("configuration for a Vault Enterprise feature has been ignored: field=autopilot_redundancy_zone"),
|
||||
},
|
||||
|
||||
// Non-voter config ------------------------------------------------------
|
||||
{
|
||||
name: "non-voter, no retry-join, valid false",
|
||||
@@ -113,7 +136,6 @@ func TestRaft_ParseConfig(t *testing.T) {
|
||||
wantMutation: func(cfg *RaftBackendConfig) {
|
||||
// Should be default
|
||||
},
|
||||
wantWarns: []string{"is configuration for a Vault Enterprise feature and has been ignored"},
|
||||
},
|
||||
{
|
||||
name: "non-voter, retry-join, valid false",
|
||||
@@ -142,6 +164,7 @@ func TestRaft_ParseConfig(t *testing.T) {
|
||||
cfg.RetryJoin = "not-empty"
|
||||
cfg.RaftNonVoter = true
|
||||
},
|
||||
wantWarns: ceOnlyWarnings("configuration for a Vault Enterprise feature has been ignored: field=retry_join_as_non_voter"),
|
||||
},
|
||||
{
|
||||
name: "non-voter, no retry-join, invalid empty",
|
||||
@@ -209,6 +232,7 @@ func TestRaft_ParseConfig(t *testing.T) {
|
||||
cfg.RetryJoin = "not-empty"
|
||||
cfg.RaftNonVoter = true // Any non-empty value is true
|
||||
},
|
||||
wantWarns: ceOnlyWarnings("configuration for a Vault Enterprise feature has been ignored: field=retry_join_as_non_voter"),
|
||||
},
|
||||
{
|
||||
name: "non-voter, no retry-join, valid env true",
|
||||
@@ -229,6 +253,7 @@ func TestRaft_ParseConfig(t *testing.T) {
|
||||
cfg.RetryJoin = "not-empty"
|
||||
cfg.RaftNonVoter = true
|
||||
},
|
||||
wantWarns: ceOnlyWarnings("configuration for a Vault Enterprise feature has been ignored: field=retry_join_as_non_voter"),
|
||||
},
|
||||
{
|
||||
name: "non-voter, no retry-join, valid env not-boolean",
|
||||
@@ -249,6 +274,7 @@ func TestRaft_ParseConfig(t *testing.T) {
|
||||
cfg.RetryJoin = "not-empty"
|
||||
cfg.RaftNonVoter = true
|
||||
},
|
||||
wantWarns: ceOnlyWarnings("configuration for a Vault Enterprise feature has been ignored: field=retry_join_as_non_voter"),
|
||||
},
|
||||
{
|
||||
name: "non-voter, no retry-join, valid env empty",
|
||||
@@ -294,6 +320,7 @@ func TestRaft_ParseConfig(t *testing.T) {
|
||||
cfg.RetryJoin = "not-empty"
|
||||
cfg.RaftNonVoter = true // Env should win
|
||||
},
|
||||
wantWarns: ceOnlyWarnings("configuration for a Vault Enterprise feature has been ignored: field=retry_join_as_non_voter"),
|
||||
},
|
||||
|
||||
// Entry Size Limits -----------------------------------------------------
|
||||
@@ -307,6 +334,7 @@ func TestRaft_ParseConfig(t *testing.T) {
|
||||
cfg.MaxEntrySize = 123456
|
||||
cfg.MaxMountAndNamespaceTableEntrySize = 654321
|
||||
},
|
||||
wantWarns: ceOnlyWarnings("configuration for a Vault Enterprise feature has been ignored: field=max_mount_and_namespace_table_entry_size"),
|
||||
},
|
||||
{
|
||||
name: "entry size, junk entry size",
|
||||
@@ -394,6 +422,9 @@ func TestRaft_ParseConfig(t *testing.T) {
|
||||
for _, warn := range tc.wantWarns {
|
||||
require.Contains(t, allLogs, warn)
|
||||
}
|
||||
if len(tc.wantWarns) == 0 {
|
||||
require.NotContains(t, allLogs, "[WARN]", "no warnings expected")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,5 @@ func (b *RaftBackend) entrySizeLimitForPath(path string) uint64 {
|
||||
}
|
||||
|
||||
func emitEntWarning(logger hclog.Logger, field string) {
|
||||
logger.Warn("%s is configuration for a Vault Enterprise feature and has been ignored.", field)
|
||||
logger.Warn("configuration for a Vault Enterprise feature has been ignored", "field", field)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user