-
Notifications
You must be signed in to change notification settings - Fork 16
Fix #327 and #326 Tests and docs for --cli-version and --path options #414
Conversation
@hferentschik Lets get rid of this PR 😄 |
Examples: | ||
| box | provider | ip | | ||
| adb | virtualbox | 10.10.10.42 | | ||
| adb | libvirt | 10.10.10.42 | | ||
| cdk | virtualbox | 10.10.10.42 | |
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.
Didn't we say we keep the CDK tests in cdk-openshift? I am trying to remember what the plan was?
And the binary "docker" should be installed with version "1.12.1" | ||
|
||
# '../vagrant.d' maps to ENV['VAGRANT_HOME'] | ||
When I run `bundle exec vagrant service-manager install-cli docker --path ../vagrant.d/docker` |
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 am still skeptical about ../vagrant.d/docker. Have you tried "#{ENV['VAGRANT_HOME']/docker}?
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.
@hferentschik , it will not work as #{ENV['VAGRANT_HOME']/docker}
is not know through command line. Even when passing $VAGRANT_HOME/docker
, ruby tried to create $VAGRANT_HOME
directory inside aruba directory.
@@ -236,11 +244,11 @@ As per default, binaries are downloaded to | |||
To install client binary for Docker: | |||
|
|||
---------------------------------------------------------------------------------------------------- | |||
$ vagrant service-manager install-cli docker | |||
# Binary already available at /home/johndoe/.vagrant.d/data/service-manager/bin/docker/1.9.1/docker | |||
$ vagrant service-manager install-cli docker --cli-version 1.9.1 --path /home/johndoe/docker |
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.
What's about /home/johndoe/bin/docker as an example dir. No one puts a binary directly into the home directory, right?
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.
@hferentschik Ok agreed
@@ -55,3 +55,12 @@ Style/Documentation: | |||
Style/FileName: | |||
Exclude: | |||
- 'lib/vagrant-service-manager.rb' | |||
|
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 think there should be no more Rubocop changes required in this pull request, right? Also this seems to create a merge conflict when applying to master.
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.
@hferentschik Yes
@@ -104,7 +104,9 @@ en: | |||
A supported service. For example: docker, kubernetes or openshift. | |||
|
|||
Options: | |||
-h, --help print this help | |||
-h, --help print this help | |||
--cli-version binary version to install |
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.
we are not providing any short options for this?
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.
@hferentschik , no. Do you think it is mandatory? we have other options like --script-readable etc too which doesn't have short options
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.
Works for me. Just wanted to make sure we are not missing something.
- 'test/vagrant-service-manager/binary_handlers/*.rb' | ||
|
||
Lint/Eval: | ||
Enabled: false |
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 guess this might be needed, right?
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.
Yes @hferentschik
@hferentschik All tests passed 😄 |
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.
Looking good. I'd suggest to make one more change to the way the features are written, but otherwise ok now.
@@ -57,6 +57,12 @@ Feature: Command output from various OpenShift related commands in ADB | |||
Then the exit status should be 0 | |||
And the binary "oc" should be installed | |||
|
|||
# '../vagrant.d' maps to ENV['VAGRANT_HOME'] | |||
When I run `bundle exec vagrant service-manager install-cli openshift --cli-version 1.3.0 --path ../vagrant.d/oc` |
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.
Here is what I came up with. The issue is really that Aruba does not execute the command in backticks directly and hence interpolation will take place. What's about:
When I evaluate and run `bundle exec vagrant service-manager install-cli docker --path #{ENV['VAGRANT_HOME']}/docker`
Then the exit status should be 0
And the binary should be installed in path "#{ENV['VAGRANT_HOME']}/docker"
To make this work we need a new step defintion:
# Per default the built-in Aruba 'When I run' will not evaluate/interpolate the string.
# We create a custom step definition to work around this
When(/^I evaluate and run `([^`]*)`$/)do |cmd|
cmd = eval('"' + cmd + '"')
cmd = sanitize_text(cmd)
run_simple(cmd, :fail_on_error => false)
end
Note, I also changed the way ' And the binary should be installed in path' is implemented:
Then(/^the binary should be installed in path "([^"]*)"$/) do |path|
binary_path = eval('"' + path + '"')
expect(File.file?(binary_path)).to eq(true)
expect(File.executable?(binary_path)).to eq(true)
end
With this in place one can consistently use '#{ENV['VAGRANT_HOME']}' (or any other variable really). I think this is a "cleaner" solution. Everything is explicit. WDYT?
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.
@hferentschik This works great 👍 💯
I didn't know that 😄 Thanks
$ vagrant service-manager install-cli docker | ||
# Binary already available at /home/johndoe/.vagrant.d/data/service-manager/bin/docker/1.9.1/docker | ||
$ vagrant service-manager install-cli docker --cli-version 1.9.1 --path /home/johndoe/bin/docker | ||
# Binary already available at /home/johndoe/bin/docker | ||
# run binary as: |
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.
+1
@@ -104,7 +104,9 @@ en: | |||
A supported service. For example: docker, kubernetes or openshift. | |||
|
|||
Options: | |||
-h, --help print this help | |||
-h, --help print this help | |||
--cli-version binary version to install |
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.
Works for me. Just wanted to make sure we are not missing something.
When I evaluate and run `bundle exec vagrant service-manager install-cli openshift --cli-version 1.3.0 --path #{ENV['VAGRANT_HOME']}/oc` | ||
Then the exit status should be 0 | ||
And the binary "oc" should be installed with version "1.3.0" | ||
And the binary should be installed in path "ENV['VAGRANT_HOME']/oc" |
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.
hmm, is this right? Should it not be "#{ENV['VAGRANT_HOME']}/oc"?
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 would expect this to fail, tbh
@@ -223,10 +223,18 @@ Similarly, you can use `$ vagrant service-manager status openshift`, | |||
|
|||
If you need to install the client binary for a specified service, use: + | |||
|
|||
`vagrant service-manager install-cli [service]` + | |||
`vagrant service-manager install-cli [service] [options] [arg]` + |
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.
Do you really need '[arg]' here? The value for an option is really encapsulated in [options] itself, right? I guess one can do something like '--cli-version=' to indicate that the option takes a value.
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.
@hferentschik --cli-version=
will create more confusion IMO as user will then assume they need to enter option value as --cli-version=1.3.0
which VSM cannot parse ATM.
Or you think the options description should include the value as:
The following options can be used:
--cli-version value
:: Specify the version of the binary to be installed
--path value
:: Specify the absolute or relative path where the binary should be installed
-h, --help
:: Prints help for the specific command being run.
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.
That latter works as well for me. ' [options] [arg]' seems wrong. OR what do you think?
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.
As it stands it is wrong '[options] [arg]'. It implies that options and args are disconnected
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.
@hferentschik updated the PR with the changes.
end | ||
|
||
Then(/^the binary "([^"]*)" should be installed with version "([^"]*)"$/) do |binary, version| | ||
binary_path = "#{ENV['VAGRANT_HOME']}/data/service-manager/bin/#{version}/#{binary}" |
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 was wrong, we cannot build the path directly. This test fails now, there is one more level after 'bin' which depicts the service. We either would need to pass the service as well to build the full path or we indeed have to do some path matching. Maybe it is more explicit to so something like with something like:
"Then(/^the binary "([^"])" of service "([^"])" should be installed with version "([^"]*)"$/)"? I just want to make sure we don't get any false positives by using a recursive scan approach.
@hferentschik Pushed the new changes which include missing service name in step definition alongwith tests fix |
@hferentschik CI seems to be passing now 👍 |
@@ -70,6 +70,19 @@ Feature: Command output from various OpenShift related commands in CDK | |||
Then the exit status should be 0 | |||
And the binary "oc" should be installed | |||
|
|||
When I run `bundle exec vagrant service-manager install-cli openshift --cli-version 1.3.0` | |||
Then the exit status should be 0 | |||
And the binary "oc" of service "openshift" should be installed with version "1.3.0" |
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 think this is better
@hferentschik Anything remaining in this PR now? I think it is ready to merge now. |
@@ -223,10 +223,16 @@ Similarly, you can use `$ vagrant service-manager status openshift`, | |||
|
|||
If you need to install the client binary for a specified service, use: + | |||
|
|||
`vagrant service-manager install-cli [service]` + | |||
`vagrant service-manager install-cli [service] [options]` + |
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.
👍
@@ -57,6 +57,14 @@ Feature: Command output from various OpenShift related commands in ADB | |||
Then the exit status should be 0 | |||
And the binary "oc" should be installed | |||
|
|||
When I run `bundle exec vagrant service-manager install-cli openshift --cli-version 1.3.0` | |||
Then the exit status should be 0 | |||
And the binary "oc" of service "openshift" should be installed with version "1.3.0" |
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 created issue #415 to follow up on what's going on with CI and why we did not get test failures when some of the tests were clearly wrong. We need to get to the bottom of this, otherwise we cannot trust CI results, in particular since these tests are not run per default on the dev machine
Then the exit status should be 0 | ||
And the binary "oc" of service "openshift" should be installed with version "1.3.0" | ||
|
||
When I evaluate and run `bundle exec vagrant service-manager install-cli openshift --path #{ENV['VAGRANT_HOME']}/oc` |
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 like how the tests look like now. Also nice to use the same path in the When and Then clause and that it gets transparently interpolated.
@@ -52,6 +54,14 @@ Feature: Command behavior of client side tools installation | |||
Then the exit status should be 0 | |||
And the binary "docker" should be installed | |||
|
|||
When I run `bundle exec vagrant service-manager install-cli docker --cli-version 1.12.1` | |||
Then the exit status should be 0 | |||
And the binary "docker" of service "docker" should be installed with version "1.12.1" |
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 think this step is also quite nice now. Allows us to do a dedicated check in its implementation
File.exist? "#{dir_path}\\oc.exe" | ||
end | ||
|
||
oc_path_dir.nil? ? nil : oc_path_dir + '\oc.exe' |
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.
We let this sneak in for now ;-)
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.
@hferentschik I had already explained it 😄
So, in windows, devsuite download the oc binary and place it in C:\DevSuite\cdk\bin\oc.exe
which is also added in environment variable $PATH.
Previously, I was only checking through the directory paths presents in $PATH and checking the existence of dir_path + '\oc.exe' file. On first detection, I return the dir_path only. However, I need the actual full path not dir_path
.
Now, sometime if detect doesn't match anything then it returns nil.
Probably, I should have changed this line to
oc_path_dir + '\oc.exe' unless oc_path_dir.nil?
Yeah :-) |
Fix #327 and #326