cluster-api-provider-ibmcloud icon indicating copy to clipboard operation
cluster-api-provider-ibmcloud copied to clipboard

EPIC: Add UT accross various files in repository

Open Karthik-K-N opened this issue 1 year ago • 15 comments

/kind feature /area provider/ibmcloud

Describe the solution you'd like [A clear and concise description of what you want to happen.]

Recently we added lots of functionality but haven't added any corresponding UT's to it. Its time to add unit test cases and overall goal is to reach 80% of test coverage.

As a non-goal during the time of adding UT if we find any redundant or unwanted or code duplication, a separate PR needs to be submitted to optimize the code.

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

  • [ ] cloud/scope/powervs_cluster.go
  • [ ] cloud/scope/powervs_machine.go

Instructions for running individual tests on VS Code

  1. Get kubebuilder asset path
$ cd cluster-api-provider-ibmcloud
$ make setup-envtest
kube-builder assets set using darwin OS at location /Users/karthikkn/Library/Application Support/io.kubebuilder.envtest/k8s/1.29.3-darwin-amd64
  1. Create settings.json file with kubebuilder asset path
$ cd cluster-api-provider-ibmcloud/.vscode
$ cat settings.json
cat settings.json
{
    "go.testEnvVars": {
        "KUBEBUILDER_ASSETS": "/Users/karthikkn/Library/Application Support/io.kubebuilder.envtest/k8s/1.29.3-darwin-amd64",
    },
}

  1. Run individual test by clicking on run test above test function name in VS Code editor

Instructions for checking code coverage of file

  1. Generate the test coverage html page
$ cd cluster-api-provider-ibmcloud/.vscode
$ make test-cover

A file named cover.html will be created under cluster-api-provider-ibmcloud directory

example path: /Users/karthikkn/k8-workspace/cluster-api-provider-ibmcloud/cover.html

  1. Copy the path of the file and paste in browser to view the html page and select the file to view the lines covered in UT.
image
### Helper PRs
- [ ] https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/pull/1913
- [ ] https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/pull/1899
### UT PRs
- [ ] https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/pull/1912
- [ ] https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/pull/1927
- [ ] https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/pull/1928

Karthik-K-N avatar May 30 '24 07:05 Karthik-K-N

~Will take up adding UT for cloud/scope/powervs_cluster.go~ Currently not assigning to myself, feel free to pick up UT for powervs_cluster.go

Amulyam24 avatar Jun 04 '24 04:06 Amulyam24

We will add UT for ibmpowervscluster_controller.go file once we finalize and fix the issue https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/issues/1837 as it involves some code refactoring.

Karthik-K-N avatar Jul 10 '24 05:07 Karthik-K-N

If contributing to this issue, Please do comment here with function name to avoid multiple folks working on same thing.

Karthik-K-N avatar Aug 01 '24 06:08 Karthik-K-N

I am working on adding UT for ReconcileNetwork, ReconcileVPC and ReconcileVPCSubnets function

Shilpa-Gokul avatar Aug 22 '24 05:08 Shilpa-Gokul

/reopen

Karthik-K-N avatar Sep 17 '24 06:09 Karthik-K-N

@Karthik-K-N: Reopened this issue.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Sep 17 '24 06:09 k8s-ci-robot

Picking up UT for the ReconcileLoadBalancers function

carmal891 avatar Sep 19 '24 12:09 carmal891

Picking up UT for ReconcileVPCSecurityGroups function

arshadd-b avatar Sep 25 '24 06:09 arshadd-b

Picking up UT for ReconcileTransitGateway function

arshadd-b avatar Oct 23 '24 08:10 arshadd-b

/reopen

Karthik-K-N avatar Oct 25 '24 13:10 Karthik-K-N

@Karthik-K-N: Reopened this issue.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Oct 25 '24 13:10 k8s-ci-robot

/reopen

Amulyam24 avatar Oct 25 '24 14:10 Amulyam24

@Amulyam24: Reopened this issue.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Oct 25 '24 14:10 k8s-ci-robot

Unfortunately we discovered this bug https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/issues/2026, which could have well avoided if we had UT.

Karthik-K-N avatar Oct 28 '24 06:10 Karthik-K-N

picking up UT for ReconcileCOSInstance

carmal891 avatar Oct 28 '24 07:10 carmal891