Skip to content

Commit

Permalink
Skip bundles override for e2e-test when upgrade is from latest minor …
Browse files Browse the repository at this point in the history
…release (#8807)
  • Loading branch information
jhaanvi5 authored Oct 17, 2024
1 parent 7415c2b commit e93b1ef
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 36 deletions.
35 changes: 23 additions & 12 deletions test/e2e/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4931,11 +4931,12 @@ func TestVSphereKubernetes127UbuntuTo128UpgradeWithCheckpoint(t *testing.T) {

func TestVSphereKubernetes131RedhatUpgradeFromLatestMinorRelease(t *testing.T) {
release := latestMinorRelease(t)
useBundlesOverride := false
provider := framework.NewVSphere(t,
framework.WithVSphereFillers(
api.WithOsFamilyForAllMachines(v1alpha1.RedHat),
),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube131, framework.RedHat8, release),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube131, framework.RedHat8, release, useBundlesOverride),
)
test := framework.NewClusterE2ETest(
t,
Expand All @@ -4962,11 +4963,12 @@ func TestVSphereKubernetes131WithOIDCManagementClusterUpgradeFromLatestSideEffec

func TestVSphereKubernetes127To128UbuntuUpgradeFromLatestMinorRelease(t *testing.T) {
release := latestMinorRelease(t)
useBundlesOverride := false
provider := framework.NewVSphere(t,
framework.WithVSphereFillers(
api.WithOsFamilyForAllMachines(v1alpha1.Ubuntu),
),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube127, framework.Ubuntu2004, release),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube127, framework.Ubuntu2004, release, useBundlesOverride),
)
test := framework.NewClusterE2ETest(
t,
Expand All @@ -4989,11 +4991,12 @@ func TestVSphereKubernetes127To128UbuntuUpgradeFromLatestMinorRelease(t *testing

func TestVSphereKubernetes128To129UbuntuUpgradeFromLatestMinorRelease(t *testing.T) {
release := latestMinorRelease(t)
useBundlesOverride := false
provider := framework.NewVSphere(t,
framework.WithVSphereFillers(
api.WithOsFamilyForAllMachines(v1alpha1.Ubuntu),
),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube128, framework.Ubuntu2004, release),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube128, framework.Ubuntu2004, release, useBundlesOverride),
)
test := framework.NewClusterE2ETest(
t,
Expand All @@ -5016,11 +5019,12 @@ func TestVSphereKubernetes128To129UbuntuUpgradeFromLatestMinorRelease(t *testing

func TestVSphereKubernetes129To130UbuntuUpgradeFromLatestMinorRelease(t *testing.T) {
release := latestMinorRelease(t)
useBundlesOverride := false
provider := framework.NewVSphere(t,
framework.WithVSphereFillers(
api.WithOsFamilyForAllMachines(v1alpha1.Ubuntu),
),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube129, framework.Ubuntu2004, release),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube129, framework.Ubuntu2004, release, useBundlesOverride),
)
test := framework.NewClusterE2ETest(
t,
Expand All @@ -5043,11 +5047,12 @@ func TestVSphereKubernetes129To130UbuntuUpgradeFromLatestMinorRelease(t *testing

func TestVSphereKubernetes130To131UbuntuUpgradeFromLatestMinorRelease(t *testing.T) {
release := latestMinorRelease(t)
useBundlesOverride := false
provider := framework.NewVSphere(t,
framework.WithVSphereFillers(
api.WithOsFamilyForAllMachines(v1alpha1.Ubuntu),
),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube130, framework.Ubuntu2004, release),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube130, framework.Ubuntu2004, release, useBundlesOverride),
)
test := framework.NewClusterE2ETest(
t,
Expand All @@ -5070,12 +5075,13 @@ func TestVSphereKubernetes130To131UbuntuUpgradeFromLatestMinorRelease(t *testing

func TestVSphereKubernetes130To131UbuntuInPlaceUpgradeFromLatestMinorRelease(t *testing.T) {
release := latestMinorRelease(t)
useBundlesOverride := false
provider := framework.NewVSphere(
t,
framework.WithVSphereFillers(
api.WithOsFamilyForAllMachines(v1alpha1.Ubuntu),
),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube130, framework.Ubuntu2004, release),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube130, framework.Ubuntu2004, release, useBundlesOverride),
)
test := framework.NewClusterE2ETest(
t,
Expand Down Expand Up @@ -5145,11 +5151,12 @@ func TestVSphereKubernetes128BottlerocketAndRemoveWorkerNodeGroups(t *testing.T)

func TestVSphereKubernetes127To128RedhatUpgradeFromLatestMinorRelease(t *testing.T) {
release := latestMinorRelease(t)
useBundlesOverride := false
provider := framework.NewVSphere(t,
framework.WithVSphereFillers(
api.WithOsFamilyForAllMachines(v1alpha1.RedHat),
),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube127, framework.RedHat8, release),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube127, framework.RedHat8, release, useBundlesOverride),
)
test := framework.NewClusterE2ETest(
t,
Expand All @@ -5172,11 +5179,12 @@ func TestVSphereKubernetes127To128RedhatUpgradeFromLatestMinorRelease(t *testing

func TestVSphereKubernetes128To129RedhatUpgradeFromLatestMinorRelease(t *testing.T) {
release := latestMinorRelease(t)
useBundlesOverride := false
provider := framework.NewVSphere(t,
framework.WithVSphereFillers(
api.WithOsFamilyForAllMachines(v1alpha1.RedHat),
),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube128, framework.RedHat8, release),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube128, framework.RedHat8, release, useBundlesOverride),
)
test := framework.NewClusterE2ETest(
t,
Expand All @@ -5199,11 +5207,12 @@ func TestVSphereKubernetes128To129RedhatUpgradeFromLatestMinorRelease(t *testing

func TestVSphereKubernetes129To130RedhatUpgradeFromLatestMinorRelease(t *testing.T) {
release := latestMinorRelease(t)
useBundlesOverride := false
provider := framework.NewVSphere(t,
framework.WithVSphereFillers(
api.WithOsFamilyForAllMachines(v1alpha1.RedHat),
),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube129, framework.RedHat8, release),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube129, framework.RedHat8, release, useBundlesOverride),
)
test := framework.NewClusterE2ETest(
t,
Expand All @@ -5226,11 +5235,12 @@ func TestVSphereKubernetes129To130RedhatUpgradeFromLatestMinorRelease(t *testing

func TestVSphereKubernetes130To131RedhatUpgradeFromLatestMinorRelease(t *testing.T) {
release := latestMinorRelease(t)
useBundlesOverride := false
provider := framework.NewVSphere(t,
framework.WithVSphereFillers(
api.WithOsFamilyForAllMachines(v1alpha1.RedHat),
),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube130, framework.RedHat8, release),
framework.WithKubeVersionAndOSForRelease(v1alpha1.Kube130, framework.RedHat8, release, useBundlesOverride),
)
test := framework.NewClusterE2ETest(
t,
Expand Down Expand Up @@ -5284,6 +5294,7 @@ func TestVSphereKubernetes131UbuntuUpgradeAndRemoveWorkerNodeGroupsAPI(t *testin
func TestVSphereKubernetes130to131UpgradeFromLatestMinorReleaseBottleRocketAPI(t *testing.T) {
release := latestMinorRelease(t)
provider := framework.NewVSphere(t)
useBundlesOverride := false
managementCluster := framework.NewClusterE2ETest(
t, provider,
)
Expand All @@ -5295,7 +5306,7 @@ func TestVSphereKubernetes130to131UpgradeFromLatestMinorReleaseBottleRocketAPI(t
api.VSphereToConfigFiller(
api.WithOsFamilyForAllMachines(v1alpha1.Bottlerocket),
),
provider.WithKubeVersionAndOSForRelease(v1alpha1.Kube130, framework.Bottlerocket1, release),
provider.WithKubeVersionAndOSForRelease(v1alpha1.Kube130, framework.Bottlerocket1, release, useBundlesOverride),
)

test := framework.NewMulticlusterE2ETest(t, managementCluster)
Expand All @@ -5311,7 +5322,7 @@ func TestVSphereKubernetes130to131UpgradeFromLatestMinorReleaseBottleRocketAPI(t
api.VSphereToConfigFiller(
api.WithOsFamilyForAllMachines(v1alpha1.Bottlerocket),
),
provider.WithKubeVersionAndOSForRelease(v1alpha1.Kube130, framework.Bottlerocket1, release),
provider.WithKubeVersionAndOSForRelease(v1alpha1.Kube130, framework.Bottlerocket1, release, useBundlesOverride),
)

test.WithWorkloadClusters(wc)
Expand Down
9 changes: 5 additions & 4 deletions test/framework/cloudstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,11 @@ func cloudStackMachineConfig(name string, fillers ...api.CloudStackMachineConfig
// templateForKubeVersionAndOS returns a CloudStack filler for the given OS and Kubernetes version.
func (c *CloudStack) templateForKubeVersionAndOS(kubeVersion anywherev1.KubernetesVersion, os OS, release *releasev1.EksARelease) api.CloudStackFiller {
var template string
useBundlesOverride := getBundlesOverride() == "true"
if release == nil {
template = c.templateForDevRelease(kubeVersion, os)
template = c.templateForDevRelease(kubeVersion, os, useBundlesOverride)
} else {
template = c.templatesRegistry.templateForRelease(c.t, release, kubeVersion, os)
template = c.templatesRegistry.templateForRelease(c.t, release, kubeVersion, os, useBundlesOverride)
}

return api.WithCloudStackTemplateForAllMachines(template)
Expand Down Expand Up @@ -510,9 +511,9 @@ func (c *CloudStack) getDevRelease() *releasev1.EksARelease {
return c.devRelease
}

func (c *CloudStack) templateForDevRelease(kubeVersion anywherev1.KubernetesVersion, os OS) string {
func (c *CloudStack) templateForDevRelease(kubeVersion anywherev1.KubernetesVersion, os OS, useBundlesOverride bool) string {
c.t.Helper()
return c.templatesRegistry.templateForRelease(c.t, c.getDevRelease(), kubeVersion, os)
return c.templatesRegistry.templateForRelease(c.t, c.getDevRelease(), kubeVersion, os, useBundlesOverride)
}

// envVarForTemplate Looks for explicit configuration through an env var: "T_CLOUDSTACK_TEMPLATE_{osFamily}_{eks-d version}"
Expand Down
12 changes: 7 additions & 5 deletions test/framework/nutanix.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ func WithRedHat9Kubernetes131Nutanix() NutanixOpt {
// to use this OS family.
func withNutanixKubeVersionAndOSForUUID(kubeVersion anywherev1.KubernetesVersion, os OS, release *releasev1.EksARelease) NutanixOpt {
return func(n *Nutanix) {
name := n.templateForDevRelease(kubeVersion, os)
useBundlesOverride := getBundlesOverride() == "true"
name := n.templateForDevRelease(kubeVersion, os, useBundlesOverride)
n.fillers = append(n.fillers, n.withNutanixUUID(name, osFamiliesForOS[os])...)
}
}
Expand Down Expand Up @@ -449,10 +450,11 @@ func WithNutanixSubnetUUID() NutanixOpt {
// templateForKubeVersionAndOS returns a Nutanix filler for the given OS and Kubernetes version.
func (n *Nutanix) templateForKubeVersionAndOS(kubeVersion anywherev1.KubernetesVersion, os OS, release *releasev1.EksARelease) api.NutanixFiller {
var template string
useBundlesOverride := getBundlesOverride() == "true"
if release == nil {
template = n.templateForDevRelease(kubeVersion, os)
template = n.templateForDevRelease(kubeVersion, os, useBundlesOverride)
} else {
template = n.templatesRegistry.templateForRelease(n.t, release, kubeVersion, os)
template = n.templatesRegistry.templateForRelease(n.t, release, kubeVersion, os, useBundlesOverride)
}
return api.WithNutanixMachineTemplateImageName(template)
}
Expand Down Expand Up @@ -566,9 +568,9 @@ func (n *Nutanix) getDevRelease() *releasev1.EksARelease {
return n.devRelease
}

func (n *Nutanix) templateForDevRelease(kubeVersion anywherev1.KubernetesVersion, os OS) string {
func (n *Nutanix) templateForDevRelease(kubeVersion anywherev1.KubernetesVersion, os OS, useBundlesOverride bool) string {
n.t.Helper()
return n.templatesRegistry.templateForRelease(n.t, n.getDevRelease(), kubeVersion, os)
return n.templatesRegistry.templateForRelease(n.t, n.getDevRelease(), kubeVersion, os, useBundlesOverride)
}

// envVarForTemplate looks for explicit configuration through an env var: "T_NUTANIX_TEMPLATE_{osFamily}_{eks-d version}"
Expand Down
4 changes: 2 additions & 2 deletions test/framework/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ type templateRegistry struct {
// 3. If the template doesn't exist, default to the value of the default template env vars: eg. "T_CLOUDSTACK_TEMPLATE_REDHAT_1_23".
// This is a catch all condition. Mostly for edge cases where the bundle has been updated with a new eks-d version, but the
// the new template hasn't been imported yet. It also preserves backwards compatibility.
func (tc *templateRegistry) templateForRelease(t *testing.T, release *releasev1.EksARelease, kubeVersion anywherev1.KubernetesVersion, operatingSystem OS) string {
func (tc *templateRegistry) templateForRelease(t *testing.T, release *releasev1.EksARelease, kubeVersion anywherev1.KubernetesVersion, operatingSystem OS, useBundlesOverride bool) string {
t.Helper()
versionsBundle := readVersionsBundles(t, release, kubeVersion)
versionsBundle := readVersionsBundles(t, release, kubeVersion, useBundlesOverride)
eksDName := versionsBundle.EksD.Name

templateEnvVarName := tc.generator.envVarForTemplate(operatingSystem, eksDName)
Expand Down
28 changes: 15 additions & 13 deletions test/framework/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,17 +460,19 @@ func (v *VSphere) WithNewVSphereWorkerNodeGroup(name string, workerNodeGroup *Wo
// templateForKubeVersionAndOS returns a vSphere filler for the given OS and Kubernetes version.
func (v *VSphere) templateForKubeVersionAndOS(kubeVersion anywherev1.KubernetesVersion, os OS, release *releasev1.EksARelease) api.VSphereFiller {
var template string
useBundlesOverride := getBundlesOverride() == "true"
if release == nil {
template = v.templateForDevRelease(kubeVersion, os)
template = v.templateForDevRelease(kubeVersion, os, useBundlesOverride)
} else {
template = v.templatesRegistry.templateForRelease(v.t, release, kubeVersion, os)
template = v.templatesRegistry.templateForRelease(v.t, release, kubeVersion, os, useBundlesOverride)
}
return api.WithTemplateForAllMachines(template)
}

// templateForKubeVersionAndOSMachineConfig returns a vSphere filler for the given OS and Kubernetes version for a specific machine config.
func (v *VSphere) templateForKubeVersionAndOSMachineConfig(name string, kubeVersion anywherev1.KubernetesVersion, os OS) api.VSphereFiller {
template := v.templateForDevRelease(kubeVersion, os)
useBundlesOverride := getBundlesOverride() == "true"
template := v.templateForDevRelease(kubeVersion, os, useBundlesOverride)
return api.WithMachineTemplate(name, template)
}

Expand Down Expand Up @@ -593,9 +595,9 @@ func (v *VSphere) getDevRelease() *releasev1.EksARelease {
return v.devRelease
}

func (v *VSphere) templateForDevRelease(kubeVersion anywherev1.KubernetesVersion, os OS) string {
func (v *VSphere) templateForDevRelease(kubeVersion anywherev1.KubernetesVersion, os OS, useBundlesOverride bool) string {
v.t.Helper()
return v.templatesRegistry.templateForRelease(v.t, v.getDevRelease(), kubeVersion, os)
return v.templatesRegistry.templateForRelease(v.t, v.getDevRelease(), kubeVersion, os, useBundlesOverride)
}

func RequiredVsphereEnvVars() []string {
Expand Down Expand Up @@ -636,22 +638,22 @@ func buildVSphereWorkerNodeGroupClusterFiller(machineConfigName string, workerNo

// WithKubeVersionAndOSForRelease returns a vSphereOpt that sets the cluster kube version and the right template for all
// vsphere machine configs based on the EKS-A release.
func WithKubeVersionAndOSForRelease(kubeVersion anywherev1.KubernetesVersion, os OS, release *releasev1.EksARelease) VSphereOpt {
return optionToSetTemplateForRelease(kubeVersion, os, release)
func WithKubeVersionAndOSForRelease(kubeVersion anywherev1.KubernetesVersion, os OS, release *releasev1.EksARelease, useBundlesOverride bool) VSphereOpt {
return optionToSetTemplateForRelease(kubeVersion, os, release, useBundlesOverride)
}

// WithKubeVersionAndOSForRelease returns a cluster config filler that sets the cluster kube version and the right template for all
// vsphere machine configs based on the EKS-A release.
func (v *VSphere) WithKubeVersionAndOSForRelease(kubeVersion anywherev1.KubernetesVersion, os OS, release *releasev1.EksARelease) api.ClusterConfigFiller {
func (v *VSphere) WithKubeVersionAndOSForRelease(kubeVersion anywherev1.KubernetesVersion, os OS, release *releasev1.EksARelease, useBundlesOverride bool) api.ClusterConfigFiller {
return api.VSphereToConfigFiller(
api.WithTemplateForAllMachines(v.templatesRegistry.templateForRelease(v.t, release, kubeVersion, os)),
api.WithTemplateForAllMachines(v.templatesRegistry.templateForRelease(v.t, release, kubeVersion, os, useBundlesOverride)),
)
}

func optionToSetTemplateForRelease(kubeVersion anywherev1.KubernetesVersion, os OS, release *releasev1.EksARelease) VSphereOpt {
func optionToSetTemplateForRelease(kubeVersion anywherev1.KubernetesVersion, os OS, release *releasev1.EksARelease, useBundlesOverride bool) VSphereOpt {
return func(v *VSphere) {
v.fillers = append(v.fillers,
api.WithTemplateForAllMachines(v.templatesRegistry.templateForRelease(v.t, release, kubeVersion, os)),
api.WithTemplateForAllMachines(v.templatesRegistry.templateForRelease(v.t, release, kubeVersion, os, useBundlesOverride)),
)
}
}
Expand Down Expand Up @@ -691,11 +693,11 @@ func (v *VSphere) searchTemplate(ctx context.Context, template string) (string,
return foundTemplate, nil
}

func readVersionsBundles(t testing.TB, release *releasev1.EksARelease, kubeVersion anywherev1.KubernetesVersion) *releasev1.VersionsBundle {
func readVersionsBundles(t testing.TB, release *releasev1.EksARelease, kubeVersion anywherev1.KubernetesVersion, useBundlesOverride bool) *releasev1.VersionsBundle {
reader := newFileReader()
var allBundles *releasev1.Bundles
var err error
if getBundlesOverride() == "true" {
if useBundlesOverride {
allBundles, err = bundles.Read(reader, defaultBundleReleaseManifestFile)
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit e93b1ef

Please sign in to comment.