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

Commits on Jul 25, 2024

  1. Add MkFwData and SplitFwData commands to LfMerge

    Will be used in end-to-end testing scenarios
    rmunn committed Jul 25, 2024
    Configuration menu
    Copy the full SHA
    7a4873e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ab49c3b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    96f5d39 View commit details
    Browse the repository at this point in the history
  4. Add methods for resetting projects in LexBox

    This will enable setting projects to specific commits before the test.
    rmunn committed Jul 25, 2024
    Configuration menu
    Copy the full SHA
    5dd0a60 View commit details
    Browse the repository at this point in the history
  5. Add a basic unit test to exercise project reset

    This test can now exercise the "reset project to known revision"
    functionality in LexBox, proving that it works.
    rmunn committed Jul 25, 2024
    Configuration menu
    Copy the full SHA
    05a8c93 View commit details
    Browse the repository at this point in the history

Commits on Jul 30, 2024

  1. Add helper method to clone Lcm project from LexBox

    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).
    rmunn committed Jul 30, 2024
    Configuration menu
    Copy the full SHA
    554bd2e View commit details
    Browse the repository at this point in the history
  2. Add GetEntries helper method

    rmunn committed Jul 30, 2024
    Configuration menu
    Copy the full SHA
    4d5d4c9 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    41c58ed View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    83d6e21 View commit details
    Browse the repository at this point in the history
  5. Add helper for commit and push

    Also add test demonstrating that the helper works, and we can modify an
    entry's citation form, then push the modified entry to LexBox.
    rmunn committed Jul 30, 2024
    Configuration menu
    Copy the full SHA
    2b4e84a View commit details
    Browse the repository at this point in the history

Commits on Jul 31, 2024

  1. Improve LcmTestHelper method for setting text

    Now test code doesn't have to deal with undo/redo accessors.
    rmunn committed Jul 31, 2024
    Configuration menu
    Copy the full SHA
    3a54e81 View commit details
    Browse the repository at this point in the history
  2. Add test to ensure commit is working

    So far the test is failing, so it's not working yet.
    rmunn committed Jul 31, 2024
    Configuration menu
    Copy the full SHA
    f28c6ef View commit details
    Browse the repository at this point in the history

Commits on Aug 7, 2024

  1. Start of new SRTestBase class which will autoreset

    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.
    rmunn committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    d2665f5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f273aa6 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4b844e9 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6f93dec View commit details
    Browse the repository at this point in the history

Commits on Aug 8, 2024

  1. Remove overload of SRTestEnvironment constructor

    It's causing overload ambiguity when you create an SRTestEnvironment
    with no parameters. We'll just pass the port number in as a string.
    rmunn committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    fd82dfc View commit details
    Browse the repository at this point in the history
  2. Much better setup and teardown in SRTestBase

    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.
    rmunn committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    9d15c3b View commit details
    Browse the repository at this point in the history
  3. Clone, commit, and push tests are now repeatable

    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.
    rmunn committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    8399906 View commit details
    Browse the repository at this point in the history
  4. Fix the CommitChanges helper function

    Turns out the .fwdata file isn't updated until you call .Commit() on the
    action handler.
    rmunn committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    37fb990 View commit details
    Browse the repository at this point in the history
  5. Fix Mercurial commits committing too much

    Also renamed CommitChanges to CommitAndPush.
    rmunn committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    7009555 View commit details
    Browse the repository at this point in the history

Commits on Aug 9, 2024

  1. Make CallLfMergeBridge public so tests can use it

    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.
    rmunn committed Aug 9, 2024
    Configuration menu
    Copy the full SHA
    1bb8789 View commit details
    Browse the repository at this point in the history
  2. Add basic (rudimentary, even) test for comments

    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.
    rmunn committed Aug 9, 2024
    Configuration menu
    Copy the full SHA
    c9e6854 View commit details
    Browse the repository at this point in the history

Commits on Aug 13, 2024

  1. Refactor, moving HTTP stuff out of LcmTestHelper

    LcmTestHelper was the wrong place to put CommitAndPush since that needs
    to deal with URLs, and URLs are already being dealt with in SRTestEnv.
    rmunn committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    fa873e2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5055ee2 View commit details
    Browse the repository at this point in the history
  3. Refactor SRTestEnv to keep track of URL parts

    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.
    rmunn committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    78bc1f6 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6c857ab View commit details
    Browse the repository at this point in the history
  5. Fix reset-project method failing on existing files

    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.
    rmunn committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    213a7df View commit details
    Browse the repository at this point in the history
  6. Add ability to make GraphQL queries to LexBox

    Plus a basic test demonstrating creating a new project, which will
    eventually move to the base class or the SRTestEnvironment class.
    rmunn committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    7dfef75 View commit details
    Browse the repository at this point in the history
  7. Add other project types even if we won't use them

    Even if we won't use other project types than FLEx, might as well keep
    the enum the same as what LexBox uses, so that if we get a project type
    response that we didn't expect, System.Text.Json will know how to
    deserialize it correctly.
    rmunn committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    3c90d12 View commit details
    Browse the repository at this point in the history
  8. Ensure sena-3.zip is available to all tests

    This gives us a known starting point for all end-to-end tests, without
    needing to check the .zip file into the LfMerge repo.
    rmunn committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    43c02e7 View commit details
    Browse the repository at this point in the history
  9. Move CreateProject into SRTestBase

    Now any test method can just create a new project with a single line.
    rmunn committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    b0c2fe9 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    99e7384 View commit details
    Browse the repository at this point in the history
  11. Auto-delete created projects on test success

    Failed tests will still leave the project in LexBox so that it can be
    examined later.
    rmunn committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    9bd0a09 View commit details
    Browse the repository at this point in the history
  12. Slight GraphQL improvement

    rmunn committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    bf52e49 View commit details
    Browse the repository at this point in the history
  13. Attempt to debug teardown race condition

    Somehow, if the UploadNewProject test is run after the other BasicTests,
    Mercurial isn't finding the newly-created project when the UploadZip
    step runs. However, if UploadNewProject is run in isolation, then
    Mercurial finds it. This is apparently a race condition involving
    Mercurial's new project registration, which we can reproduce
    consistently here.
    
    To reproduce, run:
    
        dotnet test -l "console;verbosity=normal" --filter=Foo_
    
    We should see:
    
    About to reset sr-f7f322b8-b6d8-47e9-bb2c-7dd30426a5a1
    About to upload /tmp/LfMergeSRTests/data/sena-3.zip to sr-f7f322b8-b6d8-47e9-bb2c-7dd30426a5a1
    Done with reset and upload for sr-f7f322b8-b6d8-47e9-bb2c-7dd30426a5a1
    Created sr-f7f322b8-b6d8-47e9-bb2c-7dd30426a5a1
    Teardown for Foo_UploadNewProject
    About to delete project ID f7f322b8-b6d8-47e9-bb2c-7dd30426a5a1
    Successfully deleted project ID f7f322b8-b6d8-47e9-bb2c-7dd30426a5a1
    Teardown for Foo_UploadNewProject completed
    
    But instead we see:
    
    About to reset sr-f7f322b8-b6d8-47e9-bb2c-7dd30426a5a1
    About to upload /tmp/LfMergeSRTests/data/sena-3.zip to sr-f7f322b8-b6d8-47e9-bb2c-7dd30426a5a1
    Teardown for Foo_UploadNewProject
    Teardown for Foo_UploadNewProject completed
    
    And the "Done with reset and upload" step is never reached, becaue the
    LexBox server returns a 404 on the project when we upload the zip file.
    rmunn committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    238049a View commit details
    Browse the repository at this point in the history

Commits on Aug 14, 2024

  1. Remove debug logging since race condition is fixed

    Race condition fixed in LexBox, so we don't need the Console.WriteLine
    calls any longer.
    rmunn committed Aug 14, 2024
    Configuration menu
    Copy the full SHA
    ef5f480 View commit details
    Browse the repository at this point in the history
  2. Derive SRTestEnv from TestEnv class

    Tests continue to pass, so there are no hidden conflicts.
    rmunn committed Aug 14, 2024
    Configuration menu
    Copy the full SHA
    a18650e View commit details
    Browse the repository at this point in the history
  3. Set env var so FW will use temp folder for storage

    FieldWorks and liblcm use the FW_CommonAppData environment variable to
    locate the folder where they should store things like writing systems
    downloaded from SLDR. We want it set to a temp folder for E2E tests.
    rmunn committed Aug 14, 2024
    Configuration menu
    Copy the full SHA
    221d6c3 View commit details
    Browse the repository at this point in the history
  4. Add beginnings of first "real" end-to-end test

    Currently pulls project down from LexBox and verifies data. Next step
    will be to change data in a FieldWorks project, push that to LexBox, and
    verify that LfMerge can resolve merge conflicts.
    rmunn committed Aug 14, 2024
    Configuration menu
    Copy the full SHA
    06ca00c View commit details
    Browse the repository at this point in the history

Commits on Aug 15, 2024

  1. Use static properties for SRTestEnv.HttpClient

    This simplifies the constructor a lot and ends up making tests that
    clone FieldWorks projects a lot easier to write.
    rmunn committed Aug 15, 2024
    Configuration menu
    Copy the full SHA
    6af7169 View commit details
    Browse the repository at this point in the history
  2. Make most SRTestEnv methods static

    Most methods in SRTestEnvironment now access only static properties such
    as the HttpClient, so most of them can now be made static as well.
    rmunn committed Aug 15, 2024
    Configuration menu
    Copy the full SHA
    adcd8f2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    985683d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    70e34e8 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    3fa3660 View commit details
    Browse the repository at this point in the history

