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

[wasm] Add support for a random test case orderer, for xunit tests #65628

Merged
merged 8 commits into from
Feb 21, 2022

Conversation

radical
Copy link
Member

@radical radical commented Feb 20, 2022

This is enabled by default for wasm with $(XUnitUseRandomizedTestOrderer)=true.

When the library tests run, they print two messages like:

  info: Using random seed for test cases: 700149826
  info: Using random seed for collections: 700149826
  info: Starting:    System.Collections.Immutable.Tests.dll

These seeds are picked randomly every time the tests are run. To run the
tests with a specific seed, use environment variable
XUNIT_RANDOM_ORDER_SEED, which would run the tests in the exact same order.

When running tests, the environment variable is automatically passed to
the wasm app.

This is enabled by default for wasm with
`$(XUnitUseRandomizedTestOrderer)=true`.

When the library tests run, they print two messages like:

```
  info: Using random seed for test cases: 700149826
  info: Using random seed for collections: 700149826
  info: Starting:    System.Collections.Immutable.Tests.dll
```

These seeds are picked randomly every time the tests are run. To run the
tests with a specific seed, use environment variable
`XUNIT_RANDOM_ORDER_SEED`.

When running with tests, this can be used as:

    `WasmXHarnessMonoArgs="--setenv=XUNIT_RANDOM_ORDER_SEED=<seed>`
@radical radical added the arch-wasm WebAssembly architecture label Feb 20, 2022
@ghost
Copy link

ghost commented Feb 20, 2022

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

This is enabled by default for wasm with
$(XUnitUseRandomizedTestOrderer)=true.

When the library tests run, they print two messages like:

  info: Using random seed for test cases: 700149826
  info: Using random seed for collections: 700149826
  info: Starting:    System.Collections.Immutable.Tests.dll

These seeds are picked randomly every time the tests are run. To run the
tests with a specific seed, use environment variable
XUNIT_RANDOM_ORDER_SEED.

When running with tests, this can be used as:

`WasmXHarnessMonoArgs="--setenv=XUNIT_RANDOM_ORDER_SEED=<seed>`
Author: radical
Assignees: -
Labels:

arch-wasm

Milestone: -

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost assigned radical Feb 20, 2022
@radical
Copy link
Member Author

radical commented Feb 20, 2022

I'm not sure where to add the documentation. Thoughts?

@radical
Copy link
Member Author

radical commented Feb 20, 2022

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz
Copy link
Contributor

vargaz commented Feb 20, 2022

Does this make the test order deterministic wrt to a specific seed ?

@radical
Copy link
Member Author

radical commented Feb 20, 2022

Yep

@radical
Copy link
Member Author

radical commented Feb 20, 2022

Random test failure with v8/linux, but seems to be reliably reproducible with XUNIT_RANDOM_ORDER_SEED=1883302047:

[03:29:54] info: Starting:    System.Runtime.Numerics.Tests.dll
[03:29:58] fail: [FAIL] System.Numerics.Tests.cast_toTest.RunDoubleExplicitCastToBigIntegerTests
[03:29:58] info: Assert.Equal() Failure
[03:29:58] info:           ↓ (pos 0)
[03:29:58] info: Expected: -0
[03:29:58] info: Actual:   0
[03:29:58] info:           ↑ (pos 0)
[03:29:58] info:    at System.Numerics.Tests.cast_toTest.VerifyDoubleExplicitCastToBigInteger(Double value)
[03:29:58] info:    at System.Numerics.Tests.cast_toTest.RunDoubleExplicitCastToBigIntegerTests()
[03:29:58] info:    at System.Reflection.RuntimeMethodInfo.InvokeWorker(Object obj, BindingFlags invokeAttr, Span`1 parameters)

@radical
Copy link
Member Author

radical commented Feb 20, 2022

System.Runtime.Loader.Tests fail randomly, but deterministically with XUNIT_RANDOM_ORDER_SEED=2106784294.

[06:25:43] fail: [FAIL] System.Runtime.Loader.Tests.SatelliteAssembliesTests.SatelliteLoadsCorrectly_FromName(alc: "Empty", assemblyName: "System.Runtime.Loader.Tests", culture: "en")
[06:25:43] info: Assert.Same() Failure
[06:25:43] info: Expected: "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0
[06:25:43] info: Actual:   "Empty" System.Runtime.Loader.AssemblyLoadContext #4
[06:25:43] info:    at System.Runtime.Loader.Tests.SatelliteAssembliesTests.SatelliteLoadsCorrectly_FromName(String alc, String assemblyName, String culture)
[06:25:43] info:    at System.Reflection.RuntimeMethodInfo.InvokeWorker(Object obj, BindingFlags invokeAttr, Span`1 parameters)

