Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions acceptance/framework/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type TestConfig struct {
VaultServerVersion string

NoCleanupOnFailure bool
NoCleanupWanFed bool
Comment thread
20sr20 marked this conversation as resolved.
Outdated
TestDuration string
DebugDirectory string

UseAKS bool
Expand Down
73 changes: 36 additions & 37 deletions acceptance/framework/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type TestFlags struct {
flagHCPResourceID string

flagNoCleanupOnFailure bool
flagNoCleanupWanFed bool
flagTestDuration string

flagDebugDirectory string

Expand Down Expand Up @@ -116,6 +118,11 @@ func (t *TestFlags) init() {
"If true, the tests will not cleanup Kubernetes resources they create when they finish running."+
"Note this flag must be run with -failfast flag, otherwise subsequent tests will fail.")

flag.BoolVar(&t.flagNoCleanupWanFed, "no-cleanup-wan-fed", false,
"If true, the tests will not cleanup Kubernetes resources for Vault Wan Fed test")

flag.StringVar(&t.flagTestDuration, "test-duration", " ", "The time you need to work on the test.")

flag.StringVar(&t.flagDebugDirectory, "debug-directory", "", "The directory where to write debug information about failed test runs, "+
"such as logs and pod definitions. If not provided, a temporary directory will be created by the tests.")

Expand Down Expand Up @@ -155,43 +162,35 @@ func (t *TestFlags) TestConfigFromFlags() *config.TestConfig {
//vaultserverVersion, _ := version.NewVersion(t.flagVaultServerVersion)

return &config.TestConfig{
Kubeconfig: t.flagKubeconfig,
KubeContext: t.flagKubecontext,
KubeNamespace: t.flagNamespace,

EnableMultiCluster: t.flagEnableMultiCluster,
SecondaryKubeconfig: t.flagSecondaryKubeconfig,
SecondaryKubeContext: t.flagSecondaryKubecontext,
SecondaryKubeNamespace: t.flagSecondaryNamespace,

EnableEnterprise: t.flagEnableEnterprise,
EnterpriseLicense: t.flagEnterpriseLicense,

EnableOpenshift: t.flagEnableOpenshift,

Kubeconfig: t.flagKubeconfig,
KubeContext: t.flagKubecontext,
KubeNamespace: t.flagNamespace,
EnableMultiCluster: t.flagEnableMultiCluster,
SecondaryKubeconfig: t.flagSecondaryKubeconfig,
SecondaryKubeContext: t.flagSecondaryKubecontext,
SecondaryKubeNamespace: t.flagSecondaryNamespace,
EnableEnterprise: t.flagEnableEnterprise,
EnterpriseLicense: t.flagEnterpriseLicense,
EnableOpenshift: t.flagEnableOpenshift,
EnablePodSecurityPolicies: t.flagEnablePodSecurityPolicies,

EnableCNI: t.flagEnableCNI,

EnableTransparentProxy: t.flagEnableTransparentProxy,

DisablePeering: t.flagDisablePeering,

HelmChartVersion: t.flagHelmChartVersion,
ConsulImage: t.flagConsulImage,
ConsulK8SImage: t.flagConsulK8sImage,
ConsulVersion: consulVersion,
EnvoyImage: t.flagEnvoyImage,
ConsulCollectorImage: t.flagConsulCollectorImage,
VaultHelmChartVersion: t.flagVaultHelmChartVersion,
VaultServerVersion: t.flagVaultServerVersion,

HCPResourceID: t.flagHCPResourceID,

NoCleanupOnFailure: t.flagNoCleanupOnFailure,
DebugDirectory: tempDir,
UseAKS: t.flagUseAKS,
UseGKE: t.flagUseGKE,
UseKind: t.flagUseKind,
EnableCNI: t.flagEnableCNI,
EnableTransparentProxy: t.flagEnableTransparentProxy,
DisablePeering: t.flagDisablePeering,
HelmChartVersion: t.flagHelmChartVersion,
ConsulImage: t.flagConsulImage,
ConsulK8SImage: t.flagConsulK8sImage,
ConsulVersion: consulVersion,
EnvoyImage: t.flagEnvoyImage,
ConsulCollectorImage: t.flagConsulCollectorImage,
HCPResourceID: t.flagHCPResourceID,
VaultHelmChartVersion: t.flagVaultHelmChartVersion,
VaultServerVersion: t.flagVaultServerVersion,
NoCleanupOnFailure: t.flagNoCleanupOnFailure,
NoCleanupWanFed: t.flagNoCleanupWanFed,
TestDuration: t.flagTestDuration,
DebugDirectory: tempDir,
UseAKS: t.flagUseAKS,
UseGKE: t.flagUseGKE,
UseKind: t.flagUseKind,
}
}
23 changes: 23 additions & 0 deletions acceptance/framework/vault/vault_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ package vault
import (
"context"
"fmt"
"os"
"strings"
"testing"
"time"

"github.com/gruntwork-io/terratest/modules/helm"
terratestk8s "github.com/gruntwork-io/terratest/modules/k8s"
terratestLogger "github.com/gruntwork-io/terratest/modules/logger"
"github.com/hashicorp/consul-k8s/acceptance/framework/config"
"github.com/hashicorp/consul-k8s/acceptance/framework/consul"
"github.com/hashicorp/consul-k8s/acceptance/framework/environment"
"github.com/hashicorp/consul-k8s/acceptance/framework/helpers"
"github.com/hashicorp/consul-k8s/acceptance/framework/k8s"
Expand Down Expand Up @@ -54,12 +57,32 @@ func NewVaultCluster(t *testing.T, ctx environment.TestContext, cfg *config.Test
logger := terratestLogger.New(logger.TestLogger{})

kopts := ctx.KubectlOptions(t)
ns := ctx.KubectlOptions(t).Namespace

entstr := "-ent"

values := defaultHelmValues(releaseName)
if cfg.EnablePodSecurityPolicies {
values["global.psp.enable"] = "true"
}
vaultReleaseName := helpers.RandomName()
k8sClient := environment.KubernetesClientFromOptions(t, ctx.KubectlOptions(t))
vaultLicenseSecretName := fmt.Sprintf("%s-enterprise-license", vaultReleaseName)
vaultLicenseSecretKey := "license"

vaultEnterpriseLicense := os.Getenv("VAULT_LICENSE")

if cfg.VaultServerVersion != "" {

if strings.Contains(cfg.VaultServerVersion, entstr) {

//logger.Log(t, "Creating secret for Vault license")
Comment thread
20sr20 marked this conversation as resolved.
Outdated
consul.CreateK8sSecret(t, k8sClient, cfg, ns, vaultLicenseSecretName, vaultLicenseSecretKey, vaultEnterpriseLicense)

values["server.image.repository"] = "docker.mirror.hashicorp.services/hashicorp/vault-enterprise"
values["server.enterpriseLicense.secretName"] = vaultLicenseSecretName
values["server.enterpriseLicense.secretKey"] = vaultLicenseSecretKey
}
values["server.image.tag"] = cfg.VaultServerVersion
}
vaultHelmChartVersion := defaultVaultHelmChartVersion
Expand Down
23 changes: 20 additions & 3 deletions acceptance/tests/vault/vault_wan_fed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package vault
import (
"context"
"fmt"
"strconv"
"testing"
"time"

"github.com/hashicorp/consul-k8s/acceptance/framework/config"
"github.com/hashicorp/consul-k8s/acceptance/framework/consul"
Expand All @@ -31,9 +33,9 @@ import (
// in the secondary that will treat the Vault server in the primary as an external server.
func TestVault_WANFederationViaGateways(t *testing.T) {
cfg := suite.Config()
if cfg.UseKind {
t.Skipf("Skipping this test because it's currently flaky on kind")
}
//if cfg.UseKind {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder: add back?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added back

// t.Skipf("Skipping this test because it's currently flaky on kind")
//}
if !cfg.EnableMultiCluster {
t.Skipf("skipping this test because -enable-multi-cluster is not set")
}
Expand Down Expand Up @@ -491,11 +493,13 @@ func TestVault_WANFederationViaGateways(t *testing.T) {
logger.Log(t, "creating proxy-defaults config")
kustomizeDir := "../fixtures/bases/mesh-gateway"
k8s.KubectlApplyK(t, primaryCtx.KubectlOptions(t), kustomizeDir)

helpers.Cleanup(t, cfg.NoCleanupOnFailure, func() {
k8s.KubectlDeleteK(t, primaryCtx.KubectlOptions(t), kustomizeDir)
})

// Check that we can connect services over the mesh gateways.

logger.Log(t, "creating static-server in dc2")
k8s.DeployKustomize(t, secondaryCtx.KubectlOptions(t), cfg.NoCleanupOnFailure, cfg.DebugDirectory, "../fixtures/cases/static-server-inject")

Expand All @@ -517,6 +521,19 @@ func TestVault_WANFederationViaGateways(t *testing.T) {

logger.Log(t, "checking that connection is successful")
k8s.CheckStaticServerConnectionSuccessful(t, primaryCtx.KubectlOptions(t), StaticClientName, "http://localhost:1234")

if cfg.NoCleanupWanFed {
//time.Sleep(1800 * time.Second)
intVar, err := strconv.Atoi(cfg.TestDuration)
Comment thread
20sr20 marked this conversation as resolved.
Outdated

if err != nil {
logger.Log(t, "Couldn't convert string to int")

}
time.Sleep(time.Duration(intVar) * time.Hour)

}

}

// vaultAddress returns Vault's server URL depending on test configuration.
Expand Down
12 changes: 12 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
go 1.20
Comment thread
20sr20 marked this conversation as resolved.
Outdated

use (
./acceptance
./charts
./cli
./control-plane
./control-plane/cni
./hack/aws-acceptance-test-cleanup
./hack/copy-crds-to-chart
./hack/helm-reference-gen
)
Loading