Skip to content

Conversation

@iSazonov
Copy link
Collaborator

@iSazonov iSazonov commented Nov 29, 2018

(Replace #8237)

Motivation

I have a PR where there are many new xUnit tests.
It would also be useful to create new xUnit tests for public APIs.
The number of xUnit tests will increase and their ordering is required.

PR Summary

  • Move C# xUnit tests in new folder. This allows to put new xUnit tests in directory structure in accordance with directory structure where cs files are.
  • Use an xUnit TestCaseOrderer attribute to sequentially process tests for powershell.config.json.
  • Update README.md
  • A race condition was fixed which allowed to run all XUnit tests in single batch job.

PR Checklist

Remove unneeded dotnet restore

Add  --no-restore

Add extraParams for MacOS

Fix TestRunspaceWithPowerShellAndInitialSessionState

Fix race condition to access powershell.config.json

Reduce an impact of the inter process race condition

Fix race condition to access powershell.config.json (PowerShell#8249)
@iSazonov iSazonov mentioned this pull request Nov 29, 2018
11 tasks
@iSazonov iSazonov added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Nov 29, 2018
@iSazonov
Copy link
Collaborator Author

@daxian-dbw @TravisEz13 @adityapatwardhan Could you please review the PR? It blocks my follow PRs (one could be used to speed up startup).

@@ -0,0 +1,45 @@
using System;
Copy link
Member

Choose a reason for hiding this comment

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

Please add copyright header.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@@ -0,0 +1,12 @@
using System;
Copy link
Member

Choose a reason for hiding this comment

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

Please add copyright header.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Member

Choose a reason for hiding this comment

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

Still missing copyright header here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, I lost new commits.

Fixed.

}

# we are having intermittent issues on macOS with these tests failing.
# VSTS has suggested forcing them to be sequential
Copy link
Member

Choose a reason for hiding this comment

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

Can we validate if this is still the case. If not, we can removed the condition.

Copy link
Collaborator Author

@iSazonov iSazonov Nov 30, 2018

Choose a reason for hiding this comment

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

Perhaps @TravisEz13 can comment this.

Copy link
Member

Choose a reason for hiding this comment

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

We would have to try it to know.

Copy link
Collaborator Author

@iSazonov iSazonov Dec 1, 2018

Choose a reason for hiding this comment

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

We could open a tracking issue for the work and don't block the PR.

Also we have many CodeFactor issues. Also we need to have more tests for binary APIs. Also we need to have performance tests. I think we should open new tracking issues.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done #8400

public void TestRunspaceWithPowerShellAndInitialSessionState()
{
InitialSessionState iss = InitialSessionState.CreateDefault2();
InitialSessionState iss = InitialSessionState.CreateDefault();
Copy link
Member

Choose a reason for hiding this comment

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

Why was this changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Two tests above use the CreateDefault(). I guess it was typo. If we need tests for CreateDefault2() I believe it should be added in new PR.

Copy link
Member

Choose a reason for hiding this comment

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

I believe CreateDefault2 is intentional as it creates an ISS without any modules loaded. Please change it back.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reverted with new comment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@adityapatwardhan that seems like a method name that probably needs revising, if we can, or adding an alias for in some fashion. Ilya is generally pretty familiar with the repo; if he got it confused, it's likely others will also.

Copy link
Member

Choose a reason for hiding this comment

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

Changing the methodName would be a huge breaking change, but we could add a new method that calls this that is named better. I would suggest filing an issue about this.

@adityapatwardhan
Copy link
Member

@iSazonov Please resolve the merge conflict.

Copy link
Member

Choose a reason for hiding this comment

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

Why was this added?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was temporary additions.

Removed.

@iSazonov
Copy link
Collaborator Author

iSazonov commented Dec 6, 2018

I restarted CI-Windows - there was a race condition again. Perhaps it is only test specific issue. @adityapatwardhan @daxian-dbw could you please look? There test cleanup code failed but I don't understand that process lock the config file. I guess it is other test processes. In this case we need improve the test cleanup code like we did in WaitFile().

@iSazonov
Copy link
Collaborator Author

iSazonov commented Dec 7, 2018

I updated #8400 to fix the rare race condition in tests.

@adityapatwardhan We could merge.

@iSazonov
Copy link
Collaborator Author

@adityapatwardhan Could you please update your code review and merge?

@TravisEz13
Copy link
Member

@iSazonov @adityapatwardhan Is out of the office until the new year.

@iSazonov
Copy link
Collaborator Author

@TravisEz13 If you could merge I could continue my work.

@TravisEz13 TravisEz13 self-assigned this Dec 12, 2018
Remove unneeded dotnet restore

Add  --no-restore

Add extraParams for MacOS

Fix TestRunspaceWithPowerShellAndInitialSessionState

Fix race condition to access powershell.config.json

Reduce an impact of the inter process race condition

Fix race condition to access powershell.config.json (PowerShell#8249)
@TravisEz13
Copy link
Member

rebased the branch mainly to verify the tests still pass

@iSazonov
Copy link
Collaborator Author

The test TestRunspaceWithPowerShellAndInitialSessionState fail exclusively and randomly on MacOs if we use CreateDefault2(). The test passes with CreateDefault(). I guess that previously we hided an race condition issue on MacOs by using sequential tests.
I added the issue to #8400 for tracking the issue and added commit to use ``CreateDefault()`.

@TravisEz13 TravisEz13 dismissed adityapatwardhan’s stale review December 13, 2018 22:20

Aditya is out of the office

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Test Indicates that a PR should be marked as a test change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants