Don't require every test to specify a VaultLicense field (#20372)

This commit is contained in:
Nick Cabatoff 2023-04-26 14:39:48 -04:00 committed by GitHub
parent cbb5b2fa22
commit f5b5662122
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 7 deletions

View File

@ -36,8 +36,6 @@ const (
GenerateRecovery
)
const VAULT_LICENSE_CI_ENV = "VAULT_LICENSE_CI"
// GenerateRoot generates a root token on the target cluster.
func GenerateRoot(t testing.T, cluster *vault.TestCluster, kind GenerateRootKind) string {
t.Helper()

View File

@ -0,0 +1,8 @@
package testcluster
const (
// EnvVaultLicenseCI is the name of an environment variable that contains
// a signed license string used for Vault Enterprise binary-based tests.
// The binary will be run with the env var VAULT_LICENSE set to this value.
EnvVaultLicenseCI = "VAULT_LICENSE_CI"
)

View File

@ -406,6 +406,9 @@ func NewTestDockerCluster(t *testing.T, opts *DockerClusterOptions) *DockerClust
if opts.NetworkName == "" {
opts.NetworkName = os.Getenv("TEST_DOCKER_NETWORK_NAME")
}
if opts.VaultLicense == "" {
opts.VaultLicense = os.Getenv(testcluster.EnvVaultLicenseCI)
}
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
t.Cleanup(cancel)

View File

@ -59,6 +59,9 @@ func NewTestExecDevCluster(t *testing.T, opts *ExecDevClusterOptions) *ExecDevCl
if opts.Logger == nil {
opts.Logger = logging.NewVaultLogger(log.Trace).Named(t.Name()) // .Named("container")
}
if opts.VaultLicense == "" {
opts.VaultLicense = os.Getenv(EnvVaultLicenseCI)
}
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
t.Cleanup(cancel)

View File

@ -15,7 +15,6 @@ import (
"github.com/hashicorp/go-cleanhttp"
"github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/helper/testhelpers"
vaulthttp "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/internalshared/configutil"
"github.com/hashicorp/vault/sdk/helper/testcluster"
@ -51,8 +50,7 @@ func TestSysPprof_Exec(t *testing.T) {
}
cluster := testcluster.NewTestExecDevCluster(t, &testcluster.ExecDevClusterOptions{
ClusterOptions: testcluster.ClusterOptions{
NumCores: 1,
VaultLicense: os.Getenv(testhelpers.VAULT_LICENSE_CI_ENV),
NumCores: 1,
},
BinaryPath: binary,
BaseListenAddress: "127.0.0.1:8208",
@ -248,7 +246,6 @@ func TestSysPprof_Standby_Exec(t *testing.T) {
VaultNodeConfig: &testcluster.VaultNodeConfig{
DisablePerformanceStandby: true,
},
VaultLicense: os.Getenv(testhelpers.VAULT_LICENSE_CI_ENV),
},
BinaryPath: binary,
BaseListenAddress: "127.0.0.1:8210",

View File

@ -468,7 +468,6 @@ func TestRaft_Configuration_Docker(t *testing.T) {
// "performance_multiplier": "1",
//},
},
VaultLicense: os.Getenv(testhelpers.VAULT_LICENSE_CI_ENV),
},
}
cluster := docker.NewTestDockerCluster(t, opts)