Skip to content

Commit

Permalink
removed unnecessary tests, fixed windows version in tests and fixture
Browse files Browse the repository at this point in the history
[#172135935](https://www.pivotaltracker.com/story/show/172135935)
 As a member of the pcf-eagle team I can create my own AWS stemcells using a functional AWS pipeline

Co-authored-by: Flora Gallina-Jones <fgallinajones@pivotal.io>
  • Loading branch information
XenoPhex and fg-j committed May 4, 2020
1 parent 626262f commit d89e5e2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 85 deletions.
Binary file not shown.
81 changes: 0 additions & 81 deletions spec/packer/config/vsphere_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,87 +10,6 @@
Timecop.return
end

describe 'VSphereAddUpdates' do
describe 'builders' do
it 'returns the expected builders' do
builders = Packer::Config::VSphereAddUpdates.new(
output_directory: 'output_directory',
num_vcpus: 1,
mem_size: 1000,
administrator_password: 'password',
source_path: 'source_path',
os: 'windows2019',
http_proxy: '',
https_proxy: '',
bypass_list: ''
).builders
expect(builders[0]).to eq(
'type' => 'vmware-vmx',
'source_path' => 'source_path',
'headless' => false,
'boot_wait' => '2m',
'communicator' => 'winrm',
'winrm_username' => 'Administrator',
'winrm_password' => 'password',
'winrm_timeout' => '6h',
'winrm_insecure' => true,
'vm_name' => 'packer-vmx',
'shutdown_command' => "C:\\Windows\\System32\\shutdown.exe /s",
'shutdown_timeout' => '1h',
'vmx_data' => {
'memsize' => '1000',
'numvcpus' => '1',
'displayname' => "packer-vmx-#{Time.now.getutc.to_i}"
},
'output_directory' => 'output_directory'
)
end
end

describe 'provisioners' do
it 'returns the expected provisioners' do
allow(SecureRandom).to receive(:hex).and_return("some-password")

provisioners = Packer::Config::VSphereAddUpdates.new(
output_directory: 'output_directory',
num_vcpus: 1,
mem_size: 1000,
administrator_password: 'password',
source_path: 'source_path',
os: 'windows2019',
http_proxy: 'foo',
https_proxy: 'bar',
bypass_list: 'bee'
).provisioners
expect(provisioners).to eq(
[
{"type" => "file", "source" => "build/bosh-psmodules.zip", "destination" => "C:\\provision\\bosh-psmodules.zip"},
{"type"=>"file", "source"=>"scripts/install-bosh-psmodules.ps1", "destination"=>"C:\\provision\\install-bosh-psmodules.ps1"},
{"type"=>"powershell", "inline"=>['$ErrorActionPreference = "Stop";', 'C:\\provision\\install-bosh-psmodules.ps1']},
{'type' => 'powershell', 'inline' => ['$ErrorActionPreference = "Stop";',
'trap { $host.SetShouldExit(1) }',
'Set-ProxySettings "foo" "bar" "bee"']},
{"type" => "powershell", "inline" => ["$ErrorActionPreference = \"Stop\";", "trap { $host.SetShouldExit(1) }", "New-Provisioner"]},
{"type" => "powershell", "inline" => ["$ErrorActionPreference = \"Stop\";", "trap { $host.SetShouldExit(1) }", "Add-Account -User Provisioner -Password some-password!"]},
{"type" => "powershell", "inline" => ["$ErrorActionPreference = \"Stop\";", "trap { $host.SetShouldExit(1) }", "Register-WindowsUpdatesTask"]},
{"type" => "powershell", "inline" => ["$ErrorActionPreference = \"Stop\";", "trap { $host.SetShouldExit(1) }", "Wait-WindowsUpdates -Password some-password! -User Provisioner"]},
{"type"=>"windows-restart", "restart_timeout"=>"12h", "check_registry" => true},
{"type" => "powershell", "inline" => ["$ErrorActionPreference = \"Stop\";", "trap { $host.SetShouldExit(1) }", "Unregister-WindowsUpdatesTask"]},
{"type" => "powershell", "inline" => ["$ErrorActionPreference = \"Stop\";", "trap { $host.SetShouldExit(1) }", "Get-HotFix > hotfixes.log"]},
{"type" => "file", "source" => "hotfixes.log", "destination" => "hotfixes.log", "direction" => "download"},
{"type" => "powershell", "inline" => ["$ErrorActionPreference = \"Stop\";", "trap { $host.SetShouldExit(1) }", "Remove-Account -User Provisioner"]},
{"type" => "powershell", "inline" => ["$ErrorActionPreference = \"Stop\";", "trap { $host.SetShouldExit(1) }", "Test-InstalledUpdates"]},
{'type' => 'powershell', 'inline' => ['$ErrorActionPreference = "Stop";',
'trap { $host.SetShouldExit(1) }',
'Clear-ProxySettings']},
{"type" => "powershell", "inline" => ["$ErrorActionPreference = \"Stop\";", "trap { $host.SetShouldExit(1) }", "Clear-Provisioner"]},
{"type" => "windows-restart", "restart_command" => "powershell.exe -Command Start-Sleep -Seconds 900; Restart-Computer -Force", "restart_timeout" => "1h", "restart_check_command" => "powershell -command \"& {Write-Output 'restarted.'}\"", "check_registry" => true}
].flatten
)
end
end
end

describe 'VSphere' do
describe 'builders' do
it 'returns the expected builders' do
Expand Down
8 changes: 4 additions & 4 deletions spec/stemcell/packager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@
before(:each) do
fixtures = File.join('spec', 'fixtures', 'aws', 'amis')
@amis_path = Dir.mktmpdir
FileUtils.cp(File.join(fixtures, "light-bosh-stemcell-1089.0-aws-xen-hvm-windows2012R2-go_agent-some-region-1.tgz"), @amis_path)
FileUtils.cp(File.join(fixtures, "light-bosh-stemcell-1089.0-aws-xen-hvm-windows2012R2-go_agent-some-region-2.tgz"), @amis_path)
FileUtils.cp(File.join(fixtures, "light-bosh-stemcell-1089.0-aws-xen-hvm-windows2019-go_agent-some-region-1.tgz"), @amis_path)
FileUtils.cp(File.join(fixtures, "light-bosh-stemcell-1089.0-aws-xen-hvm-windows2019-go_agent-some-region-2.tgz"), @amis_path)
end
it 'creates a single tar file' do
output_dir = Dir.mktmpdir
Stemcell::Packager.aggregate_the_amis(@amis_path, output_dir, 'some-region-1')

stemcell_path = File.join(output_dir, 'light-bosh-stemcell-1089.0-aws-xen-hvm-windows2012R2-go_agent.tgz')
stemcell_path = File.join(output_dir, 'light-bosh-stemcell-1089.0-aws-xen-hvm-windows2019-go_agent.tgz')
expect(File.exist?(stemcell_path)).to eq(true)
end

Expand All @@ -97,7 +97,7 @@

Stemcell::Packager.aggregate_the_amis(@amis_path, output_dir, 'some-region-1')

stemcell_path = File.join(output_dir, 'light-bosh-stemcell-1089.0-aws-xen-hvm-windows2012R2-go_agent.tgz')
stemcell_path = File.join(output_dir, 'light-bosh-stemcell-1089.0-aws-xen-hvm-windows2019-go_agent.tgz')

stemcell_manifest_contents = read_from_tgz(stemcell_path, "stemcell.MF")
manifest = YAML.load(stemcell_manifest_contents)
Expand Down

0 comments on commit d89e5e2

Please sign in to comment.