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

[TS-1197] feat: use nextest #16

Merged
merged 10 commits into from
Jul 25, 2024
Merged

Conversation

GuillaumeDecMeetsMore
Copy link
Collaborator

@GuillaumeDecMeetsMore GuillaumeDecMeetsMore commented Jul 17, 2024

Changed

  • Use nextest for running the tests
  • Add script for launching tests and use it in Just's config
    • Use a temporary container for the tests + use Ryuk to avoid having containers left running in background without any garbage collection

@GuillaumeDecMeetsMore GuillaumeDecMeetsMore self-assigned this Jul 17, 2024
@GuillaumeDecMeetsMore GuillaumeDecMeetsMore changed the title feat: use nextest [TS-1197] feat: use nextest Jul 17, 2024
Base automatically changed from guillaume/refactor/rework-tracing-and-tokio to master July 17, 2024 10:09

Choose a reason for hiding this comment

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

[question] Could we just use testcontainers for this?

Copy link
Collaborator Author

@GuillaumeDecMeetsMore GuillaumeDecMeetsMore Jul 18, 2024

Choose a reason for hiding this comment

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

Ah I forgot to post my comment about this 😓

I wanted to use testcontainers, but the problems is that Rust by default doesn't have a concept of global "beforeAll" and "afterAll"

nextest does have the feature for beforeAll (as an experimental feature), but from what I understand, it's a "one time thing". So, using testcontainers there or a shell script would mean that the containers would start and be killed before running the tests (because the script/app/context is killed before).

(technically, it would work fine for starting the containers. The issue would be on how to garbage collect them)

Note that with NodeJS, I believe it works by keeping a connection opened to the Ryuk container. This is possible because the NodeJS context ("main context") stays alive as long as the tests are running (and the tests are ran inside this context via the use of the vm module). Once the tests are finished, the app "exits", Ryuk detects that the connection is closed and therefore it can kill the containers.

Here, for Rust, from what I understand, each file of test is like a binary executed independently, so we don't have that "main context" (or it's not accessible from what I searched).

So wrapping everything in a shell script seemed the easiest and less complex 😅

Also worth noting that the garbage collection in testcontainers is not finished testcontainers/testcontainers-rs#577

Choose a reason for hiding this comment

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

Works for me!

Copy link

@GuillaumeDecMeetsMore GuillaumeDecMeetsMore merged commit 2215480 into master Jul 25, 2024
2 checks passed
@GuillaumeDecMeetsMore GuillaumeDecMeetsMore deleted the guillaume/feat/use-nextest branch July 25, 2024 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants