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

simplify and align functional test CI and docs, and fix failing skipped test #424

Merged
merged 7 commits into from
Sep 4, 2020

Conversation

chrisd8088
Copy link
Contributor

@chrisd8088 chrisd8088 commented Aug 27, 2020

This PR aims to simplify the options for the functional test program, align them between macOS and Windows (including in CI), update the relevant documentation, and fix a failing test so it runs and passes on all platforms.

It may be easiest to review commit-by-commit, but I've also tried to put all of the relevant background into this description as well.


The CI jobs run Scripts\RunFunctionalTests.bat --test-scalar-on-path on Windows and Scripts/Mac/RunFunctionalTests.sh --test-scalar-on-path on macOS. However, these two scripts are different in that the Mac one adds the --full-suite option while the Windows one does not.

One consequence of this is that about 7 additional tests run on macOS than Windows, in the Azure Pipelines CI jobs; for example in this recent build:

Test Count: 189, Passed: 185, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 4

Test Count: 196, Passed: 192, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 4

Specifically these tests are from the CacheServerTests and FetchStepWithoutSharedCacheTests classes.

One of the latter FetchStepWithoutSharedCacheTests currently fails on Windows (the only platform on which it executed, due to its categorization as MacTODO.TestNeedsToLockFile); see for example this Azure Pipeline run in which the ExtraCoverage tests were included on Windows. The failure may have been introduced with the refactoring of the RunVerb logic in PR #295, and not noticed because the CI framework happens to skip this Windows-exclusive job on Windows.


First, we remove the ExtraCoverage category and --extra-only functional test program option, as well as the --windows-only option.

The ExtraCoverage category only includes a small number of tests now, and many of those are marked NeedsUpdatesForNonVirtualizedMode so they don't execute at all. Originally introduced in microsoft/VFSForGit#1046 as an enhancement over the FullSuiteOnly category from the Azure Repos PR 302803, with the intent of speeding developer test runs. Given the small remaining set of working tests in the category, it seems simplest to just remove it.

For similar reasons, we remove the --windows-only option (while keeping the WindowsOnly category). We could add matching --mac-only and --linux-only options, but given the small number of relevant tests, this seems too complex for now.

The --full-suite option currently has no effect, because the only tests parameterized over the set of FileSystemRunners in ScalarTestConfig are the GitMoveRenameTests, and since these are marked NeedsUpdatesForNonVirtualizedMode they don't run at all. With the ExtraCoverage category removed, this means the difference between the Windows RunFunctionalTests.bat script and the Mac RunFunctionalTests.sh one (where the latter uses --full-suite but not the former) no longer has an effect, and the FetchStepFailsWhenItCannotRemoveABadPrefetchPack() test will now run, and fail, on Windows CI jobs.

We could remove --full-suite but instead choose to simply align the Mac RunFunctionalTests.sh script with the Windows equivalent (i.e., not passing that option by default), and then adding the option to both platform's scripts in our Azure Pipelines configurations. This way, if the option does begin to have an effect again in the future, it will run on all CI jobs but won't slow down manual tests.

We update the AuthoringTests.md documentation to reflect these changes as well as others which have been introduced since this project diverged from VFSForGit, particularly the removal of a number of specialized test programs,
classes, and options.

Another cleanup we make is to remove the creation of the EnableGitStatusCacheToken.dat file on Windows by the functional test program, since the relevant implementation was removed in PR #29.

Lastly, we address the skipped-and-failing FetchStepFailsWhenItCannotRemoveABadPrefetchPack() functional
test, which was looking for the string "Unable to delete" in the output from a Scalar run fetch command. That string is no longer output by ReportErrorAndExit() as a result of PR #295, which introduced a common progress meter to the run command. To resolve the test failure we simply check for the continued presence of the locked bad pack file after the first fetch attempt instead of parsing for a specific text string.

The test is also Windows-specific because it depends on an open file handle with a FileShare.None attribute blocking attempts by other processes to delete the file, and this only works in C# on the Windows platform. On Unix platforms, the C# core libraries implement file sharing in an advisory manner only, meaning other programs may simply delete the file.

We therefore mark this test as WindowsOnly, since it effectively does not apply to other platforms. Note that the previous category assigned to the test, MacTODO.TestNeedsToLockFile, dates from VFSForGit and has been migrated to just this one test as a result of changes in PR #170. However, the meaning of that category varies, so we clarify the situation by just marking this WindowsOnly.

@chrisd8088 chrisd8088 changed the title [WIP] [DRAFT ONLY EXPERIMENT] also run ExtraCoverage tests in CI on Windows [WIP] run ExtraCoverage tests in CI on Windows and fix FetchStep test Sep 3, 2020
A limited subset of functional tests are marked as belonging to
the ExtraCoverage category, which was introduced in the
microsoft/VFSForGit#1046 PR as an enhancement over the
FullSuiteOnly category from the Azure Repos PR 302803.
The intent was to make the default functional test run faster
by excluding some less-fragile tests.

