kubernetes-sigs / cluster-api-provider-ibmcloud

Cluster API Provider for IBM Cloud
https://cluster-api-ibmcloud.sigs.k8s.io
Apache License 2.0
62 stars 77 forks source link

Enhance the unit test coverage #662

Closed mkumatag closed 2 years ago

mkumatag commented 2 years ago

/kind feature /area provider/ibmcloud

Describe the solution you'd like Here is the present unit test coverage as on 5th May 2022 which is really low, needs improvement

image

Anything else you would like to add: [Miscellaneous information that will assist in solving the issue.]

mkumatag commented 2 years ago

/assign @Amulyam24 /cc @Prajyot-Parab

Prajyot-Parab commented 2 years ago

Findings -

cluster-api is using Gomega based approach for unit testing purposes. capi-ibmcloud should follow the same approach to be in sync with the capi project.

This might lead to major refactoring work in capi-ibmcloud to achieve the same. Also need to explore on helper methods available in capi for reusability purpose or write new ones mainly dealing with test env creation and deletion.

@Amulyam24 Please add if anything is missing

Amulyam24 commented 2 years ago

After a discussion with @Prajyot-Parab, we have decided to follow the unit test framework of cluster-api by avoiding ginkgo.

Prajyot-Parab commented 2 years ago

Files targeted for UT coverage (divided into 2 groups PowerVS and VPC)

Functions to be mocked -

1. powervs_cluster.go / powervs_machine.go
 / powervs_image.go -> NewPowerVSClusterScope -> authenticator.GetAuthenticator()
2. powervs_cluster.go / powervs_machine.go
 / powervs_image.go -> NewPowerVSClusterScope -> servicesutils.GetAccount(auth)

Note - will update the list incase of further mocking required for any other functions.
PowerVS


Cloud/Scope

- powervs_cluster.go

- powervs_machine.go


- powervs_image.go





controllers




- ibmpowervscluster_controller.go




- ibmpowervsmachine_controller.go




- ibmpowervsimage_controller.go


VPC

Cloud/Scope

- cluster.go

- machine.go

controllers

- ibmvpccluster_controller.go

- ibmvpcmachine_controller.go

Note - WIP: compiling list of scenarios to be covered in each of the targeted file, will update soon.

Prajyot-Parab commented 2 years ago

WIP list of the scenarios to be covered in IBMPowerVSCluster controller tests :

Amulyam24 commented 2 years ago

WIP test scenarios for IBMPowerVS machine controller:

Prajyot-Parab commented 2 years ago

PRs related to this work-item:

Prajyot-Parab commented 2 years ago

Can be closed. /close

k8s-ci-robot commented 2 years ago

@Prajyot-Parab: Closing this issue.

In response to [this](https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/issues/662#issuecomment-1199827267): >Can be closed. >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.