Skip to content

Commit 4c269ba

Browse files
committed
test: validate CoreDNS image version in e2e tests
1 parent 6c14aec commit 4c269ba

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

test/e2e/coredns_helpers.go

Lines changed: 34 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,34 @@ 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 :=
63+
corednsversions.GetCoreDNSVersion(input.WorkloadCluster.Spec.Topology.Version)
64+
Expect(found).To(
65+
BeTrue(),
66+
"failed to get default CoreDNS version for Cluster version %s",
67+
input.WorkloadCluster.Spec.Topology.Version,
68+
)
69+
70+
framework.WaitForDNSUpgrade(ctx, framework.WaitForDNSUpgradeInput{
71+
Getter: workloadClusterClient,
72+
DNSVersion: defaultCoreDNSVersion,
73+
})
74+
}

test/e2e/quick_start_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,17 @@ 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+
283294
WaitForCoreDNSToBeReadyInWorkloadCluster(
284295
ctx,
285296
WaitForCoreDNSToBeReadyInWorkloadClusterInput{

test/e2e/self_hosted_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818

1919
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
2020
apivariables "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/variables"
21+
corednsversions "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/versions"
2122
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/variables"
2223
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/test/e2e/framework"
2324
)
@@ -142,6 +143,19 @@ var _ = Describe("Self-hosted", Serial, func() {
142143
},
143144
)
144145

146+
defaultCoreDNSVersion, found := corednsversions.GetCoreDNSVersion(
147+
workloadCluster.Spec.Topology.Version,
148+
)
149+
if found {
150+
capiframework.WaitForDNSUpgrade(
151+
ctx,
152+
capiframework.WaitForDNSUpgradeInput{
153+
Getter: proxy.GetClient(),
154+
DNSVersion: defaultCoreDNSVersion,
155+
},
156+
)
157+
}
158+
145159
WaitForCoreDNSToBeReadyInWorkloadCluster(
146160
ctx,
147161
WaitForCoreDNSToBeReadyInWorkloadClusterInput{

0 commit comments

Comments
 (0)