beaker-vagrant 0.4.0 → 0.5.0

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: 74c1cb569c6a0c707030b00ca1a05d16642a0c53
4
- data.tar.gz: 91b7008f99327d8e84d668a289430b52b9c4e642
3
+ metadata.gz: b0507afd930ed4038b5828c44deaba498093bce5
4
+ data.tar.gz: 2936af72e1c7ca90377b1179ec783fc2257ff697
5
5
  SHA512:
6
- metadata.gz: 6d9fa34cb3d014bb41bfe680a76a7814d9bf163573e3d86fa5cdab6b3bb32c6743d2357fda231ca157c74f196fe15dfe653d8ebf054e2d6a79c32adcae0838e0
7
- data.tar.gz: e64456d0bc01007038eadb0eaa94355818b8f6da4d58ac45373f9be98e22e14183bd01a75ba4888dad6345161d995c82eea9bc110dbf8f003d5fba90d9274bec
6
+ metadata.gz: 4b513ccb24fcdd1f0dd5fb13c4779629d0b913988398fbab3bf69bb48ec181678ff50c3d2ed3e26209588c42fd3454ec5204ba52a4534faf0c2b114c6e108928
7
+ data.tar.gz: 423b6c4bff4c7561750f38017986a682327d37563bc99737a1351ee2363ac7d9918f14357cadf423c37add92bfef912508b96b8745c8f58c6366b020a8784b91
@@ -1,3 +1,3 @@
1
1
  module BeakerVagrant
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -3,6 +3,7 @@ require 'open3'
3
3
  module Beaker
4
4
  class Vagrant < Beaker::Hypervisor
5
5
 
6
+ require 'beaker/hypervisor/vagrant/mount_folder'
6
7
  require 'beaker/hypervisor/vagrant_virtualbox'
7
8
  # Return a random mac address
8
9
  #
@@ -56,7 +57,12 @@ module Beaker
56
57
 
57
58
  unless host['mount_folders'].nil?
58
59
  host['mount_folders'].each do |name, folder|
59
- v_file << " v.vm.synced_folder '#{folder[:from]}', '#{folder[:to]}', create: true\n"
60
+ mount_folder = Vagrant::MountFolder.new(name, folder)
61
+ if mount_folder.required_keys_present?
62
+ v_file << " v.vm.synced_folder '#{mount_folder.from}', '#{mount_folder.to}', create: true\n"
63
+ else
64
+ @logger.warn "Using 'mount_folders' requires options 'from' and 'to' for vagrant node, given #{folder.inspect}"
65
+ end
60
66
  end
61
67
  end
62
68
 
@@ -0,0 +1,20 @@
1
+ module Beaker
2
+ class Vagrant::MountFolder
3
+ def initialize(name, spec)
4
+ @name = name
5
+ @spec = spec
6
+ end
7
+
8
+ def required_keys_present?
9
+ not from.nil? and not to.nil?
10
+ end
11
+
12
+ def from
13
+ @spec[:from]
14
+ end
15
+
16
+ def to
17
+ @spec[:to]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ require 'beaker/hypervisor/vagrant'
2
+
3
+ class Beaker::VagrantDesktop < Beaker::Vagrant
4
+ def provision(provider = 'vmware_desktop')
5
+ super
6
+ end
7
+
8
+ def self.provider_vfile_section(host, options)
9
+ v_provider = " v.vm.provider :vmware_desktop do |v|\n"
10
+ v_provider << " v.vmx['gui'] = true\n" if host['gui'] == true
11
+ v_provider << " v.vmx['memsize'] = '#{memsize(host,options)}'\n"
12
+ v_provider << " v.vmx['whitelist_verified'] = '#{host['whitelist_verified']}'\n" unless host['whitelist_verified'].nil?
13
+ v_provider << " v.vmx['functional_hgfs'] = '#{host['functional_hgfs']}'\n" unless host['functional_hgfs'].nil?
14
+ v_provider << " v.vmx['unmount_default_hgfs'] = '#{host['unmount_default_hgfs']}'\n" unless host['unmount_default_hgfs'].nil?
15
+ v_provider << " v.vmx['utility_port'] = '#{host['utility_port']}'\n" unless host['utility_port'].nil?
16
+ v_provider << " end\n"
17
+ end
18
+ end
@@ -5,9 +5,14 @@ class Beaker::VagrantWorkstation < Beaker::Vagrant
5
5
  super
6
6
  end
7
7
 
