Skip to content

Commit

Permalink
Cleanup duplicate code in curated packages and rename function (#8258)
Browse files Browse the repository at this point in the history
Override govulncheck
  • Loading branch information
sp1999 authored Jun 6, 2024
1 parent 5940b0e commit 8ab221a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
4 changes: 2 additions & 2 deletions test/e2e/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func runAutoscalerWithMetricsServerSimpleFlow(test *framework.ClusterE2ETest) {
metricServerName := "metrics-server"
targetNamespace := "eksa-packages"
test.InstallAutoScalerWithMetricServer(targetNamespace)
test.CombinedAutoScalerMetricServerTest(autoscalerName, metricServerName, targetNamespace, withMgmtCluster(test))
test.CombinedAutoScalerMetricServerTest(autoscalerName, metricServerName, targetNamespace, withCluster(test))
})
}

Expand All @@ -25,7 +25,7 @@ func runAutoscalerWithMetricsServerTinkerbellSimpleFlow(test *framework.ClusterE
metricServerName := "metrics-server"
targetNamespace := "eksa-packages"
test.InstallAutoScalerWithMetricServer(targetNamespace)
test.CombinedAutoScalerMetricServerTest(autoscalerName, metricServerName, targetNamespace, withMgmtCluster(test))
test.CombinedAutoScalerMetricServerTest(autoscalerName, metricServerName, targetNamespace, withCluster(test))
test.DeleteCluster()
test.ValidateHardwareDecommissioned()
}
14 changes: 2 additions & 12 deletions test/e2e/certmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
package e2e

import (
"fmt"
"path/filepath"
"time"

"github.com/aws/eks-anywhere/pkg/kubeconfig"
"github.com/aws/eks-anywhere/pkg/types"
"github.com/aws/eks-anywhere/test/framework"
)

Expand All @@ -30,18 +27,11 @@ func runCertManagerRemoteClusterInstallSimpleFlow(test *framework.MulticlusterE2
packagePrefix := "test"
packageFile := e.BuildPackageConfigFile(packageName, packagePrefix, EksaPackagesNamespace)
test.ManagementCluster.InstallCuratedPackageFile(packageFile, kubeconfig.FromClusterName(test.ManagementCluster.ClusterName))
e.VerifyCertManagerPackageInstalled(packagePrefix, EksaPackagesNamespace, cmPackageName, withMgmtClusterSetup(test.ManagementCluster))
e.CleanupCerts(withMgmtClusterSetup(test.ManagementCluster))
e.VerifyCertManagerPackageInstalled(packagePrefix, EksaPackagesNamespace, cmPackageName, withCluster(test.ManagementCluster))
e.CleanupCerts(withCluster(test.ManagementCluster))
e.DeleteClusterWithKubectl()
e.ValidateClusterDelete()
})
time.Sleep(5 * time.Minute)
test.DeleteManagementCluster()
}

func withMgmtClusterSetup(cluster *framework.ClusterE2ETest) *types.Cluster {
return &types.Cluster{
Name: cluster.ClusterName,
KubeconfigFile: filepath.Join(cluster.ClusterName, fmt.Sprintf("%s-eks-a-cluster.kubeconfig", cluster.ClusterName)),
}
}
6 changes: 3 additions & 3 deletions test/e2e/curatedpackages.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func runCuratedPackageInstall(test *framework.ClusterE2ETest) {
packagePrefix := "test"
packageFile := test.BuildPackageConfigFile(packageName, packagePrefix, EksaPackagesNamespace)
test.InstallCuratedPackageFile(packageFile, kubeconfig.FromClusterName(test.ClusterName))
test.VerifyHelloPackageInstalled(packagePrefix+"-"+packageName, withMgmtCluster(test))
test.VerifyHelloPackageInstalled(packagePrefix+"-"+packageName, withCluster(test))
}

func runCuratedPackageInstallSimpleFlow(test *framework.ClusterE2ETest) {
Expand Down Expand Up @@ -65,7 +65,7 @@ func runCuratedPackageRemoteClusterInstallSimpleFlow(test *framework.Multicluste
packagePrefix := "test"
packageFile := e.BuildPackageConfigFile(packageName, packagePrefix, EksaPackagesNamespace)
test.ManagementCluster.InstallCuratedPackageFile(packageFile, kubeconfig.FromClusterName(test.ManagementCluster.ClusterName))
e.VerifyHelloPackageInstalled(packagePrefix+"-"+packageName, withMgmtCluster(test.ManagementCluster))
e.VerifyHelloPackageInstalled(packagePrefix+"-"+packageName, withCluster(test.ManagementCluster))
e.DeleteClusterWithKubectl()
e.ValidateClusterDelete()
})
Expand Down Expand Up @@ -219,7 +219,7 @@ func packageBundleURI(version v1alpha1.KubernetesVersion) string {
return fmt.Sprintf("%s:%s", EksaPackageBundleURI, tag)
}

func withMgmtCluster(cluster *framework.ClusterE2ETest) *types.Cluster {
func withCluster(cluster *framework.ClusterE2ETest) *types.Cluster {
return &types.Cluster{
Name: cluster.ClusterName,
KubeconfigFile: filepath.Join(cluster.ClusterName, fmt.Sprintf("%s-eks-a-cluster.kubeconfig", cluster.ClusterName)),
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/emissary.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func runCuratedPackageEmissaryInstall(test *framework.ClusterE2ETest) {
test.SetPackageBundleActive()
packageFile := test.BuildPackageConfigFile(emissaryPackageName, emissaryPackagePrefix, EksaPackagesNamespace)
test.InstallCuratedPackageFile(packageFile, kubeconfig.FromClusterName(test.ClusterName))
test.VerifyEmissaryPackageInstalled(emissaryPackagePrefix+"-"+emissaryPackageName, withMgmtCluster(test))
test.VerifyEmissaryPackageInstalled(emissaryPackagePrefix+"-"+emissaryPackageName, withCluster(test))
if test.Provider.Name() == constants.DockerProviderName {
test.TestEmissaryPackageRouting(emissaryPackagePrefix+"-"+emissaryPackageName, "hello", withMgmtCluster(test))
test.TestEmissaryPackageRouting(emissaryPackagePrefix+"-"+emissaryPackageName, "hello", withCluster(test))
}
}

Expand All @@ -41,7 +41,7 @@ func runCuratedPackageEmissaryRemoteClusterInstallSimpleFlow(test *framework.Mul
test.ManagementCluster.SetPackageBundleActive()
packageFile := e.BuildPackageConfigFile(emissaryPackageName, emissaryPackagePrefix, EksaPackagesNamespace)
test.ManagementCluster.InstallCuratedPackageFile(packageFile, kubeconfig.FromClusterName(test.ManagementCluster.ClusterName))
e.VerifyEmissaryPackageInstalled(emissaryPackagePrefix+"-"+emissaryPackageName, withMgmtCluster(test.ManagementCluster))
e.VerifyEmissaryPackageInstalled(emissaryPackagePrefix+"-"+emissaryPackageName, withCluster(test.ManagementCluster))
e.DeleteClusterWithKubectl()
e.ValidateClusterDelete()
})
Expand Down

0 comments on commit 8ab221a

Please sign in to comment.