Skip to content

Commit

Permalink
Setting up curated packages tests to use regional packages for vSpher…
Browse files Browse the repository at this point in the history
…e tests (#8569)
  • Loading branch information
pokearu authored Aug 6, 2024
1 parent 4bc1f21 commit 6fe21e0
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 34 deletions.
1 change: 1 addition & 0 deletions test/e2e/adot.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func runCuratedPackagesAdotInstall(test *framework.ClusterE2ETest) {

func runCuratedPackagesAdotInstallWithUpdate(test *framework.ClusterE2ETest) {
test.SetPackageBundleActive()
test.ValidateIfRegionalCuratedPackage()
test.CreateNamespace(adotTargetNamespace)
test.InstallCuratedPackage(adotPackageName, adotPackagePrefix+"-"+adotPackageName,
kubeconfig.FromClusterName(test.ClusterName),
Expand Down
1 change: 1 addition & 0 deletions test/e2e/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func runAutoscalerWithMetricsServerSimpleFlow(test *framework.ClusterE2ETest) {
autoscalerName := "cluster-autoscaler"
metricServerName := "metrics-server"
targetNamespace := "eksa-packages"
test.ValidateIfRegionalCuratedPackage()
test.InstallAutoScalerWithMetricServer(targetNamespace)
test.CombinedAutoScalerMetricServerTest(autoscalerName, metricServerName, targetNamespace, withCluster(test))
})
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/curatedpackages.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func runCuratedPackageInstall(test *framework.ClusterE2ETest) {
if err != nil {
test.T.Fatalf("packages controller crds not in installed state: %s", err)
}

test.ValidateIfRegionalCuratedPackage()

packageName := "hello-eks-anywhere"
packagePrefix := "test"
packageFile := test.BuildPackageConfigFile(packageName, packagePrefix, EksaPackagesNamespace)
Expand Down
12 changes: 1 addition & 11 deletions test/e2e/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1352,17 +1352,7 @@ func TestDockerKubernetesRegionalCuratedPackages(t *testing.T) {
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube128)),
)

test.WithCluster(func(e *framework.ClusterE2ETest) {
runCuratedPackageInstall(e)

pbc, err := test.KubectlClient.GetPackageBundleController(context.Background(), test.KubeconfigFilePath(), test.ClusterName)
if err != nil {
e.T.Fatalf("cannot get PackageBundleController: %v", err)
}
if pbc.Spec.DefaultImageRegistry != pbc.Spec.DefaultRegistry {
e.T.Fatal("in regional pbc, DefaultImageRegistry should equal to DefaultRegistry")
}
})
runCuratedPackageInstallSimpleFlow(test)
}

func TestDockerKubernetesUpgradeManagementComponents(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions test/e2e/emissary.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (

func runCuratedPackageEmissaryInstall(test *framework.ClusterE2ETest) {
test.SetPackageBundleActive()
test.ValidateIfRegionalCuratedPackage()
packageFile := test.BuildPackageConfigFile(emissaryPackageName, emissaryPackagePrefix, EksaPackagesNamespace)
test.InstallCuratedPackageFile(packageFile, kubeconfig.FromClusterName(test.ClusterName))
test.VerifyEmissaryPackageInstalled(emissaryPackagePrefix+"-"+emissaryPackageName, withCluster(test))
Expand Down
1 change: 1 addition & 0 deletions test/e2e/harbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

func runCuratedPackageHarborInstallSimpleFlowLocalStorageProvisioner(test *framework.ClusterE2ETest) {
test.WithCluster(func(test *framework.ClusterE2ETest) {
test.ValidateIfRegionalCuratedPackage()
test.InstallLocalStorageProvisioner()

packagePrefix := "test"
Expand Down
1 change: 1 addition & 0 deletions test/e2e/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func runCuratedPackagesPrometheusInstall(test *framework.ClusterE2ETest) {
test.InstallLocalStorageProvisioner()
test.CreateNamespace(prometheusPackageTargetNamespace)
test.SetPackageBundleActive()
test.ValidateIfRegionalCuratedPackage()
test.InstallCuratedPackage(prometheusPackageName, packageFullName,
kubeconfig.FromClusterName(test.ClusterName),
"--set server.persistentVolume.storageClass=local-path")
Expand Down
44 changes: 22 additions & 22 deletions test/e2e/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestVSphereKubernetes126CuratedPackagesSimpleFlow(t *testing.T) {
runCuratedPackageInstallSimpleFlow(test)
}

func TestVSphereKubernetes127CuratedPackagesSimpleFlow(t *testing.T) {
func TestVSphereKubernetes127RegionalCuratedPackagesSimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithUbuntu127()),
Expand All @@ -292,7 +292,7 @@ func TestVSphereKubernetes128CuratedPackagesSimpleFlow(t *testing.T) {
runCuratedPackageInstallSimpleFlow(test)
}

func TestVSphereKubernetes129CuratedPackagesSimpleFlow(t *testing.T) {
func TestVSphereKubernetes129RegionalCuratedPackagesSimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithUbuntu129()),
Expand Down Expand Up @@ -328,7 +328,7 @@ func TestVSphereKubernetes126BottleRocketCuratedPackagesSimpleFlow(t *testing.T)
runCuratedPackageInstallSimpleFlow(test)
}

func TestVSphereKubernetes127BottleRocketCuratedPackagesSimpleFlow(t *testing.T) {
func TestVSphereKubernetes127BottleRocketRegionalCuratedPackagesSimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithBottleRocket127()),
Expand All @@ -352,7 +352,7 @@ func TestVSphereKubernetes128BottleRocketCuratedPackagesSimpleFlow(t *testing.T)
runCuratedPackageInstallSimpleFlow(test)
}

func TestVSphereKubernetes129BottleRocketCuratedPackagesSimpleFlow(t *testing.T) {
func TestVSphereKubernetes129BottleRocketRegionalCuratedPackagesSimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithBottleRocket129()),
Expand Down Expand Up @@ -388,7 +388,7 @@ func TestVSphereKubernetes126CuratedPackagesEmissarySimpleFlow(t *testing.T) {
runCuratedPackageEmissaryInstallSimpleFlow(test)
}

func TestVSphereKubernetes127CuratedPackagesEmissarySimpleFlow(t *testing.T) {
func TestVSphereKubernetes127RegionalCuratedPackagesEmissarySimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithUbuntu127()),
Expand All @@ -412,7 +412,7 @@ func TestVSphereKubernetes128CuratedPackagesEmissarySimpleFlow(t *testing.T) {
runCuratedPackageEmissaryInstallSimpleFlow(test)
}

func TestVSphereKubernetes129CuratedPackagesEmissarySimpleFlow(t *testing.T) {
func TestVSphereKubernetes129RegionalCuratedPackagesEmissarySimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithUbuntu129()),
Expand Down Expand Up @@ -448,7 +448,7 @@ func TestVSphereKubernetes126BottleRocketCuratedPackagesEmissarySimpleFlow(t *te
runCuratedPackageEmissaryInstallSimpleFlow(test)
}

func TestVSphereKubernetes127BottleRocketCuratedPackagesEmissarySimpleFlow(t *testing.T) {
func TestVSphereKubernetes127BottleRocketRegionalCuratedPackagesEmissarySimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithBottleRocket127()),
Expand All @@ -472,7 +472,7 @@ func TestVSphereKubernetes128BottleRocketCuratedPackagesEmissarySimpleFlow(t *te
runCuratedPackageEmissaryInstallSimpleFlow(test)
}

func TestVSphereKubernetes129BottleRocketCuratedPackagesEmissarySimpleFlow(t *testing.T) {
func TestVSphereKubernetes129BottleRocketRegionalCuratedPackagesEmissarySimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithBottleRocket129()),
Expand Down Expand Up @@ -508,7 +508,7 @@ func TestVSphereKubernetes126CuratedPackagesHarborSimpleFlow(t *testing.T) {
runCuratedPackageHarborInstallSimpleFlowLocalStorageProvisioner(test)
}

func TestVSphereKubernetes127CuratedPackagesHarborSimpleFlow(t *testing.T) {
func TestVSphereKubernetes127RegionalCuratedPackagesHarborSimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithUbuntu127()),
Expand All @@ -532,7 +532,7 @@ func TestVSphereKubernetes128CuratedPackagesHarborSimpleFlow(t *testing.T) {
runCuratedPackageHarborInstallSimpleFlowLocalStorageProvisioner(test)
}

func TestVSphereKubernetes129CuratedPackagesHarborSimpleFlow(t *testing.T) {
func TestVSphereKubernetes129RegionalCuratedPackagesHarborSimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithUbuntu129()),
Expand Down Expand Up @@ -568,7 +568,7 @@ func TestVSphereKubernetes126BottleRocketCuratedPackagesHarborSimpleFlow(t *test
runCuratedPackageHarborInstallSimpleFlowLocalStorageProvisioner(test)
}

func TestVSphereKubernetes127BottleRocketCuratedPackagesHarborSimpleFlow(t *testing.T) {
func TestVSphereKubernetes127BottleRocketRegionalCuratedPackagesHarborSimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithBottleRocket127()),
Expand All @@ -592,7 +592,7 @@ func TestVSphereKubernetes128BottleRocketCuratedPackagesHarborSimpleFlow(t *test
runCuratedPackageHarborInstallSimpleFlowLocalStorageProvisioner(test)
}

func TestVSphereKubernetes129BottleRocketCuratedPackagesHarborSimpleFlow(t *testing.T) {
func TestVSphereKubernetes129BottleRocketRegionalCuratedPackagesHarborSimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithBottleRocket129()),
Expand Down Expand Up @@ -628,7 +628,7 @@ func TestVSphereKubernetes126CuratedPackagesAdotUpdateFlow(t *testing.T) {
runCuratedPackagesAdotInstallUpdateFlow(test)
}

func TestVSphereKubernetes127CuratedPackagesAdotUpdateFlow(t *testing.T) {
func TestVSphereKubernetes127RegionalCuratedPackagesAdotUpdateFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithUbuntu127()),
Expand All @@ -652,7 +652,7 @@ func TestVSphereKubernetes128CuratedPackagesAdotUpdateFlow(t *testing.T) {
runCuratedPackagesAdotInstallUpdateFlow(test)
}

func TestVSphereKubernetes129CuratedPackagesAdotUpdateFlow(t *testing.T) {
func TestVSphereKubernetes129RegionalCuratedPackagesAdotUpdateFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithUbuntu129()),
Expand Down Expand Up @@ -688,7 +688,7 @@ func TestVSphereKubernetes126BottleRocketCuratedPackagesAdotUpdateFlow(t *testin
runCuratedPackagesAdotInstallUpdateFlow(test)
}

func TestVSphereKubernetes127BottleRocketCuratedPackagesAdotUpdateFlow(t *testing.T) {
func TestVSphereKubernetes127BottleRocketRegionalCuratedPackagesAdotUpdateFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithBottleRocket127()),
Expand All @@ -712,7 +712,7 @@ func TestVSphereKubernetes128BottleRocketCuratedPackagesAdotUpdateFlow(t *testin
runCuratedPackagesAdotInstallUpdateFlow(test)
}

func TestVSphereKubernetes129BottleRocketCuratedPackagesAdotUpdateFlow(t *testing.T) {
func TestVSphereKubernetes129BottleRocketRegionalCuratedPackagesAdotUpdateFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithBottleRocket129()),
Expand Down Expand Up @@ -750,7 +750,7 @@ func TestVSphereKubernetes126UbuntuCuratedPackagesClusterAutoscalerSimpleFlow(t
runAutoscalerWithMetricsServerSimpleFlow(test)
}

func TestVSphereKubernetes127UbuntuCuratedPackagesClusterAutoscalerSimpleFlow(t *testing.T) {
func TestVSphereKubernetes127UbuntuRegionalCuratedPackagesClusterAutoscalerSimpleFlow(t *testing.T) {
minNodes := 1
maxNodes := 2
framework.CheckCuratedPackagesCredentials(t)
Expand Down Expand Up @@ -778,7 +778,7 @@ func TestVSphereKubernetes128UbuntuCuratedPackagesClusterAutoscalerSimpleFlow(t
runAutoscalerWithMetricsServerSimpleFlow(test)
}

func TestVSphereKubernetes129UbuntuCuratedPackagesClusterAutoscalerSimpleFlow(t *testing.T) {
func TestVSphereKubernetes129UbuntuRegionalCuratedPackagesClusterAutoscalerSimpleFlow(t *testing.T) {
minNodes := 1
maxNodes := 2
framework.CheckCuratedPackagesCredentials(t)
Expand Down Expand Up @@ -820,7 +820,7 @@ func TestVSphereKubernetes126BottleRocketCuratedPackagesClusterAutoscalerSimpleF
runAutoscalerWithMetricsServerSimpleFlow(test)
}

func TestVSphereKubernetes127BottleRocketCuratedPackagesClusterAutoscalerSimpleFlow(t *testing.T) {
func TestVSphereKubernetes127BottleRocketRegionalCuratedPackagesClusterAutoscalerSimpleFlow(t *testing.T) {
minNodes := 1
maxNodes := 2
framework.CheckCuratedPackagesCredentials(t)
Expand Down Expand Up @@ -915,7 +915,7 @@ func TestVSphereKubernetes126UbuntuCuratedPackagesPrometheusSimpleFlow(t *testin
runCuratedPackagesPrometheusInstallSimpleFlow(test)
}

func TestVSphereKubernetes127UbuntuCuratedPackagesPrometheusSimpleFlow(t *testing.T) {
func TestVSphereKubernetes127UbuntuRegionalCuratedPackagesPrometheusSimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithUbuntu127()),
Expand All @@ -939,7 +939,7 @@ func TestVSphereKubernetes128UbuntuCuratedPackagesPrometheusSimpleFlow(t *testin
runCuratedPackagesPrometheusInstallSimpleFlow(test)
}

func TestVSphereKubernetes129UbuntuCuratedPackagesPrometheusSimpleFlow(t *testing.T) {
func TestVSphereKubernetes129UbuntuRegionalCuratedPackagesPrometheusSimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithUbuntu129()),
Expand Down Expand Up @@ -975,7 +975,7 @@ func TestVSphereKubernetes126BottleRocketCuratedPackagesPrometheusSimpleFlow(t *
runCuratedPackagesPrometheusInstallSimpleFlow(test)
}

func TestVSphereKubernetes127BottleRocketCuratedPackagesPrometheusSimpleFlow(t *testing.T) {
func TestVSphereKubernetes127BottleRocketRegionalCuratedPackagesPrometheusSimpleFlow(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewVSphere(t, framework.WithBottleRocket127()),
Expand Down
15 changes: 15 additions & 0 deletions test/framework/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"os/exec"
"path/filepath"
"regexp"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -1172,6 +1173,20 @@ func (e *ClusterE2ETest) InstallCuratedPackageFile(packageFile, kubeconfig strin
})
}

// ValidateIfRegionalCuratedPackage checks if the current e2e test is a Regional Curated packages test and runs a validation.
func (e *ClusterE2ETest) ValidateIfRegionalCuratedPackage() {
regionalPackagesRegex := `^.*RegionalCuratedPackages.*$`
if regexp.MustCompile(regionalPackagesRegex).MatchString(e.T.Name()) {
pbc, err := e.KubectlClient.GetPackageBundleController(context.Background(), e.KubeconfigFilePath(), e.ClusterName)
if err != nil {
e.T.Fatalf("cannot get PackageBundleController: %v", err)
}
if pbc.Spec.DefaultImageRegistry != pbc.Spec.DefaultRegistry {
e.T.Fatal("in regional pbc, DefaultImageRegistry should equal to DefaultRegistry")
}
}
}

func (e *ClusterE2ETest) generatePackageConfig(ns, targetns, prefix, packageName string) []byte {
yamlB := make([][]byte, 0, 4)
generatedName := fmt.Sprintf("%s-%s", prefix, packageName)
Expand Down
41 changes: 41 additions & 0 deletions test/framework/cluster_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package framework

import (
"bytes"
"encoding/json"
"testing"

"github.com/golang/mock/gomock"

packagesv1 "github.com/aws/eks-anywhere-packages/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/executables"
mockexecutables "github.com/aws/eks-anywhere/pkg/executables/mocks"
)

func TestValidateIfRegionalCuratedPackage(t *testing.T) {
ctrl := gomock.NewController(t)
executable := mockexecutables.NewMockExecutable(ctrl)
testPbc := &packagesv1.PackageBundleController{
Spec: packagesv1.PackageBundleControllerSpec{
DefaultRegistry: "123.ecr",
DefaultImageRegistry: "123.ecr",
},
}
respJSON, err := json.Marshal(testPbc)
if err != nil {
t.Errorf("marshaling test service: %s", err)
}
ret := bytes.NewBuffer(respJSON)
expectedParam := []string{"get", "packagebundlecontroller.packages.eks.amazonaws.com", "test", "-o", "json", "--kubeconfig", "test/test-eks-a-cluster.kubeconfig", "--namespace", "eksa-packages", "--ignore-not-found=true"}
t.Run("IsARegionalCuratedPackagesTest", func(t *testing.T) {
e := &ClusterE2ETest{
T: t,
ClusterConfigFolder: "test",
ClusterName: "test",
KubectlClient: executables.NewKubectl(executable),
}

executable.EXPECT().Execute(gomock.Any(), gomock.Eq(expectedParam)).Return(*ret, nil).AnyTimes()
e.ValidateIfRegionalCuratedPackage()
})
}
2 changes: 1 addition & 1 deletion test/framework/testingt.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (t LoggingOnlyT) Logf(format string, args ...any) {

// Name implements T.
func (t LoggingOnlyT) Name() string {
panic("LoggingOnlyT implements only the logging methods of T")
return (&testing.T{}).Name()
}

// Parallel implements T.
Expand Down

0 comments on commit 6fe21e0

Please sign in to comment.