add integration tests for mountpoints

This commit is contained in:
Christoph Hartmann 2015-12-31 01:10:39 +01:00
parent a5acb03e49
commit 50d2ef4db5
3 changed files with 66 additions and 0 deletions

View file

@ -6,6 +6,7 @@
include_recipe('os_prepare::apt')
include_recipe('os_prepare::file')
include_recipe('os_prepare::mount')
include_recipe('os_prepare::json_yaml_csv_ini')
include_recipe('os_prepare::package')
include_recipe('os_prepare::registry_key')

View file

@ -0,0 +1,29 @@
# encoding: utf-8
# author: Christoph Hartmann
# author: Dominik Richter
#
# file mount tests
# download alpine linux for file mount tests
remote_file '/root/alpine-3.3.0-x86_64.iso' do
source 'http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.3/releases/x86_64/alpine-3.3.0-x86_64.iso'
owner 'root'
group 'root'
mode '0755'
action :create
end
# create mount directory
directory '/mnt/iso-disk' do
owner 'root'
group 'root'
mode '0755'
action :create
end
# mount -o loop /root/alpine-3.3.0-x86_64.iso /mnt/iso-disk
mount '/mnt/iso-disk' do
device '/root/alpine-3.3.0-x86_64.iso'
options 'loop'
action [:mount, :enable]
end

View file

@ -108,4 +108,40 @@ if os.unix?
its('type') { should eq :directory }
end
# for server spec compatibility
# Do not use `.with` or `.only_with`, this syntax is deprecated and will be removed
# in InSpec version 1
describe file('/mnt/iso-disk') do
it { should be_mounted }
it { should be_mounted.with( :type => 'iso9660' ) }
it { should be_mounted.with( :type => 'iso9660', :options => { :ro => true } ) }
it { should be_mounted.with( :type => 'iso9660', :device => '/root/alpine-3.3.0-x86_64.iso' ) }
it { should_not be_mounted.with( :type => 'ext4' ) }
it { should_not be_mounted.with( :type => 'xfs' ) }
end
# compare with exact match
describe file('/mnt/iso-disk') do
it { should be_mounted.only_with( {
:device=>"/root/alpine-3.3.0-x86_64.iso",
:type=>"iso9660",
:options=>{
:ro=>true}
})
}
end
# instead of `.with` or `.only_with` we recommend to use the `mount` resource
describe mount '/mnt/iso-disk' do
it { should be_mounted }
its('device') { should eq '/root/alpine-3.3.0-x86_64.iso' }
its('type') { should eq 'iso9660' }
its('options') { should eq ['ro'] }
end
elsif os.windows?
describe file('C:\\Windows') do
it { should exist }
it { should be_directory }
end
end