Skip to content

Commit 5538771

Browse files
Verify CAPIO deployment is removed
Signed-off-by: Danil-Grigorev <[email protected]>
1 parent 9e60e2e commit 5538771

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

test/e2e/suites/chart-upgrade/chart_upgrade_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ var _ = Describe("Chart upgrade functionality should work", Label(e2e.ShortTestL
5959

6060
testenv.DeployChartMuseum(ctx, chartMuseumDeployInput)
6161

62+
// Perform upgrade with migration to embedded operator implementation
6263
rtInput.AdditionalValues["cluster-api-operator.enabled"] = "false"
6364
rtInput.AdditionalValues["rancherTurtles.features.embedded-operator.enabled"] = "true"
6465

@@ -68,6 +69,17 @@ var _ = Describe("Chart upgrade functionality should work", Label(e2e.ShortTestL
6869
PostUpgradeSteps: []func(){},
6970
}
7071

72+
upgradeInput.PostUpgradeSteps = append(upgradeInput.PostUpgradeSteps, func() {
73+
By("Waiting for the upstream CAPI operator deployment to be removed")
74+
framework.WaitForDeploymentsRemoved(ctx, framework.WaitForDeploymentsRemovedInput{
75+
Getter: bootstrapClusterProxy.GetClient(),
76+
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{
77+
Name: "rancher-turtles-cluster-api-operator",
78+
Namespace: e2e.RancherTurtlesNamespace,
79+
}},
80+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
81+
})
82+
7183
upgradeInput.PostUpgradeSteps = append(upgradeInput.PostUpgradeSteps, func() {
7284
By("Waiting for CAAPF deployment to be available")
7385
capiframework.WaitForDeploymentsAvailable(ctx, capiframework.WaitForDeploymentsAvailableInput{

test/framework/turtles.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"strings"
2222

23+
apierrors "k8s.io/apimachinery/pkg/api/errors"
2324
"k8s.io/apimachinery/pkg/types"
2425
"k8s.io/klog/v2"
2526

@@ -71,3 +72,25 @@ func WaitForCAPIProviderRollout(ctx context.Context, input WaitForCAPIProviderRo
7172
client.ObjectKeyFromObject(input.Deployment).String(), input.Image, klog.KObj(input.Deployment))
7273
}
7374
}
75+
76+
// WaitForDeploymentsRemovedInput is the input for WaitForDeploymentsRemoved.
77+
type WaitForDeploymentsRemovedInput = capiframework.WaitForDeploymentsAvailableInput
78+
79+
// WaitForDeploymentsAvRemoved waits until the Deployment is removed.
80+
func WaitForDeploymentsRemoved(ctx context.Context, input WaitForDeploymentsRemovedInput, intervals ...interface{}) {
81+
Byf("Waiting for deployment %s to be removed", klog.KObj(input.Deployment))
82+
deployment := &appsv1.Deployment{}
83+
Eventually(func() bool {
84+
key := client.ObjectKey{
85+
Namespace: input.Deployment.GetNamespace(),
86+
Name: input.Deployment.GetName(),
87+
}
88+
if err := input.Getter.Get(ctx, key, deployment); err == nil {
89+
return false
90+
} else if apierrors.IsNotFound(err) {
91+
return true
92+
}
93+
94+
return false
95+
}, intervals...).Should(BeTrue(), func() string { return capiframework.DescribeFailedDeployment(input, deployment) })
96+
}

0 commit comments

Comments
 (0)