coderanger / kitchen-sync

Test Kitchen transport plugin to speed up tests.
Apache License 2.0
81 stars 24 forks source link

First run does not use SFTP -- subsequent runs properly use SFTP #2

Closed chuckg closed 9 years ago

chuckg commented 9 years ago

kitchen-sync does not appear to be injected into the "first run" (setup or converge, not sure which) of test-kitchen, the default SCP transport method appears to be used. If I cancel the run, then immediately reissue the test kitchen command, the SFTP transport method gets used correctly.

Example:

$ bundle exec kitchen converge nginx
-----> Starting Kitchen (v1.2.1)
-----> Creating <nginx-ubuntu-1404>...
       Creating <>...
       If you are not using an account that qualifies under the AWS
       free-tier, you may be charged to run these suites. The charge
       should be minimal, but neither Test Kitchen nor its maintainers
       are responsible for your incurred costs.
       EC2 instance <i-cad1d5c7> created.
..................       (server ready)
       Waiting for 10.80.2.141:22...
       Waiting for 10.80.2.141:22...
       Waiting for 10.80.2.141:22...
       Waiting for 10.80.2.141:22...
       Waiting for 10.80.2.141:22...
       Waiting for 10.80.2.141:22...
       (ssh ready)

       Finished creating <nginx-ubuntu-1404> (0m57.94s).
-----> Converging <nginx-ubuntu-1404>...
       Preparing files for transfer
       Resolving cookbook dependencies with Librarian-Chef 0.0.4...
       Removing non-cookbook files before transfer
       Preparing data bags
       Preparing encrypted data bag secret
-----> Installing Chef Omnibus (true)
downloading https://www.getchef.com/chef/install.sh
  to file /tmp/install.sh
trying wget...
Downloading Chef  for ubuntu...
<downloading chef messages>
Installing Chef
installing with dpkg...
Selecting previously unselected package chef.
(Reading database ... 51085 files and directories currently installed.)
Preparing to unpack .../chef_11.16.2-1_amd64.deb ...
Unpacking chef (11.16.2-1) ...
Setting up chef (11.16.2-1) ...
Thank you for installing Chef!
       Transfering files to <nginx-ubuntu-1404>
       [sync] Time taken to upload /var/folders/3r/0lr0xf5n68n5sk97916yrvpwg02g03/T/nginx-ubuntu-1404-sandbox-20140924-83598-1iiu5ex/cache to #<Net::SSH::Connection::Session:0x007fe0bbf74d58>:/tmp/kitchen: 0.30 sec
       [sync] Time taken to upload /var/folders/3r/0lr0xf5n68n5sk97916yrvpwg02g03/T/nginx-ubuntu-1404-sandbox-20140924-83598-1iiu5ex/client.rb to #<Net::SSH::Connection::Session:0x007fe0bbf74d58>:/tmp/kitchen: 0.37 sec
^C^C

SCP was used to transfer the first two files (cache, client.rb). You can see me Control-C'ing out of the converge, since otherwise it would take the usual ~4m period to upload the cookbooks using default transport. Immediately after, I can re-issue the same command:

$ bundle exec kitchen converge nginx
-----> Starting Kitchen (v1.2.1)
-----> Converging <nginx-ubuntu-1404>...
       Preparing files for transfer
       Resolving cookbook dependencies with Librarian-Chef 0.0.4...
       Removing non-cookbook files before transfer
       Preparing data bags
       Preparing encrypted data bag secret
       Transfering files to <nginx-ubuntu-1404>
       [sync:sftp] Running /opt/chef/embedded/bin/ruby /tmp/checksums-6db3047073294040fc8eff294d6d0060a72b2de2.rb /tmp/kitchen/cache
       [sync] Time taken to upload /var/folders/3r/0lr0xf5n68n5sk97916yrvpwg02g03/T/nginx-ubuntu-1404-sandbox-20140924-84713-2il42f/cache to #<Net::SSH::Connection::Session:0x007fa08355e2b0>:/tmp/kitchen: 0.61 sec
       [sync:sftp] Running /opt/chef/embedded/bin/ruby /tmp/checksums-6db3047073294040fc8eff294d6d0060a72b2de2.rb /tmp/kitchen/client.rb
       [sync] Time taken to upload /var/folders/3r/0lr0xf5n68n5sk97916yrvpwg02g03/T/nginx-ubuntu-1404-sandbox-20140924-84713-2il42f/client.rb to #<Net::SSH::Connection::Session:0x007fa08355e2b0>:/tmp/kitchen: 0.28 sec
       [sync:sftp] Running /opt/chef/embedded/bin/ruby /tmp/checksums-6db3047073294040fc8eff294d6d0060a72b2de2.rb /tmp/kitchen/cookbooks
       [sync] Time taken to upload /var/folders/3r/0lr0xf5n68n5sk97916yrvpwg02g03/T/nginx-ubuntu-1404-sandbox-20140924-84713-2il42f/cookbooks to #<Net::SSH::Connection::Session:0x007fa08355e2b0>:/tmp/kitchen: 2.88 sec
       [sync] Time taken to upload /var/folders/3r/0lr0xf5n68n5sk97916yrvpwg02g03/T/nginx-ubuntu-1404-sandbox-20140924-84713-2il42f/data_bags to #<Net::SSH::Connection::Session:0x007fa08355e2b0>:/tmp/kitchen: 0.73 sec
       [sync] Time taken to upload /var/folders/3r/0lr0xf5n68n5sk97916yrvpwg02g03/T/nginx-ubuntu-1404-sandbox-20140924-84713-2il42f/dna.json to #<Net::SSH::Connection::Session:0x007fa08355e2b0>:/tmp/kitchen: 0.22 sec
       [sync] Time taken to upload /var/folders/3r/0lr0xf5n68n5sk97916yrvpwg02g03/T/nginx-ubuntu-1404-sandbox-20140924-84713-2il42f/encrypted_data_bag_secret to #<Net::SSH::Connection::Session:0x007fa08355e2b0>:/tmp/kitchen: 0.66 sec
       [sync] Time taken to upload /var/folders/3r/0lr0xf5n68n5sk97916yrvpwg02g03/T/nginx-ubuntu-1404-sandbox-20140924-84713-2il42f/validation.pem to #<Net::SSH::Connection::Session:0x007fa08355e2b0>:/tmp/kitchen: 0.29 sec
[2014-09-24T17:22:39+00:00] INFO: Starting chef-zero on host localhost, port 8889 with repository at repository at /tmp/kitchen
  One version per cookbook

[2014-09-24T17:22:39+00:00] INFO: Forking chef instance to converge...
Starting Chef Client, version 11.16.2

SFTP was properly used to sync the files.

StaymanHou commented 9 years ago

+1

coderanger commented 9 years ago

It does use SFTP, it just doesn't print out detailed info because if the target doesn't exist it doesn't bother with the pseudo-rsync stuff.

StaymanHou commented 9 years ago

Just figured that out. Add the option -l debug to your kitchen command, and you will be able to see the transfer mode. A little confusing for first time user. How about change the log level to info for the 'transfer mode' and 'falling back to scp' msg? Current message makes me feel like it was falling back to scp until I looked into the source code.