Skip to content

(FM-8151) Add Windows Server 2019 support #493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
{
"operatingsystem": "Windows",
"operatingsystemrelease": [
"Server 2016"
"2016",
"2019"
]
}
],
Expand Down
6 changes: 5 additions & 1 deletion spec/acceptance/compose_v3_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
file_extension = '.exe'
docker_args = 'docker_ee => true'
tmp_path = 'C:/cygwin64/tmp'
test_container = 'nanoserver-sac2016'
test_container = if fact('os.release.major') == '2019'
'nanoserver'
else
'nanoserver-sac2016'
end
else
docker_args = if fact('os.name') == 'RedHat'
"repo_opt => '--enablerepo=localmirror-extras'"
Expand Down
31 changes: 20 additions & 11 deletions spec/acceptance/docker_full_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
if fact('kernel') == 'windows'
docker_args = 'docker_ee => true'
default_image = 'winamd64/hello-seattle'
default_image_tag = 'nanoserver-sac2016'
default_image_tag = if fact('os.release.major') == '2019'
'nanoserver'
else
'nanoserver-sac2016'
end
default_digest = 'sha256:dcba85354678b50608b8c40ec6d17cce063a224aa0e12b6a55dc47b67f039e75'
second_image = 'winamd64/hola-mundo'
default_dockerfile = 'C:/Users/Administrator/AppData/Local/Temp/Dockerfile'
Expand All @@ -14,9 +18,9 @@
default_docker_run_arg = "restart => 'always', net => 'nat',"
default_run_command = 'ping 127.0.0.1 -t'
docker_command = '"/cygdrive/c/Program Files/Docker/docker"'
default_docker_exec_lr_command = 'cmd /c "ping 127.0.0.1 -t > c:\windows\temp\test_file.txt"'
default_docker_exec_command = 'cmd /c "echo test > c:\windows\temp\test_file.txt"'
docker_mount_path = 'C:/Users/Administrator/AppData/Local/Temp'
default_docker_exec_lr_command = 'cmd /c "ping 127.0.0.1 -t > C:\Users\Public\test_file.txt"'
default_docker_exec_command = 'cmd /c "echo test > C:\Users\Public\test_file.txt"'
docker_mount_path = 'C:/Users/Public/DockerVolume'
storage_driver = 'windowsfilter'
else
docker_args = if fact('os.family') == 'RedHat'
Expand Down Expand Up @@ -313,7 +317,7 @@ class { 'docker': #{docker_args} }

it 'creates a new image based on a Dockerfile' do
run_cmd = if fact('osfamily') == 'windows'
'RUN echo test > C:\\Windows\\Temp\\Dockerfile_test.txt'
'RUN echo test > C:\\Users\\Public\\Dockerfile_test.txt'
else
"RUN echo test > #{dockerfile_test}"
end
Expand All @@ -339,7 +343,7 @@ class { 'docker': #{docker_args} }
# A sleep to give docker time to execute properly
sleep 4
if fact('osfamily') == 'windows'
shell("#{docker_command} run alpine_with_file cmd /c dir Windows\\\\Temp") do |r|
shell("#{docker_command} run alpine_with_file cmd /c dir Users\\\\Public") do |r|
expect(r.stdout).to match(%r{_test.txt})
end
else
Expand Down Expand Up @@ -467,7 +471,7 @@ class { 'docker': #{docker_args}

container_id = shell("#{docker_command} ps | awk 'FNR == 2 {print $1}'")
if fact('osfamily') == 'windows'
shell("#{docker_command} exec #{container_id.stdout.strip} cmd /c dir Windows\\\\Temp") do |r|
shell("#{docker_command} exec #{container_id.stdout.strip} cmd /c dir Users\\\\Public") do |r|
expect(r.stdout).to match(%r{test_file.txt})
end
else
Expand Down Expand Up @@ -555,6 +559,11 @@ class { 'docker': #{docker_args} }
#{default_docker_run_arg}
}

file { '#{docker_mount_path}':
ensure => directory,
before => File['#{docker_mount_path}/test_mount.txt'],
}

file { '#{docker_mount_path}/test_mount.txt':
ensure => present,
before => Docker::Run['container_3_4'],
Expand All @@ -568,7 +577,7 @@ class { 'docker': #{docker_args} }
sleep 4
container_id = shell("#{docker_command} ps | awk 'FNR == 2 {print $1}'")
if fact('osfamily') == 'windows'
shell("#{docker_command} exec #{container_id.stdout.strip} cmd /c dir Users\\\\Administrator\\\\AppData\\\\Local\\\\Temp\\\\mnt") do |r|
shell("#{docker_command} exec #{container_id.stdout.strip} cmd /c dir Users\\\\Public\\\\DockerVolume\\\\mnt") do |r|
expect(r.stdout).to match(%r{test_mount.txt})
end
else
Expand Down Expand Up @@ -874,7 +883,7 @@ class { 'docker': #{docker_args} }

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

if fact('osfamily') == 'windows'
shell("#{docker_command} exec #{container_name} cmd /c dir Windows\\\\Temp") do |r|
shell("#{docker_command} exec #{container_name} cmd /c dir Users\\\\Public") do |r|
expect(r.stdout).not_to match(%r{test_file.txt})
end
else
Expand Down Expand Up @@ -944,7 +953,7 @@ class { 'docker': #{docker_args} }
sleep 4

if fact('osfamily') == 'windows'
shell("#{docker_command} exec #{container_name} cmd /c dir Windows\\\\Temp") do |r|
shell("#{docker_command} exec #{container_name} cmd /c dir Users\\\\Public") do |r|
expect(r.stdout).to match(%r{test_file.txt})
end
else
Expand Down
26 changes: 24 additions & 2 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, e
EOS
docker_compose_override_v3_windows = <<-EOS
version: "3"
services:
compose_test:
image: winamd64/hello-seattle:nanoserver
command: cmd.exe /C "ping 8.8.8.8 -t"
networks:
default:
external:
name: nat
EOS
docker_compose_override_v3_windows2016 = <<-EOS
version: "3"
services:
compose_test:
image: winamd64/hello-seattle:nanoserver-sac2016
Expand All @@ -153,15 +164,26 @@ def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, e
EOS
docker_stack_override_windows = <<-EOS
version: "3"
services:
compose_test:
image: winamd64/hello-seattle:nanoserver
EOS
docker_stack_override_windows2016 = <<-EOS
version: "3"
services:
compose_test:
image: winamd64/hello-seattle:nanoserver-sac2016
EOS
if fact_on(host, 'osfamily') == 'windows'
create_remote_file(host, '/tmp/docker-compose-v3.yml', docker_compose_content_v3_windows)
create_remote_file(host, '/tmp/docker-stack.yml', docker_stack_content_windows)
create_remote_file(host, '/tmp/docker-compose-override-v3.yml', docker_compose_override_v3_windows)
create_remote_file(host, '/tmp/docker-stack-override.yml', docker_stack_override_windows)
if fact_on(host, 'os.release.major') == '2019'
create_remote_file(host, '/tmp/docker-compose-override-v3.yml', docker_compose_override_v3_windows)
create_remote_file(host, '/tmp/docker-stack-override.yml', docker_stack_override_windows)
else
create_remote_file(host, '/tmp/docker-compose-override-v3.yml', docker_compose_override_v3_windows2016)
create_remote_file(host, '/tmp/docker-stack-override.yml', docker_stack_override_windows2016)
end
else
create_remote_file(host, '/tmp/docker-compose-v3.yml', docker_compose_content_v3)
create_remote_file(host, '/tmp/docker-stack.yml', docker_compose_content_v3)
Expand Down