Skip to content

Commit

Permalink
Merge pull request cert-manager#6387 from wallrj/portable-e2e-test-bi…
Browse files Browse the repository at this point in the history
…nary

Allow the E2E tests to run on clusters that have not been prepared by the Makefile
  • Loading branch information
jetstack-bot committed Oct 4, 2023
2 parents 7c7e8f4 + 0b7f36a commit 3ac37ba
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions test/e2e/framework/addon/vault/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"fmt"
"math/big"
"net"
"os"
"time"

corev1 "k8s.io/api/core/v1"
Expand All @@ -46,8 +47,12 @@ import (
const (
vaultHelmChartRepo = "https://helm.releases.hashicorp.com"
vaultHelmChartVersion = "0.24.1"
vaultImageRepository = "local/vault"
vaultImageTag = "local"
// This local Vault image is only used when the tests are run using make,
// because it downloads the Vault image, saves it in the scratch folder on
// the filesystem, and copies it to the cluster-under-test before the E2E
// tests get executed.
vaultImageRepository = "local/vault"
vaultImageTag = "local"
)

// Vault describes the configuration details for an instance of Vault
Expand Down Expand Up @@ -182,19 +187,6 @@ func (v *Vault) Setup(cfg *config.Config, leaderData ...internal.AddonTransferab
Key: "server.volumeMounts[0].mountPath",
Value: "/vault/tls",
},
// configure image and repo
{
Key: "server.image.repository",
Value: vaultImageRepository,
},
{
Key: "server.image.tag",
Value: vaultImageTag,
},
{
Key: "server.image.pullPolicy",
Value: "Never",
},
// configure resource requests
{
Key: "server.resources.requests.cpu",
Expand All @@ -206,6 +198,38 @@ func (v *Vault) Setup(cfg *config.Config, leaderData ...internal.AddonTransferab
},
},
}

// When the tests have been launched by make, the cluster will be a kind
// cluster into which we will have loaded some locally cached Vault images.
// But we also want people to be able to compile the E2E test binary and run
// the tests on their chosen cluster, in which case we do not override the
// Vault image and the default chart image will be downloaded and run
// instead.
// MAKELEVEL is always set by make so that it can know whether it is being
// called recursively, so we use that variable as a marker to know whether
// the tests are being executed from our Makefile. See
// https://www.gnu.org/software/make/manual/html_node/Variables_002fRecursion.html
if os.Getenv("MAKELEVEL") != "" {
v.chart.Vars = append(
v.chart.Vars,
[]chart.StringTuple{
// configure image and repo
{
Key: "server.image.repository",
Value: vaultImageRepository,
},
{
Key: "server.image.tag",
Value: vaultImageTag,
},
{
Key: "server.image.pullPolicy",
Value: "Never",
},
}...,
)
}

_, err := v.chart.Setup(cfg)
if err != nil {
return nil, err
Expand Down

0 comments on commit 3ac37ba

Please sign in to comment.