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 f61f6fb
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 0 deletions.
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 {

Check failure on line 10 in internal/test/e2e/oob.go

View workflow job for this annotation

GitHub Actions / lint

func `(*E2ESession).setupOOBEnv` is unused (unused)
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) {

Check failure on line 8 in test/e2e/oob.go

View workflow job for this annotation

GitHub Actions / lint

func `runOOBConfigFlow` is unused (unused)
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) {

Check failure on line 17 in test/e2e/oob.go

View workflow job for this annotation

GitHub Actions / lint

func `runOOBConfigUpgradeFlow` is unused (unused)
test.GenerateClusterConfig()
test.GenerateHardwareConfig()
test.CreateCluster(framework.WithControlPlaneWaitTimeout("20m"))
test.UpgradeClusterWithNewConfig(clusterOpts)
test.ValidateCluster(updateVersion)
test.StopIfFailed()
test.DeleteCluster()
test.ValidateHardwareDecommissioned()
}
30 changes: 30 additions & 0 deletions test/e2e/tinkerbell_test.go
Original file line number Diff line number Diff line change
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

Check failure on line 8 in test/framework/oob.go

View workflow job for this annotation

GitHub Actions / lint

Comment should end in a period (godot)
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 {

Check warning on line 22 in test/framework/oob.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported function RequiredOOBEnvVars should have comment or be unexported (revive)
return requiredOOBEnvVars
}

func WithOOBConfiguration() ClusterE2ETestOpt {

Check warning on line 26 in test/framework/oob.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported function WithOOBConfiguration should have comment or be unexported (revive)
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 f61f6fb

Please sign in to comment.