Skip to content

Commit

Permalink
Cover image substitution in e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <[email protected]>
  • Loading branch information
Danil-Grigorev committed Nov 27, 2024
1 parent 902a12f commit ae0f034
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
2 changes: 2 additions & 0 deletions internal/controllers/clusterctl/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ data:
repository: "registry.suse.com/rancher"
infrastructure-azure:
repository: "registry.suse.com/rancher"
infrastructure-vsphere:
repository: "registry.suse.com/rancher"
33 changes: 31 additions & 2 deletions test/e2e/suites/chart-upgrade/chart_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ var _ = Describe("Chart upgrade functionality should work", Label(e2e.ShortTestL

upgradeInput.PostUpgradeSteps = append(upgradeInput.PostUpgradeSteps, func() {
framework.WaitForCAPIProviderRollout(ctx, framework.WaitForCAPIProviderRolloutInput{
Getter: setupClusterResult.BootstrapClusterProxy.GetClient(),
Version: e2e.CAPIVersion,
Getter: setupClusterResult.BootstrapClusterProxy.GetClient(),
Version: e2e.CAPIVersion,
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{
Name: "capi-controller-manager",
Namespace: "capi-system",
}},
Image: "registry.suse.com/rancher/cluster-api-controller:",
Name: "cluster-api",
Namespace: "capi-system",
}, e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand All @@ -115,6 +120,30 @@ var _ = Describe("Chart upgrade functionality should work", Label(e2e.ShortTestL
Name: "kubeadm-control-plane",
Namespace: "capi-kubeadm-control-plane-system",
}, e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-controllers")...)
}, func() {
framework.WaitForCAPIProviderRollout(ctx, framework.WaitForCAPIProviderRolloutInput{
Getter: setupClusterResult.BootstrapClusterProxy.GetClient(),
Version: e2e.CAPIVersion,
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{
Name: "rke2-bootstrap-controller-manager",
Namespace: "rke2-bootstrap-system",
}},
Image: "registry.suse.com/rancher/cluster-api-provider-rke2-bootstrap:",
Name: "rke2-bootstrap",
Namespace: "rke2-bootstrap-system",
}, e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-controllers")...)
}, func() {
framework.WaitForCAPIProviderRollout(ctx, framework.WaitForCAPIProviderRolloutInput{
Getter: setupClusterResult.BootstrapClusterProxy.GetClient(),
Version: e2e.CAPIVersion,
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{
Name: "rke2-control-plane-controller-manager",
Namespace: "rke2-control-plane-system",
}},
Image: "registry.suse.com/rancher/cluster-api-provider-rke2-controlplane:",
Name: "rke2-control-plane",
Namespace: "rke2-control-plane-system",
}, e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-controllers")...)
}, func() {
framework.WaitForCAPIProviderRollout(ctx, framework.WaitForCAPIProviderRolloutInput{
Getter: setupClusterResult.BootstrapClusterProxy.GetClient(),
Expand Down
21 changes: 20 additions & 1 deletion test/framework/turtles.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@ package framework

import (
"context"
"strings"

"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"

turtlesv1 "github.com/rancher/turtles/api/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
capiframework "sigs.k8s.io/cluster-api/test/framework"
"sigs.k8s.io/controller-runtime/pkg/client"

. "github.com/onsi/gomega"
)

type WaitForCAPIProviderRolloutInput struct {
capiframework.Getter
Name, Namespace, Version string
Deployment *appsv1.Deployment
Name, Namespace, Version, Image string
}

func WaitForCAPIProviderRollout(ctx context.Context, input WaitForCAPIProviderRolloutInput, intervals ...interface{}) {
Expand All @@ -49,4 +53,19 @@ func WaitForCAPIProviderRollout(ctx context.Context, input WaitForCAPIProviderRo
}, intervals...).Should(Succeed(),
"Failed to get CAPIProvider %s with version %s. Last observed: %s",
key.String(), input.Version, klog.KObj(capiProvider))

if input.Deployment != nil && input.Version != "" {
Eventually(func(g Gomega) {
g.Expect(input.Getter.Get(ctx, client.ObjectKeyFromObject(input.Deployment), input.Deployment)).To(Succeed())
found := false
for _, container := range input.Deployment.Spec.Template.Spec.Containers {
if strings.HasPrefix(container.Image, input.Image) {
found = true
}
}
g.Expect(found).To(BeTrue())
}, intervals...).Should(Succeed(),
"Failed to get Deployemnt %s with image %s. Last observed: %s",
client.ObjectKeyFromObject(input.Deployment).String(), input.Image, klog.KObj(input.Deployment))
}
}

0 comments on commit ae0f034

Please sign in to comment.