Skip to content

Commit d3da5e7

Browse files
committed
Add specs for volume provision flavor no root disk
If a flavor has no root disk we have to set up the bootable volume manually based on the first requested volume.
1 parent d7e2dab commit d3da5e7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

spec/models/manageiq/providers/openstack/cloud_manager/provision/volume_attachment_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,30 @@
2929

3030
expect(task.create_requested_volumes(task.options[:volumes])).to eq([default_volume, requested_volume])
3131
end
32+
33+
context "with a flavor that has no root disk" do
34+
let(:flavor) { FactoryBot.create(:flavor_openstack, :root_disk_size => 0) }
35+
36+
it "sets the requested volume as a boot disk" do
37+
expected_volume = {:name => "custom_volume_1", :size => 2, :uuid => volume.id, :source_type => "volume",
38+
:destination_type => "volume", :boot_index => 0, :bootable => true, :imageRef => template.ems_ref}
39+
40+
expect(task.create_requested_volumes(task.options[:volumes])).to eq([expected_volume])
41+
end
42+
43+
context "with multiple requested volumes" do
44+
let(:task_volumes) { [{:name => "custom_volume_1", :size => 2}, {:name => "custom_volume_2", :size => 4}] }
45+
46+
it "sets other volumes as boot_index -1" do
47+
expected_volume_1 = {:name => "custom_volume_1", :size => 2, :uuid => volume.id, :source_type => "volume",
48+
:destination_type => "volume", :boot_index => 0, :bootable => true, :imageRef => template.ems_ref}
49+
expected_volume_2 = {:name => "custom_volume_2", :size => 4, :uuid => volume.id, :source_type => "volume",
50+
:destination_type => "volume", :boot_index => -1}
51+
52+
expect(task.create_requested_volumes(task.options[:volumes])).to eq([expected_volume_1, expected_volume_2])
53+
end
54+
end
55+
end
3256
end
3357

3458
context "#check_volumes" do

0 commit comments

Comments
 (0)