From 98fa8d4e6669e6fc76b3feeb5d1611342e0b7075 Mon Sep 17 00:00:00 2001 From: Matthew Booth Date: Tue, 26 Mar 2024 11:43:39 +0000 Subject: [PATCH] Fix generation of bastion image in e2e tests --- api/v1alpha6/conversion_test.go | 16 ++++++++++++++++ api/v1alpha7/conversion_test.go | 16 ++++++++++++++++ api/v1beta1/types.go | 7 +++++++ .../cluster-prev1beta1/kustomization.yaml | 10 ++++++++++ .../patch-cluster.yaml | 0 .../common-patches/cluster/kustomization.yaml | 10 ++++++++++ .../common-patches/cluster/patch-cluster.yaml | 15 +++++++++++++++ .../common-patches/cni/kustomization.yaml | 4 ---- .../data/kustomize/default/kustomization.yaml | 1 + .../kustomize/flatcar-sysext/kustomization.yaml | 1 + .../data/kustomize/flatcar/kustomization.yaml | 1 + .../data/kustomize/v1alpha6/kustomization.yaml | 1 + .../data/kustomize/v1alpha7/kustomization.yaml | 1 + .../data/kustomize/without-lb/kustomization.yaml | 1 + 14 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 test/e2e/data/kustomize/common-patches/cluster-prev1beta1/kustomization.yaml rename test/e2e/data/kustomize/common-patches/{cni => cluster-prev1beta1}/patch-cluster.yaml (100%) create mode 100644 test/e2e/data/kustomize/common-patches/cluster/kustomization.yaml create mode 100644 test/e2e/data/kustomize/common-patches/cluster/patch-cluster.yaml diff --git a/api/v1alpha6/conversion_test.go b/api/v1alpha6/conversion_test.go index aeeadc2969..c988ce8f76 100644 --- a/api/v1alpha6/conversion_test.go +++ b/api/v1alpha6/conversion_test.go @@ -246,6 +246,22 @@ func TestFuzzyConversion(t *testing.T) { param.ID = nil } }, + + // v1beta1 image param contains exactly one of ID or filter + func(param *infrav1.ImageParam, c fuzz.Continue) { + if c.RandBool() { + id := nonEmptyString(c) + param.ID = &id + param.Filter = nil + } else { + filter := infrav1.ImageFilter{} + for filter.IsZero() { + c.FuzzNoCustom(&filter) + } + param.Filter = &filter + param.ID = nil + } + }, } } diff --git a/api/v1alpha7/conversion_test.go b/api/v1alpha7/conversion_test.go index f7559e460b..57c111c8d5 100644 --- a/api/v1alpha7/conversion_test.go +++ b/api/v1alpha7/conversion_test.go @@ -234,6 +234,22 @@ func TestFuzzyConversion(t *testing.T) { param.ID = nil } }, + + // v1beta1 image param contains exactly one of ID or filter + func(param *infrav1.ImageParam, c fuzz.Continue) { + if c.RandBool() { + id := nonEmptyString(c) + param.ID = &id + param.Filter = nil + } else { + filter := infrav1.ImageFilter{} + for filter.IsZero() { + c.FuzzNoCustom(&filter) + } + param.Filter = &filter + param.ID = nil + } + }, } } diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index 52fd8aab42..bd6e469ea7 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -57,6 +57,13 @@ type ImageFilter struct { Tags []string `json:"tags,omitempty"` } +func (f *ImageFilter) IsZero() bool { + if f == nil { + return true + } + return f.Name == nil && len(f.Tags) == 0 +} + type ExternalRouterIPParam struct { // The FixedIP in the corresponding subnet FixedIP string `json:"fixedIP,omitempty"` diff --git a/test/e2e/data/kustomize/common-patches/cluster-prev1beta1/kustomization.yaml b/test/e2e/data/kustomize/common-patches/cluster-prev1beta1/kustomization.yaml new file mode 100644 index 0000000000..7136e9600d --- /dev/null +++ b/test/e2e/data/kustomize/common-patches/cluster-prev1beta1/kustomization.yaml @@ -0,0 +1,10 @@ +# Modifications to release templates common to all e2e test scenarios +--- +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +patches: +- target: + kind: OpenStackCluster + name: \${CLUSTER_NAME} + path: patch-cluster.yaml diff --git a/test/e2e/data/kustomize/common-patches/cni/patch-cluster.yaml b/test/e2e/data/kustomize/common-patches/cluster-prev1beta1/patch-cluster.yaml similarity index 100% rename from test/e2e/data/kustomize/common-patches/cni/patch-cluster.yaml rename to test/e2e/data/kustomize/common-patches/cluster-prev1beta1/patch-cluster.yaml diff --git a/test/e2e/data/kustomize/common-patches/cluster/kustomization.yaml b/test/e2e/data/kustomize/common-patches/cluster/kustomization.yaml new file mode 100644 index 0000000000..7136e9600d --- /dev/null +++ b/test/e2e/data/kustomize/common-patches/cluster/kustomization.yaml @@ -0,0 +1,10 @@ +# Modifications to release templates common to all e2e test scenarios +--- +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +patches: +- target: + kind: OpenStackCluster + name: \${CLUSTER_NAME} + path: patch-cluster.yaml diff --git a/test/e2e/data/kustomize/common-patches/cluster/patch-cluster.yaml b/test/e2e/data/kustomize/common-patches/cluster/patch-cluster.yaml new file mode 100644 index 0000000000..b6d9564506 --- /dev/null +++ b/test/e2e/data/kustomize/common-patches/cluster/patch-cluster.yaml @@ -0,0 +1,15 @@ +--- +- op: add + path: /spec/bastion + value: + enabled: true + spec: + flavor: ${OPENSTACK_BASTION_MACHINE_FLAVOR} + image: + filter: + name: ${OPENSTACK_BASTION_IMAGE_NAME} + sshKeyName: ${OPENSTACK_SSH_KEY_NAME} +- op: add + path: /spec/controlPlaneAvailabilityZones + value: + - ${OPENSTACK_FAILURE_DOMAIN} diff --git a/test/e2e/data/kustomize/common-patches/cni/kustomization.yaml b/test/e2e/data/kustomize/common-patches/cni/kustomization.yaml index 60fe867342..0f10084b63 100644 --- a/test/e2e/data/kustomize/common-patches/cni/kustomization.yaml +++ b/test/e2e/data/kustomize/common-patches/cni/kustomization.yaml @@ -7,8 +7,4 @@ resources: - cni.yaml patches: -- target: - kind: OpenStackCluster - name: \${CLUSTER_NAME} - path: patch-cluster.yaml - path: patch-cni.yaml diff --git a/test/e2e/data/kustomize/default/kustomization.yaml b/test/e2e/data/kustomize/default/kustomization.yaml index 30f2c9d85d..e85e60a623 100644 --- a/test/e2e/data/kustomize/default/kustomization.yaml +++ b/test/e2e/data/kustomize/default/kustomization.yaml @@ -3,6 +3,7 @@ kind: Kustomization resources: - ../../../../../kustomize/v1beta1/default components: +- ../common-patches/cluster - ../common-patches/cni - ../upgrade-patches - ../common-patches/ccm diff --git a/test/e2e/data/kustomize/flatcar-sysext/kustomization.yaml b/test/e2e/data/kustomize/flatcar-sysext/kustomization.yaml index 6738cde3a8..63c5035c15 100644 --- a/test/e2e/data/kustomize/flatcar-sysext/kustomization.yaml +++ b/test/e2e/data/kustomize/flatcar-sysext/kustomization.yaml @@ -3,6 +3,7 @@ resources: - ../../../../../kustomize/v1beta1/flatcar-sysext components: +- ../common-patches/cluster - ../common-patches/cni - ../common-patches/ccm - ../common-patches/externalNetworkByName diff --git a/test/e2e/data/kustomize/flatcar/kustomization.yaml b/test/e2e/data/kustomize/flatcar/kustomization.yaml index 2de905e98e..ca872d20cb 100644 --- a/test/e2e/data/kustomize/flatcar/kustomization.yaml +++ b/test/e2e/data/kustomize/flatcar/kustomization.yaml @@ -4,6 +4,7 @@ resources: - ../../../../../kustomize/v1beta1/flatcar components: +- ../common-patches/cluster - ../common-patches/cni - ../common-patches/ccm - ../common-patches/externalNetworkByName diff --git a/test/e2e/data/kustomize/v1alpha6/kustomization.yaml b/test/e2e/data/kustomize/v1alpha6/kustomization.yaml index 9f7ac4445d..f2035ba071 100644 --- a/test/e2e/data/kustomize/v1alpha6/kustomization.yaml +++ b/test/e2e/data/kustomize/v1alpha6/kustomization.yaml @@ -4,6 +4,7 @@ resources: - ../../../../../kustomize/v1alpha6/external-cloud-provider components: +- ../common-patches/cluster-prev1beta1 - ../common-patches/cni - ../common-patches/ccm diff --git a/test/e2e/data/kustomize/v1alpha7/kustomization.yaml b/test/e2e/data/kustomize/v1alpha7/kustomization.yaml index ed5685505c..9bcee09929 100644 --- a/test/e2e/data/kustomize/v1alpha7/kustomization.yaml +++ b/test/e2e/data/kustomize/v1alpha7/kustomization.yaml @@ -4,6 +4,7 @@ resources: - ../../../../../kustomize/v1alpha6/external-cloud-provider components: +- ../common-patches/cluster-prev1beta1 - ../common-patches/cni - ../common-patches/ccm diff --git a/test/e2e/data/kustomize/without-lb/kustomization.yaml b/test/e2e/data/kustomize/without-lb/kustomization.yaml index 7f3842e60c..2d88085bde 100644 --- a/test/e2e/data/kustomize/without-lb/kustomization.yaml +++ b/test/e2e/data/kustomize/without-lb/kustomization.yaml @@ -4,6 +4,7 @@ resources: - ../../../../../kustomize/v1beta1/without-lb components: +- ../common-patches/cluster - ../common-patches/cni - ../common-patches/ccm - ../common-patches/externalNetworkByName