Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tinkerbell airgapped e2e tests #7117

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 9 additions & 8 deletions test/e2e/airgap.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

const (
bottlerocketOSFileName = "bottlerocket.img.gz"
bottlerocketOSFileName = "bottlerocket"
airgapUsername = "airgap"
bundleReleasePathFromArtifacts = "./eks-anywhere-downloads/bundle-release.yaml"
)
Expand All @@ -37,7 +37,7 @@ func runAirgapConfigFlow(test *framework.ClusterE2ETest, localCIDRs string) {
test.DeleteCluster()
}

func runTinkerbellAirgapConfigFlow(test *framework.ClusterE2ETest, localCIDRs string) {
func runTinkerbellAirgapConfigFlow(test *framework.ClusterE2ETest, localCIDRs, kubeVersion string) {
test.DownloadArtifacts()
test.ExtractDownloadedArtifacts()

Expand All @@ -46,7 +46,7 @@ func runTinkerbellAirgapConfigFlow(test *framework.ClusterE2ETest, localCIDRs st
test.T.Fatalf("Cannot read bundleRelease file: %v", err)
}

server := downloadAndServeTinkerbellArtifacts(test.T, brContent)
server := downloadAndServeTinkerbellArtifacts(test.T, brContent, kubeVersion)
defer server.Shutdown(context.Background())

test.GenerateClusterConfig()
Expand All @@ -69,7 +69,7 @@ func runTinkerbellAirgapConfigFlow(test *framework.ClusterE2ETest, localCIDRs st
test.ValidateHardwareDecommissioned()
}

func runTinkerbellAirgapConfigProxyFlow(test *framework.ClusterE2ETest, localCIDRs string) {
func runTinkerbellAirgapConfigProxyFlow(test *framework.ClusterE2ETest, localCIDRs, kubeVersion string) {
test.DownloadArtifacts()
test.ExtractDownloadedArtifacts()
// for testing proxy feature in an air gapped env
Expand All @@ -79,7 +79,7 @@ func runTinkerbellAirgapConfigProxyFlow(test *framework.ClusterE2ETest, localCID
test.T.Fatalf("Cannot read bundleRelease file: %v", err)
}

server := downloadAndServeTinkerbellArtifacts(test.T, brContent)
server := downloadAndServeTinkerbellArtifacts(test.T, brContent, kubeVersion)
defer server.Shutdown(context.Background())

test.GenerateClusterConfig()
Expand Down Expand Up @@ -123,7 +123,7 @@ func downloadFile(url string, output string) error {
return nil
}

func downloadAndServeTinkerbellArtifacts(t framework.T, bundleRelease []byte) *http.Server {
func downloadAndServeTinkerbellArtifacts(t framework.T, bundleRelease []byte, kubeVersion string) *http.Server {
initramfsUrl := regexp.MustCompile(`https://.*/hook/.*initramfs-x86_64`).Find(bundleRelease)
if initramfsUrl == nil {
t.Fatalf("Cannot find initramfsUrl from release bundle")
Expand All @@ -134,7 +134,7 @@ func downloadAndServeTinkerbellArtifacts(t framework.T, bundleRelease []byte) *h
t.Fatalf("Cannot find vmlinuzUrl from release bundle")
}

brOsUrl := regexp.MustCompile(`https://.*/raw/1-24/.*bottlerocket.*amd64.img.gz`).Find(bundleRelease)
brOsUrl := regexp.MustCompile(fmt.Sprintf("https://.*/raw/%s/.*bottlerocket.*amd64.img.gz", kubeVersion)).Find(bundleRelease)
if brOsUrl == nil {
t.Fatalf("Cannot find bottlerocketOS url from release bundle")
}
Expand All @@ -158,7 +158,8 @@ func downloadAndServeTinkerbellArtifacts(t framework.T, bundleRelease []byte) *h
}

t.Logf("Download bottlerocket OS from %s", brOsUrl)
err = downloadFile(string(brOsUrl), dir+"/"+bottlerocketOSFileName)
// Save image file with kube version in the image name to satisfy condition to have kube version in the template name.
err = downloadFile(string(brOsUrl), dir+"/"+bottlerocketOSFileName+"-"+kubeVersion+".img.gz")
if err != nil {
t.Fatal(err)
}
Expand Down
16 changes: 12 additions & 4 deletions test/e2e/tinkerbell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package e2e

import (
"strings"
"testing"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -2106,12 +2107,15 @@ func TestTinkerbellAirgappedKubernetes128BottleRocketRegistryMirror(t *testing.T
}
t.Logf("Admin machine's IP is: %s", localIp)

// Append kube version in the image name to satisfy condition to have kube version in the template name.
kubeVersion := strings.Replace(string(v1alpha1.Kube128), ".", "-", 1)

test := framework.NewClusterE2ETest(
t,
framework.NewTinkerbell(t,
framework.WithBottleRocketTinkerbell(),
framework.WithHookImagesURLPath("http://"+localIp.String()+":8080"),
framework.WithOSImageURL("http://"+localIp.String()+":8080/"+bottlerocketOSFileName),
framework.WithOSImageURL("http://"+localIp.String()+":8080/"+bottlerocketOSFileName+"-"+kubeVersion+".img.gz"),
),
framework.WithClusterFiller(
api.WithKubernetesVersion(v1alpha1.Kube128),
Expand All @@ -2121,7 +2125,7 @@ func TestTinkerbellAirgappedKubernetes128BottleRocketRegistryMirror(t *testing.T
framework.WithRegistryMirrorEndpointAndCert(constants.TinkerbellProviderName),
)

runTinkerbellAirgapConfigFlow(test, "10.80.0.0/16")
runTinkerbellAirgapConfigFlow(test, "10.80.0.0/16", kubeVersion)
}

// Proxy tests
Expand All @@ -2133,6 +2137,8 @@ func TestTinkerbellAirgappedKubernetes128BottlerocketProxyConfigFlow(t *testing.
}
t.Logf("Admin machine's IP is: %s", localIp)

kubeVersion := strings.Replace(string(v1alpha1.Kube128), ".", "-", 1)

test := framework.NewClusterE2ETest(
t,
framework.NewTinkerbell(t,
Expand All @@ -2147,7 +2153,7 @@ func TestTinkerbellAirgappedKubernetes128BottlerocketProxyConfigFlow(t *testing.
framework.WithProxy(framework.TinkerbellProxyRequiredEnvVars),
)

runTinkerbellAirgapConfigProxyFlow(test, "10.80.0.0/16")
runTinkerbellAirgapConfigProxyFlow(test, "10.80.0.0/16", kubeVersion)
}

func TestTinkerbellAirgappedKubernetes128UbuntuProxyConfigFlow(t *testing.T) {
Expand All @@ -2157,6 +2163,8 @@ func TestTinkerbellAirgappedKubernetes128UbuntuProxyConfigFlow(t *testing.T) {
}
t.Logf("Admin machine's IP is: %s", localIp)

kubeVersion := strings.Replace(string(v1alpha1.Kube128), ".", "-", 1)

test := framework.NewClusterE2ETest(
t,
framework.NewTinkerbell(t,
Expand All @@ -2171,7 +2179,7 @@ func TestTinkerbellAirgappedKubernetes128UbuntuProxyConfigFlow(t *testing.T) {
framework.WithProxy(framework.TinkerbellProxyRequiredEnvVars),
)

runTinkerbellAirgapConfigProxyFlow(test, "10.80.0.0/16")
runTinkerbellAirgapConfigProxyFlow(test, "10.80.0.0/16", kubeVersion)
}

// OOB test
Expand Down