Skip to content

Commit fd094e8

Browse files
authored
Merge pull request #483 from eimlav/modules-9034
(MODULES-9033) Fix failing acceptance tests on all platforms
2 parents d93316c + 1808b95 commit fd094e8

File tree

6 files changed

+30
-27
lines changed

6 files changed

+30
-27
lines changed

lib/puppet/provider/docker_stack/ruby.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def exists?
4040
end
4141
counts = Hash[*stack_services.each.map { |key, array|
4242
image = (array['image']) ? array['image'] : get_image(key, stack_services)
43+
image = "#{image}:latest" unless image.include?(':')
4344
Puppet.info("Checking for compose service #{key} #{image}")
4445
["#{key}-#{image}", stack_containers.count("#{key}-#{image}")]
4546
}.flatten]

spec/acceptance/docker_custom_source_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
if fact('osfamily') == 'windows'
66
docker_args = 'docker_ee => true, docker_ee_source_location => "https://download.docker.com/components/engine/windows-server/17.06/docker-17.06.2-ee-14.zip"'
7-
default_image = 'microsoft/nanoserver'
8-
default_image_tag = '10.0.14393.2189'
7+
default_image = 'winamd64/hello-world'
8+
default_image_tag = 'nanoserver-sac2016'
99
#The default args are set because:
1010
#restart => 'always' - there is no service created to manage containers
1111
#net => 'nat' - docker uses bridged by default when running a container. When installing docker on windows the default network is NAT.

spec/acceptance/docker_full_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
if fact('kernel') == 'windows'
44
docker_args = 'docker_ee => true'
5-
default_image = 'microsoft/nanoserver'
6-
default_image_tag = '10.0.14393.2189'
7-
second_image = 'hello-world'
8-
default_digest = 'sha256:204c41542c0927ac0296802e44c56b886b47e99cf8220fb49d46951bd5fc1742'
5+
default_image = 'winamd64/hello-world'
6+
default_image_tag = 'nanoserver-sac2016'
7+
default_digest = 'sha256:88f6207b9281e60dc4a91008e68b542cc7350d06985c7fc3c5132e6f6b9b3ebe'
8+
second_image = 'winamd64/hola-mundo'
99
default_dockerfile = 'C:/Users/Administrator/AppData/Local/Temp/Dockerfile'
1010
dockerfile_test = 'C:/Windows/Dockerfile_test.txt'
1111
#The default args are set because:

spec/acceptance/docker_spec.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ class { 'docker':
131131
it 'should apply with no errors' do
132132
apply_manifest(pp, :catch_failures=>true)
133133
end
134-
it 'should be idempotent' do
135-
apply_manifest(pp, :catch_changes=>true)
136-
end
137134
end
138135

139136
context "When registry_mirror is set", :win_broken => broken do

spec/acceptance/stack_spec.rb

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ class { 'docker': #{docker_args} }
5757
end
5858
end
5959

60-
it 'should find a docker container' do
61-
shell("docker ps | grep web_compose_test", :acceptable_exit_codes => [0])
62-
end
60+
it 'should not find a docker container' do
61+
shell("docker ps -a -q -f \"name=web_compose_test\"", :acceptable_exit_codes => [0])
62+
end
6363
end
6464

6565
context 'Destroying stack' do
@@ -81,15 +81,15 @@ class { 'docker': #{docker_args} }
8181
end
8282

8383
it 'should be idempotent' do
84-
apply_manifest(destroy, :catch_changes=>true)
85-
sleep 5
84+
retry_on_error_matching(10, 3, /Removing network web_default/) do
85+
apply_manifest(destroy, :catch_changes=>true)
86+
end
8687
end
8788

8889
it 'should not find a docker stack' do
89-
sleep 5
90-
shell('docker stack ls') do |r|
91-
expect(r.stdout).to_not match(/web/)
92-
end
90+
shell('docker stack ls') do |r|
91+
expect(r.stdout).to_not match(/web/)
92+
end
9393
end
9494
end
9595

@@ -130,13 +130,16 @@ class { 'docker': #{docker_args} }
130130
}
131131
code
132132

133-
apply_manifest(@destroy_code, :catch_failures=>true)
134-
sleep 10# wait for containers to stop
133+
retry_on_error_matching(10, 3, /Removing network web_default/) do
134+
apply_manifest(@destroy_code, :catch_failures=>true)
135+
end
136+
sleep 15 # Wait for containers to stop and be destroyed
135137
end
136138

137139
it 'should be idempotent' do
138-
apply_manifest(@destroy_code, :catch_changes=>true)
139-
sleep 5
140+
retry_on_error_matching(10, 3, /Removing network web_default/) do
141+
apply_manifest(@destroy_code, :catch_changes=>true)
142+
end
140143
end
141144

142145
it 'should not find a docker stack' do
@@ -146,7 +149,9 @@ class { 'docker': #{docker_args} }
146149
end
147150

148151
it 'should not find a docker container' do
149-
shell("docker ps | grep web_compose_test", :acceptable_exit_codes => [1])
152+
shell("docker ps", :acceptable_exit_codes => [0]) do |r|
153+
expect(r.stdout).not_to match(/web_compose_test/)
154+
end
150155
end
151156
end
152157

spec/spec_helper_acceptance.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, e
112112
version: "3"
113113
services:
114114
compose_test:
115-
image: hello-world:nanoserver
115+
image: winamd64/hello-world
116116
command: cmd.exe /C "ping 8.8.8.8 -t"
117117
networks:
118118
default:
@@ -123,7 +123,7 @@ def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, e
123123
version: "3"
124124
services:
125125
compose_test:
126-
image: hello-world:nanoserver-sac2016
126+
image: winamd64/hello-world:nanoserver-sac2016
127127
command: cmd.exe /C "ping 8.8.8.8 -t"
128128
networks:
129129
default:
@@ -134,14 +134,14 @@ def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, e
134134
version: "3"
135135
services:
136136
compose_test:
137-
image: hello-world:nanoserver
137+
image: winamd64/hello-world
138138
command: cmd.exe /C "ping 8.8.8.8 -t"
139139
EOS
140140
docker_stack_override_windows = <<-EOS
141141
version: "3"
142142
services:
143143
compose_test:
144-
image: hello-world:nanoserver-sac2016
144+
image: winamd64/hello-world:nanoserver-sac2016
145145
EOS
146146
if fact_on(host, 'osfamily') == 'windows'
147147
create_remote_file(host, '/tmp/docker-compose-v3.yml', docker_compose_content_v3_windows)

0 commit comments

Comments
 (0)