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

Allow using cargo nextest for running tests #13045

Merged
merged 7 commits into from
Oct 25, 2024

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Oct 21, 2024

Which issue does this PR close?

Closes #13044

Rationale for this change

I want to use cargo nextest: https://nexte.st/ is a faster way to run tests

I want to run like this

cargo nextest run

But that errors as explained on #13044

What changes are included in this PR?

  1. Stub out some more CLI arguments in sqllogictests test runner so it doesn't interfere with nextest

Are these changes tested?

Yes, by CI

I also ran it manually and I can now run the entire test suite (other than sqllogictest) in 30s keeping all cores busy

(venv) andrewlamb@Andrews-MacBook-Pro-2:~/Software/datafusion$ cargo nextest run
...
        PASS [   3.946s] datafusion-physical-expr-common binary_map::tests::test_string_overflow
        PASS [  27.468s] datafusion::fuzz fuzz_cases::equivalence::projection::ordering_satisfy_after_projection_random
------------
     Summary [  29.137s] 5349 tests run: 5349 passed, 11 skipped

Are there any user-facing changes?

No this is a developer change

@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Oct 21, 2024
@alamb alamb added development-process Related to development process of DataFusion devrel and removed devrel labels Oct 21, 2024
datafusion/sqllogictest/bin/sqllogictests.rs Outdated Show resolved Hide resolved
// nextest parses stdout
if options.list {
eprintln!("NOTICE: --list option unsupported quitting");
return Ok(());
Copy link
Member

Choose a reason for hiding this comment

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

why Ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because if it returns an error, cargo nextest aborts immediately

What is happening I think is that nextest lists all possible commands first (by running cargo test ... --list --format terse) and then uses that output to determine what is subsequently run.

So if the --list part returns an error then none of the tests run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some comments in fd15523

@github-actions github-actions bot removed the development-process Related to development process of DataFusion label Oct 22, 2024
Comment on lines +68 to +71
// return Ok, not error so that tools like nextest which are listing all
// workspace tests (by running `cargo test ... --list --format terse`)
// do not fail when they encounter this binary. Instead, print nothing
// to stdout and return OK so they can continue listing other tests.
Copy link
Member

Choose a reason for hiding this comment

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

❤️
a very good explanation

datafusion/sqllogictest/bin/sqllogictests.rs Outdated Show resolved Hide resolved
datafusion/sqllogictest/bin/sqllogictests.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@jayzhan211 jayzhan211 left a comment

Choose a reason for hiding this comment

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

👍

@findepi
Copy link
Member

findepi commented Oct 25, 2024

if cargo nextest is supposed to work, are we also going to have CI guarantee that?

@alamb
Copy link
Contributor Author

alamb commented Oct 25, 2024

if cargo nextest is supposed to work, are we also going to have CI guarantee that?

That is an excellent question

One way to do this would be to use nextest to run the tests, which might improve the CI speed (though we would have to pay for the time to build/install nextest itself) -- we actually do this in influxdb_iox and it works pretty well.

In general I assume this is a developer convenience for a small number of developers, if it breaks as part of a subsequent PR we can also always fix it again and it won't affect other PRs. If these assumptions turn out to be untrue, we should reasses.

Thus in my opinion adding adding a CI test would impose a burden that is not commensurate with the value that would be gained

@alamb
Copy link
Contributor Author

alamb commented Oct 25, 2024

Thanks @findepi and @jayzhan211 for the reviews

@findepi
Copy link
Member

findepi commented Oct 25, 2024

cargo test vs cargo nextest -- there is more to than just speed.

cargo nextest runs each test in separate process, providing awesome isolation.
Is it good for developers? it should, but it actually depends.
The tools i tried (RustRover, VS Code) are capable of running a test module, but they don't seem to understand nextest, so they run without process-per-test isolation, which kills productivity if tests actuall leverage isolation.
(@alamb do you or someone at influx have a solution to this?)

so

  • if it's just supported but not guaranteed (this PR), i am fine with the change -- LGTM
  • if we want to embrace nextest as the way to run tests -- i am probably fine to, but let's make sure we understand benefits and drawbacks

@alamb
Copy link
Contributor Author

alamb commented Oct 25, 2024

if it's just supported but not guaranteed (this PR), i am fine with the change -- LGTM

if we want to embrace nextest as the way to run tests -- i am probably fine to, but let's make sure we understand benefits and drawbacks

I don't think this is necessary / good to try and push. I think allowing developers the freedom to use whatever tools they deem best is better than trying to require one particular toolset

they run without process-per-test isolation, which kills productivity if tests actuall leverage isolation.
(@alamb do you or someone at influx have a solution to this?)

TLDR is we make sure all our tests are isolated / don't use global state -- which takes quite a bit of finagling when it involves subprocesses / end to end type tests.

@alamb alamb merged commit 7b2284c into apache:main Oct 25, 2024
24 checks passed
@alamb
Copy link
Contributor Author

alamb commented Oct 25, 2024

Thank you again @findepi and @jayzhan211 for your helpful comments

@alamb alamb deleted the alamb/support-nextest branch October 25, 2024 21:27
@Omega359
Copy link
Contributor

@alamb
Copy link
Contributor Author

alamb commented Oct 29, 2024

Would this be worthy of adding to https://github.com/apache/datafusion/blob/main/docs/source/contributor-guide/testing.md ?

Yes, totally -- proposed change in #13160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support running datafusion tests with cargo nextest
4 participants