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

SubmoduleTests: Setup repos once for all tests #8334

Merged
merged 2 commits into from Jul 20, 2020

Conversation

gerhardol
Copy link
Member

Fixes #8279

Proposed changes

Setup the Git repos used in the tests only once, to speed up tests.
For me, test time goes down from 1,6 mon to 11s, about twice the time for one test. (Longer time for other users.)

  • Setup attributes for Parallelizable to disallow the individual tests in parallel

More comments in the code

I consider this to be a major hack.

Test methodology

Tests only

Test environment(s)

  • Git Extensions 33.33.33
  • Build da7659f
  • Git 2.27.0.windows.1
  • Microsoft Windows NT 10.0.18362.0
  • .NET Framework 4.8.4180.0
  • DPI 96dpi (no scaling)

✒️ I contribute this code under The Developer Certificate of Origin.

Setup attributes for Parallelizable to disallow the individual tests in parallel
@codecov
Copy link

codecov bot commented Jul 17, 2020

Codecov Report

Merging #8334 into master will decrease coverage by 0.06%.
The diff coverage is 48.71%.

@@            Coverage Diff             @@
##           master    #8334      +/-   ##
==========================================
- Coverage   52.77%   52.70%   -0.07%     
==========================================
  Files         866      866              
  Lines       62691    62615      -76     
  Branches    11300    11289      -11     
==========================================
- Hits        33083    33000      -83     
- Misses      26965    26972       +7     
  Partials     2643     2643              
Flag Coverage Δ
#production 40.74% <ø> (-0.03%) ⬇️
#tests 94.22% <48.71%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@mstv
Copy link
Member

mstv commented Jul 17, 2020

[OneTimeSetUp] cannot be used, as the setup must run after BeforeTest in CommonTestUtils\ConfigureJoinableTaskFactoryAttribute.cs

We should keep this in mind for all tests. CC: @sharwell

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

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

Quick formal comparison with previous.

return;
}

_isInit = true;
_repo1 = new GitModuleTestHelper("repo1");
Copy link
Member

Choose a reason for hiding this comment

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

Tests shouldn't concern themselves with resetting the state after execution. I was thinking of a change along the lines of ReferenceRepoistory:

            if (_repo1 is null)
            {
                _repo1 = new GitModuleTestHelper("repo1");
            }
            else
            {
                _repo1.Reset();
            }

Do you think we can re-write these tests to utilise ReferenceRepository instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

The repos would need not just to reset, but also undo commits. That would require that the initial commit have to be remembered, which will make a more complex setup. Also, a reset will increase the test time slightly.
The test cases cleaning up is much easier.

Copy link
Member Author

Choose a reason for hiding this comment

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

A clean is needed too, in addition to reset and checkout.

@RussKie
Copy link
Member

RussKie commented Jul 19, 2020

Much better now:
image

@RussKie
Copy link
Member

RussKie commented Jul 19, 2020

However on my work machine tests fail to stage and I need 649552a.

@gerhardol
Copy link
Member Author

Much better now:

The tests requiring a second basically runs UpdateSubmoduleStructureAndWaitForResultAsync() for top module (a series of commands parsing .gitmodules creating GitModules recursively) then a couple of git-status from top module and one or two other commands.

Stepping in one test case, one time: Submodule_status_changes_for_top_module_with_first_nested_module_commit_second_nested_module_change
1.1s without setup in debug, 550 ms normally
Repo setup: 6.6 s
UpdateSubmoduleStructureAndWaitForResultAsync: 30 ms
// No changes in repo
First status 114ms
UpdateSubmoduleStatusAndWaitForResultAsync 8 ms
// Make a change in repo3
Commit 8ms
Status 175 ms
UpdateSubmoduleStatusAndWaitForResultAsync 75 ms
// Revert the change for repo3
Status 331ms
UpdateSubmoduleStatusAndWaitForResultAsync 78 ms
// Revert the change
checkout 64 ms
CheckRevertedStatus 76 ms (git-status)

Git status is cached, the time cannot be taken out of context

However, the check that a repo is clean before and after adds 200 ms for this test. Slightly less for some, more for others.
Those could be excluded by default. Just excluding CheckRevertedStatus reduces execution time from 12,3 s to 10,9 s for me.
Harder to find why a test fails though.

Unless there are requests to optimize, I plan to merge in a day or so.

@RussKie
Copy link
Member

RussKie commented Jul 20, 2020 via email

@RussKie RussKie merged commit 7d57d2c into gitextensions:master Jul 20, 2020
@ghost ghost added this to the 4.0 milestone Jul 20, 2020
@gerhardol gerhardol deleted the feature/i8279-subm-tests branch November 14, 2021 13:01
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.

SubmoduleStatusProviderTests extremely slow
3 participants