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

one_session branch working with win7 #14

Open
wants to merge 5 commits into
base: Transport
Choose a base branch
from
Open

one_session branch working with win7 #14

wants to merge 5 commits into from

Conversation

mwrock
Copy link

@mwrock mwrock commented Dec 7, 2014

This is now working on windows 7 and follows the approach we discussed of counting operations. I ended up taking the code in the latest WinRM dev branch that has my latest file copy code and copying it over because its cleaner and organized in such a way that tracking state on the shell is easier.

Unfortunately the lookup commands on the maxConcurrentOperationsPerUser property are also blocked remotely so I base the limit on your OS version. There is a slim chance that a user may have tweaked these but likely to increase them so I think this is pretty safe.

There was also a small but significant powershell snippet that broke in psv2 so had to fix that too and will be porting both fixes to winrm. Really glad you caught this! When winrm v1.3 releases, we can delete most of this code (yay!).

I'm gonna look into the busser copying next. Let me know if you run into any issues here.

…itial copy is working but dirty check not working and recopy copying bad zip
…e. The is implemented from the base driver so SSH will remain unchanged but winrm will go down this path
@mwrock
Copy link
Author

mwrock commented Dec 8, 2014

The busser will currently fail given any set of test files greater than 8k. This is due to windows 8k command line limit that basically limits what can be sent to the busser via stdin.

I just added functionality to ensure that the busser uses the transport upload method. This is done in the base driver so SSH is unaffected. It may be best to have SSH go down this route as well to keep things simpler. However, its clear that the original intent of the busser is to have the busser gem handle as much instance side logic as possible including file copy. I think this needs to be reconsidered in a future release since this approach just will not work with any sizable windows test suite.

@daxgames
Copy link

I think this breaks linux via test kitchen. See below:

chefdk! $> kitchen verify
-----> Starting Kitchen (v1.3.0)
-----> Verifying ...
Removing /tmp/busser/suites/bats

------Exception-------
Class: Kitchen::ActionFailed
Message: Failed to complete #verify action: [scp: /tmp/busser/suites/bats: Permission denied

]

Please see .kitchen/logs/kitchen.log for more details
Also try running kitchen diagnose --all for configuration

If I switch back to Salim's code Linux works but Windows does not due to 8K limitation.

@mwrock
Copy link
Author

mwrock commented Dec 18, 2014

Interesting. Would you mind running with -l debug and posting the output? and also share which driver you are using?

I have not had issues running against linux but perhaps your driver is using the base driver and not the ssh_base driver. My assumption, perhaps false, was that any linux guest would be using the ssh_base driver and therefore be unaffected by these changes.

Thanks for reporting this!

@daxgames
Copy link

I will as soon as I am able. I am using Salim's kitchen-vagrant fork.

@mwrock
Copy link
Author

mwrock commented Dec 20, 2014

cool. what driver are you using?

@daxgames
Copy link

The kitchen-vagrant fork 0.16.0 from salim's repo with vagrant 1.6.5 and virtualbox 4.3.20. Hopefully this answers your question.

@daxgames
Copy link

Transport branch

@mwrock
Copy link
Author

mwrock commented Dec 20, 2014

that does thanks!

@daxgames
Copy link

kitchen debug output:

-----> Starting Kitchen (v1.3.0)
D [kitchen::driver::vagrant command] BEGIN (vagrant --version)
D [kitchen::driver::vagrant command] END (0m0.20s)
D Berksfile found at /Users/daxgames/chef_archops/cookbooks/netbackup/Berksfile, loading Berkshelf
D Berkshelf 3.2.1 library loaded
D Berksfile found at /Users/daxgames/chef_archops/cookbooks/netbackup/Berksfile, loading Berkshelf
D Berkshelf 3.2.1 previously loaded
D Berksfile found at /Users/daxgames/chef_archops/cookbooks/netbackup/Berksfile, loading Berkshelf
D Berkshelf 3.2.1 previously loaded
-----> Verifying ...
D Creating Vagrantfile for (/Users/daxgames/chef_archops/cookbooks/netbackup/.kitchen/kitchen-vagrant/rhel-netbackup-rhel65-x86-64/Vagrantfile)
D ------------
D Vagrant.configure("2") do |c|
D c.vm.box = "rhel65-x86-64"
D c.vm.box_url = "http://web_server/rhel65-x86-64.box"
D c.vm.hostname = "SERVER01"
D c.vm.communicator = "ssh"
D c.vm.network(:private_network, {:ip=>"172.0.2.15"})
D c.vm.synced_folder ".", "/vagrant", disabled: true
D c.vm.provider :virtualbox do |p|
D p.gui = true
D p.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
D p.customize ["modifyvm", :id, "--memory", "1024"]
D end
D end
D ------------
D [Kitchen::Transport::Ssh] [email protected]:2222<{:user_known_hosts_file=>"/dev/null", :paranoid=>false, :keys_only=>true, :password=>"vagrant", :port=>2222, :keys=>["/Users/daxgames/.vagrant.d/insecure_private_key"]}> (sh -c '
BUSSER_ROOT="/tmp/busser" GEM_HOME="/tmp/busser/gems" GEM_PATH="/tmp/busser/gems" GEM_CACHE="/tmp/busser/gems/cache"
export BUSSER_ROOT GEM_HOME GEM_PATH GEM_CACHE

sudo -E /tmp/busser/bin/busser suite cleanup

')
D [Kitchen::Transport::Ssh] opening connection to [email protected]:2222<{:user_known_hosts_file=>"/dev/null", :paranoid=>false, :keys_only=>true, :password=>"vagrant", :port=>2222, :keys=>["/Users/daxgames/.vagrant.d/insecure_private_key"]}>�
Suite path directory /tmp/busser/suites does not exist, skipping.
D ------Exception-------
D Class: Kitchen::ActionFailed
D Message: Failed to complete #verify action: [scp: /tmp/busser/suites: Permission denied
]
D ---Nested Exception---
D Class: RuntimeError
D Message: scp: /tmp/busser/suites: Permission denied

