Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[envtest]Improve coverage #63

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ vet: gowork ## Run go vet against code.

.PHONY: test
test: manifests generate gowork fmt vet envtest ginkgo ## Run tests.
# TODO(gibi): enable --randomize-all and fix test failures
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) -v debug --bin-dir $(LOCALBIN) use $(ENVTEST_K8S_VERSION) -p path)" $(GINKGO) --trace --cover --coverpkg=../../pkg/placement,../../controllers,../../api/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./tests/...
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) -v debug --bin-dir $(LOCALBIN) use $(ENVTEST_K8S_VERSION) -p path)" $(GINKGO) --trace --cover --coverpkg=../../pkg/placement,../../controllers,../../api/v1beta1 --coverprofile cover.out --covermode=atomic --randomize-all $(GINKGO_ARGS) ./tests/...

##@ Build

Expand Down
58 changes: 58 additions & 0 deletions tests/functional/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,64 @@ import (
placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1"
)

type Names struct {
Namespace string
PlacementAPIName types.NamespacedName
ConfigMapName types.NamespacedName
DBSyncJobName types.NamespacedName
MariaDBDatabaseName types.NamespacedName
DeploymentName types.NamespacedName
PublicServiceName types.NamespacedName
InternalServiceName types.NamespacedName
KeystoneServiceName types.NamespacedName
KeystoneEndpointName types.NamespacedName
ServiceAccountName types.NamespacedName
RoleName types.NamespacedName
RoleBindingName types.NamespacedName
}

func CreateNames(placementAPIName types.NamespacedName) Names {
return Names{
Namespace: placementAPIName.Namespace,
PlacementAPIName: placementAPIName,
ConfigMapName: types.NamespacedName{
Namespace: placementAPIName.Namespace,
Name: placementAPIName.Name + "-config-data"},
// FIXME(gibi): the db sync job name should not be hardcoded
// but based on the name of the PlacementAPI CR
DBSyncJobName: types.NamespacedName{
Namespace: placementAPIName.Namespace,
Name: "placement-db-sync"},
MariaDBDatabaseName: placementAPIName,
// FIXME(gibi): the deployment name should not be hardcoded
// but based on the name of the PlacementAPI CR
DeploymentName: types.NamespacedName{
Namespace: placementAPIName.Namespace,
Name: "placement"},
PublicServiceName: types.NamespacedName{
Namespace: placementAPIName.Namespace,
Name: "placement-public"},
InternalServiceName: types.NamespacedName{
Namespace: placementAPIName.Namespace,
Name: "placement-internal"},
KeystoneServiceName: types.NamespacedName{
Namespace: placementAPIName.Namespace,
Name: "placement"},
KeystoneEndpointName: types.NamespacedName{
Namespace: placementAPIName.Namespace,
Name: "placement"},
ServiceAccountName: types.NamespacedName{
Namespace: placementAPIName.Namespace,
Name: "placement-" + placementAPIName.Name},
RoleName: types.NamespacedName{
Namespace: placementAPIName.Namespace,
Name: "placement-" + placementAPIName.Name + "-role"},
RoleBindingName: types.NamespacedName{
Namespace: placementAPIName.Namespace,
Name: "placement-" + placementAPIName.Name + "-rolebinding"},
}
}

func GetDefaultPlacementAPISpec() map[string]interface{} {
return map[string]interface{}{
"databaseInstance": "openstack",
Expand Down
Loading