-
Notifications
You must be signed in to change notification settings - Fork 6k
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
tests/rgw/notifications: Add tests for RGWPSListTopicsOp::execute() #60788
Conversation
@@ -4359,6 +4360,243 @@ def test_ps_s3_multiple_topics_notification(): | |||
http_server.close() | |||
|
|||
|
|||
@attr('basic_test') |
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.
@attr('basic_test') | |
@attr('data_path_v2_test') |
|
||
|
||
@attr('basic_test') | ||
def test_ps_s3_multiple_topics_v2(): |
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.
def test_ps_s3_multiple_topics_v2(): | |
def test_ps_s3_list_topics(): |
this is not version specific. juts testing topic listing via REST and not via admin command (the main test that was missing)
tenant_topic_conf.del_config(tenant_topic_arn2) | ||
|
||
@attr('basic_test') | ||
def test_ps_s3_multiple_topics_v1(): |
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.
def test_ps_s3_multiple_topics_v1(): | |
def test_ps_s3_list_topics_v1(): |
8800baa
to
cadd9ef
Compare
tenant_topic_conf.del_config(tenant_topic_arn1) | ||
tenant_topic_conf.del_config(tenant_topic_arn2) | ||
|
||
@attr('data_path_v1_test') |
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'm uncertain whether this test should be tagged as basic_test
. Is it appropriate to add @attr('data_path_v1_test')
here? It seems that there aren't currently any tag for v1 tests, while attributes like data_path_v2_test
are present.
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.
the main reason for the v2 tag is so that the automatic test system would run this test in an environment where there is a realm configured.
this is why this test should eb marked as "v2" even though it tests the v1 case
cadd9ef
to
6d25188
Compare
jenkins test make check arm64 |
ListTopicsResult = ListTopicsResponse.get('ListTopicsResult', {}) | ||
Topics = ListTopicsResult.get('Topics', {}) | ||
member = Topics['member'] if Topics else [] | ||
assert_equal(len(member), 4) |
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.
member
is holding 6 topics, both the v2 and the v1 topics
ListTopicsResult = ListTopicsResponse.get('ListTopicsResult', {}) | ||
Topics = ListTopicsResult.get('Topics', {}) | ||
member = Topics['member'] if Topics else [] | ||
assert_equal(len(member), 2) |
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.
member
is holding 3 tenant topics, both the v2 and the v1 topics
""" delete all topics """ | ||
if tenant == '': | ||
topics_result = admin(['topic', 'list'], cluster) | ||
topics_json = json.loads(topics_result[0]) | ||
if(version == 'v1'): |
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 may break, depending with the order opf execution of the test.
what if you try to delete v1 topics that were created intentionally in v1, whiule the conf says v2?
would recommend a more robust way, do a try-catch on Key error, and select the option based on that
6d25188
to
0dad861
Compare
@@ -247,13 +247,15 @@ def delete_all_topics(conn, tenant, cluster): | |||
if tenant == '': | |||
topics_result = admin(['topic', 'list'], cluster) | |||
topics_json = json.loads(topics_result[0]) | |||
for topic in topics_json['topics']: | |||
topics = topics_json.get('topics', []) |
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.
but in this case we do not clear v1 topics.
maybe better to check if topics
is empty, and try to: topics_json.get('result, [])
?
if the value here is not empty, get the topics
.
in this case, it might be simpler to use the KeyError
exception
0dad861
to
9171f06
Compare
for topic in topics_json['topics']: | ||
rm_result = admin(['topic', 'rm', '--topic', topic['name']], cluster) | ||
print(rm_result) | ||
except KeyError as e: |
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.
please do not catch the exception here.
if the results dont have ['topics']
and dont have ['result']['topics']
it is better to let the KeyError
not be caught and fail the test
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.
Thank you for the feedback! I’ve removed the try-except block. If the keys topics
or result
are missing, the KeyError
will now surface naturally, the test will fail appropriately.
for topic in topics_json['topics']: | ||
rm_result = admin(['topic', 'rm', '--tenant', tenant, '--topic', topic['name']], cluster) | ||
print(rm_result) | ||
except KeyError as e: |
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.
same comment
Tests: Add comprehensive test cases to verify the behavior of `RGWPSListTopicsOp::execute()` under various scenarios: Migration case: Validate correct handling when `support_all_zones` is enabled, with v1 in a new state after migration and v2 topics present. v2 notification case: Ensure proper retrieval when v2 notifications are supported. v1 notification case: Verify fallback behavior when v2 notifications are unavailable. Enhancements: Update `delete_all_topics` to handle v1 responses with the `result` key. fixes: https://tracker.ceph.com/issues/68756 Signed-off-by: Oshrey Avraham <[email protected]>
9171f06
to
65614c4
Compare
jenkins test api |
Test Additions:
Added new test cases for
RGWPSListTopicsOp::execute()
to cover the following scenarios:Version Handling for delete_all_topics:
Updated the
delete_all_topics
function to include a version parameter, allowing for better control over topic deletions in v1 and v2 systems. The logic now correctly handles v1 responses, which include a result key in topics_json.Checklist
Show available Jenkins commands
jenkins retest this please
jenkins test classic perf
jenkins test crimson perf
jenkins test signed
jenkins test make check
jenkins test make check arm64
jenkins test submodules
jenkins test dashboard
jenkins test dashboard cephadm
jenkins test api
jenkins test docs
jenkins render docs
jenkins test ceph-volume all
jenkins test ceph-volume tox
jenkins test windows
jenkins test rook e2e