Skip to content

Commit

Permalink
Add e2e for oob configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ahreehong committed Oct 17, 2023
1 parent c50df49 commit 039debc
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ env:
T_HTTP_PROXY_TINKERBELL: "proxy-config-data:httpProxyTinkerbell"
T_HTTPS_PROXY_TINKERBELL: "proxy-config-data:httpsProxyTinkerbell"
T_NO_PROXY_TINKERBELL: "proxy-config-data:noProxyTinkerbell"
T_TINKERBELL_BMC_CONSUMER_URL: "tinkerbell_ci:bmc_consumer_url"
T_TINKERBELL_BMC_HMAC_SECRETS: "tinkerbell_ci:bmc_hmac_secrets"
T_TINKERBELL_BMC_TIMESTAMP_HEADER: "tinkerbell_ci:bmc_timestamp_header"
T_TINKERBELL_BMC_INCLUDED_PAYLOAD_HEADERS: "tinkerbell_ci:bmc_included_payload_headers"
phases:
pre_build:
commands:
Expand Down
23 changes: 23 additions & 0 deletions internal/test/e2e/oob.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package e2e

import (
"os"
"regexp"

e2etests "github.com/aws/eks-anywhere/test/framework"
)

func (e *E2ESession) setupOOBEnv(testRegex string) error {
re := regexp.MustCompile(`^.*OOB.*$`)
if !re.MatchString(testRegex) {
return nil
}

requiredEnvVars := e2etests.RequiredOOBEnvVars()
for _, eVar := range requiredEnvVars {
if val, ok := os.LookupEnv(eVar); ok {
e.testEnvVars[eVar] = val
}
}
return nil
}
5 changes: 5 additions & 0 deletions internal/test/e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ func (e *E2ESession) setup(regex string) error {
return err
}

err = e.setupOOBEnv(regex)
if err != nil {
return err
}

err = e.setupPackagesEnv(regex)
if err != nil {
return err
Expand Down
31 changes: 31 additions & 0 deletions test/e2e/tinkerbell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2125,3 +2125,34 @@ func TestTinkerbellAirgappedKubernetes128UbuntuProxyConfigFlow(t *testing.T) {

runTinkerbellAirgapConfigProxyFlow(test, "10.80.0.0/16")
}

// OOB test
func TestTinkerbellKubernetes128UbuntuOOB(t *testing.T) {
test := framework.NewClusterE2ETest(
t,
framework.NewTinkerbell(t, framework.WithUbuntu128Tinkerbell()),
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube128)),
framework.WithOOBConfiguration(),
framework.WithControlPlaneHardware(1),
framework.WithWorkerHardware(1),
)
runTinkerbellSimpleFlow(test)
}

func TestTinkerbellK8sUpgrade127to128WithUbuntuOOB(t *testing.T) {
provider := framework.NewTinkerbell(t, framework.WithUbuntu127Tinkerbell())
test := framework.NewClusterE2ETest(
t,
provider,
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube127)),
framework.WithOOBConfiguration(),
framework.WithControlPlaneHardware(1),
framework.WithWorkerHardware(1),
)
runSimpleUpgradeFlowForBareMetal(
test,
v1alpha1.Kube128,
framework.WithClusterUpgrade(api.WithKubernetesVersion(v1alpha1.Kube128)),
provider.WithProviderUpgrade(framework.Ubuntu128Image()),
)
}
12 changes: 12 additions & 0 deletions test/framework/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type ClusterE2ETest struct {
TestHardware map[string]*api.Hardware
HardwarePool map[string]*api.Hardware
WithNoPowerActions bool
WithOOBConfiguration bool
ClusterName string
ClusterConfig *cluster.Config
clusterStateValidationConfig *clusterf.StateValidationConfig
Expand Down Expand Up @@ -495,6 +496,17 @@ func (e *ClusterE2ETest) generateHardwareConfig(opts ...CommandOpt) {
}
testHardware = hardwareWithNoBMC
}
// create hardware CSV with no bmc username/password
if e.WithOOBConfiguration {
hardwareWithNoUsernamePassword := make(map[string]*api.Hardware)
for k, h := range testHardware {
lessBmc := *h
lessBmc.BMCUsername = ""
lessBmc.BMCPassword = ""
hardwareWithNoUsernamePassword[k] = &lessBmc
}
testHardware = hardwareWithNoUsernamePassword
}

err := api.WriteHardwareMapToCSV(testHardware, e.HardwareCsvLocation)
if err != nil {
Expand Down
53 changes: 53 additions & 0 deletions test/framework/oob.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package framework

import (
"os"
)

const (
tinkerbellBMCConsumerURL = "T_TINKERBELL_BMC_CONSUMER_URL"
tinkerbellBMCHMACSecret = "T_TINKERBELL_BMC_HMAC_SECRETS"
tinkerbellBMCTimestampHeader = "T_TINKERBELL_BMC_TIMESTAMP_HEADER"
tinkerbellBMCIncludedPayloadHeaders = "T_TINKERBELL_BMC_INCLUDED_PAYLOAD_HEADERS"
)

var requiredOOBEnvVars = []string{
tinkerbellBMCConsumerURL,
tinkerbellBMCHMACSecret,
tinkerbellBMCTimestampHeader,
tinkerbellBMCIncludedPayloadHeaders,
}

// RequiredOOBEnvVars returns the environment variables required to run OOB related e2e tests.
func RequiredOOBEnvVars() []string {
return requiredOOBEnvVars
}

// WithOOBConfiguration sets up the required environment to run OOB e2e tests.
func WithOOBConfiguration() ClusterE2ETestOpt {
return func(e *ClusterE2ETest) {
checkRequiredEnvVars(e.T, requiredOOBEnvVars)
consumerURL := os.Getenv(tinkerbellBMCConsumerURL)
HMACSecret := os.Getenv(tinkerbellBMCHMACSecret)
timestampHeader := os.Getenv(tinkerbellBMCTimestampHeader)
includedPayloadHeaders := os.Getenv(tinkerbellBMCIncludedPayloadHeaders)
err := os.Setenv("TINKERBELL_BMC_CONSUMER_URL", consumerURL)
if err != nil {
e.T.Fatalf("unable to set TINKERBELL_BMC_CONSUMER_URL: %v", err)
}
err = os.Setenv("TINKERBELL_BMC_HMAC_SECRETS", HMACSecret)
if err != nil {
e.T.Fatalf("unable to set TINKERBELL_BMC_HMAC_SECRETS: %v", err)
}
err = os.Setenv("TINKERBELL_BMC_TIMESTAMP_HEADER", timestampHeader)
if err != nil {
e.T.Fatalf("unable to set TINKERBELL_BMC_TIMESTAMP_HEADER: %v", err)
}
err = os.Setenv("TINKERBELL_BMC_INCLUDED_PAYLOAD_HEADERS", includedPayloadHeaders)
if err != nil {
e.T.Fatalf("unable to set TINKERBELL_BMC_INCLUDED_PAYLOAD_HEADERS: %v", err)
}

e.WithOOBConfiguration = true
}
}

0 comments on commit 039debc

Please sign in to comment.