Skip to content

Commit 2d6be68

Browse files
author
Daniel Carabas
committed
Convert acceptance tests to Litmus
1 parent 6174b52 commit 2d6be68

27 files changed

Lines changed: 415 additions & 603 deletions

.fixtures.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ fixtures:
66
powershell: 'puppetlabs-powershell'
77
reboot: 'puppetlabs-reboot'
88
repositories:
9+
facts: 'git://github.com/puppetlabs/puppetlabs-facts.git'
10+
puppet_agent: 'git://github.com/puppetlabs/puppetlabs-puppet_agent.git'
11+
provision: 'git://github.com/puppetlabs/provision.git'
912
yumrepo_core:
1013
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
1114
puppet_version: ">= 6.0.0"
1215
symlinks:
13-
docker: "#{source_dir}"
16+
docker: "#{source_dir}"

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,5 @@ extra_gemfiles.each do |gemfile|
7676
eval(File.read(gemfile), binding)
7777
end
7878
end
79+
gem "puppet_litmus", git: "https://github.com/puppetlabs/puppet_litmus", require: false, platforms: [:ruby, :mswin, :mingw, :x64_mingw] if ENV['PUPPET_GEM_VERSION'].nil? or ENV['PUPPET_GEM_VERSION'] !~ %r{ 5}
7980
# vim: syntax=ruby

provision.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
default:
3+
provisioner: vagrant
4+
images: [ 'ubuntu/xenial64', 'ubuntu/bionic64']
5+
centos:
6+
provisioner: vagrant
7+
images: ['centos/7']
8+
debian:
9+
provisioner: vagrant
10+
images: ['debian/stretch64', 'debian/buster64']
11+
release_checks:
12+
provisioner: vmpooler
13+
images: ['redhat-7-x86_64','centos-7-x86_64', 'ubuntu-1604-x86_64', 'ubuntu-1804-x86_64', 'debian-9-x86_64', 'debian-10-x86_64', 'win-2016-x86_64', 'win-2019-x86_64']

spec/acceptance/compose_v3_spec.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
require 'spec_helper_acceptance'
22

3-
if fact('osfamily') == 'windows'
3+
if os[:family] == 'windows'
44
install_dir = '/cygdrive/c/Program Files/Docker'
55
file_extension = '.exe'
66
docker_args = 'docker_ee => true'
77
tmp_path = 'C:/cygwin64/tmp'
8-
test_container = if fact('os.release.major') == '2019'
8+
test_container = if os[:release] =~ /2019/
99
'nanoserver'
1010
else
1111
'nanoserver-sac2016'
1212
end
1313
else
14-
docker_args = if fact('os.name') == 'RedHat'
14+
docker_args = if os[:name] == 'RedHat'
1515
"repo_opt => '--enablerepo=localmirror-extras'"
16-
elsif fact('os.name') == 'Centos'
16+
elsif os[:name] == 'Centos'
1717
"repo_opt => '--enablerepo=localmirror-extras'"
18-
elsif fact('os.name') == 'Ubuntu' && fact('os.release.full') == '14.04'
18+
elsif os[:name] == 'Ubuntu' && os[:release][:full] == '14.04'
1919
"version => '18.06.1~ce~3-0~ubuntu'"
2020
else
2121
''
@@ -50,15 +50,15 @@ class { 'docker::compose':
5050
end
5151

5252
it 'is idempotent' do
53-
idempotent_apply(default, install_pp, {})
53+
idempotent_apply(install_pp)
5454
end
5555

5656
it 'has docker compose installed' do
57-
shell('docker-compose --help', acceptable_exit_codes: [0])
57+
run_shell('docker-compose --help', expect_failures: false)
5858
end
5959

6060
it 'finds a docker container' do
61-
shell('docker inspect web_compose_test_1', acceptable_exit_codes: [0])
61+
run_shell('docker inspect web_compose_test_1', expect_failures: false)
6262
end
6363
end
6464

@@ -75,7 +75,7 @@ class { 'docker::compose':
7575
end
7676

7777
it "should find container with #{test_container} tag" do
78-
shell("docker inspect web1_compose_test_1 | grep #{test_container}", acceptable_exit_codes: [0])
78+
run_shell("docker inspect web1_compose_test_1 | grep #{test_container}", acceptable_exit_codes: [0])
7979
end
8080
end
8181

@@ -101,11 +101,11 @@ class { 'docker::compose':
101101
end
102102

103103
it 'is idempotent' do
104-
idempotent_apply(default, destroy_pp, {})
104+
idempotent_apply(destroy_pp)
105105
end
106106

107107
it 'does not find a docker container' do
108-
shell('docker inspect web1_compose_test_1', acceptable_exit_codes: [1])
108+
run_shell('docker inspect web1_compose_test_1', expect_failures: true)
109109
end
110110
end
111111

@@ -120,11 +120,11 @@ class { 'docker::compose':
120120
version => '#{version}',
121121
}
122122
MANIFEST
123-
idempotent_apply(default, pp, {})
123+
idempotent_apply(pp)
124124
end
125125

126126
it 'has installed the requested version' do
127-
shell('docker-compose --version', acceptable_exit_codes: [0]) do |r|
127+
run_shell('docker-compose --version', expect_failures: false) do |r|
128128
expect(r.stdout).to match(%r{#{version}})
129129
end
130130
end
@@ -142,12 +142,12 @@ class { 'docker::compose':
142142
version => '#{version}',
143143
}
144144
MANIFEST
145-
idempotent_apply(default, pp, {})
145+
idempotent_apply(pp)
146146
end
147147

148148
it 'has removed the relevant files' do
149-
shell("test -e \"#{install_dir}/docker-compose#{file_extension}\"", acceptable_exit_codes: [1])
150-
shell("test -e \"#{install_dir}/docker-compose-#{version}#{file_extension}\"", acceptable_exit_codes: [1])
149+
run_shell("test -e \"#{install_dir}/docker-compose#{file_extension}\"", expect_failures: true)
150+
run_shell("test -e \"#{install_dir}/docker-compose-#{version}#{file_extension}\"", expect_failures: true)
151151
end
152152

153153
after(:all) do

spec/acceptance/docker_custom_source_spec.rb

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

33
skip = false
44

5-
if fact('osfamily') == 'windows'
5+
if os[:family] == '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"'
77
default_image = 'winamd64/hello-seattle'
88
# The default args are set because:
@@ -12,7 +12,7 @@
1212
default_run_command = 'ping 127.0.0.1 -t'
1313
docker_command = '"/cygdrive/c/Program Files/Docker/docker"'
1414
skip = false
15-
elsif fact('os.name') == 'Ubuntu' && fact('os.release.full') == '14.04'
15+
elsif os[:name] == 'Ubuntu' && os[:release][:full] == '14.04'
1616
docker_args = "version => '18.06.1~ce~3-0~ubuntu'"
1717
skip = true
1818
else
@@ -33,23 +33,24 @@ class { 'docker': #{docker_args} }
3333
end
3434

3535
it 'runs idempotently' do
36+
require 'pry'; binding.pry
3637
apply_manifest(pp, catch_changes: true) unless fact('selinux') == 'true'
3738
end
3839

3940
it 'is start a docker process' do
4041
if fact('osfamily') == 'windows'
41-
shell('powershell Get-Process -Name dockerd') do |r|
42+
run_shell('powershell Get-Process -Name dockerd') do |r|
4243
expect(r.stdout).to match(%r{ProcessName})
4344
end
4445
else
45-
shell('ps aux | grep docker') do |r|
46+
run_shell('ps aux | grep docker') do |r|
4647
expect(r.stdout).to match %r{dockerd -H unix:\/\/\/var\/run\/docker.sock}
4748
end
4849
end
4950
end
5051

5152
it 'installs a working docker client' do
52-
shell("#{docker_command} ps", acceptable_exit_codes: [0])
53+
run_shell("#{docker_command} ps", expect_failures: false)
5354
end
5455

5556
it 'stops a running container and remove container' do
@@ -88,19 +89,19 @@ class { 'docker': #{docker_args} }
8889
# A sleep to give docker time to execute properly
8990
sleep 15
9091

91-
shell("#{docker_command} ps", acceptable_exit_codes: [0])
92+
run_shell("#{docker_command} ps", expect_failures: false)
9293

9394
apply_manifest(pp2, catch_failures: true)
9495
apply_manifest(pp2, catch_changes: true) unless fact('selinux') == 'true'
9596

9697
# A sleep to give docker time to execute properly
9798
sleep 15
9899

99-
shell("#{docker_command} inspect container-3-6", acceptable_exit_codes: [1])
100-
if fact('osfamily') == 'windows'
101-
shell('test -f /cygdrive/c/Users/Administrator/AppData/Local/Temp/container-3-6.service', acceptable_exit_codes: [1])
100+
run_shell("#{docker_command} inspect container-3-6", expect_failures: true)
101+
if os[:family] == 'windows'
102+
run_shell('test -f /cygdrive/c/Users/Administrator/AppData/Local/Temp/container-3-6.service', expect_failures: true)
102103
else
103-
shell('test -f /etc/systemd/system/container-3-6.service', acceptable_exit_codes: [1])
104+
run_shell('test -f /etc/systemd/system/container-3-6.service', expect_failures: true)
104105
end
105106
end
106107
end

0 commit comments

Comments
 (0)