spec/beaker/hypervisor/vagrant_spec.rb in beaker-2.49.0 vs spec/beaker/hypervisor/vagrant_spec.rb in beaker-2.50.0
- old
+ new
@@ -115,10 +115,40 @@
vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile")))
expect( vagrantfile ).to match(/v.vm.synced_folder .* disabled: true/)
end
+ it "can make a Vagrantfile with network mac autogenerated" do
+ path = vagrant.instance_variable_get( :@vagrant_path )
+
+ hosts = make_hosts({},1)
+ vagrant.make_vfile( hosts, options )
+
+ vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile")))
+ expect( vagrantfile ).to match(/v.vm.network :private_network, ip: "ip.address.for.vm1", :netmask => "255.255.0.0", :mac => ".+/)
+ end
+
+ it "can make a Vagrantfile with network mac specified" do
+ path = vagrant.instance_variable_get( :@vagrant_path )
+
+ hosts = make_hosts({:network_mac => 'b6:33:ae:19:48:f9'},1)
+ vagrant.make_vfile( hosts, options )
+
+ vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile")))
+ expect( vagrantfile ).to match(/v.vm.network :private_network, ip: "ip.address.for.vm1", :netmask => "255.255.0.0", :mac => "b6:33:ae:19:48:f9/)
+ end
+
+ it "can make a Vagrantfile with network mac disabled" do
+ path = vagrant.instance_variable_get( :@vagrant_path )
+
+ hosts = make_hosts({:network_mac => 'false'},1)
+ vagrant.make_vfile( hosts, options )
+
+ vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile")))
+ expect( vagrantfile ).to match(/v.vm.network :private_network, ip: "ip.address.for.vm1", :netmask => "255.255.0.0"/)
+ end
+
it "generates a valid windows config" do
path = vagrant.instance_variable_get( :@vagrant_path )
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
@hosts[0][:platform] = 'windows'
@@ -149,23 +179,23 @@
match = generated_file.match(/vb.customize \['modifyvm', :id, '--memory', 'hello!', '--cpus', '1'\]/)
expect( match ).to_not be nil
end
-
+
it "uses the cpus defined per vagrant host" do
path = vagrant.instance_variable_get( :@vagrant_path )
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
-
+
vagrant.make_vfile( @hosts, {'vagrant_cpus' => 'goodbye!'} )
-
+
generated_file = File.read( File.expand_path( File.join( path, "Vagrantfile") ) )
-
+
match = generated_file.match(/vb.customize \['modifyvm', :id, '--memory', '1024', '--cpus', 'goodbye!'\]/)
-
+
expect( match ).to_not be nil
-
+
end
context "port forwarding rules" do
it "supports all Vagrant parameters" do
path = vagrant.instance_variable_get( :@vagrant_path )
@@ -267,21 +297,31 @@
it "can copy to root on unix" do
host = @hosts[0]
host[:platform] = 'unix'
expect( Command ).to receive( :new ).with("sudo su -c \"cp -r .ssh /root/.\"").once
+ expect( Command ).to receive( :new ).with("sudo fixfiles restore /root").once
+ expect( Command ).to receive( :new ).with("sudo selinuxenabled").once
vagrant.copy_ssh_to_root( host, options )
end
it "can copy to Administrator on windows" do
host = @hosts[0]
host[:platform] = 'windows'
expect( host ).to receive( :is_cygwin? ).and_return(true)
+ expect( Command ).to_not receive( :new ).with("sudo fixfiles restore /root")
expect( Command ).to receive( :new ).with("cp -r .ssh /cygdrive/c/Users/Administrator/.").once
expect( Command ).to receive( :new ).with("chown -R Administrator /cygdrive/c/Users/Administrator/.ssh").once
+
+ # This is checked on all platforms since Linux isn't called out specifically in the code
+ # If this fails, nothing further is activated
+ result = Beaker::Result.new(host, '')
+ result.exit_code = 1
+ expect( Command ).to receive( :new ).with("sudo selinuxenabled")
+ allow( host ).to receive(:exec).and_return(result)
vagrant.copy_ssh_to_root( host, options )
end
end