However, in Scalar, many of these tests are also marked with
NeedsUpdatesForNonVirtualizedMode and therefore do not run at all,
while the ones which remain have been running in CI on the macOS
platform but not Windows, because Scripts/Mac/RunFunctionalTests.sh
passes the --full-suite option.

In order to simplify the CI and functional test framework,
we eliminate the ExtraCoverage category entirely, which
ensures all working tests run on all platforms in CI.
Since the number of Windows-only functional tests is quite small,
and we generally want to run all tests in CI, the original purpose
of the --windows-only option to the functional test suite has
less value than in the VFSForGit project.  We also do not have
an equivalent --mac-only or --linux-only option.

Therefore we simply remove this option, which tidies the program
logic and ensures all platforms have an equal set of test options.
We make a number of simplifications to the documentation of
the functional test suite to reflect changes from VFSForGit,
notably the absence of a number of specialized test programs,
classes, and options.
In PR microsoft#29 and commit cedeeaa the
VFSForGit GitStatusCache implementation was removed from Scalar.

However, the functional test suite still checked for and created
the EnableGitStatusCacheToken.dat file if it was missing (but only
on Windows).  Since this setup is no longer relevant, we can remove
it now.
In order to align better with the Windows RunFunctionalTests.bat
script, on macOS we change the RunFunctionalTests.sh script so it
does not always pass the --full-suite option to the functional
test program.

This has no substantive impact right now, as the --full-suite option
just defines a set of FileSystemRunners applicable to the platform
in ScalarTestConfig.FileSystemRunners, which is then returned by
FileSystemRunner.Runners() and may be used to parameterize tests
so they run with each type of runner.

However, at present, the only tests parameterized in this way are
the EnlistmentPerFixture.GitMoveRenameTests, which are also in
the NeedsUpdatesForNonVirtualizedMode category and thus do not
run at all.
Although the --full-suite option to the functional test program
does not have any effect at present, per the notes in commit
3a7d9a1, we still choose to pass it in our Azure Pipelines
CI jobs in case it becomes significant again in the future.
The FetchStepFailsWhenItCannotRemoveABadPrefetchPack() functional
test fails at present, as it looks for specific output from the
FetchStep maintenance command in the form of an "Unable to delete"
message.  This string is no longer written to standard output by
the command, however, due to the changes in PR microsoft#295 which introduced
a standard progress meter.  Instead, that string is only written
using this.Context.Tracer.RelatedWarning() in the PerformMaintenance()
method of Scalar.Common.Maintenance.FetchStep, and thus appears only
in the maintenance log files.

The breakage of the test was not noticed because it belongs to the
ExtraCoverage category, and therefore has not been running as part
of the CI suite on Windows because the RunFunctionalTests.bat
script does not supply the --full-suite option.

To resolve the test failure we simply check for the continued
presence of the locked bad pack file after the first fetch attempt
instead of parsing for a specific text string.

The test is also Windows-specific because it depends on an open
file handle with a FileShare.None attribute blocking attempts by
other processes to delete the file, and this only works in C# on
the Windows platform.  On Unix platforms, the C# core libraries
implement file sharing in an advisory manner only; see:

https://github.com/dotnet/runtime/blob/341b8b22280e297daa7d96b4b8a9fa1d40d28aa9/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Unix.cs#L73-L88

We therefore mark this test as WindowsOnly, since it effectively
does not apply to other platforms.  Note that the previous category
assigned to the test, MacTODO.TestNeedsToLockFile, dates from
VFSForGit and has been migrated to just this one test as a
result of changes in PR microsoft#170.  However, the meaning of that
category varies, as the one other functional test in the category
uses Scalar's FileBasedLock and not C# FileShare settings, so we
clarify the situation by just marking this WindowsOnly.
@chrisd8088 chrisd8088 changed the title [WIP] run ExtraCoverage tests in CI on Windows and fix FetchStep test [WIP] simplify and align functional test CI and docs, and fix failing skipped test Sep 4, 2020
@chrisd8088 chrisd8088 changed the title [WIP] simplify and align functional test CI and docs, and fix failing skipped test simplify and align functional test CI and docs, and fix failing skipped test Sep 4, 2020
@chrisd8088 chrisd8088 marked this pull request as ready for review September 4, 2020 02:33
Copy link
Contributor

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

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

I looked at each commit. Great job splitting into small chunks. Thanks for re-adding test coverage.

@chrisd8088 chrisd8088 merged commit 5aaba18 into microsoft:main Sep 4, 2020
@chrisd8088 chrisd8088 deleted the func-test-extra-ci branch September 4, 2020 05:44
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.

2 participants