Skip to content

Commit

Permalink
Fix generation of bastion image in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdbooth committed Mar 27, 2024
1 parent 9532430 commit 98fa8d4
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 4 deletions.
16 changes: 16 additions & 0 deletions api/v1alpha6/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
}
}

Expand Down
16 changes: 16 additions & 0 deletions api/v1alpha7/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
}
}

Expand Down
7 changes: 7 additions & 0 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions test/e2e/data/kustomize/common-patches/cluster/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions test/e2e/data/kustomize/common-patches/cluster/patch-cluster.yaml
Original file line number Diff line number Diff line change
@@ -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}
4 changes: 0 additions & 4 deletions test/e2e/data/kustomize/common-patches/cni/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ resources:
- cni.yaml

patches:
- target:
kind: OpenStackCluster
name: \${CLUSTER_NAME}
path: patch-cluster.yaml
- path: patch-cni.yaml
1 change: 1 addition & 0 deletions test/e2e/data/kustomize/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: Kustomization
resources:
- ../../../../../kustomize/v1beta1/default
components:
- ../common-patches/cluster
- ../common-patches/cni
- ../upgrade-patches
- ../common-patches/ccm
Expand Down
1 change: 1 addition & 0 deletions test/e2e/data/kustomize/flatcar-sysext/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resources:
- ../../../../../kustomize/v1beta1/flatcar-sysext

components:
- ../common-patches/cluster
- ../common-patches/cni
- ../common-patches/ccm
- ../common-patches/externalNetworkByName
1 change: 1 addition & 0 deletions test/e2e/data/kustomize/flatcar/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resources:
- ../../../../../kustomize/v1beta1/flatcar

components:
- ../common-patches/cluster
- ../common-patches/cni
- ../common-patches/ccm
- ../common-patches/externalNetworkByName
1 change: 1 addition & 0 deletions test/e2e/data/kustomize/v1alpha6/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resources:
- ../../../../../kustomize/v1alpha6/external-cloud-provider

components:
- ../common-patches/cluster-prev1beta1
- ../common-patches/cni
- ../common-patches/ccm

Expand Down
1 change: 1 addition & 0 deletions test/e2e/data/kustomize/v1alpha7/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resources:
- ../../../../../kustomize/v1alpha6/external-cloud-provider

components:
- ../common-patches/cluster-prev1beta1
- ../common-patches/cni
- ../common-patches/ccm

Expand Down
1 change: 1 addition & 0 deletions test/e2e/data/kustomize/without-lb/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resources:
- ../../../../../kustomize/v1beta1/without-lb

components:
- ../common-patches/cluster
- ../common-patches/cni
- ../common-patches/ccm
- ../common-patches/externalNetworkByName

0 comments on commit 98fa8d4

Please sign in to comment.