Skip to content

server: update TestRangeResponse unit test to work correctly with secondary tenant#139841

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
shaikzakiriitm:issue_110018
Feb 3, 2025
Merged

server: update TestRangeResponse unit test to work correctly with secondary tenant#139841
craig[bot] merged 1 commit intocockroachdb:masterfrom
shaikzakiriitm:issue_110018

Conversation

@shaikzakiriitm
Copy link
Copy Markdown
Contributor

@shaikzakiriitm shaikzakiriitm commented Jan 27, 2025

server/storage_api: update TestRangeResponse unit test, to work correctly with secondary application tenant
What was there before: the change focuses on updating the unit test which was failing with secondary tenant while hitting the
_status/range/{id} endpoint. This was happening because the the test had a hard-coded range id 1 to be
fetched from the aforementioned endpoint. And this range id lies outside the scope of a secondary application
tenant.

resolution: made changes to the test to include a range id which lies well within the scope of the secondary tenant.
Fixes: #110018
Part of: https://cockroachlabs.atlassian.net/browse/CRDB-31224
Epic: CRDB-38968

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@shaikzakiriitm shaikzakiriitm self-assigned this Jan 28, 2025
@shaikzakiriitm shaikzakiriitm marked this pull request as ready for review January 29, 2025 05:23
@shaikzakiriitm shaikzakiriitm changed the title Updating TestRangeResponse unit test, to work correctly with secondar… server/storage_api: updating TestRangeResponse unit test, to work correctly with secondary application tenant Jan 29, 2025
Copy link
Copy Markdown
Contributor

@shubhamdhama shubhamdhama left a comment

Choose a reason for hiding this comment

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

Congrats on your first PR 🎉

It's a great start. I have left some minor comments.

t.Run("access range endpoint within current tenant's scope", func(t *testing.T) {
// Test case 1, looking for a range id which lies within the current tenant's (system or secondary tenant, chosen probabilistically) range
var currentTenantRangeId int64 // could be a system tenant or a secondary application tenant
t.Logf("Is system tenant enabled : %v", isSystemTenant)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can remove all these log statements (I'm not very convinced if they are adding value here).

@shubhamdhama
Copy link
Copy Markdown
Contributor

I have some suggestions for the commit message too,

  1. You can remove the first line of "Fix for the issue server: the "range" status API endpoint should work with secondary tenants with sufficient capability #110018". It's mentioned later in Fixes
  2. "Part of" can be removed IMO

@cthumuluru-crdb
Copy link
Copy Markdown
Contributor

nit: fix the commit title as per https://cockroachlabs.atlassian.net/wiki/spaces/CRDB/pages/73072807/Git+Commit+Messages#Commit-title.

Use the imperative mood for titles. For example, write docs: clarify user privileges instead of other moods like docs: claried user privileges or docs: clarifies user privileges.

@shaikzakiriitm
Copy link
Copy Markdown
Contributor Author

shaikzakiriitm commented Jan 30, 2025

  1. You can remove the first line of "Fix for the issue server: the "range" status API endpoint should work with secondary tenants with sufficient capability #110018". It's mentioned later in Fixes

Done

  1. "Part of" can be removed IMO

I wanted to link the pr with the jira ticket, hence used Part of. In the section Epic, we can only link this issue with the epic and not the original task ticket. I wanted that connection between this pr and the actual task ticket. Lmk if there is another way you would suggest this linking.

@shaikzakiriitm shaikzakiriitm changed the title server/storage_api: updating TestRangeResponse unit test, to work correctly with secondary application tenant server/storage_api: update TestRangeResponse unit test, to work correctly with secondary application tenant Jan 30, 2025
@shaikzakiriitm
Copy link
Copy Markdown
Contributor Author

nit: fix the commit title as per https://cockroachlabs.atlassian.net/wiki/spaces/CRDB/pages/73072807/Git+Commit+Messages#Commit-title.

Use the imperative mood for titles. For example, write docs: clarify user privileges instead of other moods like docs: claried user privileges or docs: clarifies user privileges.

done 👍

Copy link
Copy Markdown
Contributor

@cthumuluru-crdb cthumuluru-crdb left a comment

Choose a reason for hiding this comment

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

Congrats on your first PR!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider require.ErrorContains() with "wrong number of ranges in the response" substring.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a custom message which is added as part of the unit test returned from the invocation of validateRangeBelongsToTenant(). Sticking to full error message comparison as this error message is something which is articulated as part of this test and not something returned from the applicationServer or any other such component.

Copy link
Copy Markdown
Contributor

@cthumuluru-crdb cthumuluru-crdb Jan 31, 2025

Choose a reason for hiding this comment

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

Yeah, I saw that. Please consider that comment as a nit. You can also checkout require.EqualError() and require.EqualErrorf() if any of them fit better here.

Copy link
Copy Markdown
Contributor

@shubhamdhama shubhamdhama left a comment

Choose a reason for hiding this comment

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

LGTM!

Left some nits, otherwise looks good.

@shubhamdhama shubhamdhama changed the title server/storage_api: update TestRangeResponse unit test, to work correctly with secondary application tenant server/storage_api: update TestRangeResponse unit test to work correctly with secondary tenant Feb 3, 2025
@shubhamdhama shubhamdhama changed the title server/storage_api: update TestRangeResponse unit test to work correctly with secondary tenant server: update TestRangeResponse unit test to work correctly with secondary tenant Feb 3, 2025
@shubhamdhama
Copy link
Copy Markdown
Contributor

I think you need to fixup last two commits into the first commit. The end state should contain only one commit.

…ctly with secondary application tenant

What was there before: the change focuses on updating the unit test which was failing with secondary tenant while hitting the
_status/range/{id} endpoint. This was happening because the the test had a hard-coded range id `1` to be
fetched from the aforementioned endpoint. And this range id lies outside the scope of a secondary application
tenant.

resolution: made changes to the test to include a range id which lies well within the scope of the secondary tenant.
Fixes: cockroachdb#110018
Part of: https://cockroachlabs.atlassian.net/browse/CRDB-31224
Epic: CRDB-38968

Release note: None
@shaikzakiriitm
Copy link
Copy Markdown
Contributor Author

bors r=shubhamdhama,cthumuluru-crdb

@shaikzakiriitm
Copy link
Copy Markdown
Contributor Author

shaikzakiriitm commented Feb 3, 2025

Thank you @shubhamdhama @cthumuluru-crdb for your feedback and reviews on my first pr.

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 3, 2025

@craig craig bot merged commit 1eceee1 into cockroachdb:master Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

server: the "range" status API endpoint should work with secondary tenants with sufficient capability

4 participants