8
- def self.provider_vfile_section(host, options)
9
- " v.vm.provider :vmware_workstation do |v|\n" +
10
- " v.vmx['memsize'] = '#{memsize(host,options)}'\n" +
11
- " end\n"
8
+ def self.provider_vfile_section(host, options)
9
+ v_provider = " v.vm.provider :vmware_workstation do |v|\n"
10
+ v_provider << " v.vmx['gui'] = true\n" if host['gui'] == true
11
+ v_provider << " v.vmx['memsize'] = '#{memsize(host,options)}'\n"
12
+ v_provider << " v.vmx['whitelist_verified'] = '#{host['whitelist_verified']}'\n" unless host['whitelist_verified'].nil?
13
+ v_provider << " v.vmx['functional_hgfs'] = '#{host['functional_hgfs']}'\n" unless host['functional_hgfs'].nil?
14
+ v_provider << " v.vmx['unmount_default_hgfs'] = '#{host['unmount_default_hgfs']}'\n" unless host['unmount_default_hgfs'].nil?
15
+ v_provider << " v.vmx['utility_port'] = '#{host['utility_port']}'\n" unless host['utility_port'].nil?
16
+ v_provider << " end\n"
12
17
  end
13
18
  end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe Beaker::VagrantDesktop do
4
+ let( :options ) { make_opts.merge({ :hosts_file => 'sample.cfg', 'logger' => double().as_null_object }) }
5
+ let( :vagrant ) { Beaker::VagrantDesktop.new( @hosts, options ) }
6
+
7
+ before :each do
8
+ @hosts = make_hosts()
9
+ end
10
+
11
+ it "uses the vmware_desktop provider for provisioning" do
12
+ @hosts.each do |host|
13
+ host_prev_name = host['user']
14
+ expect( vagrant ).to receive( :set_ssh_config ).with( host, 'vagrant' ).once
15
+ expect( vagrant ).to receive( :copy_ssh_to_root ).with( host, options ).once
16
+ expect( vagrant ).to receive( :set_ssh_config ).with( host, host_prev_name ).once
17
+ end
18
+ expect( vagrant ).to receive( :hack_etc_hosts ).with( @hosts, options ).once
19
+ expect( vagrant ).to receive( :vagrant_cmd ).with( "up --provider vmware_desktop" ).once
20
+ vagrant.provision
21
+ end
22
+
23
+ it "can make a Vagranfile for a set of hosts" do
24
+ path = vagrant.instance_variable_get( :@vagrant_path )
25
+ allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
26
+
27
+ vagrant.make_vfile( @hosts )
28
+
29
+ vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile")))
30
+ expect( vagrantfile ).to include( %Q{ v.vm.provider :vmware_desktop do |v|\n v.vmx['memsize'] = '1024'\n end})
31
+ end
32
+
33
+ it "can enable whitelist_verified on hosts" do
34
+ path = vagrant.instance_variable_get( :@vagrant_path )
35
+ hosts = make_hosts({:whitelist_verified => true},1)
36
+
37
+ vagrant.make_vfile( hosts )
38
+
39
+ vagrantfile = File.read( File.expand_path( File.join( path, 'Vagrantfile' )))
40
+ expect( vagrantfile ).to include( %Q{ v.vmx['whitelist_verified'] = 'true'})
41
+ end
42
+
43
+ it "can enable functional_hgfs on hosts" do
44
+ path = vagrant.instance_variable_get( :@vagrant_path )
45
+ hosts = make_hosts({:functional_hgfs => true},1)
46
+
47
+ vagrant.make_vfile( hosts )
48
+
49
+ vagrantfile = File.read( File.expand_path( File.join( path, 'Vagrantfile' )))
50
+ expect( vagrantfile ).to include( %Q{ v.vmx['functional_hgfs'] = 'true'})
51
+ end
52
+
53
+ it "can enable unmount_default_hgfs on hosts" do
54
+ path = vagrant.instance_variable_get( :@vagrant_path )
55
+ hosts = make_hosts({:unmount_default_hgfs => true},1)
56
+
57
+ vagrant.make_vfile( hosts )
58
+
59
+ vagrantfile = File.read( File.expand_path( File.join( path, 'Vagrantfile' )))
60
+ expect( vagrantfile ).to include( %Q{ v.vmx['unmount_default_hgfs'] = 'true'})
61
+ end
62
+
63
+ it "can enable gui on hosts" do
64
+ path = vagrant.instance_variable_get( :@vagrant_path )
65
+ hosts = make_hosts({:gui => true},1)
66
+
67
+ vagrant.make_vfile( hosts )
68
+
69
+ vagrantfile = File.read( File.expand_path( File.join( path, 'Vagrantfile' )))
70
+ expect( vagrantfile ).to include( %Q{ v.vmx['gui'] = true})
71
+ end
72
+ end
@@ -110,7 +110,7 @@ EOF
110
110
  path = vagrant.instance_variable_get( :@vagrant_path )
111
111
  allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
112
112
 
113
- host = make_host( 'name-with_underscore', {} )
113
+ host = make_host( 'name-with_underscore', {} )
114
114
  vagrant.make_vfile( [host,], options )
115
115
 
116
116
  vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile")))
@@ -159,6 +159,25 @@ EOF
159
159
  expect( vagrantfile ).to match(/v.vm.network :private_network, ip: "ip.address.for.vm1", :netmask => "255.255.0.0"/)
160
160
  end
161
161
 
