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

Set up end to end Send/Receive testing with LexBox #342

Merged
merged 73 commits into from
Aug 26, 2024

Conversation

rmunn
Copy link
Collaborator

@rmunn rmunn commented Jul 25, 2024

Fixes #339.

This PR uses the LexBox API to set up end-to-end testing of Send/Receive scenarios.

Work completed:

  • Reset project on LexBox to empty
  • Upload new state of LexBox project
  • Remove the last N commits from a LexBox project
  • LcmTestHelper class full of static methods
  • SRTestBase class that sets up and tears down temp folders appropriately, and can pass appropriate temp folders to LcmTestHelper methods
  • Commit .fwdata changes and push result to LexBox
  • First real end-to-end S/R test

Future plans:

In a new PR, I will port most of the SynchronizeActionTests tests and convert them to real end-to-end tests. Then I'll add some more tests testing things like round-tripping of comments, various merge conflict scenarios, and so on.

Will be used in end-to-end testing scenarios
This will enable setting projects to specific commits before the test.
This test can now exercise the "reset project to known revision"
functionality in LexBox, proving that it works.
Copy link

github-actions bot commented Jul 25, 2024

Test Results

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

Results for commit 9f09fc0. ± Comparison against base commit f518d8d.

♻️ This comment has been updated with latest results.

rmunn added 24 commits July 30, 2024 13:55
Give it a project code, get an FwProject back, it does the rest. (It's
the caller's job to dispose of the FwProject when you're done, though).
Also add test demonstrating that the helper works, and we can modify an
entry's citation form, then push the modified entry to LexBox.
Now test code doesn't have to deal with undo/redo accessors.
So far the test is failing, so it's not working yet.
Now, if you tag a test with `[Property("projectCode", "sena-3")]` it
will automatically restore the sena-3 project to its original state at
the end of the test. This will ensure idempotence even if tests fail.
It's causing overload ambiguity when you create an SRTestEnvironment
with no parameters. We'll just pass the port number in as a string.
Now we have one folder per test, and it's deleted afterwards if the test
passed. If the test failed, the folder is preserved, but it will be
deleted the next time the test runs, so investigate before re-running
tests if you need the files in the folder.
Now that temp folders are set up properly, we can run tests that clone,
commit, and push repeatedly: the LexBox project is automatically
returned to its original state at the end of the test, and the temp
folders are cleaned up prior to the next test being run.
Turns out the .fwdata file isn't updated until you call .Commit() on the
action handler.
Also renamed CommitChanges to CommitAndPush.
Also make it static so that tests can supply their own dependencies
without needing to create an instance of ConvertMongoToLcmComments or
ConvertLcmToMongoComments in order to use the method.
This causes a .ChorusNotes file to show up in the sena-3 project in
LexBox, thereby proving that it can be done. Later we'll turn this into
a real round-trip test of some kind.
LcmTestHelper was the wrong place to put CommitAndPush since that needs
to deal with URLs, and URLs are already being dealt with in SRTestEnv.
This will enable other code to just ask the test environment what the
lexbox username and password are, and not have to look it up from the
environment variables all the time.
If you run multiple tests that want to reset the same project, the
second one was erroring out because the zip file already existed. We
now use random names for the files and dirs in the reset-project
method so that this cannot occur.
Plus a basic test demonstrating creating a new project, which will
eventually move to the base class or the SRTestEnvironment class.
Run `dotnet test --filter E2E_` to see `hg clone` return 404 on a
newly-created project. Won't happen every single time, but will happen
often enough that it's likely to cause problems. Solution is going to be
to make CloneRepoFromLexbox more resilient against temporary 404s.
@rmunn
Copy link
Collaborator Author

rmunn commented Aug 19, 2024

Okay, commit 779358e demonstrates the race condition with hgweb's dir cache in local LexBox, and commit 80d45bb adjusts these tests to expect newly-created projects to sometimes not be available right away, avoiding the race condition. To test a potential fix in LexBox, use commit 779358e and run dotnet test --filter E2E_ repeatedly until you get test failures (shouldn't take long).

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.

This looks like a great start. I think there's still a bit of work to do before we can merge it in. Inparticualr I'd like to make a bunch of the static code to be non static instead. Also it's not clear to me why we have both SRTest base and e2eTestBase and why one inherits from the other. I'd like to either merge those into one class, or just make one encapsulate the other.

src/LfMerge.Core.Tests/E2E/TryOutE2ETests.cs Outdated Show resolved Hide resolved
src/LfMerge.Core.Tests/E2E/E2ETestBase.cs Outdated Show resolved Hide resolved
src/LfMerge.Core.Tests/SRTestEnvironment.cs Show resolved Hide resolved
src/LfMerge.Core.Tests/SRTestBase.cs Outdated Show resolved Hide resolved
src/LfMerge.Core.Tests/TestDoubles.cs Outdated Show resolved Hide resolved
This ensures that the override will only affect the test it's set in,
rather than potentially affecting other tests if we forget to clear the
environment variable in a `finally` block.
Rather than assume that the test will be running against the sena-3
project, let's make the test grab an arbitrary entry (the first one that
the LexEntryRepository knows about) and use it. Since the entry whose
GUID we hardcoded was actually the first LexEntry sorted by GUID, this
currently has no effect as we're actually testing the same entry we were
before — but it will allow us to change the test later.
Since we're not going to be creating any other test fixtures derived
from SRTestBase, there's no point in having two base classes; it has
become over-engineering now that we've decided on just one E2E test.
Instead of the tests failing if LexBox isn't available, this will just
mark them as ignored.
@rmunn rmunn requested a review from hahn-kev August 21, 2024 07:08
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.

left some more feedback for this PR.

src/LfMerge.Core.Tests/E2E/E2ETestBase.cs Outdated Show resolved Hide resolved
src/LfMerge.Core.Tests/E2E/E2ETestBase.cs Outdated Show resolved Hide resolved
src/LfMerge.Core.Tests/E2E/E2ETestBase.cs Outdated Show resolved Hide resolved
src/LfMerge.Core.Tests/E2E/E2ETestBase.cs Show resolved Hide resolved
src/LfMerge.Core.Tests/SRTestEnvironment.cs Show resolved Hide resolved
src/LfMerge.Core.Tests/E2E/E2ETestBase.cs Show resolved Hide resolved
src/LfMerge.Core.Tests/E2E/E2ETestBase.cs Outdated Show resolved Hide resolved
src/LfMerge.Core.Tests/SRTestEnvironment.cs Outdated Show resolved Hide resolved
@rmunn rmunn requested a review from hahn-kev August 22, 2024 06:00
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.

left 2 requests. Otherwise it's looking almost done

src/LfMerge.Core.Tests/SRTestEnvironment.cs Outdated Show resolved Hide resolved
The library doesn't do this for us. This would be unsafe if we weren't
awaiting the result of TusPatchAsync, but by the time TusPatchAsync
returns, the FileStream is no longer needed.
@rmunn rmunn requested a review from hahn-kev August 26, 2024 06:44
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, we will enable these to run on CI in another PR

@rmunn rmunn merged commit 0af5ec7 into develop Aug 26, 2024
3 checks passed
@rmunn rmunn deleted the feat/end-to-end-testing-with-lexbox branch August 26, 2024 08:11
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.

Set up end-to-end testing of Send/Receive
2 participants