|
25 | 25 | vm_size: 'some-vm-size', |
26 | 26 | output_directory: '', |
27 | 27 | os: '', |
28 | | - vm_prefix: 'some-vm-prefix' |
| 28 | + vm_prefix: 'some-vm-prefix', |
| 29 | + mount_ephemeral_disk: false, |
29 | 30 | ).builders |
30 | 31 | expect(builders[0]).to eq( |
31 | 32 | 'type' => 'azure-arm', |
|
79 | 80 | end |
80 | 81 |
|
81 | 82 | describe 'provisioners' do |
| 83 | + before(:each) do |
| 84 | + @stemcell_deps_dir = Dir.mktmpdir('gcp') |
| 85 | + ENV['STEMCELL_DEPS_DIR'] = @stemcell_deps_dir |
| 86 | + end |
| 87 | + |
| 88 | + after(:each) do |
| 89 | + FileUtils.rm_rf(@stemcell_deps_dir) |
| 90 | + ENV.delete('STEMCELL_DEPS_DIR') |
| 91 | + end |
| 92 | + |
82 | 93 | context 'windows 2012' do |
83 | 94 | it 'returns the expected provisioners' do |
84 | | - stemcell_deps_dir = Dir.mktmpdir('azure') |
85 | | - ENV['STEMCELL_DEPS_DIR'] = stemcell_deps_dir |
86 | | - |
87 | 95 | allow(SecureRandom).to receive(:hex).and_return("some-password") |
88 | 96 | provisioners = Packer::Config::Azure.new( |
89 | 97 | client_id: '', |
|
97 | 105 | vm_size: '', |
98 | 106 | output_directory: 'some-output-directory', |
99 | 107 | os: 'windows2012R2', |
100 | | - vm_prefix: '' |
| 108 | + vm_prefix: '', |
| 109 | + mount_ephemeral_disk: false, |
101 | 110 | ).provisioners |
102 | 111 | expected_provisioners_except_lgpo = [ |
103 | 112 | {"type"=>"file", "source"=>"build/bosh-psmodules.zip", "destination"=>"C:\\provision\\bosh-psmodules.zip"}, |
|
130 | 139 | expect(provisioners.detect {|x| x['destination'] == "C:\\windows\\LGPO.exe"}).not_to be_nil |
131 | 140 | provisioners_no_lgpo = provisioners.delete_if {|x| x['destination'] == "C:\\windows\\LGPO.exe"} |
132 | 141 | expect(provisioners_no_lgpo).to eq (expected_provisioners_except_lgpo) |
133 | | - |
134 | | - FileUtils.rm_rf(stemcell_deps_dir) |
135 | | - ENV.delete('STEMCELL_DEPS_DIR') |
136 | 142 | end |
137 | 143 | end |
138 | 144 | context 'windows 2016' do |
139 | 145 | it 'returns the expected provisioners' do |
140 | | - stemcell_deps_dir = Dir.mktmpdir('azure') |
141 | | - ENV['STEMCELL_DEPS_DIR'] = stemcell_deps_dir |
142 | | - |
143 | 146 | allow(SecureRandom).to receive(:hex).and_return("some-password") |
144 | 147 | provisioners = Packer::Config::Azure.new( |
145 | 148 | client_id: '', |
|
153 | 156 | vm_size: '', |
154 | 157 | output_directory: 'some-output-directory', |
155 | 158 | os: 'windows2016', |
156 | | - vm_prefix: '' |
| 159 | + vm_prefix: '', |
| 160 | + mount_ephemeral_disk: false, |
157 | 161 | ).provisioners |
158 | 162 | expected_provisioners_except_lgpo = [ |
159 | 163 | {"type"=>"file", "source"=>"build/bosh-psmodules.zip", "destination"=>"C:\\provision\\bosh-psmodules.zip"}, |
|
183 | 187 | expect(provisioners.detect {|x| x['destination'] == "C:\\windows\\LGPO.exe"}).not_to be_nil |
184 | 188 | provisioners_no_lgpo = provisioners.delete_if {|x| x['destination'] == "C:\\windows\\LGPO.exe"} |
185 | 189 | expect(provisioners_no_lgpo).to eq (expected_provisioners_except_lgpo) |
| 190 | + end |
| 191 | + |
| 192 | + context 'when provisioning with emphemeral disk mounting enabled' do |
| 193 | + it 'calls Install-Agent with -EnableEphemeralDiskMounting' do |
| 194 | + allow(SecureRandom).to receive(:hex).and_return("some-password") |
| 195 | + provisioners = Packer::Config::Azure.new( |
| 196 | + client_id: '', |
| 197 | + client_secret: '', |
| 198 | + tenant_id: '', |
| 199 | + subscription_id: '', |
| 200 | + object_id: '', |
| 201 | + resource_group_name: '', |
| 202 | + storage_account: '', |
| 203 | + location: '', |
| 204 | + vm_size: '', |
| 205 | + output_directory: 'some-output-directory', |
| 206 | + os: 'windows2016', |
| 207 | + vm_prefix: '', |
| 208 | + mount_ephemeral_disk: true, |
| 209 | + ).provisioners |
186 | 210 |
|
187 | | - FileUtils.rm_rf(stemcell_deps_dir) |
188 | | - ENV.delete('STEMCELL_DEPS_DIR') |
| 211 | + expect(provisioners).to include( |
| 212 | + { |
| 213 | + "type"=>"powershell", |
| 214 | + "inline"=>[ |
| 215 | + "$ErrorActionPreference = \"Stop\";", |
| 216 | + "trap { $host.SetShouldExit(1) }", |
| 217 | + "Install-Agent -IaaS azure -agentZipPath 'C:\\provision\\agent.zip' -EnableEphemeralDiskMounting" |
| 218 | + ] |
| 219 | + } |
| 220 | + ) |
| 221 | + end |
189 | 222 | end |
190 | 223 | end |
191 | 224 | end |
|
0 commit comments