|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require_relative '../spec_helper' |
| 4 | + |
| 5 | +describe 'package domain', acceptance: true do |
| 6 | + include_context 'libvirt_acceptance' |
| 7 | + |
| 8 | + before(:all) do |
| 9 | + expect(Vagrant::Util::Which.which('virt-sysprep')).to be_truthy, |
| 10 | + 'packaging tests require virt-sysprep, please install' |
| 11 | + expect(Vagrant::Util::Which.which('virt-sparsify')).to be_truthy, |
| 12 | + 'packaging tests require virt-sparsify, please install' |
| 13 | + |
| 14 | + result = (File.exist?('C:\\') ? `dir /-C #{Dir.tmpdir}` : `df #{Dir.tmpdir}`).split("\n").last |
| 15 | + expect(result.split[3].to_i).to be > 6 * 1024 * 1024, |
| 16 | + "packaging tests require more than 6GiB of space under #{Dir.tmpdir}" |
| 17 | + end |
| 18 | + |
| 19 | + after(:each) do |
| 20 | + assert_execute('vagrant', 'destroy', '--force') |
| 21 | + end |
| 22 | + |
| 23 | + let(:testbox_envvars) { { VAGRANT_VAGRANTFILE: 'Vagrantfile.testbox' } } |
| 24 | + |
| 25 | + context 'simple' do |
| 26 | + before do |
| 27 | + environment.skeleton('package_simple') |
| 28 | + end |
| 29 | + |
| 30 | + after do |
| 31 | + result = environment.execute('vagrant', 'destroy', '--force', extra_env: testbox_envvars) |
| 32 | + expect(result).to exit_with(0) |
| 33 | + |
| 34 | + assert_execute('vagrant', 'box', 'remove', '--force', 'test-package-simple-domain') |
| 35 | + end |
| 36 | + |
| 37 | + it 'should succeed' do |
| 38 | + status('Test: machine is created successfully') |
| 39 | + expect(environment.execute('vagrant', 'up')).to exit_with(0) |
| 40 | + |
| 41 | + status('Test: package machine successfully') |
| 42 | + expect(environment.execute('vagrant', 'package')).to exit_with(0) |
| 43 | + |
| 44 | + status('Test: add packaged box') |
| 45 | + expect(environment.execute( |
| 46 | + 'vagrant', 'box', 'add', '--force', '--name', 'test-package-simple-domain', 'package.box' |
| 47 | + )).to exit_with(0) |
| 48 | + |
| 49 | + status('Test: machine from packaged box is created successfully') |
| 50 | + result = environment.execute('vagrant', 'up', extra_env: testbox_envvars) |
| 51 | + expect(result).to exit_with(0) |
| 52 | + expect(result.stdout).to match(/test-package-simple-domain/) |
| 53 | + end |
| 54 | + end |
| 55 | + |
| 56 | + context 'complex' do |
| 57 | + before do |
| 58 | + environment.skeleton('package_complex') |
| 59 | + extra_env.merge!( |
| 60 | + { |
| 61 | + VAGRANT_LIBVIRT_VIRT_SYSPREP_OPERATIONS: 'defaults,-ssh-userdir,customize', |
| 62 | + VAGRANT_LIBVIRT_VIRT_SYSPREP_OPTIONS: '--run $(pwd)/scripts/sysprep.sh', |
| 63 | + } |
| 64 | + ) |
| 65 | + end |
| 66 | + |
| 67 | + after do |
| 68 | + expect(environment.execute('vagrant', 'destroy', '--force', extra_env: testbox_envvars)).to exit_with(0) |
| 69 | + assert_execute('vagrant', 'box', 'remove', '--force', 'test-package-complex-domain') |
| 70 | + end |
| 71 | + |
| 72 | + it 'should succeed' do |
| 73 | + status('Test: machine is created successfully') |
| 74 | + expect(environment.execute('vagrant', 'up')).to exit_with(0) |
| 75 | + |
| 76 | + status('Test: package machine successfully') |
| 77 | + expect(environment.execute('vagrant', 'package')).to exit_with(0) |
| 78 | + |
| 79 | + status('Test: add packaged box') |
| 80 | + expect(environment.execute( |
| 81 | + 'vagrant', 'box', 'add', '--force', '--name', 'test-package-complex-domain', 'package.box' |
| 82 | + )).to exit_with(0) |
| 83 | + |
| 84 | + status('Test: machine from packaged box is created successfully') |
| 85 | + result = environment.execute('vagrant', 'up', extra_env: testbox_envvars) |
| 86 | + expect(result).to exit_with(0) |
| 87 | + expect(result.stdout).to match(/test-package-complex-domain/) |
| 88 | + end |
| 89 | + end |
| 90 | +end |
0 commit comments