D ------Backtrace-------
D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-scp-1.2.1/lib/net/scp.rb:398:in await_response_state' D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-scp-1.2.1/lib/net/scp.rb:369:inblock (3 levels) in start_command'
D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:311:in call' D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:311:inprocess'
D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:222:in block in preprocess' D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:222:ineach'
D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:222:in preprocess' D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:inprocess'
D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in block in loop' D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:inloop'
D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in loop' D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:inwait'
D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-scp-1.2.1/lib/net/scp.rb:284:in upload!' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/transport/ssh.rb:60:inblock in upload!'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/transport/ssh.rb:59:in each' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/transport/ssh.rb:59:inupload!'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/driver/base.rb:97:in block in verify' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/transport/base.rb:73:inconnection'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/driver/base.rb:94:in verify' D /Users/daxgames/.chefdk/gem/ruby/2.1.0/gems/kitchen-vagrant-0.17.0/lib/kitchen/driver/vagrant.rb:92:inverify'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:373:in public_send' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:373:inblock in perform_action'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:437:in call' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:437:insynchronize_or_call'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:402:in block in action' D /opt/chefdk/embedded/lib/ruby/2.1.0/benchmark.rb:279:inmeasure'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:401:in action' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:373:inperform_action'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:351:in verify_action' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:313:inblock in transition_to'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:312:in each' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:312:intransition_to'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:160:in verify' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/command.rb:176:inpublic_send'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/command.rb:176:in block (2 levels) in run_action' D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:incall'
D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'
D ----------------------

@mwrock
Copy link
Author

mwrock commented Dec 21, 2014

Thanks. I'll take a look at this today. I'm working out of a new pr now.

test-kitchen#562

Salim's branch was recently ported to a new branch that has been merged with the latest test-kitchen code.

That branch has been broken by some of the recent path changes but I've got that working to the point now that I can test your scenario.

I typically use a vsphere driver for Linux VMS and not vagrant so that driver is likely going through the base driver so I obviously need to tweak things there.

@mwrock
Copy link
Author

mwrock commented Dec 22, 2014

I was able to reproduce this using this cookbook:

https://github.com/mwrock/export-node

I have a fix that i pushed to the PR mentioned above:

test-kitchen#562

I validated the fix on my box. Its a simple one line change that adds the /tmp/busser directory on linux during setup so that the subsequent uploads via scp do not fail with permissions problems.

Again, thanks so much for mentioning this and if you have a chance to test, let me know if you have any further issues.

@daxgames
Copy link

Hmm, just looked at your most recent change. Have not tested it yet but wondering how that one line affects sup connections to Linux, given where it is in the code. Will test it today.

@daxgames
Copy link

Forget my last, I see it, was originally thinking it was in the cmd block but now see it is in Bourne block. Will test it today.

@daxgames
Copy link

Still failing.

I run Salim's Transport branch code and verify works fine using a bats test suite.

I then change to to this code leaving the successfully verified virtual box vm untouched and run another verify.

Setup Completes. Verify Starts and runs 'sudo -E /tmp/busser/bin/busser suite cleanup' which deletes '/tmp/busser/suites/bats' leaving '/tmp/busser/suites/'.

I think the issue is with the code:

183 local_suite_files.each do |f|
184 cmd << stream_file(f, remote_file(f, config[:suite_name])).concat("\n")
185 end

