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 79 forks source link

EPIC: Add UT accross various files in repository #1818

Open Karthik-K-N opened 4 months ago

Karthik-K-N commented 4 months ago

/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.]

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
  2. 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",
    },
    }
3. 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

2. 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.

<img width="1431" alt="image" src="https://github.com/user-attachments/assets/2fd2c8e4-52eb-429a-acae-c09ab8b24592">

```[tasklist]
### 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
Amulyam24 commented 4 months ago

~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

Karthik-K-N commented 2 months ago

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 commented 2 months ago

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

Shilpa-Gokul commented 1 month ago

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

Karthik-K-N commented 2 weeks ago

/reopen

k8s-ci-robot commented 2 weeks ago

@Karthik-K-N: Reopened this issue.

In response to [this](https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/issues/1818#issuecomment-2354608413): >/reopen 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-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
carmal891 commented 2 weeks ago

Picking up UT for the ReconcileLoadBalancers function

arshadd-b commented 1 week ago

Picking up UT for ReconcileVPCSecurityGroups function