Commits on Aug 19, 2024

  1. Clone LF and FW projects with different codes

    This will allow us to check out the LF and FW projects separately, to
    better simulate a true Send/Receive scenario.
    rmunn committed Aug 19, 2024
    Configuration menu
    Copy the full SHA
    01364ce View commit details
    Browse the repository at this point in the history
  2. Working end-to-end Send/Receive test

    Our first test from SynchronizeActionTests fully converted to do
    end-to-end testing with a real LexBox instance, and working.
    rmunn committed Aug 19, 2024
    Configuration menu
    Copy the full SHA
    5689335 View commit details
    Browse the repository at this point in the history
  3. Improve LcmTestHelper API

    Slightly simplifies E2E test code
    rmunn committed Aug 19, 2024
    Configuration menu
    Copy the full SHA
    b0158a4 View commit details
    Browse the repository at this point in the history
  4. Refactor common code, greatly simplifying E2E test

    The code for updating glosses in FW and LF can be extracted into the
    test base class, allowing the individual tests to become a lot more
    readable as it's clear at a glance what's being updated.
    rmunn committed Aug 19, 2024
    Configuration menu
    Copy the full SHA
    ab3c21e View commit details
    Browse the repository at this point in the history
  5. Final refactoring of first E2E test

    The process of doing a Send/Receive to LexBox is also an obvious bit of
    code to extract into a common method call. With this, the whole E2E test
    ends up readable without needing to scroll.
    rmunn committed Aug 19, 2024
    Configuration menu
    Copy the full SHA
    f737703 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    aaf4f36 View commit details
    Browse the repository at this point in the history
  7. Minor code alignment tweak

    rmunn committed Aug 19, 2024
    Configuration menu
    Copy the full SHA
    16d03cd View commit details
    Browse the repository at this point in the history
  8. Remove MkFwData code; we don't need it after all

    The E2E tests aren't going to run the MkFwData executable, they're just
    going to call the LfMergeBridge API directly when needed. Saves time.
    rmunn committed Aug 19, 2024
    Configuration menu
    Copy the full SHA
    38fce52 View commit details
    Browse the repository at this point in the history
  9. Delete more now-unused S/R test code

    Now that we're not modifying existing LexBox projects but rather cloning
    them and creating new projects for each test, we don't need the entire
    "roll project back to previous revision" code.
    rmunn committed Aug 19, 2024
    Configuration menu
    Copy the full SHA
    e48052e View commit details
    Browse the repository at this point in the history
  10. Fix creating empty FLEx projects in LexBox

    Not used in the current E2E test, but will be used in an upcoming test
    rmunn committed Aug 19, 2024
    Configuration menu
    Copy the full SHA
    6d99535 View commit details
    Browse the repository at this point in the history
  11. Remove unused using statements

    rmunn committed Aug 19, 2024
    Configuration menu
    Copy the full SHA
    8db4721 View commit details
    Browse the repository at this point in the history
  12. Demonstrate another hgweb race condition

    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 committed Aug 19, 2024
    Configuration menu
    Copy the full SHA
    779358e View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    80d45bb View commit details
    Browse the repository at this point in the history

Commits on Aug 21, 2024

  1. Make most SRTestEnv methods non-static again

    As requested in code review
    rmunn committed Aug 21, 2024
    Configuration menu
    Copy the full SHA
    3749cbe View commit details
    Browse the repository at this point in the history
  2. Allow overriding repo URL in settings, not env vars

    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.
    rmunn committed Aug 21, 2024
    Configuration menu
    Copy the full SHA
    bea1713 View commit details
    Browse the repository at this point in the history
  3. Don't hardcode GUID in LexBox tests

    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.
    rmunn committed Aug 21, 2024
    Configuration menu
    Copy the full SHA
    946468d View commit details
    Browse the repository at this point in the history
  4. Consolidate E2E base classes into one base class

    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.
    rmunn committed Aug 21, 2024
    Configuration menu
    Copy the full SHA
    5c7059b View commit details
    Browse the repository at this point in the history
  5. Ignore E2E tests if LexBox isn't available

    Instead of the tests failing if LexBox isn't available, this will just
    mark them as ignored.
    rmunn committed Aug 21, 2024
    Configuration menu
    Copy the full SHA
    129aaa2 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    a5b5449 View commit details
    Browse the repository at this point in the history

Commits on Aug 22, 2024

  1. Configuration menu
    Copy the full SHA
    0af5fb2 View commit details
    Browse the repository at this point in the history
  2. Replace unmaintained TUS library with newer one

    Newer library allows passing in an HttpClient, so we don't have to copy
    cookies around.
    rmunn committed Aug 22, 2024
    Configuration menu
    Copy the full SHA
    b3e258d View commit details
    Browse the repository at this point in the history
  3. Dispose SRTestEnv during test TearDown method

    We keep the temp directory around if the test failed, but we dispose
    everything else.
    rmunn committed Aug 22, 2024
    Configuration menu
    Copy the full SHA
    5fe1d6d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    52017e9 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    1eea903 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    0d1e52f View commit details
    Browse the repository at this point in the history

Commits on Aug 26, 2024

  1. Remove now-unused properties

    rmunn committed Aug 26, 2024
    Configuration menu
    Copy the full SHA
    6844012 View commit details
    Browse the repository at this point in the history
  2. Dispose of FileStream after TUS upload

    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 committed Aug 26, 2024
    Configuration menu
    Copy the full SHA
    0f10f6b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9f09fc0 View commit details
    Browse the repository at this point in the history