forked from puppetlabs/puppetlabs-apache
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker stack tests (puppetlabs#356)
- Loading branch information
1 parent
b53adc6
commit fdf2b78
Showing
5 changed files
with
206 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
if fact('osfamily') == 'windows' | ||
docker_args = 'docker_ee => true' | ||
tmp_path = 'C:/cygwin64/tmp' | ||
test_container = 'nanoserver-sac2016' | ||
wait_for_container_seconds = 120 | ||
else | ||
docker_args = '' | ||
tmp_path = '/tmp' | ||
test_container = 'debian' | ||
wait_for_container_seconds = 10 | ||
end | ||
|
||
describe 'docker stack' do | ||
before(:all) do | ||
retry_on_error_matching(60, 5, /connection failure running/) do | ||
@install_code = <<-code | ||
class { 'docker': #{docker_args} } | ||
docker::swarm {'cluster_manager': | ||
init => true, | ||
ensure => 'present', | ||
} | ||
code | ||
apply_manifest(@install_code, :catch_failures=>true) | ||
end | ||
end | ||
|
||
context 'Creating stack' do | ||
let(:install) {" | ||
docker::stack { 'web': | ||
stack_name => 'web', | ||
compose_files => ['#{tmp_path}/docker-stack.yml'], | ||
ensure => present, | ||
}" | ||
} | ||
|
||
it 'should deploy stack' do | ||
apply_manifest(install, :catch_failures=>true) | ||
sleep wait_for_container_seconds | ||
end | ||
|
||
it 'should be idempotent' do | ||
apply_manifest(install, :catch_changes=>true) | ||
end | ||
|
||
it 'should find a stack' do | ||
shell('docker stack ls') do |r| | ||
expect(r.stdout).to match(/web/) | ||
end | ||
end | ||
|
||
it 'should find a docker container' do | ||
shell("docker ps | grep web_compose_test", :acceptable_exit_codes => [0]) | ||
end | ||
end | ||
|
||
context 'Destroying stack' do | ||
let(:install) {" | ||
docker::stack { 'web': | ||
stack_name => 'web', | ||
compose_files => ['#{tmp_path}/docker-stack.yml'], | ||
ensure => present, | ||
}" | ||
} | ||
let(:destroy) {" | ||
docker::stack { 'web': | ||
stack_name => 'web', | ||
compose_files => ['#{tmp_path}/docker-stack.yml'], | ||
ensure => absent, | ||
}" | ||
} | ||
it 'should run successfully' do | ||
apply_manifest(destroy, :catch_failures=>true) | ||
end | ||
|
||
it 'should be idempotent' do | ||
apply_manifest(destroy, :catch_changes=>true) | ||
end | ||
|
||
it 'should not find a docker stack' do | ||
shell('docker stack ls') do |r| | ||
expect(r.stdout).to_not match(/web/) | ||
end | ||
end | ||
end | ||
|
||
context 'creating stack with multi compose files' do | ||
|
||
before(:all) do | ||
@install_code = <<-code | ||
docker::stack { 'web': | ||
stack_name => 'web', | ||
compose_files => ['#{tmp_path}/docker-stack.yml', '#{tmp_path}/docker-stack-override.yml'], | ||
ensure => present, | ||
} | ||
code | ||
|
||
apply_manifest(@install_code, :catch_failures=>true) | ||
end | ||
|
||
it "should find container with web_compose_test tag" do | ||
sleep wait_for_container_seconds | ||
shell("docker ps | grep web_compose_test", :acceptable_exit_codes => [0]) | ||
end | ||
end | ||
|
||
context 'Destroying project with multiple compose files' do | ||
before(:all) do | ||
@install_code = <<-code | ||
docker::stack { 'web': | ||
stack_name => 'web', | ||
compose_files => ['#{tmp_path}/docker-stack.yml', '#{tmp_path}/docker-stack-override.yml'], | ||
ensure => present, | ||
} | ||
code | ||
|
||
apply_manifest(@install_code, :catch_failures=>true) | ||
|
||
@destroy_code = <<-code | ||
docker::stack { 'web': | ||
stack_name => 'web', | ||
compose_files => ['#{tmp_path}/docker-stack.yml', '#{tmp_path}/docker-stack-override.yml'], | ||
ensure => absent, | ||
} | ||
code | ||
|
||
apply_manifest(@destroy_code, :catch_failures=>true) | ||
sleep 5 # wait for containers to stop | ||
end | ||
|
||
it 'should be idempotent' do | ||
apply_manifest(@destroy_code, :catch_changes=>true) | ||
end | ||
|
||
it 'should not find a docker stack' do | ||
shell('docker stack ls') do |r| | ||
expect(r.stdout).to_not match(/web/) | ||
end | ||
end | ||
|
||
it 'should not find a docker container' do | ||
shell("docker ps | grep #{test_container}", :acceptable_exit_codes => [1]) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters