pdqtest 0.7.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile.lock +130 -0
- data/README.md +17 -12
- data/doc/acceptance_tests.md +7 -1
- data/doc/demo.gif +0 -0
- data/doc/emoji.md +25 -0
- data/docker_images/centos/Dockerfile +3 -5
- data/docker_images/ubuntu/Dockerfile +69 -0
- data/docker_images/ubuntu/Makefile +3 -0
- data/exe/pdqtest +14 -1
- data/lib/pdqtest/docker.rb +33 -3
- data/lib/pdqtest/instance.rb +33 -11
- data/lib/pdqtest/puppet.rb +4 -0
- data/lib/pdqtest/version.rb +1 -1
- data/pdqtest.gemspec +4 -5
- data/res/skeleton/Gemfile +3 -3
- metadata +29 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 933682f63736575743508992736a3013459e5041
|
|
4
|
+
data.tar.gz: 51608bfaa0b4814c81b525beef7c197f434c26c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 89c1db7812b14ff1c29f2f3402b052d654dfa4c710bda12373dfc4615ba932500f2c3681c7369d21ebf3e901913b54c00e7859c8d7890ff2641381f8bc4b2ca6
|
|
7
|
+
data.tar.gz: 406dd34b11bef83cc306d884b570beb73e0af0f879be5ff4b67fc7a2a8d563fa5253d76afd86ba4a43f2b54a8bb9f90be6320d89513f276776d0cae635ea1f35
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
pdqtest (0.8.0)
|
|
5
|
+
docker-api (= 1.33.1)
|
|
6
|
+
escort (= 0.4.0)
|
|
7
|
+
git_refresh (= 0.1.1)
|
|
8
|
+
hiera (= 3.4.0)
|
|
9
|
+
librarian-puppet (= 2.2.3)
|
|
10
|
+
minitar (= 0.6.1)
|
|
11
|
+
puppet-lint (= 2.1.0)
|
|
12
|
+
puppet-syntax (= 2.2.0)
|
|
13
|
+
puppet_factset (= 0.5.0)
|
|
14
|
+
puppetlabs_spec_helper (= 1.2.2)
|
|
15
|
+
rake (= 12.0.0)
|
|
16
|
+
rspec (= 3.5.0)
|
|
17
|
+
thor (= 0.19.4)
|
|
18
|
+
|
|
19
|
+
GEM
|
|
20
|
+
remote: https://rubygems.org/
|
|
21
|
+
specs:
|
|
22
|
+
coveralls (0.8.21)
|
|
23
|
+
json (>= 1.8, < 3)
|
|
24
|
+
simplecov (~> 0.14.1)
|
|
25
|
+
term-ansicolor (~> 1.3)
|
|
26
|
+
thor (~> 0.19.4)
|
|
27
|
+
tins (~> 1.6)
|
|
28
|
+
diff-lcs (1.3)
|
|
29
|
+
docile (1.1.5)
|
|
30
|
+
docker-api (1.33.1)
|
|
31
|
+
excon (>= 0.38.0)
|
|
32
|
+
json
|
|
33
|
+
escort (0.4.0)
|
|
34
|
+
nesty
|
|
35
|
+
excon (0.59.0)
|
|
36
|
+
facter (2.5.1)
|
|
37
|
+
fakefs (0.11.0)
|
|
38
|
+
faraday (0.9.2)
|
|
39
|
+
multipart-post (>= 1.2, < 3)
|
|
40
|
+
faraday_middleware (0.10.1)
|
|
41
|
+
faraday (>= 0.7.4, < 1.0)
|
|
42
|
+
fast_gettext (1.1.0)
|
|
43
|
+
gettext (3.2.4)
|
|
44
|
+
locale (>= 2.0.5)
|
|
45
|
+
text (>= 1.3.0)
|
|
46
|
+
gettext-setup (0.28)
|
|
47
|
+
fast_gettext (~> 1.1.0)
|
|
48
|
+
gettext (>= 3.0.2)
|
|
49
|
+
locale
|
|
50
|
+
git_refresh (0.1.1)
|
|
51
|
+
escort (= 0.4.0)
|
|
52
|
+
hiera (3.4.0)
|
|
53
|
+
json (2.1.0)
|
|
54
|
+
json_pure (1.8.6)
|
|
55
|
+
librarian-puppet (2.2.3)
|
|
56
|
+
librarianp (>= 0.6.3)
|
|
57
|
+
puppet_forge (~> 2.1)
|
|
58
|
+
rsync
|
|
59
|
+
librarianp (0.6.3)
|
|
60
|
+
thor (~> 0.15)
|
|
61
|
+
locale (2.1.2)
|
|
62
|
+
metaclass (0.0.4)
|
|
63
|
+
minitar (0.6.1)
|
|
64
|
+
mocha (1.3.0)
|
|
65
|
+
metaclass (~> 0.0.1)
|
|
66
|
+
multipart-post (2.0.0)
|
|
67
|
+
nesty (1.0.2)
|
|
68
|
+
puppet (4.10.8)
|
|
69
|
+
facter (> 2.0, < 4)
|
|
70
|
+
gettext-setup (>= 0.10, < 1)
|
|
71
|
+
hiera (>= 2.0, < 4)
|
|
72
|
+
json_pure (~> 1.8)
|
|
73
|
+
locale (~> 2.1)
|
|
74
|
+
puppet-lint (2.1.0)
|
|
75
|
+
puppet-syntax (2.2.0)
|
|
76
|
+
rake
|
|
77
|
+
puppet_factset (0.5.0)
|
|
78
|
+
puppet_forge (2.2.7)
|
|
79
|
+
faraday (~> 0.9.0)
|
|
80
|
+
faraday_middleware (>= 0.9.0, < 0.11.0)
|
|
81
|
+
gettext-setup (~> 0.11)
|
|
82
|
+
minitar
|
|
83
|
+
semantic_puppet (~> 1.0)
|
|
84
|
+
puppetlabs_spec_helper (1.2.2)
|
|
85
|
+
mocha (~> 1.0)
|
|
86
|
+
puppet-lint (~> 2.0)
|
|
87
|
+
puppet-syntax (~> 2.0)
|
|
88
|
+
rspec-puppet (~> 2.0)
|
|
89
|
+
rake (12.0.0)
|
|
90
|
+
rspec (3.5.0)
|
|
91
|
+
rspec-core (~> 3.5.0)
|
|
92
|
+
rspec-expectations (~> 3.5.0)
|
|
93
|
+
rspec-mocks (~> 3.5.0)
|
|
94
|
+
rspec-core (3.5.4)
|
|
95
|
+
rspec-support (~> 3.5.0)
|
|
96
|
+
rspec-expectations (3.5.0)
|
|
97
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
98
|
+
rspec-support (~> 3.5.0)
|
|
99
|
+
rspec-mocks (3.5.0)
|
|
100
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
101
|
+
rspec-support (~> 3.5.0)
|
|
102
|
+
rspec-puppet (2.6.9)
|
|
103
|
+
rspec
|
|
104
|
+
rspec-support (3.5.0)
|
|
105
|
+
rsync (1.0.9)
|
|
106
|
+
semantic_puppet (1.0.1)
|
|
107
|
+
gettext-setup (>= 0.3)
|
|
108
|
+
simplecov (0.14.1)
|
|
109
|
+
docile (~> 1.1.0)
|
|
110
|
+
json (>= 1.8, < 3)
|
|
111
|
+
simplecov-html (~> 0.10.0)
|
|
112
|
+
simplecov-html (0.10.2)
|
|
113
|
+
term-ansicolor (1.6.0)
|
|
114
|
+
tins (~> 1.0)
|
|
115
|
+
text (1.3.1)
|
|
116
|
+
thor (0.19.4)
|
|
117
|
+
tins (1.15.0)
|
|
118
|
+
|
|
119
|
+
PLATFORMS
|
|
120
|
+
ruby
|
|
121
|
+
|
|
122
|
+
DEPENDENCIES
|
|
123
|
+
bundler (~> 1.15)
|
|
124
|
+
coveralls (= 0.8.21)
|
|
125
|
+
fakefs (= 0.11.0)
|
|
126
|
+
pdqtest!
|
|
127
|
+
puppet (= 4.10.8)
|
|
128
|
+
|
|
129
|
+
BUNDLED WITH
|
|
130
|
+
1.15.4
|
data/README.md
CHANGED
|
@@ -12,17 +12,22 @@ And can generate code to retrofit testing to a new or existing module, along wit
|
|
|
12
12
|
|
|
13
13
|
PDQTest runs linting, syntax and RSpec tests within the machine it is running from and then loads a docker container to perform acceptance testing, sharing the puppet module and cached dependencies from your host.
|
|
14
14
|
|
|
15
|
+

|
|
16
|
+
_Adding PDQTest to a project and running acceptance tests in Docker_
|
|
17
|
+
|
|
15
18
|
## PDQTest Manual
|
|
16
19
|
1. [Installation](doc/installation.md)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
1. [Enabling testing](doc/enabling_testing.md)
|
|
21
|
+
1. [Running tests](doc/running_tests.md)
|
|
22
|
+
1. [Test generation](doc/test_generation.md)
|
|
23
|
+
1. [Acceptance tests](doc/acceptance_tests.md)
|
|
24
|
+
1. [Puppet module dependencies](doc/puppet_module_dependencies.md)
|
|
25
|
+
1. [Puppet facts](doc/puppet_facts.md)
|
|
26
|
+
1. [Hiera](doc/hiera.md)
|
|
27
|
+
1. [Caching](doc/caching.md)
|
|
28
|
+
1. [Upgrading](doc/upgrading.md)
|
|
29
|
+
1. [Emoji](doc/emoji.md)
|
|
30
|
+
1. [Examples](doc/examples.md)
|
|
31
|
+
1. [Tips and tricks](doc/tips_and_tricks.md)
|
|
32
|
+
1. [Troubleshooting](doc/troubleshooting.md)
|
|
33
|
+
1. [Development](doc/development.md)
|
data/doc/acceptance_tests.md
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
# Acceptance tests
|
|
2
2
|
* Acceptance tests run within a Docker container managed by PDQTest
|
|
3
3
|
* The Docker container breaks all the rules of Docker and runs a full version of Systemd to allow complete testing of Puppet code in the most portable way (basically treat docker as a high speed VM)... This is deliberate - PDQTest exists to get results, not be a perfect Docker app.
|
|
4
|
-
*
|
|
4
|
+
* There are two supported docker images - Centos 7 and Ubuntu 16.04
|
|
5
|
+
* Centos is used by default
|
|
6
|
+
* Ubuntu will be used if your `metadata.json` declares compatibility with Ubuntu
|
|
7
|
+
* Centos is great for mocking systems like AIX... if you replace OS binaries as required in the `__setup.sh` scripts
|
|
8
|
+
* No idea what to do to test windows on linux :/ containers seem out of the question and VMs would involve licensing
|
|
9
|
+
* If you have a specific container you want to use, pass `--image-name` on the command line, it accepts a comma delimited list of image names to test on
|
|
5
10
|
* The container will only be started if at least one example file is present **and contains the correct magic marker**
|
|
6
11
|
* You can get a shell on the docker container if needed, see [Debugging failed builds](#debugging-failed-builds)
|
|
12
|
+
* See the [docker_images](../docker_images) folder for examples
|
|
7
13
|
|
|
8
14
|
### Test workflow
|
|
9
15
|
1. Scan for all example files under `/examples`. Files must end in `.pp` and contain the magic marker `#@PDQTest` to be processed
|
data/doc/demo.gif
ADDED
|
Binary file
|
data/doc/emoji.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Emoji
|
|
2
|
+
|
|
3
|
+
Emoji are used within PDQTest to indicate progress and overall status at the request of PDQTest user. Emoji are great because by visually scanning for a distinctive symbol, the user is able to understand the overall test status without having to scan through all of the debug messages.
|
|
4
|
+
|
|
5
|
+
## What do the emoji mean?
|
|
6
|
+
|
|
7
|
+
### Progress
|
|
8
|
+
`😬` Test passed
|
|
9
|
+
|
|
10
|
+
`💣` Test failed
|
|
11
|
+
|
|
12
|
+
# Overall status
|
|
13
|
+
`😎` All tests passed
|
|
14
|
+
|
|
15
|
+
`💩` One or more tests failed
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Disabling emoji
|
|
19
|
+
In some cases it may be desirable to diable the emoji, in this case use the argument:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
--disable-emoji
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
When running PDQTest
|
|
@@ -6,8 +6,7 @@ FROM centos:centos7
|
|
|
6
6
|
# Systemd in docker - state of the art:
|
|
7
7
|
# https://developers.redhat.com/blog/2016/09/13/running-systemd-in-a-non-privileged-container/
|
|
8
8
|
ENV container docker
|
|
9
|
-
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
|
|
10
|
-
RUN yum -y update; yum clean all; \
|
|
9
|
+
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs && \
|
|
11
10
|
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
|
|
12
11
|
rm -f /lib/systemd/system/multi-user.target.wants/*;\
|
|
13
12
|
rm -f /etc/systemd/system/*.wants/*;\
|
|
@@ -19,7 +18,6 @@ rm -f /lib/systemd/system/anaconda.target.wants/*;
|
|
|
19
18
|
VOLUME [ "/sys/fs/cgroup" ]
|
|
20
19
|
CMD ["/sbin/init"]
|
|
21
20
|
|
|
22
|
-
MAINTAINER Geoff Williams <geoff.williams@puppet.com>
|
|
23
21
|
RUN yum install -y cronie \
|
|
24
22
|
initscripts \
|
|
25
23
|
git \
|
|
@@ -32,7 +30,7 @@ RUN echo "metadata_expire=never" >> /etc/yum.conf
|
|
|
32
30
|
|
|
33
31
|
# fix locale
|
|
34
32
|
RUN echo 'LANG=en_US.UTF-8' > /etc/locale.conf
|
|
35
|
-
RUN yum -y
|
|
33
|
+
RUN yum -y install glibc-common
|
|
36
34
|
# swallow errors
|
|
37
35
|
RUN localedef --quiet -v -c -i en_US -f UTF-8 en_US.UTF-8 || true
|
|
38
36
|
|
|
@@ -48,7 +46,7 @@ ENV TERM xterm
|
|
|
48
46
|
# echo "export TERM=xterm" >> /etc/environment
|
|
49
47
|
|
|
50
48
|
# puppet
|
|
51
|
-
RUN yum -y install
|
|
49
|
+
RUN yum -y install https://pm.puppetlabs.com/puppet-agent/2017.2.3/1.10.5/repos/el/7/PC1/x86_64/puppet-agent-1.10.5-1.el7.x86_64.rpm && \
|
|
52
50
|
/opt/puppetlabs/puppet/bin/puppet --version && \
|
|
53
51
|
/opt/puppetlabs/puppet/bin/facter --version
|
|
54
52
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Install all the RPM packages that puppet will install and disable
|
|
2
|
+
# metadata updates so that the environment can be joined to puppet
|
|
3
|
+
# and run without error in an offline environment
|
|
4
|
+
FROM ubuntu:16.04
|
|
5
|
+
|
|
6
|
+
ENV container docker
|
|
7
|
+
ENV LC_ALL C
|
|
8
|
+
ENV DEBIAN_FRONTEND noninteractive
|
|
9
|
+
|
|
10
|
+
RUN apt-get update && apt-get install systemd && apt-get clean && \
|
|
11
|
+
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
|
|
12
|
+
rm -f /lib/systemd/system/multi-user.target.wants/*;\
|
|
13
|
+
rm -f /etc/systemd/system/*.wants/*;\
|
|
14
|
+
rm -f /lib/systemd/system/local-fs.target.wants/*; \
|
|
15
|
+
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
|
|
16
|
+
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
|
|
17
|
+
rm -f /lib/systemd/system/basic.target.wants/*;\
|
|
18
|
+
rm -f /lib/systemd/system/anaconda.target.wants/*;
|
|
19
|
+
VOLUME [ "/sys/fs/cgroup" ]
|
|
20
|
+
CMD ["/sbin/init"]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# leave the apt metadata in place to allow apt-get install... to work (puppet
|
|
24
|
+
# package resource)
|
|
25
|
+
RUN apt-get install -y cron \
|
|
26
|
+
initscripts \
|
|
27
|
+
git \
|
|
28
|
+
zlib1g-dev \
|
|
29
|
+
debianutils \
|
|
30
|
+
libgpm-dev \
|
|
31
|
+
policycoreutils \
|
|
32
|
+
curl \
|
|
33
|
+
locales \
|
|
34
|
+
locales-all && dpkg-reconfigure locales
|
|
35
|
+
|
|
36
|
+
# fix locale
|
|
37
|
+
RUN echo 'LANG=en_US.UTF-8' > /etc/locale.conf
|
|
38
|
+
ENV LANG en_US.UTF-8
|
|
39
|
+
ENV LC_ALL en_US.UTF-8
|
|
40
|
+
ENV PATH /usr/local/bats/bin:/opt/puppetlabs/puppet/bin/:/usr/sbin:/sbin:/usr/bin:/bin
|
|
41
|
+
ENV TERM xterm
|
|
42
|
+
|
|
43
|
+
# puppet (and dont run the daemons)
|
|
44
|
+
RUN curl -Lo /tmp/puppet-agent.deb https://pm.puppetlabs.com/puppet-agent/2017.2.3/1.10.5/repos/deb/xenial/PC1/puppet-agent_1.10.5-1xenial_amd64.deb && \
|
|
45
|
+
dpkg -i /tmp/puppet-agent.deb && rm /tmp/puppet-agent.deb && \
|
|
46
|
+
/opt/puppetlabs/puppet/bin/puppet --version && \
|
|
47
|
+
/opt/puppetlabs/puppet/bin/facter --version && \
|
|
48
|
+
systemctl disable puppet && \
|
|
49
|
+
systemctl disable mcollective
|
|
50
|
+
|
|
51
|
+
# bats
|
|
52
|
+
RUN git clone https://github.com/sstephenson/bats /usr/local/bats
|
|
53
|
+
|
|
54
|
+
# librarian
|
|
55
|
+
RUN /opt/puppetlabs/puppet/bin/gem install librarian-puppet
|
|
56
|
+
|
|
57
|
+
# git refresh (for processing .fixtures.yml git modules)
|
|
58
|
+
RUN /opt/puppetlabs/puppet/bin/gem install git_refresh
|
|
59
|
+
|
|
60
|
+
# testcase (our module)
|
|
61
|
+
RUN mkdir /testcase
|
|
62
|
+
VOLUME /testcase
|
|
63
|
+
|
|
64
|
+
# code under test (deprecated)
|
|
65
|
+
RUN mkdir /cut
|
|
66
|
+
VOLUME /cut
|
|
67
|
+
|
|
68
|
+
# alternate shudown for systemd
|
|
69
|
+
STOPSIGNAL SIGRTMIN+3
|
data/exe/pdqtest
CHANGED
|
@@ -29,6 +29,13 @@ Escort::App.create do |app|
|
|
|
29
29
|
app.description "test puppet code quickly"
|
|
30
30
|
|
|
31
31
|
app.options do |opts|
|
|
32
|
+
opts.opt(:image_name,
|
|
33
|
+
'Specify docker image name(s) to use (docker store name) default is to autodetect',
|
|
34
|
+
:long => '--image-name',
|
|
35
|
+
:type => :string,
|
|
36
|
+
:default => nil,
|
|
37
|
+
)
|
|
38
|
+
|
|
32
39
|
opts.opt(:keep_container,
|
|
33
40
|
'Leave container running?',
|
|
34
41
|
:long => '--keep-container',
|
|
@@ -51,6 +58,8 @@ Escort::App.create do |app|
|
|
|
51
58
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
|
52
59
|
|
|
53
60
|
PDQTest::Instance.set_keep_container(options[:global][:options][:keep_container])
|
|
61
|
+
PDQTest::Instance.set_docker_image(options[:global][:options][:image_name])
|
|
62
|
+
|
|
54
63
|
PDQTest::Core.run([
|
|
55
64
|
lambda {PDQTest::Syntax.puppet},
|
|
56
65
|
lambda {PDQTest::Lint.puppet},
|
|
@@ -83,6 +92,7 @@ Escort::App.create do |app|
|
|
|
83
92
|
end
|
|
84
93
|
command.action do |options, arguments|
|
|
85
94
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
|
95
|
+
PDQTest::Instance.set_docker_image(options[:global][:options][:image_name])
|
|
86
96
|
PDQTest::Instance.set_keep_container(options[:global][:options][:keep_container])
|
|
87
97
|
example = options[:global][:commands][:acceptance][:options][:example]
|
|
88
98
|
PDQTest::Core.run(lambda {PDQTest::Instance.run(example)})
|
|
@@ -131,6 +141,7 @@ Escort::App.create do |app|
|
|
|
131
141
|
command.summary "Shell"
|
|
132
142
|
command.description "Open a shell inside a docker container identical to the test environment before anything has run"
|
|
133
143
|
command.action do |options, arguments|
|
|
144
|
+
PDQTest::Instance.set_docker_image(options[:global][:options][:image_name])
|
|
134
145
|
PDQTest::Instance.shell
|
|
135
146
|
end
|
|
136
147
|
end
|
|
@@ -160,7 +171,9 @@ Escort::App.create do |app|
|
|
|
160
171
|
|
|
161
172
|
command.action do |options, arguments|
|
|
162
173
|
PDQTest::Core.run(lambda {
|
|
163
|
-
|
|
174
|
+
PDQTest::Docker::IMAGES.each { |key, image|
|
|
175
|
+
system("docker pull #{image}")
|
|
176
|
+
}
|
|
164
177
|
})
|
|
165
178
|
end
|
|
166
179
|
end
|
data/lib/pdqtest/docker.rb
CHANGED
|
@@ -6,7 +6,10 @@ module PDQTest
|
|
|
6
6
|
ERR = 1
|
|
7
7
|
STATUS = 2
|
|
8
8
|
ENV='export TERM=xterm LC_ALL=C PATH=/usr/local/bats/bin:/opt/puppetlabs/puppet/bin:$PATH;'
|
|
9
|
-
|
|
9
|
+
IMAGES = {
|
|
10
|
+
:DEFAULT => 'geoffwilliams/pdqtest-centos:2017-09-19-0',
|
|
11
|
+
:UBUNTU => 'geoffwilliams/pdqtest-ubuntu:2017-09-18-0',
|
|
12
|
+
}
|
|
10
13
|
HIERA_YAML_CONTAINER = '/etc/puppetlabs/puppet/hiera.yaml'
|
|
11
14
|
HIERA_YAML_HOST = '/spec/fixtures/hiera.yaml'
|
|
12
15
|
HIERA_DIR = '/spec/fixtures/hieradata'
|
|
@@ -21,7 +24,34 @@ module PDQTest
|
|
|
21
24
|
container.exec(wrap_cmd(cmd), tty: true)
|
|
22
25
|
end
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
# detect the image to use based on metadata.json
|
|
28
|
+
def self.acceptance_test_images()
|
|
29
|
+
supported_images = [IMAGES[:DEFAULT]]
|
|
30
|
+
os_hash = Puppet::module_metadata['operatingsystem_support'] || {}
|
|
31
|
+
# returns a hash that looks like this (if non-empty):
|
|
32
|
+
# [
|
|
33
|
+
# {
|
|
34
|
+
# "operatingsystem": "RedHat",
|
|
35
|
+
# "operatingsystemrelease": [
|
|
36
|
+
# "6",
|
|
37
|
+
# "7"
|
|
38
|
+
# ]
|
|
39
|
+
# },
|
|
40
|
+
# ]
|
|
41
|
+
# We will map this list of OSs to the simple list of docker images we
|
|
42
|
+
# supply
|
|
43
|
+
os_hash.each { |os|
|
|
44
|
+
case os["operatingsystem"].downcase
|
|
45
|
+
when "ubuntu"
|
|
46
|
+
supported_images << IMAGES[:UBUNTU]
|
|
47
|
+
when "windows"
|
|
48
|
+
Escort::Logger.output.puts "Windows acceptance testing not supported yet... any ideas?"
|
|
49
|
+
end
|
|
50
|
+
}
|
|
51
|
+
supported_images.uniq
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.new_container(test_dir, image_name)
|
|
25
55
|
pwd = Dir.pwd
|
|
26
56
|
hiera_yaml_host = File.join(pwd, HIERA_YAML_HOST)
|
|
27
57
|
hiera_dir = File.join(pwd, HIERA_DIR)
|
|
@@ -46,7 +76,7 @@ module PDQTest
|
|
|
46
76
|
File.write(hiera_yaml_host, '# hiera configuration for testing')
|
|
47
77
|
end
|
|
48
78
|
container = ::Docker::Container.create(
|
|
49
|
-
'Image' =>
|
|
79
|
+
'Image' => image_name,
|
|
50
80
|
'Volumes' => {
|
|
51
81
|
test_dir => {pwd => 'rw'},
|
|
52
82
|
HIERA_YAML_CONTAINER => {hiera_yaml_host => 'rw'},
|
data/lib/pdqtest/instance.rb
CHANGED
|
@@ -8,6 +8,7 @@ module PDQTest
|
|
|
8
8
|
TEST_DIR='/testcase'
|
|
9
9
|
@@keep_container = false
|
|
10
10
|
@@active_container = nil
|
|
11
|
+
@@image_name = false
|
|
11
12
|
|
|
12
13
|
def self.get_active_container
|
|
13
14
|
@@active_container
|
|
@@ -21,36 +22,57 @@ module PDQTest
|
|
|
21
22
|
@@keep_container = keep_container
|
|
22
23
|
end
|
|
23
24
|
|
|
25
|
+
def self.set_docker_image(image_name)
|
|
26
|
+
@@image_name =
|
|
27
|
+
if image_name
|
|
28
|
+
Array(image_name.split(/,/))
|
|
29
|
+
else
|
|
30
|
+
false
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
24
34
|
def self.run(example=nil)
|
|
25
35
|
# needed to prevent timeouts from container.exec()
|
|
26
36
|
Excon.defaults[:write_timeout] = 10000
|
|
27
37
|
Excon.defaults[:read_timeout] = 10000
|
|
38
|
+
status = true
|
|
28
39
|
|
|
29
40
|
# remove reference to any previous test container
|
|
30
41
|
@@active_container = nil
|
|
31
42
|
|
|
32
43
|
if PDQTest::Puppet::find_examples().empty?
|
|
33
44
|
Escort::Logger.output.puts "No acceptance tests found, annotate examples with #{PDQTest::Puppet::MAGIC_MARKER} to make some"
|
|
34
|
-
status = true
|
|
35
45
|
else
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
# process each supported OS
|
|
47
|
+
test_platforms = @@image_name || Docker::acceptance_test_images
|
|
48
|
+
Escort::Logger.output.puts "Acceptance test on #{test_platforms}..."
|
|
49
|
+
test_platforms.each { |image_name|
|
|
50
|
+
Escort::Logger.output.puts "--- start test with #{image_name} ---"
|
|
51
|
+
@@active_container = PDQTest::Docker::new_container(TEST_DIR, image_name)
|
|
52
|
+
Escort::Logger.output.puts "alive, running tests"
|
|
53
|
+
status &= PDQTest::Puppet.run(@@active_container, example)
|
|
39
54
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
if @@keep_container
|
|
56
|
+
Escort::Logger.output.puts "finished build, container #{@@active_container.id} left on system"
|
|
57
|
+
Escort::Logger.output.puts " docker exec -ti #{@@active_container.id} bash "
|
|
58
|
+
else
|
|
44
59
|
PDQTest::Docker.cleanup_container(@@active_container)
|
|
45
60
|
@@active_container = nil
|
|
46
|
-
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
Escort::Logger.output.puts "--- end test with #{image_name} (status: #{status})---"
|
|
64
|
+
}
|
|
47
65
|
end
|
|
48
|
-
Escort::Logger.output.puts "
|
|
66
|
+
Escort::Logger.output.puts "overall acceptance test status=#{status}"
|
|
49
67
|
status
|
|
50
68
|
end
|
|
51
69
|
|
|
52
70
|
def self.shell
|
|
53
|
-
|
|
71
|
+
# pick the first test platform to test on as our shell - want to do a specific one
|
|
72
|
+
# just list it with --image-name
|
|
73
|
+
image_name = (@@image_name || Docker::acceptance_test_images).first
|
|
74
|
+
Escort::Logger.output.puts "Opening a shell in #{image_name}"
|
|
75
|
+
@@active_container = PDQTest::Docker::new_container(TEST_DIR, image_name)
|
|
54
76
|
|
|
55
77
|
# In theory I should be able to get something like the code below to
|
|
56
78
|
# redirect all input streams and give a makeshift interactive shell, howeve
|
data/lib/pdqtest/puppet.rb
CHANGED
|
@@ -47,6 +47,10 @@ module PDQTest
|
|
|
47
47
|
module_metadata['name'].split(/[\/-]/)[1]
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
+
def self.os_support
|
|
51
|
+
module_metadata['operatingsystem_support'] || []
|
|
52
|
+
end
|
|
53
|
+
|
|
50
54
|
def self.link_module
|
|
51
55
|
"test -e #{MODULE_DIR} || mkdir -p #{MODULE_DIR} && ln -s #{PDQTest::Instance::TEST_DIR} #{MODULE_DIR}/#{module_name}"
|
|
52
56
|
end
|
data/lib/pdqtest/version.rb
CHANGED
data/pdqtest.gemspec
CHANGED
|
@@ -22,17 +22,16 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
23
|
spec.require_paths = ["lib"]
|
|
24
24
|
|
|
25
|
-
spec.add_development_dependency "bundler", "1.15
|
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
|
26
26
|
spec.add_development_dependency "coveralls", "0.8.21"
|
|
27
27
|
spec.add_development_dependency "fakefs", "0.11.0"
|
|
28
|
-
spec.add_development_dependency "puppet", "4.8
|
|
28
|
+
spec.add_development_dependency "puppet", "4.10.8"
|
|
29
29
|
|
|
30
30
|
spec.add_runtime_dependency "rake", "12.0.0"
|
|
31
31
|
spec.add_runtime_dependency "rspec", "3.5.0"
|
|
32
|
-
spec.add_runtime_dependency "thor", "0.
|
|
32
|
+
spec.add_runtime_dependency "thor", "0.19.4"
|
|
33
33
|
spec.add_runtime_dependency "minitar", "0.6.1"
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
spec.add_runtime_dependency "hiera", "3.4.0"
|
|
36
35
|
spec.add_runtime_dependency "escort", "0.4.0"
|
|
37
36
|
spec.add_runtime_dependency "docker-api", "1.33.1"
|
|
38
37
|
spec.add_runtime_dependency "puppet-lint", "2.1.0"
|
data/res/skeleton/Gemfile
CHANGED
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pdqtest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Geoff Williams
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-09-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- -
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 1.15
|
|
19
|
+
version: '1.15'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- -
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 1.15
|
|
26
|
+
version: '1.15'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: coveralls
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - '='
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 4.8
|
|
61
|
+
version: 4.10.8
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - '='
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 4.8
|
|
68
|
+
version: 4.10.8
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rake
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,14 +100,14 @@ dependencies:
|
|
|
100
100
|
requirements:
|
|
101
101
|
- - '='
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version:
|
|
103
|
+
version: 0.19.4
|
|
104
104
|
type: :runtime
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - '='
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version:
|
|
110
|
+
version: 0.19.4
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
112
|
name: minitar
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -122,6 +122,20 @@ dependencies:
|
|
|
122
122
|
- - '='
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
124
|
version: 0.6.1
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: hiera
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - '='
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: 3.4.0
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - '='
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: 3.4.0
|
|
125
139
|
- !ruby/object:Gem::Dependency
|
|
126
140
|
name: escort
|
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -246,6 +260,7 @@ files:
|
|
|
246
260
|
- ".rspec"
|
|
247
261
|
- ".travis.yml"
|
|
248
262
|
- Gemfile
|
|
263
|
+
- Gemfile.lock
|
|
249
264
|
- LICENSE
|
|
250
265
|
- README.md
|
|
251
266
|
- Rakefile
|
|
@@ -253,7 +268,9 @@ files:
|
|
|
253
268
|
- bin/setup
|
|
254
269
|
- doc/acceptance_tests.md
|
|
255
270
|
- doc/caching.md
|
|
271
|
+
- doc/demo.gif
|
|
256
272
|
- doc/development.md
|
|
273
|
+
- doc/emoji.md
|
|
257
274
|
- doc/enabling_testing.md
|
|
258
275
|
- doc/examples.md
|
|
259
276
|
- doc/hiera.md
|
|
@@ -267,6 +284,8 @@ files:
|
|
|
267
284
|
- doc/upgrading.md
|
|
268
285
|
- docker_images/centos/Dockerfile
|
|
269
286
|
- docker_images/centos/Makefile
|
|
287
|
+
- docker_images/ubuntu/Dockerfile
|
|
288
|
+
- docker_images/ubuntu/Makefile
|
|
270
289
|
- exe/pdqtest
|
|
271
290
|
- lib/pdqtest.rb
|
|
272
291
|
- lib/pdqtest/core.rb
|