Skip to content

Commit

Permalink
[wip] add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stuggi committed Oct 11, 2023
1 parent 21678d1 commit d9480bc
Show file tree
Hide file tree
Showing 10 changed files with 726 additions and 39 deletions.
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ golangci-lint:
$(LOCALBIN)/golangci-lint run --fix

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
test: manifests generate gowork fmt vet envtest ginkgo ## Run tests.
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/...

##@ Build

Expand Down Expand Up @@ -202,6 +204,7 @@ $(LOCALBIN):
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
GINKGO ?= $(LOCALBIN)/ginkgo

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
Expand All @@ -223,6 +226,11 @@ envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

.PHONY: ginkgo
ginkgo: $(GINKGO) ## Download ginkgo locally if necessary.
$(GINKGO): $(LOCALBIN)
test -s $(LOCALBIN)/ginkgo || GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo

.PHONY: bundle
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
operator-sdk generate kustomize manifests -q
Expand Down Expand Up @@ -314,9 +322,7 @@ govet: get-ci-tools
GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/govet.sh ./apis

# Run go test against code
gotest: get-ci-tools
GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/gotest.sh
GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/gotest.sh ./apis
gotest: test

# Run golangci-lint test against code
golangci: get-ci-tools
Expand Down
10 changes: 5 additions & 5 deletions apis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/openstack-k8s-operators/openstack-operator/apis
go 1.19

