kitchen-vagrant 0.16.0 → 0.17.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d70f1abd832d8c586a5c1b8f74e41a791df670d6
4
- data.tar.gz: b5edfb05ad16864d0019ebf7cff317b635a8b859
3
+ metadata.gz: 20088bc568659c72b4c5ea735775acfa848846ef
4
+ data.tar.gz: 764b50f0e0e427ce0708646fcbd457bf85459348
5
5
  SHA512:
6
- metadata.gz: d4abb29d4c5a7755b069e91dcf035623f99beb13244b02d6a04ded560bb8d9b86874690d8e4d3852b0ec2b0fc66e159fb1032036ef9855352c7a9df780d611ac
7
- data.tar.gz: 1f2f35168a468324d6c99032ad8d573052eb5e2b0e3be9b0e7f0ea6065e63690987fc44b98a021c330b87a07e8a607b61f3c2be58295fbc1cc841d0b7cf14547
6
+ metadata.gz: e2a59cb01ab82a42cfa74d5e25facfde346fc022a3bd10c71bdf1e4a8d20325c0c51eff285771b59502dd09fd5792a03d4ff558898c5d0b7a6057e6f233c0648
7
+ data.tar.gz: 2b0cdab5a37f3e60cb9db88c2b70867bfeb755f6c60f4c7c99b56d0adb5b2b83c63d0ebe93362f4ca763247bd9784e54134503a84b2a650e5f5ced419f774e7e
@@ -1,3 +1,8 @@
1
+ ## 0.17.0.beta.1 / 2015-03-24
2
+
3
+ * Pull request [#154][]: Support for WinRM Transport and Windows-based instances. ([@fnichol][])
4
+
5
+
1
6
  ## 0.16.0 / 2015-03-23
2
7
 
3
8
  ### Bug fixes
@@ -241,6 +246,7 @@ The initial release.
241
246
  [#147]: https://github.com/test-kitchen/kitchen-vagrant/issues/147
242
247
  [#148]: https://github.com/test-kitchen/kitchen-vagrant/issues/148
243
248
  [#151]: https://github.com/test-kitchen/kitchen-vagrant/issues/151
249
+ [#154]: https://github.com/test-kitchen/kitchen-vagrant/issues/154
244
250
  [@Annih]: https://github.com/Annih
245
251
  [@Igorshp]: https://github.com/Igorshp
246
252
  [@RobertRehberg]: https://github.com/RobertRehberg
data/README.md CHANGED
@@ -396,9 +396,10 @@ section of the Vagrant documentation.
396
396
  To prevent this value from being rendered in the default Vagrantfile, you can
397
397
  set this value to `false`.
398
398
 
399
- The default will be computed from the name of the instance. For
400
- example, the instance was called "default-fuzz-9" will produce a default
401
- `vm_hostname` value of `"default-fuzz-9.vagrantup.com"`.
399
+ The default will be computed from the name of the instance. For example, the
400
+ instance was called "default-fuzz-9" will produce a default `vm_hostname` value
401
+ of `"default-fuzz-9"`. For Windows-based platforms, a default of `nil` is used
402
+ to save on boot time and potential rebooting.
402
403
 
403
404
  ## <a name="development"></a> Development
404
405
 
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
19
19
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
20
  gem.require_paths = ["lib"]
21
21
 
22
- gem.add_dependency "test-kitchen", "~> 1.0"
22
+ gem.add_dependency "test-kitchen", "= 1.4.0.beta.1"
23
23
 
24
24
  gem.add_development_dependency "countloc", "~> 0.4"
25
25
  gem.add_development_dependency "rake"
@@ -29,7 +29,9 @@ module Kitchen
29
29
  # Vagrant driver for Kitchen. It communicates to Vagrant via the CLI.
30
30
  #
31
31
  # @author Fletcher Nichol <fnichol@nichol.ca>
32
- class Vagrant < Kitchen::Driver::SSHBase
32
+ class Vagrant < Kitchen::Driver::Base
33
+
34
+ include ShellOut
33
35
 
34
36
  default_config(:box) { |driver| driver.default_box }
35
37
  required_config :box
@@ -46,6 +48,10 @@ module Kitchen
46
48
 
47
49
  default_config :network, []
48
50
 
51
+ default_config :password do |driver|
52
+ "vagrant" if driver.winrm_transport?
53
+ end
54
+
49
55
  default_config :pre_create_command, nil
50
56
 
51
57
  default_config :provision, false
@@ -58,13 +64,20 @@ module Kitchen
58
64
 
59
65
  default_config :synced_folders, []
60
66
 
67
+ default_config :username do |driver|
68
+ "vagrant" if driver.winrm_transport?
69
+ end
70
+
61
71
  default_config :vagrantfile_erb,
62
72
  File.join(File.dirname(__FILE__), "../../../templates/Vagrantfile.erb")
63
73
  expand_path_for :vagrantfile_erb
64
74
 
65
75
  default_config :vagrantfiles, []
76
+ expand_path_for :vagrantfiles
66
77
 
67
- default_config(:vm_hostname) { |driver| driver.instance.name }
78
+ default_config(:vm_hostname) do |driver|
79
+ driver.windows_os? ? nil : driver.instance.name
80
+ end
68
81
 
69
82
  no_parallel_for :create, :destroy
70
83
 
@@ -77,6 +90,7 @@ module Kitchen
77
90
  run_pre_create_command
78
91
  run_vagrant_up
79
92
  update_state(state)
93
+ instance.transport.connection(state).wait_until_ready
80
94
  info("Vagrant instance #{instance.to_str} created.")
81
95
  end
82
96
 
@@ -128,9 +142,7 @@ module Kitchen
128
142
  # @raise [ClientError] if instance parameter is nil
129
143
  def finalize_config!(instance)
130
144
  super
131
- config[:vagrantfiles] = config[:vagrantfiles].map do |path|
132
- File.expand_path(path, config[:kitchen_root])
133
- end
145
+ finalize_vm_hostname!
134
146
  finalize_pre_create_command!
135
147
  finalize_synced_folders!
136
148
  self
@@ -152,6 +164,13 @@ module Kitchen
152
164
  end
153
165
  end
154
166
 
167
+ # @return [TrueClass,FalseClass] whether or not the transport's name
168
+ # implies a WinRM-based transport
169
+ # @api private
170
+ def winrm_transport?
171
+ instance.transport.name.downcase =~ /win_?rm/
172
+ end
173
+
155
174
  protected
156
175
 
157
176
  WEBSITE = "http://www.vagrantup.com/downloads.html".freeze
@@ -223,6 +242,18 @@ module Kitchen
223
242
  end
224
243
  end
225
244
 
245
+ # Truncates the length of `:vm_hostname` to 12 characters for
246
+ # Windows-based operating systems.
247
+ #
248
+ # @api private
249
+ def finalize_vm_hostname!
250
+ string = config[:vm_hostname]
251
+
252
+ if windows_os? && string.is_a?(String) && string.size >= 12
253
+ config[:vm_hostname] = "#{string[0...10]}-#{string[-1]}"
254
+ end
255
+ end
256
+
226
257
  # Renders the Vagrantfile ERb template.
227
258
  #
228
259
  # @return [String] the contents for a Vagrantfile
@@ -250,6 +281,22 @@ module Kitchen
250
281
  run_command(cmd, { :cwd => vagrant_root }.merge(options))
251
282
  end
252
283
 
284
+ # Delegates to Kitchen::ShellOut.run_command, overriding some default
285
+ # options:
286
+ #
287
+ # * `:use_sudo` defaults to the value of `config[:use_sudo]` in the
288
+ # Driver object
289
+ # * `:log_subject` defaults to a String representation of the Driver's
290
+ # class name
291
+ #
292
+ # @see Kitchen::ShellOut#run_command
293
+ def run_command(cmd, options = {})
294
+ merged = {
295
+ :use_sudo => config[:use_sudo], :log_subject => name
296
+ }.merge(options)
297
+ super(cmd, merged)
298
+ end
299
+
253
300
  # Runs a local command before `vagrant up` has been called.
254
301
  #
255
302
  # @api private
@@ -288,10 +335,16 @@ module Kitchen
288
335
  hash = vagrant_ssh_config
289
336
 
290
337
  state[:hostname] = hash["HostName"]
291
- state[:username] = hash["User"]
292
- state[:ssh_key] = hash["IdentityFile"]
293
- state[:port] = hash["Port"]
294
- state[:proxy_command] = hash["ProxyCommand"] if hash["ProxyCommand"]
338
+
339
+ if winrm_transport?
340
+ state[:username] = config[:username]
341
+ state[:password] = config[:password]
342
+ else
343
+ state[:username] = hash["User"]
344
+ state[:ssh_key] = hash["IdentityFile"]
345
+ state[:port] = hash["Port"]
346
+ state[:proxy_command] = hash["ProxyCommand"] if hash["ProxyCommand"]
347
+ end
295
348
  end
296
349
 
297
350
  # @return [String] full local path to the directory containing the
@@ -21,6 +21,6 @@ module Kitchen
21
21
  module Driver
22
22
 
23
23
  # Version string for Vagrant Kitchen driver
24
- VAGRANT_VERSION = "0.16.0"
24
+ VAGRANT_VERSION = "0.17.0.beta.1"
25
25
  end
26
26
  end
@@ -23,6 +23,8 @@ require "stringio"
23
23
 
24
24
  require "kitchen/driver/vagrant"
25
25
  require "kitchen/provisioner/dummy"
26
+ require "kitchen/transport/dummy"
27
+ require "kitchen/verifier/dummy"
26
28
 
27
29
  describe Kitchen::Driver::Vagrant do
28
30
 
@@ -31,8 +33,9 @@ describe Kitchen::Driver::Vagrant do
31
33
  let(:config) { { :kitchen_root => "/kroot" } }
32
34
  let(:platform) { Kitchen::Platform.new(:name => "fooos-99") }
33
35
  let(:suite) { Kitchen::Suite.new(:name => "suitey") }
34
- let(:busser) { double("busser") }
36
+ let(:verifier) { Kitchen::Verifier::Dummy.new }
35
37
  let(:provisioner) { Kitchen::Provisioner::Dummy.new }
38
+ let(:transport) { Kitchen::Transport::Dummy.new }
36
39
  let(:state_file) { double("state_file") }
37
40
  let(:state) { Hash.new }
38
41
  let(:env) { Hash.new }
@@ -47,12 +50,13 @@ describe Kitchen::Driver::Vagrant do
47
50
 
48
51
  let(:instance) do
49
52
  Kitchen::Instance.new(
50
- :busser => busser,
53
+ :verifier => verifier,
51
54
  :driver => driver_object,
52
55
  :logger => logger,
53
56
  :suite => suite,
54
57
  :platform => platform,
55
58
  :provisioner => provisioner,
59
+ :transport => transport,
56
60
  :state_file => state_file
57
61
  )
58
62
  end
@@ -295,14 +299,60 @@ describe Kitchen::Driver::Vagrant do
295
299
  )
296
300
  end
297
301
 
298
- it "sets :vm_hostname to the instance name by default" do
299
- expect(driver[:vm_hostname]).to eq("suitey-fooos-99")
302
+ context "for unix os_types" do
303
+
304
+ before { allow(platform).to receive(:os_type).and_return("unix") }
305
+
306
+ it "sets :vm_hostname to the instance name by default" do
307
+ expect(driver[:vm_hostname]).to eq("suitey-fooos-99")
308
+ end
309
+
310
+ it "sets :vm_hostname to a custom value" do
311
+ config[:vm_hostname] = "okay"
312
+
313
+ expect(driver[:vm_hostname]).to eq("okay")
314
+ end
315
+ end
316
+
317
+ context "for windows os_types" do
318
+
319
+ before { allow(platform).to receive(:os_type).and_return("windows") }
320
+
321
+ it "sets :vm_hostname to nil by default" do
322
+ expect(driver[:vm_hostname]).to eq(nil)
323
+ end
324
+
325
+ it "sets :vm_hostname to a custom value, truncated to 12 chars" do
326
+ config[:vm_hostname] = "this-is-a-pretty-long-name-ya-think"
327
+
328
+ expect(driver[:vm_hostname]).to eq("this-is-a--k")
329
+ end
300
330
  end
301
331
 
302
- it "sets :vm_hostname to a custom value" do
303
- config[:vm_hostname] = "okay"
332
+ context "for non-WinRM-based transports" do
333
+
334
+ before { allow(transport).to receive(:name).and_return("Coolness") }
335
+
336
+ it "sets :username to nil by default" do
337
+ expect(driver[:username]).to eq(nil)
338
+ end
304
339
 
305
- expect(driver[:vm_hostname]).to eq("okay")
340
+ it "sets :password to nil by default" do
341
+ expect(driver[:password]).to eq(nil)
342
+ end
343
+ end
344
+
345
+ context "for WinRM-based transports" do
346
+
347
+ before { allow(transport).to receive(:name).and_return("WinRM") }
348
+
349
+ it "sets :username to vagrant by default" do
350
+ expect(driver[:username]).to eq("vagrant")
351
+ end
352
+
353
+ it "sets :password to vagrant by default" do
354
+ expect(driver[:password]).to eq("vagrant")
355
+ end
306
356
  end
307
357
  end
308
358
 
@@ -369,6 +419,14 @@ describe Kitchen::Driver::Vagrant do
369
419
  expect(File.exist?(File.join(vagrant_root, "Vagrantfile"))).to eq(true)
370
420
  end
371
421
 
422
+ it "calls Transport's #wait_until_ready" do
423
+ conn = double("connection")
424
+ allow(transport).to receive(:connection).with(state).and_return(conn)
425
+ expect(conn).to receive(:wait_until_ready)
426
+
427
+ cmd
428
+ end
429
+
372
430
  it "logs the Vagrantfile contents on debug level" do
373
431
  cmd
374
432
 
@@ -448,35 +506,59 @@ describe Kitchen::Driver::Vagrant do
448
506
  expect(state).to include(:hostname => "192.168.32.64")
449
507
  end
450
508
 
451
- it "sets :username from ssh-config" do
452
- cmd
509
+ context "for non-WinRM-based transports" do
453
510
 
454
- expect(state).to include(:username => "vagrant")
455
- end
511
+ before { allow(transport).to receive(:name).and_return("Coolness") }
456
512
 
457
- it "sets :ssh_key from ssh-config" do
458
- cmd
513
+ it "sets :username from ssh-config" do
514
+ cmd
459
515
 
460
- expect(state).to include(:ssh_key => "/path/to/private_key")
461
- end
516
+ expect(state).to include(:username => "vagrant")
517
+ end
462
518
 
463
- it "sets :port from ssh-config" do
464
- cmd
519
+ it "sets :ssh_key from ssh-config" do
520
+ cmd
465
521
 
466
- expect(state).to include(:port => "2022")
467
- end
522
+ expect(state).to include(:ssh_key => "/path/to/private_key")
523
+ end
468
524
 
469
- it "does not set :proxy_command by default" do
470
- cmd
525
+ it "sets :port from ssh-config" do
526
+ cmd
527
+
528
+ expect(state).to include(:port => "2022")
529
+ end
530
+
531
+ it "does not set :proxy_command by default" do
532
+ cmd
533
+
534
+ expect(state.keys).to_not include(:proxy_command)
535
+ end
471
536
 
472
- expect(state.keys).to_not include(:proxy_command)
537
+ it "sets :proxy_command if ProxyCommand is in ssh-config" do
538
+ output.concat(" ProxyCommand echo proxy\n")
539
+ cmd
540
+
541
+ expect(state).to include(:proxy_command => "echo proxy")
542
+ end
473
543
  end
474
544
 
475
- it "sets :proxy_command if ProxyCommand is in ssh-config" do
476
- output.concat(" ProxyCommand echo proxy\n")
477
- cmd
545
+ context "for WinRM-based transports" do
478
546
 
479
- expect(state).to include(:proxy_command => "echo proxy")
547
+ before { allow(transport).to receive(:name).and_return("WinRM") }
548
+
549
+ it "sets :username from config" do
550
+ config[:username] = "winuser"
551
+ cmd
552
+
553
+ expect(state).to include(:username => "winuser")
554
+ end
555
+
556
+ it "sets :password from config" do
557
+ config[:password] = "mysecret"
558
+ cmd
559
+
560
+ expect(state).to include(:password => "mysecret")
561
+ end
480
562
  end
481
563
  end
482
564
 
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-vagrant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-23 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: 1.4.0.beta.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: 1.4.0.beta.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: countloc
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -144,9 +144,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  requirements:
147
- - - ">="
147
+ - - ">"
148
148
  - !ruby/object:Gem::Version
149
- version: '0'
149
+ version: 1.3.1
150
150
  requirements: []
151
151
  rubyforge_project:
152
152
  rubygems_version: 2.4.5