Skip to content

Integration test tweaks#75

Merged
djc merged 13 commits intomainfrom
test-tweaks
Jan 28, 2025
Merged

Integration test tweaks#75
djc merged 13 commits intomainfrom
test-tweaks

Conversation

@djc
Copy link
Owner

@djc djc commented Jan 28, 2025

@cpu happy to get your feedback!

Copy link
Collaborator

@cpu cpu left a comment

Choose a reason for hiding this comment

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

90% looks great, thank you!

/// See documentation for [`PebbleEnvironment`].
#[tokio::test]
#[ignore]
async fn http_01() -> Result<(), Box<dyn StdError>> {
Copy link
Collaborator

@cpu cpu Jan 28, 2025

Choose a reason for hiding this comment

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

I think this is going to be problematic looking forward to adding more tests. My intent was to have main spin up one Pebble environment and then serially invoke each test.

I'm not a fan of this approach because if tests are run in parallel there will be port conflicts spinning up multiple pebble environments with the same config. Using a different config per test might be workable, but it ratchets up the complexity for little gain IMO.

I was initially thinking of having separate #[test]'s but a single global pebble environment but without using something like Nextest I found the Rust unit test runner too primitive to be able to nicely handle setting up/tearing down a global instance reliably.

Sorry, should have put more of this context in the original desc.

Copy link
Owner Author

@djc djc Jan 28, 2025

Choose a reason for hiding this comment

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

So IMO the previous setup has a big problem, which is that by default, cargo c/cargo t/cargo clippy don't "see" the code. This makes the IDE experience janky and also resulted in clippy issues slipping through CI. So, I'm open to doing it some other way, but I feel strongly about keeping the code in a place where Cargo can see it by default.

Maybe a solution might be to stick the PebbleEnvironment in a LazyLock and allow tests to work from there?

Copy link
Collaborator

Choose a reason for hiding this comment

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

So IMO the previous setup has a big problem, which is that by default, cargo c/cargo t/cargo clippy don't "see" the code. This makes the IDE experience pretty janky and also resulted in clippy issues slipping through CI.

Hm yeah, that is crummy. I hadn't noticed that.

What about removing test = false and then making main() skip the test with a message if it doesn't find the required binaries? based on some quick local testing removing that Cargo.toml bit seems to do the trick w.r.t clippy.

Maybe a solution might be to stick the PebbleEnvironment in a LazyLock and allow tests to work from there?

I actually tried this initially but found that static's aren't dropped and so it was leaving behind pebble processes. As far as I could tell there wasn't any way to know when all the tests were done running to do it manually :-/

Copy link
Owner Author

Choose a reason for hiding this comment

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

What about removing test = false and then making main() skip the test with a message if it doesn't find the required binaries? based on some quick local testing removing that Cargo.toml bit seems to do the trick w.r.t clippy.

I did also consider that, but I'm worried that it'll be easy to miss when the tests just don't run, since there is no kind of "skipped" state in the Cargo test framework.

There's a suggestion here that we could use an atomic counter to drop the processes when the counter goes down to zero, maybe that is a feasible solution?

Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a suggestion here that we could use an atomic counter to drop the processes when the counter goes down to zero, maybe that is a feasible solution?

That's a decent idea. It sounds workable to me. Do you want to run with it or should I?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm running low on time for today. Suggest we merge this and you can pick it up, or I might have a look tomorrow. Got a very sick kid so kinda constrained.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good, best of luck to you & kiddo!

@djc djc merged commit c1eafaf into main Jan 28, 2025
9 checks passed
@djc djc deleted the test-tweaks branch January 28, 2025 16:53
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.

2 participants