Sanity check for vagrant halt and destroy
This commit is contained in:
parent
c1d841271b
commit
ae46fff7c0
1 changed files with 18 additions and 8 deletions
|
@ -77,32 +77,42 @@ describe 'Sanity check' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
pending '`vagrant halt` on a running container' do
|
context '`vagrant halt` on a running container' do
|
||||||
before(:all) do
|
before(:all) do
|
||||||
destroy_container
|
destroy_container
|
||||||
vagrant_up
|
vagrant_up
|
||||||
vagrant_halt
|
vagrant_halt
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shuts down container'
|
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
|
||||||
|
|
||||||
it 'clears forwarded ports'
|
it 'clears forwarded ports' do
|
||||||
|
`curl -s localhost:8080 --connect-timeout 2`
|
||||||
|
expect($?.exitstatus).to_not eq 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
pending '`vagrant destroy`' do
|
context '`vagrant destroy`' do
|
||||||
before(:all) do
|
before(:all) do
|
||||||
destroy_container
|
destroy_container
|
||||||
vagrant_up
|
vagrant_up
|
||||||
|
@container_name = File.read('/vagrant/spec/.vagrant/machines/default/lxc/id').strip.chomp
|
||||||
vagrant_destroy
|
vagrant_destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'destroys the underlying container'
|
it 'destroys the underlying container' do
|
||||||
|
containers = `sudo lxc-ls`.chomp.split(/\s+/).uniq
|
||||||
|
expect(containers).to_not include @container_name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_container
|
def destroy_container
|
||||||
`sudo lxc-shutdown -n \`cat /vagrant/spec/.vagrant/machines/default/lxc/id\``
|
`sudo lxc-shutdown -n \`cat /vagrant/spec/.vagrant/machines/default/lxc/id\` 2>/dev/null`
|
||||||
`sudo lxc-wait -n \`cat /vagrant/spec/.vagrant/machines/default/lxc/id\` --state STOPPED`
|
`sudo lxc-wait -n \`cat /vagrant/spec/.vagrant/machines/default/lxc/id\` --state STOPPED 2>/dev/null`
|
||||||
`sudo lxc-destroy -n \`cat /vagrant/spec/.vagrant/machines/default/lxc/id\``
|
`sudo lxc-destroy -n \`cat /vagrant/spec/.vagrant/machines/default/lxc/id\` 2>/dev/null`
|
||||||
`sudo killall -9 redir 2>/dev/null`
|
`sudo killall -9 redir 2>/dev/null`
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue