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

[Studio][Tests] Use absolute drive path for windows studio name #6645

Merged
merged 2 commits into from Jun 11, 2019

Conversation

smacfarlane
Copy link
Contributor

When exiting the studio inside an Await session, the CWD would remain at the [Habitat] junction location. This caused the Linux style path of /hab/studios/studio-internals-test to not be resolvable and the studio rm would fail, resulting in a failing test.

This changes the studio name to use Windows-style drive letter paths, allowing the hab studio rm to behave as expected.

Signed-off-by: Scott Macfarlane smacfarlane@chef.io

Signed-off-by: Scott Macfarlane <smacfarlane@chef.io>
@chef-expeditor
Copy link
Contributor

Hello smacfarlane! Thanks for the pull request!

Here is what will happen next:

  1. Your PR will be reviewed by the maintainers.
  2. If everything looks good, one of them will approve it, and your PR will be merged.

Thank you for contributing!

@smacfarlane smacfarlane changed the title Use absolute drive path for studio name [Studio][Tests] Use absolute drive path for studio name Jun 11, 2019
@smacfarlane smacfarlane changed the title [Studio][Tests] Use absolute drive path for studio name [Studio][Tests] Use absolute drive path for windows studio name Jun 11, 2019
Copy link
Contributor

@baumanj baumanj left a comment

Choose a reason for hiding this comment

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

This is outside my area of familiarity

@@ -8,7 +8,7 @@ $env:HAB_NOCOLORING = "true"
# Await has trouble parsing non-ascii glyphs
$env:HAB_GLYPH_STYLE = "ascii"
$exit_code = 0
$studio_name = "/hab/studios/studio-internals-test"
$studio_name = "c:\hab\studios\studio-internals-test"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine our purposes here and indeed almost any scenario. I always like to use:

$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("/some/path/I/want/to/cannonacalize")

This will always transform the given string to a Windows friendly absolute path whether or not the path actually exists and applicable to one's current context. In otherwords, if you were in the d:\ drive, this would resolve to the d drive.

Note there is also the simpler and more intuitively named Resolve-Path which does the same thing but requires the given path to exist. If I know or expect the path to already exist, I prefer this command.

# Add the same behavior for `hab studio rm` to ensure that the studio is fully cleaned up before
# stopping the Await session.
$retry = 0
while(($retry -lt 10) -and (Test-Path "$studio_name")) {
while(($retry -lt 5) -and (Test-Path "$studio_name")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I still like keeping this to a higher number because if we reach the limit, subsequently deleting the studio environment is guaranteed to fail because of open file handles from the hab binary.

Signed-off-by: Scott Macfarlane <smacfarlane@chef.io>
@smacfarlane smacfarlane merged commit f0e92a9 into master Jun 11, 2019
@smacfarlane smacfarlane deleted the sm/fix-windows-studio-test branch June 11, 2019 19:08
chef-ci added a commit that referenced this pull request Jun 11, 2019
Obvious fix; these changes are the result of automation not creative thinking.
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.

None yet

3 participants