Maybe these tests have some unintended dependence on order?

`System.Xml.Tests.TCCloseOutput.*` tests seem to depend on the order of
execution.

```
[06:35:14] fail: [FAIL] System.Xml.Tests.TCCloseOutput.CloseOutput_4(utils: XmlWriterUtils { Async = False, WriterType = UTF8Writer }, outputType: "Stream")
[06:35:14] info: System.IO.FileNotFoundException : File Not Found: writer.out
[06:35:14] info:    at XmlCoreTest.Common.FilePathUtil.getStream(String filename)
[06:35:14] info:    at System.Xml.Tests.TCCloseOutput.CloseOutput_4(XmlWriterUtils utils, String outputType)
[06:35:14] info:    at System.Reflection.RuntimeMethodInfo.InvokeWorker(Object obj, BindingFlags invokeAttr, Span`1 parameters)
```
@radical
Copy link
Member Author

radical commented Feb 20, 2022

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

It seems to cause failures like, reproducible with
`XUNIT_RANDOM_ORDER_SEED=2106784294`:

```
[06:25:43] fail: [FAIL] System.Runtime.Loader.Tests.SatelliteAssembliesTests.SatelliteLoadsCorrectly_FromName(alc: "Empty", assemblyName: "System.Runtime.Loader.Tests", culture: "en")
[06:25:43] info: Assert.Same() Failure
[06:25:43] info: Expected: "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0
[06:25:43] info: Actual:   "Empty" System.Runtime.Loader.AssemblyLoadContext #4
[06:25:43] info:    at System.Runtime.Loader.Tests.SatelliteAssembliesTests.SatelliteLoadsCorrectly_FromName(String alc, String assemblyName, String culture)
[06:25:43] info:    at System.Reflection.RuntimeMethodInfo.InvokeWorker(Object obj, BindingFlags invokeAttr, Span`1 parameters)
```
Randomized runs seem to fail with:

```
[03:29:54] info: Starting:    System.Runtime.Numerics.Tests.dll
[03:29:58] fail: [FAIL] System.Numerics.Tests.cast_toTest.RunDoubleExplicitCastToBigIntegerTests
[03:29:58] info: Assert.Equal() Failure
[03:29:58] info:           ↓ (pos 0)
[03:29:58] info: Expected: -0
[03:29:58] info: Actual:   0
[03:29:58] info:           ↑ (pos 0)
[03:29:58] info:    at System.Numerics.Tests.cast_toTest.VerifyDoubleExplicitCastToBigInteger(Double value)
[03:29:58] info:    at System.Numerics.Tests.cast_toTest.RunDoubleExplicitCastToBigIntegerTests()
[03:29:58] info:    at System.Reflection.RuntimeMethodInfo.InvokeWorker(Object obj, BindingFlags invokeAttr, Span`1 parameters)
```

Reproducible with `XUNIT_RANDOM_SEED_ORDER=1883302047`.
@radical
Copy link
Member Author

radical commented Feb 20, 2022

I have disabled random ordering for these for now. But I haven't opened any issues, because I'm not entirely sure if it's a bug.

@radical
Copy link
Member Author

radical commented Feb 20, 2022

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@akoeplinger akoeplinger left a comment

Choose a reason for hiding this comment

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

LGTM, the random bugs you found look real, I'd file an issue for them and add a comment to the issue to the .csproj's

@radical
Copy link
Member Author

radical commented Feb 21, 2022

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@radical
Copy link
Member Author

radical commented Feb 21, 2022

The runtime tests failure is #65681, which was hit on a rolling build too. I will try to use this randomizer for runtime tests in a follow up PR.

The debugger tests failure is #64588 .

@radical radical merged commit cacb3bf into dotnet:main Feb 21, 2022
@radical radical deleted the tests-random-order branch February 21, 2022 21:58
@ghost ghost locked as resolved and limited conversation to collaborators Mar 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants