Skip to content

Commit

Permalink
Fix test-kitchen#365 - add name for virtualbox instances
Browse files Browse the repository at this point in the history
Signed-off-by: Seth Thomas <[email protected]>
  • Loading branch information
Seth Thomas authored and stissot committed Dec 11, 2018
1 parent 3c8aec5 commit 7e7c64d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions spec/kitchen/driver/vagrant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,16 @@ def run_command(_cmd, options = {})

before { config[:provider] = "virtualbox" }

it "sets :name for virtualbox GUI" do
cmd

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
end
RUBY
end

it "adds a line for each element in :customize" do
config[:customize] = {
:a_key => "some value",
Expand All @@ -1275,6 +1285,7 @@ def run_command(_cmd, options = {})

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["modifyvm", :id, "--a_key", "some value"]
p.customize ["modifyvm", :id, "--something", "else"]
end
Expand All @@ -1294,6 +1305,7 @@ def run_command(_cmd, options = {})

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.gui = false
end
RUBY
Expand All @@ -1305,6 +1317,7 @@ def run_command(_cmd, options = {})

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.gui = true
end
RUBY
Expand All @@ -1324,6 +1337,7 @@ def run_command(_cmd, options = {})

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.linked_clone = false
end
RUBY
Expand All @@ -1335,6 +1349,7 @@ def run_command(_cmd, options = {})

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.linked_clone = true
end
RUBY
Expand All @@ -1351,6 +1366,7 @@ def run_command(_cmd, options = {})

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["createhd", "--filename", "./d1.vmdk", "--size", 10240]
end
RUBY
Expand All @@ -1373,6 +1389,7 @@ def run_command(_cmd, options = {})

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["createhd", "--filename", "./d1.vmdk", "--size", 10240]
p.customize ["createhd", "--filename", "./d2.vmdk", "--size", 20480]
end
Expand All @@ -1392,6 +1409,7 @@ def run_command(_cmd, options = {})

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["storagectl", :id, "--name", "Custom SATA Controller", "--add", "sata", "--controller", "IntelAHCI", "--portcount", 4]
end
RUBY
Expand All @@ -1415,6 +1433,7 @@ def run_command(_cmd, options = {})

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["storagectl", :id, "--name", "Custom SATA Controller", "--add", "sata", "--controller", "IntelAHCI"]
p.customize ["storagectl", :id, "--name", "Custom SATA Controller", "--portcount", 4]
end
Expand All @@ -1432,6 +1451,7 @@ def run_command(_cmd, options = {})

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["storageattach", :id, "--type", "hdd", "--port", 1]
end
RUBY
Expand Down Expand Up @@ -1460,6 +1480,7 @@ def run_command(_cmd, options = {})

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--device", 0, "--type", "hdd", "--medium", "./d1.vmdk"]
p.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--device", 1, "--type", "hdd", "--medium", "./d2.vmdk"]
end
Expand All @@ -1474,6 +1495,7 @@ def run_command(_cmd, options = {})

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["modifyvm", :id, "--cpuidset", "00000001", "00000002"]
end
RUBY
Expand Down
5 changes: 5 additions & 0 deletions templates/Vagrantfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ Vagrant.configure("2") do |c|
<% end %>

c.vm.provider :<%= config[:provider] %> do |p|
<% case config[:provider]
when "virtualbox" %>
p.name = "kitchen-<%= File.basename(config[:kitchen_root]) %>-<%= instance.name %>"
<% end %>

<% case config[:provider]
when "virtualbox", /^vmware_/
if config[:gui] == true || config[:gui] == false %>
Expand Down

0 comments on commit 7e7c64d

Please sign in to comment.