Even if I create the full directory path manually expected on the vm the file copy fails. However, if I manually add write access using 'chmod o+w /tmp/busser/suites' a verify using your code works.

Verify action is not able to create the /tmp/busser/suites/bats folder unless suites folder has relaxed write perms.

That is as far as I got. Hopefully it points you in the right direction.

@daxgames
Copy link

Probably not a good fix but I changed your one line of code into these two lines:

#{sudo("mkdir")} -p #{config[:root_path]}/suites
#{sudo("chmod")} o+w #{config[:root_path]}/suites

Fixes the issue on Linux.

@mwrock
Copy link
Author

mwrock commented Dec 23, 2014

ah yes. this would be required if you were trying the fix on an instance that had already run setup under the former code path. I had whacked my /tmp directory prior to testing the fix. good catch and thanks!

@daxgames
Copy link

I will try again with your original code on a freshly created vm to see if that makes a difference.

@daxgames
Copy link

Tried with spinning up a new box. Still not 100%.

'kitchen test' now gets me:

...output omitted for brevity...

-----> Setting up Busser
Creating BUSSER_ROOT in /tmp/busser
Creating busser binstub
Plugin bats installed (version 0.3.0)
-----> Running postinstall for bats plugin
Installed Bats to /tmp/busser/vendor/bats/bin/bats
D [Kitchen::Transport::Ssh] closing connection to [email protected]:2222<{:user_known_hosts_file=>"/dev/null", :paranoid=>false, :keys_only=>true, :password=>"vagrant", :port=>2222, :keys=>["/Users/daxgames/.vagrant.d/insecure_priv
ate_key"], :user=>"vagrant"}>
Finished setting up (0m49.33s).
-----> Verifying ...
D [Kitchen::Transport::Ssh] [email protected]:2222<{:user_known_hosts_file=>"/dev/null", :paranoid=>false, :keys_only=>true, :password=>"vagrant", :port=>2222, :keys=>["/Users/daxgames/.vagrant.d/insecure_private_key"]}> (sh -c '
BUSSER_ROOT="/tmp/busser" GEM_HOME="/tmp/busser/gems" GEM_PATH="/tmp/busser/gems" GEM_CACHE="/tmp/busser/gems/cache"
export BUSSER_ROOT GEM_HOME GEM_PATH GEM_CACHE

sudo -E /tmp/busser/bin/busser suite cleanup

')
D [Kitchen::Transport::Ssh] opening connection to [email protected]:2222<{:user_known_hosts_file=>"/dev/null", :paranoid=>false, :keys_only=>true, :password=>"vagrant", :port=>2222, :keys=>["/Users/daxgames/.vagrant.d/insecure_priv
ate_key"]}>
Suite path directory /tmp/busser/suites does not exist, skipping.
D Uploaded /Users/daxgames/chef_archops/cookbooks/netbackup/test/integration/rhel/bats/default.bats (1497 bytes)
D [Kitchen::Transport::Ssh] [email protected]:2222<{:user_known_hosts_file=>"/dev/null", :paranoid=>false, :keys_only=>true, :password=>"vagrant", :port=>2222, :keys=>["/Users/daxgames/.vagrant.d/insecure_private_key"], :user=>"vag
rant"}> (sh -c '
BUSSER_ROOT="/tmp/busser" GEM_HOME="/tmp/busser/gems" GEM_PATH="/tmp/busser/gems" GEM_CACHE="/tmp/busser/gems/cache"
export BUSSER_ROOT GEM_HOME GEM_PATH GEM_CACHE

sudo -E /tmp/busser/bin/busser test
')
-----> Running bats test suite
bats: /tmp/busser/suites/bats does not exist
Command [/tmp/busser/vendor/bats/bin/bats /tmp/busser/suites/bats] exit code was 1

------Exception-------
Class: Kitchen::ActionFailed
Message: Failed to complete #verify action: [[ssh] exited (1) for command: [sh -c '
BUSSER_ROOT="/tmp/busser" GEM_HOME="/tmp/busser/gems" GEM_PATH="/tmp/busser/gems" GEM_CACHE="/tmp/busser/gems/cache"
export BUSSER_ROOT GEM_HOME GEM_PATH GEM_CACHE

sudo -E /tmp/busser/bin/busser test
']]


Please see .kitchen/logs/kitchen.log for more details
Also try running kitchen diagnose --all for configuration

D ------Exception-------
D Class: Kitchen::ActionFailed
D Message: Failed to complete #verify action: [[ssh] exited (1) for command: [sh -c '
BUSSER_ROOT="/tmp/busser" GEM_HOME="/tmp/busser/gems" GEM_PATH="/tmp/busser/gems" GEM_CACHE="/tmp/busser/gems/cache"
export BUSSER_ROOT GEM_HOME GEM_PATH GEM_CACHE

sudo -E /tmp/busser/bin/busser test
']]
D ---Nested Exception---
D Class: Kitchen::Transport::TransportFailed
D Message: [ssh] exited (1) for command: [sh -c '
BUSSER_ROOT="/tmp/busser" GEM_HOME="/tmp/busser/gems" GEM_PATH="/tmp/busser/gems" GEM_CACHE="/tmp/busser/gems/cache"
export BUSSER_ROOT GEM_HOME GEM_PATH GEM_CACHE

sudo -E /tmp/busser/bin/busser test
']
D ------Backtrace-------
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/transport/ssh.rb:43:in execute' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/driver/base.rb:98:inblock in verify'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/transport/base.rb:73:in connection' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/driver/base.rb:94:inverify'
D /Users/daxgames/.chefdk/gem/ruby/2.1.0/gems/kitchen-vagrant-0.17.0/lib/kitchen/driver/vagrant.rb:92:in verify' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:378:inpublic_send'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:378:in block in perform_action' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:442:incall'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:442:in synchronize_or_call' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:407:inblock in action'
D /opt/chefdk/embedded/lib/ruby/2.1.0/benchmark.rb:279:in measure' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:406:inaction'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:378:in perform_action' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:356:inverify_action'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:318:in block in transition_to' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:317:ineach'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:317:in transition_to' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:160:inverify'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:189:in block in test' D /opt/chefdk/embedded/lib/ruby/2.1.0/benchmark.rb:279:inmeasure'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:185:in test' D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/command.rb:176:inpublic_send'
D /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/command.rb:176:in block (2 levels) in run_action' D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:incall'
D /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'
D ----------------------

Looks like bats tests are loaded successfully but to '/tmp/busser/suites' instead of '/tmp/busser/suites/bats'

Running kitchen verify then succeeds.

After verify bats tests are in '/tmp/busser/suites/bats'

@daxgames
Copy link

Updated the above with debug output.

@mwrock
Copy link
Author

mwrock commented Dec 27, 2014

sorry. things have been busy and have not had a chance to get to this. @afiune chimed in offline and suggested I add /suites to the mkdir. That does fix this on linux hosts and I refreshed my PR with that. Oddly the previous version you tried works on windows hosts against linux guests. My guess is that its the scp.exe I'm using (from msysgit) I was able to repr your above error on my linux box.

@daxgames
Copy link

Yeah I posted the /suites add earlier in this thread and also told him (afiune) offline it fixed my issue. I wonder why the host OS seems to make a difference? I am developing on a Mac and the /suites is required.

I have a fork based on his Transport branch merged with your one session branch plus the /suites add that I am using until something better is available. It works well for both linux and windows but the Serverspec Tests are very slow on Windows.

@daxgames
Copy link

Is test-kitchen#562 working well at this point? Should I switch to it instead of using the older one session branch?

@mwrock
Copy link
Author

mwrock commented Dec 27, 2014

I’m gonna confirm later but it could be that the “flavor” of scp.exe on windows creates the directory with different perms??

I’ve noticed that sometimes the first test does take a while to start. I have not looked into it but it is definitely annoying.

It’ll be nice when all this stuff gets merged together into master.

From: Dax T Games
Sent: ‎Saturday‎, ‎December‎ ‎27‎, ‎2014 ‎10‎:‎01‎ ‎AM
To: afiune/test-kitchen
Cc: Matt Wrock

Yeah I posted the /suites add earlier in this thread and also told him (afiune) offline it fixed my issue. I wonder why the host OS seems to make a difference? I am developing on a Mac and the /suites is required.

I have a fork based on his Transport branch merged with your one session branch plus the /suites add that I am using until something better is available. It works well for both linux and windows but the Serverspec Tests are very slow on Windows.


Reply to this email directly or view it on GitHub.

@mwrock
Copy link
Author

mwrock commented Dec 27, 2014

That is off the branch that folks are doing testing. I need to do more testing myself but I have tested several scenarios successfully. If anything doesn’t work we’d really like to hear about it. Thanks a bunch for the feedback!

From: Dax T Games
Sent: ‎Saturday‎, ‎December‎ ‎27‎, ‎2014 ‎10‎:‎23‎ ‎AM
To: afiune/test-kitchen
Cc: Matt Wrock

Is test-kitchen#562 working well at this point? Should I switch to it instead of using the older one session branch?


Reply to this email directly or view it on GitHub.

afiune pushed a commit that referenced this pull request Oct 29, 2019
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.

2 participants