Skip to content

Commit 9a38896

Browse files
committed
test: validate CoreDNS image version in e2e tests
1 parent ee7d4ef commit 9a38896

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

test/e2e/coredns_helpers.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ package e2e
88
import (
99
"context"
1010

11+
. "github.com/onsi/gomega"
1112
appsv1 "k8s.io/api/apps/v1"
1213
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1314
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
1415
"sigs.k8s.io/cluster-api/test/framework"
16+
17+
corednsversions "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/versions"
1518
)
1619

1720
type WaitForCoreDNSToBeReadyInWorkloadClusterInput struct {
@@ -38,3 +41,35 @@ func WaitForCoreDNSToBeReadyInWorkloadCluster(
3841
},
3942
}, input.DeploymentIntervals...)
4043
}
44+
45+
// WaitForDNSUpgradeInput is the input for WaitForDNSUpgrade.
46+
type WaitForDNSUpgradeInput struct {
47+
WorkloadCluster *clusterv1.Cluster
48+
ClusterProxy framework.ClusterProxy
49+
DeploymentIntervals []interface{}
50+
}
51+
52+
// WaitForCoreDNSImageVersion waits for the CoreDNS image to be updated to the default version,
53+
// based on the Kubernetes version.
54+
func WaitForCoreDNSImageVersion(
55+
ctx context.Context,
56+
input WaitForDNSUpgradeInput,
57+
) {
58+
workloadClusterClient := input.ClusterProxy.GetWorkloadCluster(
59+
ctx, input.WorkloadCluster.Namespace, input.WorkloadCluster.Name,
60+
).GetClient()
61+
62+
defaultCoreDNSVersion, found := corednsversions.GetCoreDNSVersion(
63+
input.WorkloadCluster.Spec.Topology.Version,
64+
)
65+
Expect(found).To(
66+
BeTrue(),
67+
"failed to get default CoreDNS version for Cluster version %s",
68+
input.WorkloadCluster.Spec.Topology.Version,
69+
)
70+
71+
framework.WaitForDNSUpgrade(ctx, framework.WaitForDNSUpgradeInput{
72+
Getter: workloadClusterClient,
73+
DNSVersion: defaultCoreDNSVersion,
74+
})
75+
}

test/e2e/quick_start_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,18 @@ var _ = Describe("Quick start", func() {
280280
},
281281
)
282282

283+
WaitForCoreDNSImageVersion(
284+
ctx,
285+
WaitForDNSUpgradeInput{
286+
WorkloadCluster: workloadCluster,
287+
ClusterProxy: proxy,
288+
DeploymentIntervals: testE2EConfig.GetIntervals(
289+
flavour,
290+
"wait-deployment",
291+
),
292+
},
293+
)
294+
283295
WaitForCoreDNSToBeReadyInWorkloadCluster(
284296
ctx,
285297
WaitForCoreDNSToBeReadyInWorkloadClusterInput{

test/e2e/self_hosted_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,17 @@ var _ = Describe("Self-hosted", Serial, func() {
142142
},
143143
)
144144

145+
WaitForCoreDNSImageVersion(
146+
ctx,
147+
WaitForDNSUpgradeInput{
148+
WorkloadCluster: workloadCluster,
149+
ClusterProxy: proxy,
150+
DeploymentIntervals: e2eConfig.GetIntervals(
151+
flavour,
152+
"wait-deployment",
153+
),
154+
},
155+
)
145156
WaitForCoreDNSToBeReadyInWorkloadCluster(
146157
ctx,
147158
WaitForCoreDNSToBeReadyInWorkloadClusterInput{

0 commit comments

Comments
 (0)