Remoting and Job tests#4928
Conversation
7b504b4 to
194b9e7
Compare
There was a problem hiding this comment.
Why was this check removed?
There was a problem hiding this comment.
ComputerName cannot be null due to ParameterValidation. So this.ComputerName == null is always false. Which makes the if always false due to the &&. Hence unreachable code.
There was a problem hiding this comment.
Makes sense. Can you also remove the error message from RemotingErrorIdStrings.resx and RemotingErrorIdStrings.cs?
There was a problem hiding this comment.
I am worried about race condition here. It is possible for the job to complete before the ValidateJobInfo script runs and cause false failures. I dislike adding 'sleep 1' to the job script because it slows down the test.
I think the best thing is to remove this test for the intermediate 'Running' state and just do the following test for 'Completed' state and check the result.
There was a problem hiding this comment.
I am not as concerned about this intermediate state race condition because the second Start-Job takes time. So we are probably Ok.
There was a problem hiding this comment.
Minor comment. Should we use an AfterEach { Get-Job | Remove-Job -Force -EA Silently } block to clean up after each It block?
There was a problem hiding this comment.
This assumes the first job waiting one second will be the first to complete. This will be true most of the time but it is possible for a different job to complete first. I feel the test can allow '1', '2', '3' as the result and still be a good test
There was a problem hiding this comment.
Was this added to ensure there is a PowerShell 6.0 endpoint available? Or just to ensure remoting is enabled? If so can you add a comment?
There was a problem hiding this comment.
Typo ... "so that when"...
There was a problem hiding this comment.
I think this should be a "Feature" test. Or at least have the "Slow" tag.
There was a problem hiding this comment.
It takes about 10 seconds. I believe it is fast enough to be in CI. Thoughts?
There was a problem hiding this comment.
I am not sure but the testing guidelines say most CI tests take less than one second and the "Slow" tag should be considered if a test takes longer. Since these are critical remoting functions it seems like we should leave them as CI tests, but probably should add the "Slow" tag.
There was a problem hiding this comment.
"Feature" or "Slow" tag?
There was a problem hiding this comment.
These finish in about 12 seconds. I think that should be OK. Thoughts?
There was a problem hiding this comment.
I am not sure but the testing guidelines say most CI tests take less than one second and the "Slow" tag should be considered if a test takes longer. Since these are critical remoting functions it seems like we should leave them as CI tests, but probably should add the "Slow" tag.
PaulHigin
left a comment
There was a problem hiding this comment.
This looks good to me. The only additional feedback I have is:
a. Please also remove InvokeDisconnectWithoutComputerName resource string in InvokeCommandCommand.cs.
b. Consider using 'Slow' tag on the slower remoting tests.
There was a problem hiding this comment.
There seems to be some repetition here in each test case within this context. How about changing the BeforeEach to an AfterEach and removing lines 40, 48, etc...
There was a problem hiding this comment.
AfterEach cleanup is needed within this Context as well.
Comment applies to all Context blocks.
There was a problem hiding this comment.
Organizational nitpick: This is a Receive-Job test that is included within the Wait-Job set of tests
There was a problem hiding this comment.
Moved. Good catch.
There was a problem hiding this comment.
Would a check to make sure that none of the jobs threw errors make sense here too?
There was a problem hiding this comment.
The scriptblock { 1 + 1 } and string ' 1 + 1 ' are repeated throughout This is one of those readability vs changeability trade offs. Did you consider making them script variables?
There was a problem hiding this comment.
I preferred readability. Likelihood of we needing to change is low. Your thoughts?
|
I've had a review going for a few days. I published the comments so that I can sync it based on your latest updates |
There was a problem hiding this comment.
This test doesn't actually test the NoRecurse functionality. There should be a child job and a check should be made to ensure that it gets the correct value.
There was a problem hiding this comment.
All jobs create a childjob which returns the result. Hence with NoRecurse we cannot get the result.
There was a problem hiding this comment.
I prefer AfterEach for clean up. With BeforeEach, the last It will "leak" a Job that it should clean up.
There was a problem hiding this comment.
Nit: Please capitalize Get-Job
There was a problem hiding this comment.
Is there an issue for this in the Pester repo? If so, please include a link
There was a problem hiding this comment.
I need to do a deeper analysis to file an issue. It could be Pester or PowerShell scoping issue.
There was a problem hiding this comment.
Clean up should be done in an AfterEach. Remove-Job won't execute if the ValidateJobInfo test fails.
There was a problem hiding this comment.
This session won't get cleaned up during test failure. Comment also applies to the other It's within this Context.
There was a problem hiding this comment.
Fixed. Used try/finally
There was a problem hiding this comment.
This test doesn't validate that the scriptblock was run in the correct scope. It just validates that the scriptblock was run in a scope. It provides code coverage, but isn't really useful in terms of validating functionality as-is.
There was a problem hiding this comment.
Fixed. I set a variable in the script block and check the value after.
There was a problem hiding this comment.
Added -AutoRemove.
aa69842 to
2444dc7
Compare
|
@mirichmo Resolved all your comments. Please have another look. |
There was a problem hiding this comment.
Can you move this comment to line 271? It makes more sense there
b9138f4 to
ab1f645
Compare
|
@mirichmo Resolved all feedback. Please have a look. Unrelated tests failing. |
ab1f645 to
fb69dff
Compare
|
@mirichmo Can you update your review? |
This should increase coverage under src/System.Management.Automation/engine/remoting substantially.