162
+ it "can make a Vagrantfile with improper keys for synced folders" do
163
+ path = vagrant.instance_variable_get( :@vagrant_path )
164
+
165
+ hosts = make_hosts({:mount_folders => {
166
+ :test_invalid1 => {:host_path => '/invalid1', :container_path => '/invalid1'},
167
+ :test_invalid2 => {:from => '/invalid2', :container_path => '/invalid2'},
168
+ :test_invalid3 => {:host_path => '/invalid3', :to => '/invalid3'},
169
+ :test_valid => {:from => '/valid', :to => '/valid'}
170
+ }},1)
171
+ vagrant.make_vfile( hosts, options )
172
+
173
+ vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile")))
174
+
175
+ expect( vagrantfile ).not_to match(/v.vm.synced_folder '', '', create: true/)
176
+ expect( vagrantfile ).not_to match(/v.vm.synced_folder '\/invalid2', '', create: true/)
177
+ expect( vagrantfile ).not_to match(/v.vm.synced_folder '', '\/invalid3', create: true/)
178
+ expect( vagrantfile ).to match(/v.vm.synced_folder '\/valid', '\/valid', create: true/)
179
+ end
180
+
162
181
  context "when generating a windows config" do
163
182
  before do
164
183
  path = vagrant.instance_variable_get( :@vagrant_path )
@@ -29,4 +29,44 @@ describe Beaker::VagrantWorkstation do
29
29
  vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile")))
30
30
  expect( vagrantfile ).to include( %Q{ v.vm.provider :vmware_workstation do |v|\n v.vmx['memsize'] = '1024'\n end})
31
31
  end
32
+
33
+ it "can enable whitelist_verified on hosts" do
34
+ path = vagrant.instance_variable_get( :@vagrant_path )
35
+ hosts = make_hosts({:whitelist_verified => true},1)
36
+
37
+ vagrant.make_vfile( hosts )
38
+
39
+ vagrantfile = File.read( File.expand_path( File.join( path, 'Vagrantfile' )))
40
+ expect( vagrantfile ).to include( %Q{ v.vmx['whitelist_verified'] = 'true'})
41
+ end
42
+
43
+ it "can enable functional_hgfs on hosts" do
44
+ path = vagrant.instance_variable_get( :@vagrant_path )
45
+ hosts = make_hosts({:functional_hgfs => true},1)
46
+
47
+ vagrant.make_vfile( hosts )
48
+
49
+ vagrantfile = File.read( File.expand_path( File.join( path, 'Vagrantfile' )))
50
+ expect( vagrantfile ).to include( %Q{ v.vmx['functional_hgfs'] = 'true'})
51
+ end
52
+
53
+ it "can enable unmount_default_hgfs on hosts" do
54
+ path = vagrant.instance_variable_get( :@vagrant_path )
55
+ hosts = make_hosts({:unmount_default_hgfs => true},1)
56
+
57
+ vagrant.make_vfile( hosts )
58
+
59
+ vagrantfile = File.read( File.expand_path( File.join( path, 'Vagrantfile' )))
60
+ expect( vagrantfile ).to include( %Q{ v.vmx['unmount_default_hgfs'] = 'true'})
61
+ end
62
+
63
+ it "can enable gui on hosts" do
64
+ path = vagrant.instance_variable_get( :@vagrant_path )
65
+ hosts = make_hosts({:gui => true},1)
66
+
67
+ vagrant.make_vfile( hosts )
68
+
69
+ vagrantfile = File.read( File.expand_path( File.join( path, 'Vagrantfile' )))
70
+ expect( vagrantfile ).to include( %Q{ v.vmx['gui'] = true})
71
+ end
32
72
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-vagrant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rishi Javia, Kevin Imber, Tony Vu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-22 00:00:00.000000000 Z
11
+ date: 2018-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -173,13 +173,16 @@ files:
173
173
  - docs/vagrant_libvirt.md
174
174
  - lib/beaker-vagrant/version.rb
175
175
  - lib/beaker/hypervisor/vagrant.rb
176
+ - lib/beaker/hypervisor/vagrant/mount_folder.rb
176
177
  - lib/beaker/hypervisor/vagrant_custom.rb
178
+ - lib/beaker/hypervisor/vagrant_desktop.rb
177
179
  - lib/beaker/hypervisor/vagrant_fusion.rb
178
180
  - lib/beaker/hypervisor/vagrant_libvirt.rb
179
181
  - lib/beaker/hypervisor/vagrant_parallels.rb
180
182
  - lib/beaker/hypervisor/vagrant_virtualbox.rb
181
183
  - lib/beaker/hypervisor/vagrant_workstation.rb
182
184
  - spec/beaker/hypervisor/vagrant_custom_spec.rb
185
+ - spec/beaker/hypervisor/vagrant_desktop_spec.rb
183
186
  - spec/beaker/hypervisor/vagrant_fusion_spec.rb
184
187
  - spec/beaker/hypervisor/vagrant_libvirt_spec.rb
185
188
  - spec/beaker/hypervisor/vagrant_parallels_spec.rb