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 16, 2023
1 parent c50df49 commit 20e48e2
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 1 deletion.
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
}
26 changes: 26 additions & 0 deletions test/e2e/oob.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package e2e

import (
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/test/framework"
)

func runOOBConfigFlow(test *framework.ClusterE2ETest) {
test.GenerateClusterConfig()
test.GenerateHardwareConfig()
test.CreateCluster(framework.WithControlPlaneWaitTimeout("20m"))
test.DeleteCluster()
test.PowerOffHardware()
test.ValidateHardwareDecommissioned()
}

func runOOBConfigUpgradeFlow(test *framework.ClusterE2ETest, updateVersion v1alpha1.KubernetesVersion, clusterOpts ...framework.ClusterE2ETestOpt) {
test.GenerateClusterConfig()
test.GenerateHardwareConfig()
test.CreateCluster(framework.WithControlPlaneWaitTimeout("20m"))
test.UpgradeClusterWithNewConfig(clusterOpts)
test.ValidateCluster(updateVersion)
test.StopIfFailed()
test.DeleteCluster()
test.ValidateHardwareDecommissioned()
}
32 changes: 31 additions & 1 deletion test/e2e/tinkerbell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,7 @@ func TestTinkerbellKubernetes128SingleNodeSkipPowerActions(t *testing.T) {
}

func TestTinkerbellKubernetes128UbuntuControlPlaneScaleUp(t *testing.T) {
provider := framework.NewTinkerbell(t, framework.WithUbuntu128Tinkerbell())
provider := framework.NewTinkerbell(t, framework.WithUbuntu127Tinkerbell())
test := framework.NewClusterE2ETest(
t,
provider,
Expand Down Expand Up @@ -2125,3 +2125,33 @@ func TestTinkerbellAirgappedKubernetes128UbuntuProxyConfigFlow(t *testing.T) {

runTinkerbellAirgapConfigProxyFlow(test, "10.80.0.0/16")
}

// OOB test
func TestTinkerbellKubernetes127UbuntuOOB(t *testing.T) {
test := framework.NewClusterE2ETest(
t,
framework.NewTinkerbell(t, framework.WithUbuntu127Tinkerbell()),
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube127)),
framework.WithOOBConfiguration(),
framework.WithControlPlaneHardware(1),
framework.WithWorkerHardware(1),
)
runOOBConfigFlow(test)
}

func TestTinkerbellK8sUpgrade127to128WithUbuntuOOB(t *testing.T) {
test := framework.NewClusterE2ETest(
t,
framework.NewTinkerbell(t, framework.WithUbuntu127Tinkerbell()),
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube127)),
framework.WithOOBConfiguration(),
framework.WithControlPlaneHardware(1),
framework.WithWorkerHardware(1),
)
runOOBConfigUpgradeFlow(
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
52 changes: 52 additions & 0 deletions test/framework/oob.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package framework

import (
"os"
)

const (
// oob related stuff
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,
}

func RequiredOOBEnvVars() []string {
return requiredOOBEnvVars
}

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 20e48e2

Please sign in to comment.