-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
test: add more test cases for bucket notfication #9169
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
/* | ||
Copyright 2021 The Rook Authors. All rights reserved. | ||
|
||
|
@@ -46,7 +45,8 @@ func (n *NotificationOperation) UpdateNotification(notificationName string, topi | |
} | ||
|
||
// CheckNotification if notification was set | ||
func (t *NotificationOperation) CheckNotification(notificationName string) bool { | ||
func (t *NotificationOperation) CheckNotificationCR(notificationName string) bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole test isn't really useful. This merely verifies that kubernetes has received the request to create the cephbucketnotification resource and committed it to etcd. Things that are more critical to verify are (1) has Rook finished reconciling the notification, and (2) what is the status of the cephbucketnotification resource. I would suggest separate checks for each. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I agree. It will become sense if the notification status is present in the CR. will add as todo list and modify it after it is added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is planned to be added in phase1 (once the refactoring+UT PR is merged). see: https://gist.github.com/yuvalif/c4c7aed3dbc956a65399865a77c6a929#enhanced-cephbucketnotification-status |
||
// TODO: return result based on reconcile status of the CR | ||
thotz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const resourceName = "cephbucketnotification" | ||
_, err := t.k8sh.GetResource(resourceName, notificationName) | ||
if err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ import ( | |
"time" | ||
|
||
"github.com/coreos/pkg/capnslog" | ||
bktclient "github.com/kube-object-storage/lib-bucket-provisioner/pkg/client/clientset/versioned" | ||
"github.com/pkg/errors" | ||
rookclient "github.com/rook/rook/pkg/client/clientset/versioned" | ||
"github.com/rook/rook/pkg/clusterd" | ||
|
@@ -56,6 +57,7 @@ type K8sHelper struct { | |
remoteExecutor *exec.RemotePodCommandExecutor | ||
Clientset *kubernetes.Clientset | ||
RookClientset *rookclient.Clientset | ||
BucketClientset *bktclient.Clientset | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it is not okay to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think it might be best to add this to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO it make more sense to add here than in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. K8SHelper has all very low-level clients. What is appropriate for the K8SHelper, based on current context might be a low-level OBCClientset, but the overall of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is already There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless this changed recently, I may have been misinterpreting something. This looks good here as |
||
RunningInCluster bool | ||
T func() *testing.T | ||
} | ||
|
@@ -94,13 +96,17 @@ func CreateK8sHelper(t func() *testing.T) (*K8sHelper, error) { | |
if err != nil { | ||
return nil, fmt.Errorf("failed to get rook clientset. %+v", err) | ||
} | ||
bucketClientset, err := bktclient.NewForConfig(config) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get lib-bucket-provisioner clientset. %+v", err) | ||
} | ||
|
||
remoteExecutor := &exec.RemotePodCommandExecutor{ | ||
ClientSet: clientset, | ||
RestClient: config, | ||
} | ||
|
||
h := &K8sHelper{executor: executor, Clientset: clientset, RookClientset: rookClientset, T: t, remoteExecutor: remoteExecutor} | ||
h := &K8sHelper{executor: executor, Clientset: clientset, RookClientset: rookClientset, BucketClientset: bucketClientset, T: t, remoteExecutor: remoteExecutor} | ||
if strings.Contains(config.Host, "//10.") { | ||
h.RunningInCluster = true | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's return an error instead of logging and returning false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CheckBucketNotificationSetonRGW()
is used with along withutils.Retry()
and it expects the function to have only boolean, I can change the signature to include the error value as well, but it won't check properly inutils.Retry()
. IMO code is more neat in this way