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

Unit test for CustomClusterController #373

Merged
merged 5 commits into from Aug 21, 2023
Merged

Unit test for CustomClusterController #373

merged 5 commits into from Aug 21, 2023

Conversation

LiZhenCheng9527
Copy link
Contributor

@LiZhenCheng9527 LiZhenCheng9527 commented Aug 17, 2023

What type of PR is this?

What this PR does / why we need it:
This PR do unit test for customcluster controller. Here is the Coverage
customcluster_controller.go:317: reconcileProvision 100.0%
customcluster_controller.go:380: reconcileDelete 95.2%
customcluster_controller.go:420: deleteWorkerPods 63.6%
customcluster_controller.go:445: deleteResource 60.0%
customcluster_controller.go:484: ensureFinalizerAndOwnerRef 77.8%
customcluster_controller.go:516: WorkerToCustomClusterMapFunc 85.7%
customcluster_controller.go:530: CustomMachineToCustomClusterMapFunc 100.0%
customcluster_controller.go:548: ClusterToCustomClusterMapFunc 85.7%
Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@netlify
Copy link

netlify bot commented Aug 17, 2023

Deploy Preview for kurator-dev canceled.

Name Link
🔨 Latest commit b75e659
🔍 Latest deploy log https://app.netlify.com/sites/kurator-dev/deploys/64e30ad63b0fc50008510739

@hzxuzhonghu
Copy link
Member

for the DCO failure: run git rebase HEAD~2 --signoff and then force push

Signed-off-by: LiZhenCheng9527 <lizhencheng6@huawei.com>
Signed-off-by: LiZhenCheng9527 <lizhencheng6@huawei.com>
@Xieql
Copy link
Contributor

Xieql commented Aug 19, 2023

run make gen on your local corresponding branch, wait for the script to finish, and then push it again.

Signed-off-by: LiZhenCheng9527 <lizhencheng6@huawei.com>

Signed-off-by: LiZhenCheng9527 <lizhencheng6@huawei.com>
}

func generateCluster(clusterName string) *clusterv1.Cluster {
cluster := &clusterv1.Cluster{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cluster := &clusterv1.Cluster{
return &clusterv1.Cluster{

},
},
{
name: "CustomManchine test",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/CustomManchine/CustomMachine

args args
}{
{
name: "Not CustomMachine Error",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: recommend all using small case

Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good work

@kurator-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment


patches := gomonkey.ApplyPrivateMethod(reflect.TypeOf(r), "ensureWorkerPodDeleted",
func(_ *CustomClusterController, ctx context.Context, customCluster *v1alpha1.CustomCluster, manageAction customClusterManageAction) error {
err := errors.New("failede to delete Pod")
Copy link
Contributor

@Xieql Xieql Aug 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/failede/failed

Signed-off-by: LiZhenCheng9527 <lizhencheng6@huawei.com>
Signed-off-by: LiZhenCheng9527 <lizhencheng6@huawei.com>
@Xieql
Copy link
Contributor

Xieql commented Aug 21, 2023

/label tide/merge-method-squash

@Xieql
Copy link
Contributor

Xieql commented Aug 21, 2023

please set a new PR name that includes more information, such as "Unit test for CustomClusterController"
just edit it in this github page

@LiZhenCheng9527 LiZhenCheng9527 changed the title Ut Unit test for CustomClusterController Aug 21, 2023
Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@kurator-bot kurator-bot merged commit a1f972b into kurator-dev:main Aug 21, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants