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

EPIC: Add UT accross various files in repository #1818

Open
2 tasks
Karthik-K-N opened this issue May 30, 2024 · 4 comments · May be fixed by #1912
Open
2 tasks

EPIC: Add UT accross various files in repository #1818

Karthik-K-N opened this issue May 30, 2024 · 4 comments · May be fixed by #1912
Assignees
Labels
area/provider/ibmcloud Issues or PRs related to ibmcloud provider kind/feature Categorizes issue or PR as related to a new feature.
Milestone

Comments

@Karthik-K-N
Copy link
Contributor

Karthik-K-N commented May 30, 2024

/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
@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. area/provider/ibmcloud Issues or PRs related to ibmcloud provider labels May 30, 2024
@Amulyam24
Copy link
Contributor

Amulyam24 commented Jun 4, 2024

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
Copy link
Contributor Author

We will add UT for ibmpowervscluster_controller.go file once we finalize and fix the issue #1837 as it involves some code refactoring.

@Karthik-K-N
Copy link
Contributor Author

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

@Karthik-K-N Karthik-K-N changed the title EPIC: Add UT accross varioius files in repository EPIC: Add UT accross various files in repository Aug 6, 2024
@Shilpa-Gokul
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/provider/ibmcloud Issues or PRs related to ibmcloud provider kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants