spec/beaker/hypervisor/vagrant_spec.rb in beaker-2.18.1 vs spec/beaker/hypervisor/vagrant_spec.rb in beaker-2.18.2

- old
+ new

@@ -40,31 +40,31 @@ v.vm.box = 'vm1_of_my_box' v.vm.box_url = 'http://address.for.my.box.vm1' v.vm.box_check_update = 'true' v.vm.network :private_network, ip: "ip.address.for.vm1", :netmask => "255.255.0.0", :mac => "0123456789" v.vm.provider :virtualbox do |vb| - vb.customize ['modifyvm', :id, '--memory', '1024'] + vb.customize ['modifyvm', :id, '--memory', '1024', '--cpus', '1'] end end c.vm.define 'vm2' do |v| v.vm.hostname = 'vm2' v.vm.box = 'vm2_of_my_box' v.vm.box_url = 'http://address.for.my.box.vm2' v.vm.box_check_update = 'true' v.vm.network :private_network, ip: "ip.address.for.vm2", :netmask => "255.255.0.0", :mac => "0123456789" v.vm.provider :virtualbox do |vb| - vb.customize ['modifyvm', :id, '--memory', '1024'] + vb.customize ['modifyvm', :id, '--memory', '1024', '--cpus', '1'] end end c.vm.define 'vm3' do |v| v.vm.hostname = 'vm3' v.vm.box = 'vm3_of_my_box' v.vm.box_url = 'http://address.for.my.box.vm3' v.vm.box_check_update = 'true' v.vm.network :private_network, ip: "ip.address.for.vm3", :netmask => "255.255.0.0", :mac => "0123456789" v.vm.provider :virtualbox do |vb| - vb.customize ['modifyvm', :id, '--memory', '1024'] + vb.customize ['modifyvm', :id, '--memory', '1024', '--cpus', '1'] end end end EOF end @@ -118,13 +118,27 @@ vagrant.make_vfile( @hosts, {'vagrant_memsize' => 'hello!'} ) generated_file = File.read( File.expand_path( File.join( path, "Vagrantfile") ) ) - match = generated_file.match(/vb.customize \['modifyvm', :id, '--memory', 'hello!'\]/) + 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 it "can generate a new /etc/hosts file referencing each host" do @hosts.each do |host|