Skip to content

Commit 7bf3ea6

Browse files
committed
Modify tests to fix permissions issues
1 parent 9cac9f5 commit 7bf3ea6

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

spec/acceptance/compose_v3_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
file_extension = '.exe'
66
docker_args = 'docker_ee => true'
77
tmp_path = 'C:/cygwin64/tmp'
8-
if fact('os.release.major') == '2019'
9-
test_container = 'nanoserver'
10-
else
11-
test_container = 'nanoserver-sac2016'
12-
end
8+
test_container = if fact('os.release.major') == '2019'
9+
'nanoserver'
10+
else
11+
'nanoserver-sac2016'
12+
end
1313
else
1414
docker_args = if fact('os.name') == 'RedHat'
1515
"repo_opt => '--enablerepo=localmirror-extras'"

spec/acceptance/docker_full_spec.rb

+20-15
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
if fact('kernel') == 'windows'
44
docker_args = 'docker_ee => true'
55
default_image = 'winamd64/hello-seattle'
6-
if fact('os.release.major') == '2019'
7-
default_image_tag = 'nanoserver'
8-
else
9-
default_image_tag = 'nanoserver-sac2016'
10-
end
6+
default_image_tag = if fact('os.release.major') == '2019'
7+
'nanoserver'
8+
else
9+
'nanoserver-sac2016'
10+
end
1111
default_digest = 'sha256:dcba85354678b50608b8c40ec6d17cce063a224aa0e12b6a55dc47b67f039e75'
1212
second_image = 'winamd64/hola-mundo'
1313
default_dockerfile = 'C:/Users/Administrator/AppData/Local/Temp/Dockerfile'
@@ -18,9 +18,9 @@
1818
default_docker_run_arg = "restart => 'always', net => 'nat',"
1919
default_run_command = 'ping 127.0.0.1 -t'
2020
docker_command = '"/cygdrive/c/Program Files/Docker/docker"'
21-
default_docker_exec_lr_command = 'cmd /c "ping 127.0.0.1 -t > c:\windows\temp\test_file.txt"'
22-
default_docker_exec_command = 'cmd /c "echo test > c:\windows\temp\test_file.txt"'
23-
docker_mount_path = 'C:/Users/Administrator/AppData/Local/Temp'
21+
default_docker_exec_lr_command = 'cmd /c "ping 127.0.0.1 -t > C:\Users\Public\test_file.txt"'
22+
default_docker_exec_command = 'cmd /c "echo test > C:\Users\Public\test_file.txt"'
23+
docker_mount_path = 'C:/Users/Public/DockerVolume'
2424
storage_driver = 'windowsfilter'
2525
else
2626
docker_args = if fact('os.family') == 'RedHat'
@@ -317,7 +317,7 @@ class { 'docker': #{docker_args} }
317317

318318
it 'creates a new image based on a Dockerfile' do
319319
run_cmd = if fact('osfamily') == 'windows'
320-
'RUN echo test > C:\\Windows\\Temp\\Dockerfile_test.txt'
320+
'RUN echo test > C:\\Users\\Public\\Dockerfile_test.txt'
321321
else
322322
"RUN echo test > #{dockerfile_test}"
323323
end
@@ -343,7 +343,7 @@ class { 'docker': #{docker_args} }
343343
# A sleep to give docker time to execute properly
344344
sleep 4
345345
if fact('osfamily') == 'windows'
346-
shell("#{docker_command} run alpine_with_file cmd /c dir Windows\\\\Temp") do |r|
346+
shell("#{docker_command} run alpine_with_file cmd /c dir Users\\\\Public") do |r|
347347
expect(r.stdout).to match(%r{_test.txt})
348348
end
349349
else
@@ -471,7 +471,7 @@ class { 'docker': #{docker_args}
471471

472472
container_id = shell("#{docker_command} ps | awk 'FNR == 2 {print $1}'")
473473
if fact('osfamily') == 'windows'
474-
shell("#{docker_command} exec #{container_id.stdout.strip} cmd /c dir Windows\\\\Temp") do |r|
474+
shell("#{docker_command} exec #{container_id.stdout.strip} cmd /c dir Users\\\\Public") do |r|
475475
expect(r.stdout).to match(%r{test_file.txt})
476476
end
477477
else
@@ -559,6 +559,11 @@ class { 'docker': #{docker_args} }
559559
#{default_docker_run_arg}
560560
}
561561
562+
file { '#{docker_mount_path}':
563+
ensure => directory,
564+
before => File['#{docker_mount_path}/test_mount.txt'],
565+
}
566+
562567
file { '#{docker_mount_path}/test_mount.txt':
563568
ensure => present,
564569
before => Docker::Run['container_3_4'],
@@ -572,7 +577,7 @@ class { 'docker': #{docker_args} }
572577
sleep 4
573578
container_id = shell("#{docker_command} ps | awk 'FNR == 2 {print $1}'")
574579
if fact('osfamily') == 'windows'
575-
shell("#{docker_command} exec #{container_id.stdout.strip} cmd /c dir Users\\\\Administrator\\\\AppData\\\\Local\\\\Temp\\\\mnt") do |r|
580+
shell("#{docker_command} exec #{container_id.stdout.strip} cmd /c dir Users\\\\Public\\\\DockerVolume\\\\mnt") do |r|
576581
expect(r.stdout).to match(%r{test_mount.txt})
577582
end
578583
else
@@ -878,7 +883,7 @@ class { 'docker': #{docker_args} }
878883

879884
container_id = shell("#{docker_command} ps | awk 'FNR == 2 {print $1}'")
880885
if fact('osfamily') == 'windows'
881-
shell("#{docker_command} exec #{container_id.stdout.strip} cmd /c dir Windows\\\\Temp") do |r|
886+
shell("#{docker_command} exec #{container_id.stdout.strip} cmd /c dir Users\\\\Public") do |r|
882887
expect(r.stdout).to match(%r{test_file.txt})
883888
end
884889
else
@@ -916,7 +921,7 @@ class { 'docker': #{docker_args} }
916921
sleep 4
917922

918923
if fact('osfamily') == 'windows'
919-
shell("#{docker_command} exec #{container_name} cmd /c dir Windows\\\\Temp") do |r|
924+
shell("#{docker_command} exec #{container_name} cmd /c dir Users\\\\Public") do |r|
920925
expect(r.stdout).not_to match(%r{test_file.txt})
921926
end
922927
else
@@ -948,7 +953,7 @@ class { 'docker': #{docker_args} }
948953
sleep 4
949954

950955
if fact('osfamily') == 'windows'
951-
shell("#{docker_command} exec #{container_name} cmd /c dir Windows\\\\Temp") do |r|
956+
shell("#{docker_command} exec #{container_name} cmd /c dir Users\\\\Public") do |r|
952957
expect(r.stdout).to match(%r{test_file.txt})
953958
end
954959
else

spec/spec_helper_acceptance.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, e
144144
external:
145145
name: nat
146146
EOS
147-
docker_compose_override_v3_windows_2016 = <<-EOS
147+
docker_compose_override_v3_windows2016 = <<-EOS
148148
version: "3"
149149
services:
150150
compose_test:
@@ -168,7 +168,7 @@ def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, e
168168
compose_test:
169169
image: winamd64/hello-seattle:nanoserver
170170
EOS
171-
docker_stack_override_windows_2016 = <<-EOS
171+
docker_stack_override_windows2016 = <<-EOS
172172
version: "3"
173173
services:
174174
compose_test:
@@ -178,11 +178,11 @@ def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, e
178178
create_remote_file(host, '/tmp/docker-compose-v3.yml', docker_compose_content_v3_windows)
179179
create_remote_file(host, '/tmp/docker-stack.yml', docker_stack_content_windows)
180180
if fact_on(host, 'os.release.major') == '2019'
181-
create_remote_file(host, '/tmp/docker-compose-override-v3.yml', docker_stack_override_windows)
181+
create_remote_file(host, '/tmp/docker-compose-override-v3.yml', docker_compose_override_v3_windows)
182182
create_remote_file(host, '/tmp/docker-stack-override.yml', docker_stack_override_windows)
183183
else
184-
create_remote_file(host, '/tmp/docker-compose-override-v3.yml', docker_stack_override_windows_2016)
185-
create_remote_file(host, '/tmp/docker-stack-override.yml', docker_stack_override_windows_2016)
184+
create_remote_file(host, '/tmp/docker-compose-override-v3.yml', docker_compose_override_v3_windows2016)
185+
create_remote_file(host, '/tmp/docker-stack-override.yml', docker_stack_override_windows2016)
186186
end
187187
else
188188
create_remote_file(host, '/tmp/docker-compose-v3.yml', docker_compose_content_v3)

0 commit comments

Comments
 (0)