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

Use real MongoDB connection for E2E tests #348

Merged
merged 9 commits into from
Aug 29, 2024
Merged

Conversation

rmunn
Copy link
Collaborator

@rmunn rmunn commented Aug 23, 2024

Fixes #345.

The end-to-end LfMerge tests now use a real MongoDB container (spun up and torn down for each test, with no data persistence) rather than a mock Mongo connection. This does require the presence of Docker on the machine running the E2E tests, so that docker run mongo:6 will succeed.

@rmunn rmunn self-assigned this Aug 23, 2024
@rmunn rmunn requested a review from hahn-kev August 23, 2024 03:34
@rmunn rmunn linked an issue Aug 23, 2024 that may be closed by this pull request
Base automatically changed from feat/end-to-end-testing-with-lexbox to develop August 26, 2024 08:11
In E2E tests, the SetInputSystems call would fail because there is no
existing project record in the freshly-created, empty Mongo instance.
We don't want to change LfMerge to create the project record, because
the Language Forge code is responsible for doing that. So instead we
simply skip the update if the project record doesn't exist, allowing E2E
tests to pass while not changing the behavior of real code.
Also print instructions for deleting it once post-failure investigation
is completed.
Copy link

github-actions bot commented Aug 26, 2024

Test Results

    2 files  ±0    21 suites  ±0   5m 34s ⏱️ -8s
315 tests ±0  293 ✔️ ±0  22 💤 ±0  0 ±0 
318 runs  ±0  296 ✔️ ±0  22 💤 ±0  0 ±0 

Results for commit 95e29ea. ± Comparison against base commit 0af5ec7.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

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

the main change I would like is to always cleanup the mongo container, and to throw if mongo fails to start

src/LfMerge.Core.Tests/SRTestEnvironment.cs Show resolved Hide resolved
src/LfMerge.Core.Tests/SRTestEnvironment.cs Outdated Show resolved Hide resolved
src/LfMerge.Core/Settings/LfMergeSettings.cs Outdated Show resolved Hide resolved
src/LfMerge.Core.Tests/SRTestEnvironment.cs Outdated Show resolved Hide resolved
* Always stop Mongo container
* Throw if Mongo container fails to start
* Simpler MongoDbHostAndPort property definition
Unless the flag is set (to a non-empty value) the Mongo container will
be torn down even if tests have failed.
@rmunn rmunn requested a review from hahn-kev August 27, 2024 06:42
Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

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

looks good, I'd like to allow setting LFMERGE_E2E_LEAVE_MONGO_CONTAINER_RUNNING_ON_FAILURE to false should disable it. Otherwise it's good to go

@rmunn rmunn requested a review from hahn-kev August 28, 2024 01:09
@rmunn rmunn merged commit 96284f7 into develop Aug 29, 2024
4 checks passed
@rmunn rmunn deleted the feat/real-mongodb-for-e2e branch August 29, 2024 03:04
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.

LfMerge integration tests with real MongoDB container
2 participants