Skip to content

Commit 12e6a17

Browse files
florindragosdavejrt
authored andcommitted
Add acceptance tests for installing docker from a zip file on windows (#315)
1 parent 03316d9 commit 12e6a17

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
require 'spec_helper_acceptance'
2+
3+
skip = false
4+
5+
if fact('osfamily') == 'windows'
6+
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'
9+
#The default args are set because:
10+
#restart => 'always' - there is no service created to manage containers
11+
#net => 'nat' - docker uses bridged by default when running a container. When installing docker on windows the default network is NAT.
12+
default_docker_run_arg = "restart => 'always', net => 'nat',"
13+
default_run_command = "ping 127.0.0.1 -t"
14+
docker_command = "\"/cygdrive/c/Program Files/Docker/docker\""
15+
skip = false
16+
else
17+
skip = true
18+
end
19+
20+
describe 'the Puppet Docker module' do
21+
context 'with download location', :skip => skip do
22+
let(:pp) {"
23+
class { 'docker': #{docker_args} }
24+
"}
25+
26+
it 'should run successfully' do
27+
apply_manifest(pp, :catch_failures => true)
28+
end
29+
30+
it 'should run idempotently' do
31+
apply_manifest(pp, :catch_changes => true) unless fact('selinux') == 'true'
32+
end
33+
34+
it 'should be start a docker process' do
35+
if fact('osfamily') == 'windows'
36+
shell('powershell Get-Process -Name dockerd') do |r|
37+
expect(r.stdout).to match(/ProcessName/)
38+
end
39+
else
40+
shell('ps aux | grep docker') do |r|
41+
expect(r.stdout).to match(/dockerd -H unix:\/\/\/var\/run\/docker.sock/)
42+
end
43+
end
44+
end
45+
46+
it 'should install a working docker client' do
47+
shell("#{docker_command} ps", :acceptable_exit_codes => [0] )
48+
end
49+
50+
it 'should stop a running container and remove container' do
51+
pp=<<-EOS
52+
class { 'docker': #{docker_args} }
53+
54+
docker::image { '#{default_image}':
55+
require => Class['docker'],
56+
}
57+
58+
docker::run { 'container_3_6':
59+
image => '#{default_image}',
60+
command => '#{default_run_command}',
61+
require => Docker::Image['#{default_image}'],
62+
#{default_docker_run_arg}
63+
}
64+
EOS
65+
66+
pp2=<<-EOS
67+
class { 'docker': #{docker_args} }
68+
69+
docker::image { '#{default_image}':
70+
require => Class['docker'],
71+
}
72+
73+
docker::run { 'container_3_6':
74+
ensure => 'absent',
75+
image => '#{default_image}',
76+
require => Docker::Image['#{default_image}'],
77+
}
78+
EOS
79+
80+
apply_manifest(pp, :catch_failures => true)
81+
apply_manifest(pp, :catch_changes => true) unless fact('selinux') == 'true'
82+
83+
# A sleep to give docker time to execute properly
84+
sleep 15
85+
86+
shell("#{docker_command} ps", :acceptable_exit_codes => [0])
87+
88+
apply_manifest(pp2, :catch_failures => true)
89+
apply_manifest(pp2, :catch_changes => true) unless fact('selinux') == 'true'
90+
91+
# A sleep to give docker time to execute properly
92+
sleep 15
93+
94+
shell("#{docker_command} inspect container-3-6", :acceptable_exit_codes => [1])
95+
if fact('osfamily') == 'windows'
96+
shell('test -f /cygdrive/c/Windows/Temp/container-3-6.service', :acceptable_exit_codes => [1])
97+
else
98+
shell('test -f /etc/systemd/system/container-3-6.service', :acceptable_exit_codes => [1])
99+
end
100+
end
101+
end
102+
end

0 commit comments

Comments
 (0)