require (
github.com/onsi/ginkgo/v2 v2.12.1
github.com/onsi/ginkgo/v2 v2.13.0
github.com/onsi/gomega v1.28.0
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20231006133827-ce89e0fd01f2
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20231009142602-1164674290d8
Expand All @@ -12,15 +12,15 @@ require (
github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20231001103054-f74a88ed4971
github.com/openstack-k8s-operators/ironic-operator/api v0.3.1-0.20231006045519-4d73854cb09a
github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20231005132119-e75019792469
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231009135225-e0907a2df5d8
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231011150636-e8a0540a3c32
github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20231009110130-3c0fb7e268d4
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.0
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20231010052333-ca883b562d62
github.com/openstack-k8s-operators/nova-operator/api v0.3.1-0.20231006045746-07ad73abfcba
github.com/openstack-k8s-operators/octavia-operator/api v0.3.1-0.20231006045745-018e5ccbd82d
github.com/openstack-k8s-operators/ovn-operator/api v0.3.1-0.20231009090916-684de667f2c9
github.com/openstack-k8s-operators/placement-operator/api v0.3.1-0.20231005123239-669a438b1999
github.com/openstack-k8s-operators/swift-operator/api v0.1.1-0.20230928061421-52a9feee12c9
github.com/openstack-k8s-operators/swift-operator/api v0.3.1-0.20231011130146-67a1837c8c4d
github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20231005115253-5eccb3cf30f5
github.com/rabbitmq/cluster-operator/v2 v2.5.0
k8s.io/apimachinery v0.27.4
Expand Down Expand Up @@ -65,8 +65,8 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/openshift/api v3.9.0+incompatible // indirect
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20231009135225-e0907a2df5d8 //indirect
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20231009135225-e0907a2df5d8
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20231011150636-e8a0540a3c32 //indirect
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20231011150636-e8a0540a3c32
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
Expand Down
16 changes: 6 additions & 10 deletions apis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/onsi/ginkgo/v2 v2.12.1 h1:uHNEO1RP2SpuZApSkel9nEh1/Mu+hmQe7Q+Pepg5OYA=
github.com/onsi/ginkgo/v2 v2.12.1/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o=
github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4=
github.com/onsi/gomega v1.28.0 h1:i2rg/p9n/UqIDAMFUJ6qIUUMcsqOuUHgbpbu235Vr1c=
github.com/onsi/gomega v1.28.0/go.mod h1:A1H2JE76sI14WIP57LMKj7FVfCHx3g3BcZVjJG8bjX8=
github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxCMwNRnMjhhIDOWHJowi6q8G6koI=
Expand All @@ -142,12 +141,9 @@ github.com/openstack-k8s-operators/ironic-operator/api v0.3.1-0.20231006045519-4
github.com/openstack-k8s-operators/ironic-operator/api v0.3.1-0.20231006045519-4d73854cb09a/go.mod h1:NR5xmmZQz/v1EgGfSrL/4yCbQpRbaWLoIx1CgpGiWck=
github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20231005132119-e75019792469 h1:gi9kvJAF8YrsQnRhOVjTWtcjhOqFe7rD3uU6g6pKCFQ=
github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20231005132119-e75019792469/go.mod h1:5v0ngxNmFp8QsINo2bufx1/COJc0q6jm3FMhP3xIAWE=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231009135225-e0907a2df5d8 h1:qXeMYpPJgfZef/0fISzAcwW5+v0QJmSzWyBdaHwcWIk=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231009135225-e0907a2df5d8/go.mod h1:Ozg6SxfwOtMkiH553c0XQBWuygZQq4jDQCpR4hZqlxM=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20231009135225-e0907a2df5d8 h1:Q912rYHVmjmfJ/9P3lAtoTrbiAiv9f1/GXCCR3SYcDU=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20231009135225-e0907a2df5d8/go.mod h1:LOXXvTQCwhOBNd+0FTlgllpa3wqlkI6Vf3Q5QVRVPlw=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20231009135225-e0907a2df5d8 h1:/um/XwnIa6BMZxPZbYeEAtjNEtoLb+6Um3fVyS1UHFE=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20231009135225-e0907a2df5d8/go.mod h1:qkK/2JzIGOzoctfe0sbL+mSelrEmErAND4vuj1qTU/A=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231011150636-e8a0540a3c32 h1:r24jE5tdacLivcZczb3t6RvbvHp6kXQrW2ECuekzgH8=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20231011150636-e8a0540a3c32 h1:n9UNbe3JsJW6IYtk57y/gvYSdiV8W6L4N0PtkZ2EsEg=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20231011150636-e8a0540a3c32 h1:UswqYNyvW/ne9oI9rLwddyT7F/MT+ggL9ElMtO2SRRY=
github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20231009110130-3c0fb7e268d4 h1:w5KreewBoPHSFvmIiIED/wHowUAAovpCyfC2zXgyi2Y=
github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20231009110130-3c0fb7e268d4/go.mod h1:MKtNxShqdW5lCxASkM8/mjsVGJZ6TR6K2UWRV3ccpjQ=
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.0 h1:FB0xB6whYM6W4XIncYo2mPiOJWkFsIOWtCT+UOtvOaQ=
Expand All @@ -162,8 +158,8 @@ github.com/openstack-k8s-operators/ovn-operator/api v0.3.1-0.20231009090916-684d
github.com/openstack-k8s-operators/ovn-operator/api v0.3.1-0.20231009090916-684de667f2c9/go.mod h1:hLgc5WItywTzBSbd9/kZto4R2K5VnaW+OH1nKQtZ4vk=
github.com/openstack-k8s-operators/placement-operator/api v0.3.1-0.20231005123239-669a438b1999 h1:ngZDtnhVgysbkE/17FsdZ1LxGzQyhPKqQPWNK5D1Tn4=
github.com/openstack-k8s-operators/placement-operator/api v0.3.1-0.20231005123239-669a438b1999/go.mod h1:iyp/X2jUYQmIGovZNdvUooA8km+/KnzGOOHIcIWPa4U=
github.com/openstack-k8s-operators/swift-operator/api v0.1.1-0.20230928061421-52a9feee12c9 h1:0eFyMbHhT9qCoW6B/Mc28Ser69pSmPJkkk5mLA8xp2w=
github.com/openstack-k8s-operators/swift-operator/api v0.1.1-0.20230928061421-52a9feee12c9/go.mod h1:cmDpu3koEFV+ssOeEDMjAAW18BvwwmbWXSw0eRIo8yg=
github.com/openstack-k8s-operators/swift-operator/api v0.3.1-0.20231011130146-67a1837c8c4d h1:V1ZI75aJOl3qi7vgFm5Ryj+CDIM8qvt6IeZS9nCev18=
github.com/openstack-k8s-operators/swift-operator/api v0.3.1-0.20231011130146-67a1837c8c4d/go.mod h1:cmDpu3koEFV+ssOeEDMjAAW18BvwwmbWXSw0eRIo8yg=
github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20231005115253-5eccb3cf30f5 h1:rkUXXHZaYlnophF0oLawp/5F1AeB8bxckC+9bu1V9qM=
github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20231005115253-5eccb3cf30f5/go.mod h1:bGZyr0RZ2T2R2wO7akiVc1FzA6cVhPr0zMznPhzlmzY=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
3 changes: 3 additions & 0 deletions controllers/core/openstackcontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"

certmgrv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
routev1 "github.com/openshift/api/route/v1"
cinderv1 "github.com/openstack-k8s-operators/cinder-operator/api/v1beta1"
glancev1 "github.com/openstack-k8s-operators/glance-operator/api/v1beta1"
Expand Down Expand Up @@ -352,5 +353,7 @@ func (r *OpenStackControlPlaneReconciler) SetupWithManager(mgr ctrl.Manager) err
Owns(&redisv1.Redis{}).
Owns(&octaviav1.Octavia{}).
Owns(&routev1.Route{}).
Owns(&certmgrv1.Issuer{}).
Owns(&certmgrv1.Certificate{}).
Complete(r)
}
17 changes: 10 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/ghodss/yaml v1.0.0
github.com/go-logr/logr v1.2.4
github.com/imdario/mergo v0.3.16
github.com/onsi/ginkgo/v2 v2.12.1
github.com/onsi/ginkgo/v2 v2.13.0
github.com/onsi/gomega v1.28.0
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20231006133827-ce89e0fd01f2
github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20231009135826-787268f9a952
Expand All @@ -17,8 +17,9 @@ require (
github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20231001103054-f74a88ed4971
github.com/openstack-k8s-operators/ironic-operator/api v0.3.1-0.20231006045519-4d73854cb09a
github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20231005132119-e75019792469
github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.0.0-20231006072650-7fe7fe16bcd1
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231009135225-e0907a2df5d8
github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.0.0-20231011150636-e8a0540a3c32
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231011150636-e8a0540a3c32
github.com/openstack-k8s-operators/lib-common/modules/test v0.3.1-0.20231011150636-e8a0540a3c32
github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20231009110130-3c0fb7e268d4
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.0
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20231010052333-ca883b562d62
Expand All @@ -29,7 +30,7 @@ require (
github.com/openstack-k8s-operators/openstack-operator/apis v0.0.0-20230725141229-4ce90d0120fd
github.com/openstack-k8s-operators/ovn-operator/api v0.3.1-0.20231009090916-684de667f2c9
github.com/openstack-k8s-operators/placement-operator/api v0.3.1-0.20231005123239-669a438b1999
github.com/openstack-k8s-operators/swift-operator/api v0.1.1-0.20230928061421-52a9feee12c9
github.com/openstack-k8s-operators/swift-operator/api v0.3.1-0.20231011130146-67a1837c8c4d
github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20231005115253-5eccb3cf30f5
github.com/operator-framework/api v0.17.6
github.com/rabbitmq/cluster-operator/v2 v2.5.0
Expand All @@ -45,8 +46,10 @@ require (
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3 // indirect
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.4.0 // indirect
github.com/metal3-io/baremetal-operator/apis v0.3.1 // indirect
github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.2.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/tools v0.14.0 // indirect
sigs.k8s.io/gateway-api v0.6.0 // indirect
)
Expand All @@ -68,7 +71,7 @@ require (
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/google/uuid v1.3.1
github.com/gophercloud/gophercloud v1.7.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -78,8 +81,8 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/openshift/api v3.9.0+incompatible
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20231009135225-e0907a2df5d8 //indirect
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20231009135225-e0907a2df5d8 //indirect
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20231011150636-e8a0540a3c32 //indirect
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20231011150636-e8a0540a3c32 //indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
Expand Down
Loading

0 comments on commit d9480bc

Please sign in to comment.