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

test/cql-pytest: Add test for token() filter againts mutation_fragmen… #18759

Conversation

xemul
Copy link
Contributor

@xemul xemul commented May 20, 2024

…ts()

When selecting from mutation_fragments(table) one may want to apply token() filtering againts partition key. This doesn't work currently, but used to crash. This patch adds a regression test for that

refs: #18637

@xemul xemul added the backport/none Backport is not required label May 20, 2024
@xemul xemul requested a review from avikivity May 20, 2024 12:52
@xemul xemul requested a review from nyh as a code owner May 20, 2024 12:52
@@ -501,3 +501,11 @@ def test_many_partitions(cql, test_keyspace, scylla_only):
assert partition_starts == num_partitions
assert partition_ends == num_partitions
assert len(pks) == num_partitions


def test_mutation_fragments_vs_token(cql, test_keyspace, scylla_only):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment here - not just in the commit message - what this test is about, and that it reproduces issue #18637. Please explain that prior to that issue being fixed it used to crash, and why we consider the weird error this test expects to be correct (?). If it's not correct, please consider saying that in the comment - or perhaps even better, open an issue on what's not correct and make this test "xfail" with that issue.

Note that even an "xfail" test still runs every time, so it guarantees we don't regress the crash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, the #18768 is there and the test is updated.

This xfail marking is not extremely nice, since it would "pass" the test even if it fails somewhere else, not in the place that the test author thinks the test should step on. But chances are low indeed, in 99.(9)% of runs it should fail in the expected select

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the resistance to writing comments. It really makes me sad. Yes, I know you believe that the function name "test_mutation_fragments_vs_token" is super-self-explanatory. I know you think that the xfail "reason" text will forever stay there and refer to the issue which serves as a reasonable description of what this test is about.
But five years from now, long after this issue is solved and the xfail is removed, I don't believe anyone will understand why this test exists, what it tests or why, or if it fails, which issue regressed and which patch we forgot to backport. Especially since historically we had two kinds of failures here - a crash, and a clean failure, each has its own issue. Wouldn't it be nice to get an explanation of all of this as a reason-for this test which right now looks completely mysterious (because it basically calls select and doesn't even check the results - which looks silly if you don't know what kind of bugs this was meant to reproduce).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry that it made you sad. It's not a resistance to write comments, it's some reluctance to duplicate information 🤷 I can imagine the way to look for information about this particular place -- it's git show -> PR number -> github PR page -> github issue page. It's a lot of information already, even though it takes some effort to dig one. I'll try to be more copy-n-past-y next time

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it turns out that our decision to put a lot of effort into our git commit log (this is actually a practice that I learned from Avi, in the Linux kernel world) isn't a victimless crime - the main victim is the comments. People begin to feel that comments are not needed, because someone can always use "git blame" to figure the reason for everything. The problem that this isn't true. The oldest cql-pytest test (in test_keyspace.py) test will soon be four year olds. Our oldest dtest tests are probably 10 year old. Sometimes, "git blame" is very helpful. But very often in old code, it begins a long archeological dig to find the original patch that introduced this test and why it was introduced. When code moves or experiences style changes (e.g., take a lot at dtest's git blame) it's even harder to use git blame, and it's hardest to understand how and why the test was changed later, and is it really testing the same thing as the first version was, or maybe something changed in the purpose of this test.

When I see a test failing, I want to know what this test was intended to check - not just what the code is doing - because it's possible the test itself is buggy or checking things in a bad way. Also, if I see a recent test failing on a certain branch (e.g., 5.2), I want to know what issue this test reproduces - to know what we forgot to backport to that certain branch. When I am worried that a certain corner case isn't being tested, I want to read comments about the intentions of the author of the test - whether they forgot to check this case or there was some logic that meant we don't need to test it. Or maybe it is being tested, just in a way I wouldn't recognize just from the code. When I want to see how a certain area of the code (e.g., filter expressions in Alternator) were tested, I want to skim through the comments to understand what was tested, and what wasn't.

Many of these things I tried to push in the cql-pytest came from my past experience with dtest, where I often encountered failing tests and had no idea what they were checking and why. Conversely, in some rare cases where dtest did contain comments, those were often useful to understand failures.

In my opinion, the state of the current code is more important than any of the other things you described (git log or github issues or PRs). It's not that hard to keep both, especially since it's usually not a simple copy-paste. In your test's case I asked that you at the very minimum just say # Reproduces #18637 (I'd prefer more...). Yes, these two words also appear in the commit message and in the "xfail" line. But each of these serve a different purpose.

…ts()

When selecting from mutation_fragments(table) one may want to apply
token() filtering againts partition key. This doesn't work currently,
but used to crash. This patch adds a regression test for that

refs: scylladb#18637

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
@xemul xemul force-pushed the br-match-token-from-mutation-fragments-test branch from ab61bde to 25db6ed Compare May 20, 2024 17:28
@xemul xemul requested a review from nyh May 20, 2024 17:29
@scylladb-promoter
Copy link
Contributor

🟢 CI State: SUCCESS

✅ - Build
✅ - Unit Tests Custom
The following new/updated tests ran 100 times for each mode:
🔹 cql-pytest/test_select_from_mutation_fragments
✅ - Container Test

Build Details:

  • Duration: 1 hr 36 min
  • Builder: i-01d1ec3f9d828750f (i4i.8xlarge)

@xemul
Copy link
Contributor Author

xemul commented May 24, 2024

@nyh , please re-review

Copy link
Contributor

@nyh nyh left a comment

Choose a reason for hiding this comment

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

The test looks good.
I don't like the lack of comments, but I don't have the patience to keep repeating my requests (which I made in my last review) to add comments, so I'll let this slide this time. But please do try to add more comments next time.

@@ -501,3 +501,11 @@ def test_many_partitions(cql, test_keyspace, scylla_only):
assert partition_starts == num_partitions
assert partition_ends == num_partitions
assert len(pks) == num_partitions


def test_mutation_fragments_vs_token(cql, test_keyspace, scylla_only):
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the resistance to writing comments. It really makes me sad. Yes, I know you believe that the function name "test_mutation_fragments_vs_token" is super-self-explanatory. I know you think that the xfail "reason" text will forever stay there and refer to the issue which serves as a reasonable description of what this test is about.
But five years from now, long after this issue is solved and the xfail is removed, I don't believe anyone will understand why this test exists, what it tests or why, or if it fails, which issue regressed and which patch we forgot to backport. Especially since historically we had two kinds of failures here - a crash, and a clean failure, each has its own issue. Wouldn't it be nice to get an explanation of all of this as a reason-for this test which right now looks completely mysterious (because it basically calls select and doesn't even check the results - which looks silly if you don't know what kind of bugs this was meant to reproduce).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/none Backport is not required promoted-to-master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants