Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Fix Windows integration tests #4304
Fix Windows integration tests #4304
Changes from all commits
292c4d3
4c3d855
626361f
d742ef1
e0a70d9
8040c20
9f1d710
62438de
a2894c6
deb4fe9
4e02991
7d31e31
725e2b7
a7ab1cd
daeccb7
83ad5ae
ebd3533
bf5d963
e583834
8136886
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the os.Stat implementation will work. In my testing it always returned the same result regardless of whether docker is running or not.
Here's an alternative implementation that does work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have minimal knowledge/experience with Windows development, so bear with me while I explain my testing process...
To exercise the
os.Stat
implementation ofisDockerRunning
, I added a testwhich I ran with
I ran
get-service docker
to check if docker was already running. It was, and the test passed.I ran
stop-service docker
to stop docker. The test failed when I reran it, as was expected.I ran
start-service docker
to restart docker. The test passed.Am I not starting/stopping docker correctly? I got the same results when I swapped out the
os.Stat
implementation with the service manager implementation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on your test results, it seems that Go is handling it properly if run as part of the integration test framework. Given your test results, I'm OK with your earlier implementation since it is very simple and it works. (Plus, the implementation I provided should be modified to include deferred closures to the service manager and service instance handle.)
My concern was whether Go's
os.Stat
method can differentiate between named pipes and regular on-disk files. Named pipes are accessed via file system drivers (NPFS), but they are are not part of the actual on-disk file system, which is (typically) NTFS.Running the code snippet, as-is, on Windows in a stand-alone way doesn't seem to work right, however. That said, connecting through service manager requires the unit tests to be run as an administrator.
There is more than one way to start/stop services on Windows. start-service docker and stop-service docker is the PowerShell way to start/stop docker and is perfectly acceptable.