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
Conversation
61e7c88
to
4040d21
Compare
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
if it is not okay to add bucketclient
, I will remove it here and define in the test file
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.
Yeah, I think it might be best to add this to the TestClient
the same as the BucketClient
. Not here. https://github.com/rook/rook/blob/master/tests/framework/clients/test_client.go
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.
IMO it make more sense to add here than in TestClient{}
, bucketclient
is similar to rookclient
to execute apis directly on OBC and it requires rest.Config
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.
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 BucketClientset
I think should be in TestClient
because it is much more than just a clientset. It has many more helper methods. I think adding the bucket clientset here would be good, and adding the core of BucketClientset
with its helper methods to TestClient
is the best thing.
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.
There is already bucket client
as part of TestClient, here it more like low-level k8s operations like updating labels which can be easily with bucket client apis
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.
Unless this changed recently, I may have been misinterpreting something. This looks good here as BucketClientset *bktclient.Clientset
with other stuff in TestClient
.
02461f4
to
618bdd4
Compare
created = utils.Retry(12, 2*time.Second, "notification is created", func() bool { | ||
return helper.NotificationClient.CheckNotification(reverseNotificationName) | ||
}) |
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.
This is verifying the notification is created, but does it expect the CephBucketNotification
resource to process and report a status? Is this checking the Ceph RGW's notification, or the CephBucketNotification
resource?
I think my confusion here is a case of not having very good naming. What can we rename CheckNotification
to in order to show it's purpose more clearly? What other methods can we create to reuse in these tests that can help others read them more easily without having to understand the deep inner workings?
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.
Not really, the backend notification will be created both obc and topics are ready. I will rename the CheckNotification
into CheckNotificationCR
and CephBucketNotification
into CephBucketNotificationSetonRGW
618bdd4
to
db9a13c
Compare
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.
I have identified several places in the integration test where what is being tested isn't a valid check. At minimum, these aren't fully verifying the functionality we intend. Additionally, they may contribute to tests being flaky if the behavior in Rook is bugged.
The general trend I can identify is that for the tests that want to ensure something is not changing after some kind of update, the tests are not ensuring that Rook has finished reconciling the update before verifying the end state.
One unrelated question: are we testing that we can create multiple notifications for a single topic?
Another questions I have, possibly needing input from @yuvalif : are we testing the functional end-to-end to verify that notifications from buckets actually get sent to topics?
}) | ||
t.Run("check CephBucketNotification reverse-notification created for bucket after creating topic", func(t *testing.T) { | ||
// check whether bucket notification added, should fail since topic is not created | ||
notificationPresent := helper.BucketClient.CheckBucketNotificationSetonRGW(namespace, storeName, reverseOBCName, reverseBucketName, reverseNotificationName, s3endpoint) |
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.
This is not waiting in a loop, so I don't see how this check is valid. This check would likely always return false, even if Rook eventually reconciled the notification successfully because the test isn't waiting on reconciling to be complete before checking that the reconcile doesn't provision the notification. In order for this check to be valid, we first have to be sure that Rook has finished reconciling the CephBucketNotification resource, then verify that the notification hasn't been provisioned in the RGW.
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.
I need to check the false after reconciling is completed from rook side. From earlier your comments I guess the right way to it with help of status field in bucket notification CR. I will add TODO. so for the time being. Do I need to keep this check or not?
@@ -46,7 +45,7 @@ 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 comment
The 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 comment
The 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 comment
The 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
t.Run("delete CephBucketTopic: new-topic", func(t *testing.T) { | ||
err = helper.TopicClient.DeleteTopic(newTopicName, storeName, httpEndpointService) | ||
assert.Nil(t, err) | ||
}) |
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.
Should we validate after this that the new notification is removed from the RGW?
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.
I am not quite sure @yuvalif do the backend notifications are removed when bucket notifications is CR removed. Or this will be removed only actual bucket is remvoed
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.
- this specific line is for topic CR deletion, not notification CR deletion
- cascade deletion of notification when the notification CR is deleted is not implemented yet. it is planned to be at phase2
- when a bucket is removed, all associated notifications are removed (this is done inside the RGW)
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 add a t.Run()
placeholder with a TODO comment and t.Skip()
to know to come back later and verify then.
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.
@BlaineEXE : Sorry I am not clear here, from @yuvalif comment topic CR deletion is not result in deleting backend notifications or the notification CR. The issue is even if we delete notification CR with current code the backend notification still exists. This is removed only when bucket is removed. I will add t.Run() and TODO with t.Skipped()
as part of notification CR deletion tests cases. But not here. Am I missing something?
@@ -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 comment
The 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 BucketClientset
I think should be in TestClient
because it is much more than just a clientset. It has many more helper methods. I think adding the bucket clientset here would be good, and adding the core of BucketClientset
with its helper methods to TestClient
is the best thing.
it is not planned to add that as part of this PR. |
TBH, I think verifying the functionality end-to-end is a pretty high priority item. The risk of not testing end-to-end here would be that the feature doesn't work for users and that the resources created don't actually enable anything. It's more acceptable in my mind if resources can't be deleted or can't be updated after they're created than if the feature doesn't work at all. On that note, if this feature isn't ready for GA in the Rook 1.8 release, we have options. We could disable it by removing the CRDs from what we generate, but this is probably too everything-or-nothing for our desires right now. We could also update the documentation to warn that the feature is currently still under development and that users should use it with caution and please submit problems as bug reports to us. My estimation is that we will still be actively polishing and finishing this feature for a couple months after we release Rook v1.8.0, meaning the first release where this is actually polished is somewhere in the range of v1.8.4-v1.8.8. Personally, I think we should wait to claim this feature is GA upstream until v1.9 (which doesn't necessarily reflect what we will do downstream). It might be good to have @travisn and @leseb weigh in here as well. |
for sure this is high priority to verify that. but the question is whether this is high priority to automate in the test suite?
agree. these functionalities are in phase2 (post Rook1.8). for the upcoming release the 2 functional changes we plan are:
we will try to add end2end testing as well in the Rook1.8 timeframe after these |
s3client, err := rgw.NewS3Agent(s3AccessKey, s3SecretKey, s3endpoint, "", true, nil) | ||
|
||
if err != nil { | ||
logger.Errorf("S3 client creation failed with error %v", err) |
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 with utils.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 in utils.Retry()
. IMO code is more neat in this way
db9a13c
to
5d21d0a
Compare
I think that for any of these tests that are invalid, I would rather see them use For this PR, let's leave out implementations for tests where things are deleted or don't change with comments to come back later after specific features. Or whatever else might make the test ineffective. |
5d21d0a
to
db06c5a
Compare
@BlaineEXE PTAL |
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.
A few nits, and I think it will be better to not implement tests that aren't valid or for features that aren't yet implemented. I'd rather see TODO items with t.Skip()
that are easy to see rather than forgetting to fix partially-implemented tests that are harder to notice.
@@ -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 comment
The 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 BucketClientset *bktclient.Clientset
with other stuff in TestClient
.
t.Run("delete CephBucketTopic: new-topic", func(t *testing.T) { | ||
err = helper.TopicClient.DeleteTopic(newTopicName, storeName, httpEndpointService) | ||
assert.Nil(t, err) | ||
}) |
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 add a t.Run()
placeholder with a TODO comment and t.Skip()
to know to come back later and verify then.
Added following test cases for bucket notification integration test suite: * different order: OBC - Topic - Notification * different order: OBC - Notification - Topic * adding a label to an existing OBC * deleting a label from an existing OBC Signed-off-by: Jiffin Tony Thottan <thottanjiffin@gmail.com>
db06c5a
to
7a9a712
Compare
Thanks for the hard work and patience. |
test: add more test cases for bucket notfication (backport #9169)
Description of your changes:
Added following test cases for bucket notification integration test
suite:
Signed-off-by: Jiffin Tony Thottan thottanjiffin@gmail.com
Which issue is resolved by this Pull Request:
Resolves #
Checklist:
make codegen
) has been run to update object specifications, if necessary.