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
|
|
|
|
expect(containers).to include File.read('/vagrant/spec/.vagrant/machines/default/lxc/id').strip.chomp
|
|
|
|
end
|
2013-04-20 20:02:25 +00:00
|
|
|
|
2013-04-20 22:24:24 +00:00
|
|
|
it 'starts the newly created container' do
|
|
|
|
status = `sudo lxc-info -n #{File.read('/vagrant/spec/.vagrant/machines/default/lxc/id').strip.chomp}`
|
|
|
|
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
|
|
|
|
expect(vagrant_ssh('hostname')).to eq 'lxc-test-box'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'mounts shared folders with the right permissions' do
|
2013-04-20 23:02:56 +00:00
|
|
|
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
|
|
|
|
2013-04-20 23:02:56 +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
|
|
|
|
2013-04-20 23:02:56 +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
|
|
|
|
|
2013-04-21 20:56:37 +00:00
|
|
|
context '`vagrant halt` on a running container' do
|
2013-04-20 20:02:25 +00:00
|
|
|
before(:all) do
|
|
|
|
destroy_container
|
|
|
|
vagrant_up
|
|
|
|
vagrant_halt
|
|
|
|
end
|
|
|
|
|
2013-04-21 20:56:37 +00:00
|
|
|
it 'shuts down container' do
|
|
|
|
status = `sudo lxc-info -n #{File.read('/vagrant/spec/.vagrant/machines/default/lxc/id').strip.chomp}`
|
|
|
|
expect(status).to include 'STOPPED'
|
|
|
|
end
|
2013-04-20 20:02:25 +00:00
|
|
|
|
2013-04-21 20:56:37 +00:00
|
|
|
it 'clears forwarded ports' do
|
|
|
|
`curl -s localhost:8080 --connect-timeout 2`
|
|
|
|
expect($?.exitstatus).to_not eq 0
|
|
|
|
end
|
2013-04-20 20:02:25 +00:00
|
|
|
end
|
|
|
|
|
2013-04-21 20:56:37 +00:00
|
|
|
context '`vagrant destroy`' do
|
2013-04-20 20:02:25 +00:00
|
|
|
before(:all) do
|
|
|
|
destroy_container
|
|
|
|
vagrant_up
|
2013-04-21 20:56:37 +00:00
|
|
|
@container_name = File.read('/vagrant/spec/.vagrant/machines/default/lxc/id').strip.chomp
|
2013-04-20 20:02:25 +00:00
|
|
|
vagrant_destroy
|
|
|
|
end
|
|
|
|
|
2013-04-21 20:56:37 +00:00
|
|
|
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
|