if fact('os.family') == 'Debian' && fact('os.release.major') =~ (/14.04|^8$/)
storage_driver = "aufs"
elsif fact('os.family') == 'RedHat'
storage_driver = "devicemapper"
else
storage_driver = "overlay2"
end
end
describe 'the Puppet Docker module' do
context 'clean up before each test' do
before(:each) do
retry_on_error_matching(60, 5, /connection failure running/) do
# Stop all container using systemd
shell('ls -D -1 /etc/systemd/system/docker-container* | sed \'s/\/etc\/systemd\/system\///g\' | sed \'s/\.service//g\' | while read container; do service $container stop; done')
# Delete all running containers
shell("#{docker_command} rm -f $(#{docker_command} ps -a -q) || true")
shell('ls -D -1 /etc/systemd/system/docker-container* | sed \'s/\/etc\/systemd\/system\///g\' | sed \'s/\.service//g\' | while read container; do service $container stop; done')
# Stop all running containers
shell("#{docker_command} rm -f $(docker ps -a -q) || true")
# Make sure no other containers are running
shell("#{docker_command} ps | wc -l") do |r|
expect(r.stdout).to match(/^1$/)
end
# Export new to a tar file
shell("#{docker_command} save alpine_from_commit > /root/rootfs.tar")