From 89fd4bc2186ec00baaa1b04442a68c31fc6450e5 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Tue, 19 Mar 2024 16:49:32 -0400 Subject: [PATCH] Test updates, fixes --- Makefile | 3 + .../v1beta1/openstackcontrolplane_types.go | 1 + apis/core/v1beta1/openstackversion_types.go | 22 ++++-- .../core/openstackcontrolplane_controller.go | 6 +- .../core/openstackversion_controller.go | 11 +-- go.mod | 2 +- hack/export_related_images.sh | 72 +++++++++++++++++++ pkg/openstack/barbican.go | 2 +- pkg/openstack/version.go | 1 - tests/functional/base_test.go | 27 +++++++ .../openstackoperator_controller_test.go | 13 ++++ tests/functional/suite_test.go | 11 +++ 12 files changed, 149 insertions(+), 22 deletions(-) create mode 100755 hack/export_related_images.sh diff --git a/Makefile b/Makefile index e408fc627..c6b03d9c1 100644 --- a/Makefile +++ b/Makefile @@ -134,6 +134,7 @@ golangci-lint: .PHONY: test test: manifests generate gowork fmt vet envtest ginkgo ## Run tests. + source hack/export_related_images.sh && \ KUBEBUILDER_ASSETS="$(shell $(ENVTEST) -v debug --bin-dir $(LOCALBIN) use $(ENVTEST_K8S_VERSION) -p path)" \ OPERATOR_TEMPLATES="$(PWD)/templates" \ $(GINKGO) --trace --cover --coverpkg=../../pkg/openstack,../../pkg/openstackclient,../../pkg/util,../../controllers,../../apis/client/v1beta1,../../apis/core/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./tests/... ./apis/client/... @@ -151,6 +152,7 @@ run: export HEALTH_PORT?=8081 run: export ENABLE_WEBHOOKS?=false run: manifests generate fmt vet ## Run a controller from your host. /bin/bash hack/clean_local_webhook.sh + source hack/export_related_images.sh && \ go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" .PHONY: docker-build @@ -389,6 +391,7 @@ run-with-webhook: export METRICS_PORT?=8080 run-with-webhook: export HEALTH_PORT?=8081 run-with-webhook: manifests generate fmt vet ## Run a controller from your host. /bin/bash hack/configure_local_webhook.sh + source hack/export_related_images.sh && \ go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" # refresh the bundle extra data based on go.mod entries diff --git a/apis/core/v1beta1/openstackcontrolplane_types.go b/apis/core/v1beta1/openstackcontrolplane_types.go index b0cb6f619..0528cadeb 100644 --- a/apis/core/v1beta1/openstackcontrolplane_types.go +++ b/apis/core/v1beta1/openstackcontrolplane_types.go @@ -55,6 +55,7 @@ const ( // RabbitMqContainerImage is the fall-back container image for RabbitMQ RabbitMqContainerImage = "quay.io/podified-antelope-centos9/openstack-rabbitmq:current-podified" + // OvnDbCaName - OvnDbCaName = tls.DefaultCAPrefix + "ovn" ) diff --git a/apis/core/v1beta1/openstackversion_types.go b/apis/core/v1beta1/openstackversion_types.go index a14b91f23..eea8c2d41 100644 --- a/apis/core/v1beta1/openstackversion_types.go +++ b/apis/core/v1beta1/openstackversion_types.go @@ -22,12 +22,15 @@ import ( ) const ( + // MinorUpdateOvnControlPlane - MinorUpdateOvnControlPlane string = "Minor Update OVN Controlplane In Progress" - MinorUpdateControlPlane string = "Minor Update OVN Controlplane In Progress" - MinorUpdateComplete string = "Complete" + // MinorUpdateControlPlane - + MinorUpdateControlPlane string = "Minor Update Controlplane In Progress" + // MinorUpdateComplete - + MinorUpdateComplete string = "Complete" ) -// OpenStackVersionSpec defines the desired state of OpenStackVersion +// OpenStackVersionSpec - defines the desired state of OpenStackVersion type OpenStackVersionSpec struct { // +kubebuilder:validation:Required @@ -38,21 +41,21 @@ type OpenStackVersionSpec struct { CustomContainerImages CustomContainerImages `json:"customContainerImages,omitempty"` } -// struct for custom container images +// CustomContainerImages - struct for custom container images type CustomContainerImages struct { ContainerTemplate `json:",inline"` CinderVolumeImages map[string]*string `json:"cinderVolumeImages,omitempty"` ManilaShareImages map[string]*string `json:"manilaShareImages,omitempty"` } -// struct that contains container image default URLs for each service (internal use only) +// ContainerDefaults - struct that contains container image default URLs for each service (internal use only) type ContainerDefaults struct { ContainerTemplate `json:",inline"` CinderVolumeImage *string `json:"cinderVolumeImage,omitempty"` ManilaShareImage *string `json:"manilaShareImage,omitempty"` } -// struct acts as the source of truth for container image URLs to be deployed +// ContainerImages - struct acts as the source of truth for container image URLs to be deployed type ContainerImages struct { ContainerTemplate `json:",inline"` // CinderVolumeImages custom Cinder Volume images for each backend (default Cinder volume image is stored 'default' key) @@ -63,7 +66,7 @@ type ContainerImages struct { ManilaShareImages map[string]*string `json:"manilaShareImages,omitempty"` } -// struct that contains container image URLs for each service in OpenStackControlplane +// ContainerTemplate - struct that contains container image URLs for each service in OpenStackControlplane type ContainerTemplate struct { AgentImage *string `json:"agentImage,omitempty"` AnsibleeeImage *string `json:"ansibleeeImage,omitempty"` @@ -178,3 +181,8 @@ type OpenStackVersionList struct { func init() { SchemeBuilder.Register(&OpenStackVersion{}, &OpenStackVersionList{}) } + +// IsReady - returns true if service is ready to serve requests +func (instance OpenStackVersion) IsReady() bool { + return instance.Status.Conditions.IsTrue(condition.ReadyCondition) +} diff --git a/controllers/core/openstackcontrolplane_controller.go b/controllers/core/openstackcontrolplane_controller.go index fa701c4b4..52cae2b74 100644 --- a/controllers/core/openstackcontrolplane_controller.go +++ b/controllers/core/openstackcontrolplane_controller.go @@ -177,7 +177,7 @@ func (r *OpenStackControlPlaneReconciler) Reconcile(ctx context.Context, req ctr } // wait until the version is initialized so we have images on the version.Status - if version.Status.Conditions.IsFalse(corev1beta1.OpenStackVersionInitialized) { + if !version.IsReady() { return ctrlResult, nil } @@ -195,7 +195,7 @@ func (r *OpenStackControlPlaneReconciler) Reconcile(ctx context.Context, req ctr instance.Status.DeployedVersion = &version.Spec.TargetVersion return ctrl.Result{}, nil } else { - if version.Status.Conditions.IsFalse(corev1beta1.OpenStackVersionMinorUpdateOVNControlplane) { + if !version.Status.Conditions.IsTrue(corev1beta1.OpenStackVersionMinorUpdateOVNControlplane) { Log.Info("Minor update OVN on the ControlPlane") ctrlResult, err := r.reconcileOVNControllers(ctx, instance, version, helper) if err != nil { @@ -205,7 +205,7 @@ func (r *OpenStackControlPlaneReconciler) Reconcile(ctx context.Context, req ctr } instance.Status.DeployedOVNVersion = &version.Spec.TargetVersion return ctrl.Result{}, nil - } else if version.Status.Conditions.IsFalse(corev1beta1.OpenStackVersionMinorUpdateControlplane) { + } else if !version.Status.Conditions.IsTrue(corev1beta1.OpenStackVersionMinorUpdateControlplane) { Log.Info("Minor update on the ControlPlane") ctrlResult, err := r.reconcileNormal(ctx, instance, version, helper) if err != nil { diff --git a/controllers/core/openstackversion_controller.go b/controllers/core/openstackversion_controller.go index 24e388374..8ba3616f7 100644 --- a/controllers/core/openstackversion_controller.go +++ b/controllers/core/openstackversion_controller.go @@ -18,7 +18,6 @@ package core import ( "context" - "fmt" "os" "strings" @@ -43,7 +42,6 @@ var envAvailableVersion string // SetupVersionDefaults - func SetupVersionDefaults() { - fmt.Println("SetupVersionDefaults") localVars := make(map[string]*string) for _, name := range os.Environ() { envArr := strings.Split(name, "=") @@ -122,7 +120,6 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req instance.Status.Conditions = condition.Conditions{} // greenfield deployment - //cl := condition.Conditions{} cl := condition.CreateList( condition.UnknownCondition(corev1beta1.OpenStackVersionInitialized, condition.InitReason, string(corev1beta1.OpenStackVersionInitializedInitMessage)), ) @@ -206,12 +203,8 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req // minor update for OVN Controlplane in progress if instance.Status.DeployedVersion != nil && instance.Spec.TargetVersion != *instance.Status.DeployedVersion { - if controlPlane.Status.Conditions.IsFalse(condition.ReadyCondition) { - Log.Info("Minor update Controlplane is not in ready condition, waiting") - return ctrl.Result{}, nil - } if !compareStringPointers(controlPlane.Status.ContainerImages.OvnControllerImage, instance.Status.ContainerImages.OvnControllerImage) || - controlPlane.Status.Conditions.IsFalse(corev1beta1.OpenStackVersionMinorUpdateOVNControlplane) { + !controlPlane.Status.Conditions.IsTrue(corev1beta1.OpenStackVersionMinorUpdateOVNControlplane) { instance.Status.Conditions.Set(condition.FalseCondition( corev1beta1.OpenStackVersionMinorUpdateOVNControlplane, condition.RequestedReason, @@ -242,7 +235,7 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req corev1beta1.OpenStackVersionMinorUpdateReadyMessage) } - if controlPlane.Status.Conditions.AllSubConditionIsTrue() { + if controlPlane.IsReady() { Log.Info("Setting DeployedVersion") instance.Status.DeployedVersion = &instance.Spec.TargetVersion } diff --git a/go.mod b/go.mod index e5c2b265b..9b440da55 100644 --- a/go.mod +++ b/go.mod @@ -121,4 +121,4 @@ replace github.com/openstack-k8s-operators/openstack-operator/apis => ./apis replace github.com/openshift/api => github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 //allow-merging // custom RabbitmqClusterSpecCore for OpenStackControlplane (v2.6.0_patches_tag) -replace github.com/rabbitmq/cluster-operator/v2 => github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20240313124519-961a0ee8bf7f // allow-merging +replace github.com/rabbitmq/cluster-operator/v2 => github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20240313124519-961a0ee8bf7f //allow-merging diff --git a/hack/export_related_images.sh b/hack/export_related_images.sh new file mode 100755 index 000000000..f28a95e25 --- /dev/null +++ b/hack/export_related_images.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +export OPENSTACK_VERSION=0.0.1 +export RELATED_IMAGE_OPENSTACK_CLIENT_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-openstackclient:current-podified +export RELATED_IMAGE_RABBITMQ_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-rabbitmq:current-podified +export RELATED_IMAGE_KEYSTONE_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-keystone:current-podified +export RELATED_IMAGE_MARIADB_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-mariadb:current-podified +export RELATED_IMAGE_INFRA_MEMCACHED_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-memcached:current-podified +export RELATED_IMAGE_INFRA_REDIS_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-redis:current-podified +export RELATED_IMAGE_INFRA_DNSMASQ_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-neutron-server:current-podified +export RELATED_IMAGE_ANSIBLEEE_IMAGE_URL_DEFAULT=quay.io/openstack-k8s-operators/openstack-ansibleee-runner:current-podified +export RELATED_IMAGE_NOVA_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-nova-api:current-podified +export RELATED_IMAGE_NOVA_CONDUCTOR_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-nova-conductor:current-podified +export RELATED_IMAGE_NOVA_NOVNC_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-nova-novncproxy:current-podified +export RELATED_IMAGE_NOVA_SCHEDULER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-nova-scheduler:current-podified +export RELATED_IMAGE_NOVA_COMPUTE_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-nova-compute:current-podified +export RELATED_IMAGE_NEUTRON_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-neutron-server:current-podified +export RELATED_IMAGE_MANILA_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-manila-api:current-podified +export RELATED_IMAGE_MANILA_SCHEDULER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-manila-scheduler:current-podified +export RELATED_IMAGE_MANILA_SHARE_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-manila-share:current-podified +export RELATED_IMAGE_GLANCE_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-glance-api:current-podified +export RELATED_IMAGE_IRONIC_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ironic-api:current-podified +export RELATED_IMAGE_IRONIC_CONDUCTOR_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ironic-conductor:current-podified +export RELATED_IMAGE_IRONIC_INSPECTOR_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ironic-inspector:current-podified +export RELATED_IMAGE_IRONIC_PXE_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ironic-pxe:current-podified +export RELATED_IMAGE_IRONIC_NEUTRON_AGENT_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ironic-neutron-agent:current-podified +export RELATED_IMAGE_IRONIC_PYTHON_AGENT_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/ironic-python-agent:current-podified +export RELATED_IMAGE_OS_CONTAINER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/edpm-hardened-uefi:current-podified +export RELATED_IMAGE_AGENT_IMAGE_URL_DEFAULT=quay.io/openstack-k8s-operators/openstack-baremetal-operator-agent:current-podified +export RELATED_IMAGE_APACHE_IMAGE_URL_DEFAULT=registry.redhat.io/rhel8/httpd-24:current-podified +export OS_IMAGE_DEFAULT=edpm-hardened-uefi.qcow2 +export RELATED_IMAGE_PLACEMENT_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-placement-api:current-podified +export RELATED_IMAGE_CEILOMETER_CENTRAL_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ceilometer-central:current-podified +export RELATED_IMAGE_CEILOMETER_COMPUTE_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ceilometer-compute:current-podified +export RELATED_IMAGE_CEILOMETER_NOTIFICATION_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ceilometer-notification:current-podified +export RELATED_IMAGE_CEILOMETER_IPMI_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ceilometer-ipmi:current-podified +export RELATED_IMAGE_CEILOMETER_SGCORE_IMAGE_URL_DEFAULT=quay.io/infrawatch/sg-core:current-podified +export RELATED_IMAGE_AODH_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-aodh-api:current-podified +export RELATED_IMAGE_AODH_EVALUATOR_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-aodh-evaluator:current-podified +export RELATED_IMAGE_AODH_NOTIFIER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-aodh-notifier:current-podified +export RELATED_IMAGE_AODH_LISTENER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-aodh-listener:current-podified +export RELATED_IMAGE_OVN_NB_DBCLUSTER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ovn-nb-db-server:current-podified +export RELATED_IMAGE_OVN_SB_DBCLUSTER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ovn-sb-db-server:current-podified +export RELATED_IMAGE_OVN_NORTHD_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ovn-northd:current-podified +export RELATED_IMAGE_OVN_CONTROLLER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ovn-controller:current-podified +export RELATED_IMAGE_OVN_CONTROLLER_OVS_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ovn-base:current-podified +export RELATED_IMAGE_CINDER_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-cinder-api:current-podified +export RELATED_IMAGE_CINDER_BACKUP_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-cinder-backup:current-podified +export RELATED_IMAGE_CINDER_SCHEDULER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-cinder-scheduler:current-podified +export RELATED_IMAGE_CINDER_VOLUME_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-cinder-volume:current-podified +export RELATED_IMAGE_HORIZON_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-horizon:current-podified +export RELATED_IMAGE_HEAT_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-heat-api:current-podified +export RELATED_IMAGE_HEAT_CFNAPI_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-heat-api-cfn:current-podified +export RELATED_IMAGE_HEAT_ENGINE_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-heat-engine:current-podified +export RELATED_IMAGE_SWIFT_PROXY_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-swift-proxy-server:current-podified +export RELATED_IMAGE_SWIFT_ACCOUNT_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-swift-account:current-podified +export RELATED_IMAGE_SWIFT_CONTAINER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-swift-container:current-podified +export RELATED_IMAGE_SWIFT_OBJECT_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-swift-object:current-podified +export RELATED_IMAGE_OCTAVIA_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-octavia-api:current-podified +export RELATED_IMAGE_OCTAVIA_HOUSEKEEPING_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-octavia-housekeeping:current-podified +export RELATED_IMAGE_OCTAVIA_HEALTHMANAGER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-octavia-health-manager:current-podified +export RELATED_IMAGE_OCTAVIA_WORKER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-octavia-worker:current-podified +export RELATED_IMAGE_DESIGNATE_API_IMAGE_URL_DEFAULT=quay.io/tripleowallabycentos9/openstack-designate-api:current-podified +export RELATED_IMAGE_DESIGNATE_CENTRAL_IMAGE_URL_DEFAULT=quay.io/tripleowallabycentos9/openstack-designate-central:current-podified +export RELATED_IMAGE_DESIGNATE_MDNS_IMAGE_URL_DEFAULT=quay.io/tripleowallabycentos9/openstack-designate-mdns:current-podified +export RELATED_IMAGE_DESIGNATE_PRODUCER_IMAGE_URL_DEFAULT=quay.io/tripleowallabycentos9/openstack-designate-producer:current-podified +export RELATED_IMAGE_DESIGNATE_WORKER_IMAGE_URL_DEFAULT=quay.io/tripleowallabycentos9/openstack-designate-worker:current-podified +export RELATED_IMAGE_DESIGNATE_BACKENDBIND9_IMAGE_URL_DEFAULT=quay.io/tripleowallabycentos9/openstack-designate-backend-bind9:current-podified +export RELATED_IMAGE_DESIGNATE_UNBOUND_IMAGE_URL_DEFAULT=quay.io/tripleowallabycentos9/openstack-unbound:current-podified +export RELATED_IMAGE_BARBICAN_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-barbican-api:current-podified +export RELATED_IMAGE_BARBICAN_WORKER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-barbican-worker:current-podified +export RELATED_IMAGE_BARBICAN_KEYSTONE_LISTENER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-barbican-keystone-listener:current-podified diff --git a/pkg/openstack/barbican.go b/pkg/openstack/barbican.go index 6c0d3d48d..c4067061a 100644 --- a/pkg/openstack/barbican.go +++ b/pkg/openstack/barbican.go @@ -106,7 +106,7 @@ func ReconcileBarbican(ctx context.Context, instance *corev1beta1.OpenStackContr barbican.Spec.BarbicanWorker.ContainerImage = *version.Status.ContainerImages.BarbicanWorkerImage barbican.Spec.BarbicanKeystoneListener.ContainerImage = *version.Status.ContainerImages.BarbicanKeystoneListenerImage - // FIXME: barbican webhooks are not setting this correctly yet + // FIXME: barbican webhooks are not setting this correctly yet if barbican.Spec.DatabaseAccount == "" { barbican.Spec.DatabaseAccount = "barbican" } diff --git a/pkg/openstack/version.go b/pkg/openstack/version.go index 7a73baf18..1259608a0 100644 --- a/pkg/openstack/version.go +++ b/pkg/openstack/version.go @@ -41,7 +41,6 @@ func InitializeOpenStackVersionImageDefaults(ctx context.Context, envImages map[ Log.Info(fmt.Sprintf("Initialize Field name: %s", fieldName)) field := d.FieldByName(fieldName) if field.IsValid() && field.CanSet() { - //field.SetString(*val) field.Set(reflect.ValueOf(val)) } else { Log.Info(fmt.Sprintf("Field not found: %s", fieldName)) diff --git a/tests/functional/base_test.go b/tests/functional/base_test.go index d67654ee2..2e57d212b 100644 --- a/tests/functional/base_test.go +++ b/tests/functional/base_test.go @@ -170,6 +170,33 @@ func OpenStackClientConditionGetter(name types.NamespacedName) condition.Conditi return instance.Status.Conditions } +func CreateOpenStackVersion(name types.NamespacedName, spec map[string]interface{}) client.Object { + + raw := map[string]interface{}{ + "apiVersion": "core.openstack.org/v1beta1", + "kind": "OpenStackVersion", + "metadata": map[string]interface{}{ + "name": name.Name, + "namespace": name.Namespace, + }, + "spec": spec, + } + return th.CreateUnstructured(raw) +} + +func GetOpenStackVersion(name types.NamespacedName) *corev1.OpenStackVersion { + instance := &corev1.OpenStackVersion{} + Eventually(func(g Gomega) { + g.Expect(k8sClient.Get(ctx, name, instance)).Should(Succeed()) + }, timeout, interval).Should(Succeed()) + return instance +} + +func OpenStackVersionConditionGetter(name types.NamespacedName) condition.Conditions { + instance := GetOpenStackVersion(name) + return instance.Status.Conditions +} + func CreateOpenStackControlPlane(name types.NamespacedName, spec map[string]interface{}) client.Object { raw := map[string]interface{}{ diff --git a/tests/functional/openstackoperator_controller_test.go b/tests/functional/openstackoperator_controller_test.go index ad5d78cf8..6b431f828 100644 --- a/tests/functional/openstackoperator_controller_test.go +++ b/tests/functional/openstackoperator_controller_test.go @@ -176,6 +176,19 @@ var _ = Describe("OpenStackOperator controller", func() { // make keystoneAPI ready and create secrets usually created by keystone-controller keystone.SimulateKeystoneAPIReady(names.KeystoneAPIName) + // openstackversion exists + Eventually(func(g Gomega) { + osclient := GetOpenStackVersion(names.OpenStackControlplaneName) + g.Expect(osclient).Should(Not(BeNil())) + + th.ExpectCondition( + names.OpenStackControlplaneName, + ConditionGetterFunc(OpenStackVersionConditionGetter), + corev1.OpenStackVersionInitialized, + k8s_corev1.ConditionTrue, + ) + }, timeout, interval).Should(Succeed()) + th.CreateSecret(types.NamespacedName{Name: "openstack-config-secret", Namespace: namespace}, map[string][]byte{"secure.yaml": []byte("foo")}) th.CreateConfigMap(types.NamespacedName{Name: "openstack-config", Namespace: namespace}, map[string]interface{}{"clouds.yaml": string("foo"), "OS_CLOUD": "default"}) diff --git a/tests/functional/suite_test.go b/tests/functional/suite_test.go index 522637713..70ffdfb39 100644 --- a/tests/functional/suite_test.go +++ b/tests/functional/suite_test.go @@ -306,12 +306,16 @@ var _ = BeforeSuite(func() { err = (&openstackclientv1.OpenStackClient{}).SetupWebhookWithManager(k8sManager) Expect(err).NotTo(HaveOccurred()) + err = (&corev1.OpenStackVersion{}).SetupWebhookWithManager(k8sManager) + Expect(err).NotTo(HaveOccurred()) err = (&corev1.OpenStackControlPlane{}).SetupWebhookWithManager(k8sManager) Expect(err).NotTo(HaveOccurred()) + core_ctrl.SetupVersionDefaults() openstack.SetupServiceOperatorDefaults() openstackclientv1.SetupDefaults() corev1.SetupDefaults() + corev1.SetupVersionDefaults() err = (&client_ctrl.OpenStackClientReconciler{ Client: k8sManager.GetClient(), @@ -320,6 +324,13 @@ var _ = BeforeSuite(func() { }).SetupWithManager(k8sManager) Expect(err).ToNot(HaveOccurred()) + err = (&core_ctrl.OpenStackVersionReconciler{ + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + Kclient: kclient, + }).SetupWithManager(k8sManager) + Expect(err).ToNot(HaveOccurred()) + err = (&core_ctrl.OpenStackControlPlaneReconciler{ Client: k8sManager.GetClient(), Scheme: k8sManager.GetScheme(),