vagrant-lxc-ng/spec/acceptance/sanity_check_spec.rb

89 lines
2.5 KiB
Ruby
Raw Normal View History

2013-04-20 20:02:25 +00:00
require 'acceptance_helper'
describe 'Sanity check' do
2013-04-20 22:24:24 +00:00
after(:all) { destroy_container }
context 'running `vagrant up` from scratch' do
2013-04-20 20:02:25 +00:00
before(:all) do
destroy_container
vagrant_up
end
2013-04-20 22:24:24 +00:00
it 'creates a container' do
containers = `sudo lxc-ls`.chomp.split(/\s+/).uniq
2013-04-21 21:49:26 +00:00
expect(containers).to include vagrant_container_name
2013-04-20 22:24:24 +00:00
end
2013-04-20 20:02:25 +00:00
2013-04-20 22:24:24 +00:00
it 'starts the newly created container' do
2013-04-21 21:49:26 +00:00
status = `sudo lxc-info -n #{vagrant_container_name}`
2013-04-20 22:24:24 +00:00
expect(status).to include 'RUNNING'
end
2013-04-20 20:02:25 +00:00
2013-04-20 22:24:24 +00:00
it "is able to be SSH'ed" do
expected = 'lxc-test-box'
# HACK:
expected = ENV['BOX_NAME'].gsub(/64$/, '') if %w( squeeze64 wheezy64 sid64 ).include? ENV['BOX_NAME']
expect(vagrant_ssh('hostname')).to eq expected
2013-04-20 22:24:24 +00:00
end
it 'mounts shared folders with the right permissions' do
vagrant_ssh 'mkdir -p /vagrant/tmp && echo -n "Shared" > /vagrant/tmp/shared'
shared_file_contents = File.read('/vagrant/spec/tmp/shared')
2013-04-20 22:24:24 +00:00
expect(shared_file_contents).to eq 'Shared'
end
2013-04-20 20:02:25 +00:00
it 'provisions the container based on Vagrantfile configs' do
provisioned_file_contents = File.read('/vagrant/spec/tmp/provisioning')
expect(provisioned_file_contents).to eq 'Provisioned'
end
2013-04-20 20:02:25 +00:00
it 'forwards configured ports' do
output = `curl -s localhost:8080`.strip.chomp
expect(output).to include 'It works!'
end
2013-04-20 20:02:25 +00:00
end
context '`vagrant halt` on a running container' do
2013-04-20 20:02:25 +00:00
before(:all) do
destroy_container
vagrant_up
vagrant_ssh 'touch /tmp/{some,files}'
2013-04-20 20:02:25 +00:00
vagrant_halt
end
it 'shuts down container' do
2013-04-21 21:49:26 +00:00
status = `sudo lxc-info -n #{vagrant_container_name}`
expect(status).to include 'STOPPED'
end
2013-04-20 20:02:25 +00:00
it 'clears forwarded ports' do
`curl -s localhost:8080 --connect-timeout 2`
expect($?.exitstatus).to_not eq 0
end
2013-04-23 10:54:55 +00:00
it 'kills redir processes' do
processes = `pgrep redir`
expect($?.exitstatus).to_not eq 0
end
it 'removes files under `/tmp`' do
container_tmp = Pathname("/var/lib/lxc/#{vagrant_container_name}/rootfs/tmp")
expect(container_tmp.entries).to have(2).items # basically '.' and '..'
end
2013-04-20 20:02:25 +00:00
end
context '`vagrant destroy`' do
2013-04-20 20:02:25 +00:00
before(:all) do
destroy_container
vagrant_up
2013-04-21 21:49:26 +00:00
@container_name = vagrant_container_name
2013-04-20 20:02:25 +00:00
vagrant_destroy
end
it 'destroys the underlying container' do
containers = `sudo lxc-ls`.chomp.split(/\s+/).uniq
expect(containers).to_not include @container_name
end
2013-04-20 20:02:25 +00:00
end
end