bosh-stemcell 1.5.0.pre.1226 → 1.5.0.pre.1244

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. data/lib/bosh/stemcell/version.rb +1 -1
  2. metadata +6 -75
  3. data/.rspec +0 -3
  4. data/Berksfile +0 -3
  5. data/Berksfile.lock +0 -28
  6. data/Vagrantfile +0 -50
  7. data/bosh-stemcell.gemspec +0 -28
  8. data/spec/assets/fake-stemcell-aws.tgz +0 -0
  9. data/spec/assets/fake-stemcell-vsphere.tgz +0 -0
  10. data/spec/assets/light-fake-stemcell-aws.tgz +0 -0
  11. data/spec/bosh/monkeypatch/serverspec/backend/exec_spec.rb +0 -46
  12. data/spec/bosh/stemcell/archive_filename_spec.rb +0 -56
  13. data/spec/bosh/stemcell/archive_spec.rb +0 -123
  14. data/spec/bosh/stemcell/aws/ami_spec.rb +0 -30
  15. data/spec/bosh/stemcell/aws/light_stemcell_spec.rb +0 -94
  16. data/spec/bosh/stemcell/aws/region_spec.rb +0 -12
  17. data/spec/bosh/stemcell/builder_command_spec.rb +0 -273
  18. data/spec/bosh/stemcell/builder_options_spec.rb +0 -216
  19. data/spec/bosh/stemcell/disk_image_spec.rb +0 -163
  20. data/spec/bosh/stemcell/infrastructure_spec.rb +0 -66
  21. data/spec/bosh/stemcell/operating_system_spec.rb +0 -47
  22. data/spec/bosh/stemcell/stage_collection_spec.rb +0 -279
  23. data/spec/bosh/stemcell/stage_runner_spec.rb +0 -141
  24. data/spec/bosh/stemcell/version_spec.rb +0 -12
  25. data/spec/bosh/stemcell_spec.rb +0 -6
  26. data/spec/spec_helper.rb +0 -6
  27. data/spec/stemcells/aws_spec.rb +0 -9
  28. data/spec/stemcells/centos_spec.rb +0 -146
  29. data/spec/stemcells/go_agent_spec.rb +0 -10
  30. data/spec/stemcells/openstack_spec.rb +0 -9
  31. data/spec/stemcells/ruby_agent_spec.rb +0 -27
  32. data/spec/stemcells/ubuntu_spec.rb +0 -165
  33. data/spec/stemcells/vsphere_spec.rb +0 -9
  34. data/spec/support/rspec_fire.rb +0 -9
  35. data/spec/support/serverspec.rb +0 -4
  36. data/spec/support/spec_assets.rb +0 -11
  37. data/spec/support/stemcell_image.rb +0 -26
  38. data/spec/support/stemcell_shared_examples.rb +0 -27
  39. data/spec/support/stub_env.rb +0 -5
@@ -1,163 +0,0 @@
1
- require 'spec_helper'
2
- require 'bosh/stemcell/disk_image'
3
-
4
- module Bosh::Stemcell
5
- describe DiskImage do
6
- let(:shell) { instance_double('Bosh::Core::Shell', run: nil) }
7
-
8
- let(:kpartx_map_output) { 'add map FAKE_LOOP1p1 (252:3): 0 3997984 linear /dev/loop1 63' }
9
- let(:options) do
10
- {
11
- image_file_path: '/path/to/FAKE_IMAGE',
12
- image_mount_point: '/fake/mnt'
13
- }
14
- end
15
-
16
- subject(:disk_image) { DiskImage.new(options) }
17
-
18
- before do
19
- Bosh::Core::Shell.stub(:new).and_return(shell)
20
- end
21
-
22
- describe '#initialize' do
23
- it 'requires an image_file_path' do
24
- options.delete(:image_file_path)
25
- expect { DiskImage.new(options) }.to raise_error /key not found: :image_file_path/
26
- end
27
-
28
- it 'requires an mount_point' do
29
- options.delete(:image_mount_point)
30
-
31
- dir_mock = class_double('Dir').as_stubbed_const
32
- dir_mock.should_receive(:mktmpdir).and_return('/fake/tmpdir')
33
-
34
- expect(DiskImage.new(options).image_mount_point).to eq('/fake/tmpdir')
35
- end
36
- end
37
-
38
- describe '#mount' do
39
- it 'maps the file to a loop device' do
40
- losetup_commad = 'sudo losetup --show --find /path/to/FAKE_IMAGE'
41
- shell.stub(:run).with(losetup_commad, output_command: false).and_return('/dev/loop0')
42
- shell.should_receive(:run).with('sudo kpartx -av /dev/loop0',
43
- output_command: false).and_return(kpartx_map_output)
44
-
45
- disk_image.mount
46
- end
47
-
48
- it 'mounts the loop device' do
49
- losetup_commad = 'sudo losetup --show --find /path/to/FAKE_IMAGE'
50
- shell.stub(:run).with(losetup_commad, output_command: false).and_return('/dev/loop0')
51
- shell.stub(:run).with('sudo kpartx -av /dev/loop0', output_command: false).and_return(kpartx_map_output)
52
-
53
- shell.should_receive(:run).with('sudo mount /dev/mapper/FAKE_LOOP1p1 /fake/mnt', output_command: false)
54
-
55
- disk_image.mount
56
- end
57
-
58
- context 'when the device does not exist' do
59
- let(:mount_command) do
60
- 'sudo mount /dev/mapper/FAKE_LOOP1p1 /fake/mnt'
61
- end
62
-
63
- let(:mount_error) do
64
- "Failed: '#{mount_command}' from /fake/mnt/blah/blah/bosh-stemcell, with exit status 8192\n\n"
65
- end
66
-
67
- before do
68
- disk_image.stub(:sleep)
69
- end
70
-
71
- it 'runs mount a second time after sleeping long enough for the device node to be created' do
72
- losetup_commad = 'sudo losetup --show --find /path/to/FAKE_IMAGE'
73
- shell.stub(:run).with(losetup_commad, output_command: false).and_return('/dev/loop0')
74
- shell.stub(:run).with('sudo kpartx -av /dev/loop0', output_command: false).and_return(kpartx_map_output)
75
- shell.should_receive(:run).with(mount_command, output_command: false).ordered.and_raise(mount_error)
76
- disk_image.should_receive(:sleep).with(0.5)
77
- shell.should_receive(:run).with(mount_command, output_command: false).ordered
78
-
79
- disk_image.mount
80
- end
81
-
82
- context 'when the second mount command fails' do
83
- it 'raises an error' do
84
- losetup_commad = 'sudo losetup --show --find /path/to/FAKE_IMAGE'
85
- shell.stub(:run).with(losetup_commad, output_command: false).and_return('/dev/loop0')
86
- shell.stub(:run).with('sudo kpartx -av /dev/loop0', output_command: false).and_return(kpartx_map_output)
87
- shell.should_receive(:run).with(mount_command, output_command: false).ordered.twice.and_raise(mount_error)
88
-
89
- expect { disk_image.mount }.to raise_error(mount_error)
90
- end
91
- end
92
- end
93
-
94
- context 'when the mount command fails' do
95
- it 'runs mount a second time' do
96
- losetup_commad = 'sudo losetup --show --find /path/to/FAKE_IMAGE'
97
- shell.stub(:run).with(losetup_commad, output_command: false).and_return('/dev/loop0')
98
- shell.stub(:run).with('sudo kpartx -av /dev/loop0', output_command: false).and_return(kpartx_map_output)
99
- shell.should_receive(:run).
100
- with('sudo mount /dev/mapper/FAKE_LOOP1p1 /fake/mnt', output_command: false).ordered.
101
- and_raise(RuntimeError, 'UNEXEPECTED')
102
-
103
- expect { disk_image.mount }.to raise_error(RuntimeError, 'UNEXEPECTED')
104
- end
105
- end
106
- end
107
-
108
- describe '#unmount' do
109
- before do
110
- disk_image.stub(device: '/dev/loop0') # pretend we've mounted
111
- end
112
-
113
- it 'unmounts the loop device and then unmaps the file' do
114
- shell.should_receive(:run).with('sudo umount /fake/mnt', output_command: false).ordered
115
- shell.should_receive(:run).with('sudo kpartx -dv /dev/loop0', output_command: false).ordered
116
- shell.should_receive(:run).with('sudo losetup -dv /dev/loop0', output_command: false).ordered
117
-
118
- disk_image.unmount
119
- end
120
-
121
- it 'unmaps the file even if unmounting the device fails' do
122
- shell.should_receive(:run).with('sudo umount /fake/mnt', output_command: false).and_raise
123
- shell.should_receive(:run).with('sudo kpartx -dv /dev/loop0', output_command: false).ordered
124
- shell.should_receive(:run).with('sudo losetup -dv /dev/loop0', output_command: false).ordered
125
-
126
- expect { disk_image.unmount }.to raise_error
127
- end
128
- end
129
-
130
- describe '#while_mounted' do
131
- it 'mounts the disk, calls the provided block, and unmounts' do
132
- fake_thing = double('FakeThing')
133
- losetup_commad = 'sudo losetup --show --find /path/to/FAKE_IMAGE'
134
- shell.stub(:run).with(losetup_commad, output_command: false).and_return('/dev/loop0')
135
- shell.stub(:run).with('sudo kpartx -av /dev/loop0', output_command: false).and_return(kpartx_map_output)
136
- shell.should_receive(:run).with('sudo mount /dev/mapper/FAKE_LOOP1p1 /fake/mnt', output_command: false)
137
- fake_thing.should_receive(:fake_call).with(disk_image).ordered
138
- shell.should_receive(:run).with('sudo umount /fake/mnt', output_command: false).ordered
139
- shell.should_receive(:run).with('sudo kpartx -dv /dev/loop0', output_command: false).ordered
140
- shell.should_receive(:run).with('sudo losetup -dv /dev/loop0', output_command: false).ordered
141
-
142
- disk_image.while_mounted do |image|
143
- fake_thing.fake_call(image)
144
- end
145
- end
146
-
147
- context 'when the block raises and error' do
148
- it 'mounts the disk, calls the provided block, and unmounts' do
149
- losetup_commad = 'sudo losetup --show --find /path/to/FAKE_IMAGE'
150
- shell.stub(:run).with(losetup_commad, output_command: false).and_return('/dev/loop0')
151
- shell.stub(:run).with('sudo kpartx -av /dev/loop0', output_command: false).and_return(kpartx_map_output)
152
- shell.should_receive(:run).with('sudo mount /dev/mapper/FAKE_LOOP1p1 /fake/mnt', output_command: false)
153
-
154
- shell.should_receive(:run).with('sudo umount /fake/mnt', output_command: false).ordered
155
- shell.should_receive(:run).with('sudo kpartx -dv /dev/loop0', output_command: false).ordered
156
- shell.should_receive(:run).with('sudo losetup -dv /dev/loop0', output_command: false).ordered
157
-
158
- expect { disk_image.while_mounted { |_| raise } }.to raise_error
159
- end
160
- end
161
- end
162
- end
163
- end
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
- require 'bosh/stemcell/infrastructure'
3
-
4
- module Bosh::Stemcell
5
- describe Infrastructure do
6
- describe '.for' do
7
- it 'returns the correct infrastrcture' do
8
- expect(Infrastructure.for('openstack')).to be_an(Infrastructure::OpenStack)
9
- expect(Infrastructure.for('aws')).to be_an(Infrastructure::Aws)
10
- expect(Infrastructure.for('vsphere')).to be_a(Infrastructure::Vsphere)
11
- end
12
-
13
- it 'raises for unknown instructures' do
14
- expect {
15
- Infrastructure.for('BAD_INFRASTRUCTURE')
16
- }.to raise_error(ArgumentError, /invalid infrastructure: BAD_INFRASTRUCTURE/)
17
- end
18
- end
19
- end
20
-
21
- describe Infrastructure::Base do
22
- it 'requires a name to be specified' do
23
- expect {
24
- Infrastructure::Base.new
25
- }.to raise_error /key not found: :name/
26
- end
27
-
28
- it 'requires a hypervisor' do
29
- expect {
30
- Infrastructure::Base.new(name: 'foo', default_disk_size: 1024)
31
- }.to raise_error /key not found: :hypervisor/
32
- end
33
-
34
- it 'requires a default_disk_size' do
35
- expect {
36
- Infrastructure::Base.new(name: 'foo', hypervisor: 'xen')
37
- }.to raise_error /key not found: :default_disk_size/
38
- end
39
-
40
- it 'defaults to not supporting light stemcells' do
41
- infrastructure = Infrastructure::Base.new(name: 'foo', hypervisor: 'bar', default_disk_size: 1024)
42
- expect(infrastructure).not_to be_light
43
- end
44
- end
45
-
46
- describe Infrastructure::Aws do
47
- its(:name) { should eq('aws') }
48
- its(:hypervisor) { should eq('xen') }
49
- its(:default_disk_size) { should eq(2048) }
50
- it { should be_light }
51
- end
52
-
53
- describe Infrastructure::OpenStack do
54
- its(:name) { should eq('openstack') }
55
- its(:hypervisor) { should eq('kvm') }
56
- its(:default_disk_size) { should eq(10240) }
57
- it { should_not be_light }
58
- end
59
-
60
- describe Infrastructure::Vsphere do
61
- its(:name) { should eq('vsphere') }
62
- its(:hypervisor) { should eq('esxi') }
63
- its(:default_disk_size) { should eq(3072) }
64
- it { should_not be_light }
65
- end
66
- end
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
- require 'bosh/stemcell/operating_system'
3
-
4
- module Bosh::Stemcell
5
- describe OperatingSystem do
6
- describe '.for' do
7
- it 'returns the correct infrastrcture' do
8
- expect(OperatingSystem.for('centos')).to be_a(OperatingSystem::Centos)
9
- expect(OperatingSystem.for('ubuntu')).to be_a(OperatingSystem::Ubuntu)
10
- end
11
-
12
- it 'raises for unknown operating system' do
13
- expect {
14
- OperatingSystem.for('BAD_OPERATING_SYSTEM')
15
- }.to raise_error(ArgumentError, /invalid operating system: BAD_OPERATING_SYSTEM/)
16
- end
17
- end
18
- end
19
-
20
- describe OperatingSystem::Base do
21
- describe '#initialize' do
22
- it 'requires :name to be specified' do
23
- expect {
24
- OperatingSystem::Base.new
25
- }.to raise_error /key not found: :name/
26
- end
27
- end
28
-
29
- describe '#name' do
30
- subject { OperatingSystem::Base.new(name: 'CLOUDY_PONY_OS') }
31
-
32
- its(:name) { should eq('CLOUDY_PONY_OS') }
33
- end
34
- end
35
-
36
- describe OperatingSystem::Centos do
37
- subject { OperatingSystem::Centos.new }
38
-
39
- its(:name) { should eq('centos') }
40
- end
41
-
42
- describe OperatingSystem::Ubuntu do
43
- subject { OperatingSystem::Ubuntu.new }
44
-
45
- its(:name) { should eq('ubuntu') }
46
- end
47
- end
@@ -1,279 +0,0 @@
1
- require 'spec_helper'
2
- require 'bosh/stemcell/stage_collection'
3
-
4
- module Bosh::Stemcell
5
- describe StageCollection do
6
- subject(:stage_collection) do
7
- StageCollection.new(
8
- infrastructure: infrastructure,
9
- operating_system: operating_system,
10
- agent_name: agent_name,
11
- )
12
- end
13
-
14
- let(:ubuntu_stages) {
15
- [
16
- :base_debootstrap,
17
- :base_apt,
18
- :bosh_users,
19
- :bosh_monit,
20
- :bosh_sysstat,
21
- :bosh_sysctl,
22
- :bosh_ntpdate,
23
- :bosh_sudoers,
24
- :system_grub,
25
- :system_kernel,
26
- ]
27
- }
28
-
29
- let(:centos_stages) {
30
- [
31
- :base_centos,
32
- :base_yum,
33
- :bosh_users,
34
- :bosh_monit,
35
- #:bosh_sysstat,
36
- #:bosh_sysctl,
37
- :bosh_ntpdate,
38
- :bosh_sudoers,
39
- :system_grub,
40
- #:system_kernel,
41
- ]
42
- }
43
-
44
- let(:aws_infrastructure_stages) {
45
- [
46
- :system_aws_network,
47
- :system_aws_clock,
48
- :system_aws_modules,
49
- :system_parameters,
50
- :bosh_clean,
51
- :bosh_harden,
52
- :bosh_harden_ssh,
53
- :bosh_dpkg_list,
54
- :image_create,
55
- :image_install_grub,
56
- :image_aws_update_grub,
57
- :image_aws_prepare_stemcell,
58
- :stemcell
59
- ]
60
- }
61
-
62
- let(:openstack_infrastructure_stages) {
63
- [
64
- :system_openstack_network,
65
- :system_openstack_clock,
66
- :system_openstack_modules,
67
- :system_parameters,
68
- :bosh_clean,
69
- :bosh_harden,
70
- :bosh_harden_ssh,
71
- :bosh_dpkg_list,
72
- :image_create,
73
- :image_install_grub,
74
- :image_openstack_qcow2,
75
- :image_openstack_prepare_stemcell,
76
- :stemcell_openstack
77
- ]
78
- }
79
-
80
- let(:vsphere_infrastructure_stages) {
81
- [
82
- :system_open_vm_tools,
83
- :system_parameters,
84
- :bosh_clean,
85
- :bosh_harden,
86
- :bosh_dpkg_list,
87
- :image_create,
88
- :image_install_grub,
89
- :image_vsphere_vmx,
90
- :image_vsphere_ovf,
91
- :image_vsphere_prepare_stemcell,
92
- :stemcell
93
- ]
94
- }
95
-
96
- let(:vsphere_centos_infrastructure_stages) {
97
- [
98
- #:system_open_vm_tools,
99
- :system_parameters,
100
- :bosh_clean,
101
- :bosh_harden,
102
- #:bosh_dpkg_list,
103
- :image_create,
104
- :image_install_grub,
105
- :image_vsphere_vmx,
106
- :image_vsphere_ovf,
107
- :image_vsphere_prepare_stemcell,
108
- :stemcell
109
- ]
110
- }
111
-
112
- describe '#all_stages' do
113
- context 'when using the ruby agent' do
114
- let(:agent_name) { 'ruby' }
115
- let(:agent_stages) {
116
- [
117
- :bosh_ruby,
118
- :bosh_agent,
119
- :bosh_micro,
120
- ]
121
- }
122
-
123
- context 'when infrastructure is AWS' do
124
- let(:infrastructure) { Infrastructure.for('aws') }
125
-
126
- context 'when operating system is Ubuntu' do
127
- let(:operating_system) { OperatingSystem.for('ubuntu') }
128
-
129
- it 'has the correct stages' do
130
- expect(stage_collection.all_stages).to eq(ubuntu_stages +
131
- agent_stages +
132
- aws_infrastructure_stages)
133
- end
134
- end
135
-
136
- context 'when operating system is Centos' do
137
- let(:operating_system) { OperatingSystem.for('centos') }
138
-
139
- it 'has the correct stages' do
140
- expect(stage_collection.all_stages).to eq(centos_stages +
141
- agent_stages +
142
- aws_infrastructure_stages)
143
- end
144
- end
145
- end
146
-
147
- context 'when infrastructure is OpenStack' do
148
- let(:infrastructure) { Infrastructure.for('openstack') }
149
-
150
- context 'when operating system is Ubuntu' do
151
- let(:operating_system) { OperatingSystem.for('ubuntu') }
152
-
153
- it 'has the correct stages' do
154
- expect(stage_collection.all_stages).to eq(ubuntu_stages +
155
- agent_stages +
156
- openstack_infrastructure_stages)
157
- end
158
- end
159
-
160
- context 'when operating system is CentOS' do
161
- let(:operating_system) { OperatingSystem.for('centos') }
162
-
163
- it 'has the correct stages' do
164
- expect(stage_collection.all_stages).to eq(centos_stages +
165
- agent_stages +
166
- openstack_infrastructure_stages)
167
- end
168
- end
169
- end
170
-
171
- context 'when infrastructure is vSphere' do
172
- let(:infrastructure) { Infrastructure.for('vsphere') }
173
-
174
- context 'when operating system is Ubuntu' do
175
- let(:operating_system) { OperatingSystem.for('ubuntu') }
176
-
177
- it 'has the correct stages' do
178
- expect(stage_collection.all_stages).to eq(ubuntu_stages +
179
- agent_stages +
180
- vsphere_infrastructure_stages)
181
- end
182
- end
183
-
184
- context 'when operating system is CentOS' do
185
- let(:operating_system) { OperatingSystem.for('centos') }
186
-
187
- it 'has the correct stages' do
188
- expect(stage_collection.all_stages).to eq(centos_stages +
189
- agent_stages +
190
- vsphere_centos_infrastructure_stages)
191
- end
192
- end
193
- end
194
- end
195
-
196
- context 'when using the go agent' do
197
- let(:agent_name) { 'go' }
198
- let(:agent_stages) {
199
- [
200
- :bosh_go_agent,
201
- #:bosh_micro,
202
- ]
203
- }
204
-
205
- context 'when infrastructure is AWS' do
206
- let(:infrastructure) { Infrastructure.for('aws') }
207
-
208
- context 'when operating system is Ubuntu' do
209
- let(:operating_system) { OperatingSystem.for('ubuntu') }
210
-
211
- it 'has the correct stages' do
212
- expect(stage_collection.all_stages).to eq(ubuntu_stages +
213
- agent_stages +
214
- aws_infrastructure_stages)
215
- end
216
- end
217
-
218
- context 'when operating system is Centos' do
219
- let(:operating_system) { OperatingSystem.for('centos') }
220
-
221
- it 'has the correct stages' do
222
- expect(stage_collection.all_stages).to eq(centos_stages +
223
- agent_stages +
224
- aws_infrastructure_stages)
225
- end
226
- end
227
- end
228
-
229
- context 'when infrastructure is OpenStack' do
230
- let(:infrastructure) { Infrastructure.for('openstack') }
231
-
232
- context 'when operating system is Ubuntu' do
233
- let(:operating_system) { OperatingSystem.for('ubuntu') }
234
-
235
- it 'has the correct stages' do
236
- expect(stage_collection.all_stages).to eq(ubuntu_stages +
237
- agent_stages +
238
- openstack_infrastructure_stages)
239
- end
240
- end
241
-
242
- context 'when operating system is CentOS' do
243
- let(:operating_system) { OperatingSystem.for('centos') }
244
-
245
- it 'has the correct stages' do
246
- expect(stage_collection.all_stages).to eq(centos_stages +
247
- agent_stages +
248
- openstack_infrastructure_stages)
249
- end
250
- end
251
- end
252
-
253
- context 'when infrastructure is vSphere' do
254
- let(:infrastructure) { Infrastructure.for('vsphere') }
255
-
256
- context 'when operating system is Ubuntu' do
257
- let(:operating_system) { OperatingSystem.for('ubuntu') }
258
-
259
- it 'has the correct stages' do
260
- expect(stage_collection.all_stages).to eq(ubuntu_stages +
261
- agent_stages +
262
- vsphere_infrastructure_stages)
263
- end
264
- end
265
-
266
- context 'when operating system is CentOS' do
267
- let(:operating_system) { OperatingSystem.for('centos') }
268
-
269
- it 'has the correct stages' do
270
- expect(stage_collection.all_stages).to eq(centos_stages +
271
- agent_stages +
272
- vsphere_centos_infrastructure_stages)
273
- end
274
- end
275
- end
276
- end
277
- end
278
- end
279
- end