-
Notifications
You must be signed in to change notification settings - Fork 597
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: snapshot testing for stream executors #9787
Conversation
...ver_window/snapshots/risingwave_stream__executor__over_window__eowc__tests__over_window.snap
Outdated
Show resolved
Hide resolved
...ver_window/snapshots/risingwave_stream__executor__over_window__eowc__tests__over_window.snap
Outdated
Show resolved
Hide resolved
PTAL and tell whether you like this idea. |
how about splitting Btw, I remember we have mentioned that we can move the unit test into a separate because our streaming executor's tests do not need access private field and methods. And after that we can depend on more utils such as frontend crate. But I can not find that comments or issue. |
Not sure whether it's this comment: #7881 (comment) |
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 not sure whether there'll be many executors that can benefit from this. 🤔
- Some tests are directly manipulating the internal states.
- Some tests require more complicated control flows. (
risingwave/src/stream/src/executor/merge.rs
Line 553 in bd23cc0
async fn test_configuration_change() {
Actually, executor unit tests are not that "snapshot testing" to me. 🤔 The output is supposed to be manually derived by the developer and can be rarely changed. The ideas of simplifying these tests with DSL look good to me though.
I also have similar concerns so created a demo to gain feedbacks :p I guess most executor tests are simple enough to be tested in this way. The only exceptions in my mind are:
Yes, so we don't use snapshot testing for such more fine-grained tests.
The real motivation (as discussed with @TennyZhuang) is that manually write these tests are too tiring and the test coverage is low!!! 😄
So we may hope to find a way to write the simple test pattern (overlapping input/output events) easier. The granularity is between e2e and complete unit tests. It's kind of 1-executor |
I have thought about such test script and it looks pretty cool! |
I agree with the name, it's comparing the output snapshot of a correct (committed) version of executor with latest one. The idea looks great to me! Follow the same idea, can we also make e2e tests snapshot testing (automatically generate output)? |
Yes, that's true. To my understanding, "snapshot testing" is basically "file-based tests". The main idea is just commit the entire output!. It's also called "golden tests" (and the files are called golden files). Here's a blog introducing it https://www.cs.cornell.edu/~asampson/blog/turnt.html
I also have the same question but not sure. Sqllogictest and planner test both support auto completion, so to me they are already kind of "snapshot testing". The only difference is that they put input/output in the same file. Actually that's desired, but we can still do so (contain input in the generated output) for snapshots, which is already done in this PR. Technically I think that's doable (and not hard). The only reason not to do it I can come up with is that current situation is good enough. (I think for sqllogictest that's true, but for planner tests we have some pain points and had some discussions about it #8557) |
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.
LGTM. thanks!
.../snapshots/risingwave_stream__executor__over_window__eowc__tests__over_window_aggregate.snap
Outdated
Show resolved
Hide resolved
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 think this will be very useful to improve test coverage. More importantly it can help us locate bug sources at the executor level. Currently I rely on e2e sql to test executor, but that is not ergonomic to use when we want test something specific for the executor.
Generally LGTM, further improvements can be made in subsequent PRs.
It's exactly what I want, LGTM. We can replace the current tests step by step. |
Codecov Report
@@ Coverage Diff @@
## main #9787 +/- ##
==========================================
- Coverage 71.14% 71.11% -0.04%
==========================================
Files 1250 1250
Lines 209398 209198 -200
==========================================
- Hits 148970 148761 -209
- Misses 60428 60437 +9
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 8 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
The idea is interesting! But what if later someday we want to add mock state store that is not in-memory? Then the output is not available at the first pending. |
IIRC, we have |
I know that. But what I like most is replacing multiple |
My final decisions:
Not decided:
This PR is ready to merge. Final comments welcomed. |
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.
So is expect![[]]
auto-updated on risedev test
? What if developer forgets to run risedev test
locally, will CI check that?
src/stream/tests/it/eowc.rs
Outdated
check_with_script( | ||
|| create_executor(calls.clone(), store.clone()), | ||
r###" | ||
- !barrier 1 | ||
- !chunk |2 | ||
I T I i | ||
+ 1 p1 100 10 | ||
+ 1 p1 101 16 | ||
+ 4 p2 200 20 | ||
- !chunk |2 | ||
I T I i | ||
+ 5 p1 102 18 | ||
+ 7 p2 201 22 | ||
+ 8 p3 300 33 | ||
# NOTE: no watermark message here, since watermark(1) was already received | ||
- !barrier 2 | ||
- recovery | ||
- !barrier 3 | ||
- !chunk |2 | ||
I T I i | ||
+ 10 p1 103 13 | ||
+ 12 p2 202 28 | ||
+ 13 p3 301 39 | ||
- !barrier 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.
This looks a little bit ugly. Can we add indent here?
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.
Can we add indent here?
Yes
This looks a little bit ugly.
I don't know. In theory this is a yaml, so somebody may argue that no indent make more sense. I have no preference 😇
It's only updated if the envvar is set. It's just like a normal |
Will be nice to have sth like |
I don't want to add a script for such simple task and feel env var is good enough. But I don't object to adding it neither. 🤪 |
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Introduce snapshot testing to make writing executor tests easier. See the doc in
src/stream/tests/it/snapshot.rs
for more details.Checklist For Contributors
[ ] I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934)../risedev check
(or alias,./risedev c
)Checklist For Reviewers
Documentation
Click here for Documentation
Types of user-facing changes
Please keep the types that apply to your changes, and remove the others.
Release note