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

patch resourcebinding instead of update and update observed generation. #2345

Merged
merged 2 commits into from
Aug 10, 2022

Conversation

yy158775
Copy link
Contributor

@yy158775 yy158775 commented Aug 8, 2022

What type of PR is this?
/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

patch resourcebinding and clusterresourcebinding instead of update and update observed generation.
add test for them

…neration.

Signed-off-by: yy158775 <1584616775@qq.com>
@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 8, 2022
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 8, 2022
t.Error(err)
}
if !reflect.DeepEqual(res, test.expected) {
t.Errorf("Test %s Not Equal", test.name)
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to log the test name as the name is already present in the result.
For example(I hacked the tests and let it fails) :

$ go test ./pkg/scheduler/... -run=Test_patchBindingScheduleStatus -v
=== RUN   Test_patchBindingScheduleStatus
=== RUN   Test_patchBindingScheduleStatus/add_success_condition
=== RUN   Test_patchBindingScheduleStatus/add_failure_condition
=== RUN   Test_patchBindingScheduleStatus/replace_to_success_condition
=== RUN   Test_patchBindingScheduleStatus/replace_failure_condition
    scheduler_test.go:171: Test replace failure condition Not Equal

The Test_patchBindingScheduleStatus/replace_failure_condition is exactly the test name.

Comment on lines 170 to 172
if !reflect.DeepEqual(res, test.expected) {
t.Errorf("Test %s Not Equal", test.name)
}
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
if !reflect.DeepEqual(res, test.expected) {
t.Errorf("Test %s Not Equal", test.name)
}
if !reflect.DeepEqual(res.Status, test.expected.Status) {
t.Errorf("expected status: %v, but got: %v", test.expected.Status, res.Status)
}

t.Error(err)
}
if !reflect.DeepEqual(res.Status, test.expected.Status) {
t.Errorf("Not Equal")
Copy link
Member

Choose a reason for hiding this comment

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

t.Run(test.name, func(t *testing.T) {
_, err := karmadaClient.WorkV1alpha2().ResourceBindings(test.binding.Namespace).Create(context.TODO(), test.binding, metav1.CreateOptions{})
if err != nil {
t.Error(err)
Copy link
Member

Choose a reason for hiding this comment

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

We should use Fatal or Fatalf here since if there is an error, we can skip following checks.

Signed-off-by: yy158775 <1584616775@qq.com>
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 9, 2022
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/approve

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 10, 2022
@karmada-bot karmada-bot merged commit 0cc00f7 into karmada-io:master Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants