pdqtest 1.4.1 → 1.9.9beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -3
- data/doc/acceptance_tests.md +100 -22
- data/doc/caching.md +5 -1
- data/doc/development.md +16 -5
- data/doc/emoji.md +20 -9
- data/doc/enabling_testing.md +15 -3
- data/doc/examples.md +25 -6
- data/doc/hiera.md +30 -11
- data/doc/installation.md +59 -8
- data/doc/pdk.md +334 -0
- data/doc/puppet_facts.md +45 -3
- data/doc/puppet_module_dependencies.md +34 -16
- data/doc/running_tests.md +35 -15
- data/doc/test_generation.md +11 -19
- data/doc/tips_and_tricks.md +17 -8
- data/doc/troubleshooting.md +19 -8
- data/doc/upgrading.md +125 -6
- data/doc/windows.md +51 -0
- data/docker_images/centos/Dockerfile +4 -3
- data/docker_images/centos/Makefile +1 -1
- data/docker_images/ubuntu/Dockerfile +3 -3
- data/docker_images/windows/Dockerfile +26 -0
- data/docker_images/windows/make.ps1 +2 -0
- data/exe/pdqtest +73 -28
- data/lib/pdqtest/core.rb +1 -1
- data/lib/pdqtest/docker.rb +143 -51
- data/lib/pdqtest/emoji.rb +33 -7
- data/lib/pdqtest/fastcheck.rb +19 -0
- data/lib/pdqtest/instance.rb +16 -15
- data/lib/pdqtest/logger.rb +35 -0
- data/lib/pdqtest/pdk.rb +98 -0
- data/lib/pdqtest/pdqtest1x.rb +115 -0
- data/lib/pdqtest/puppet.rb +277 -134
- data/lib/pdqtest/skeleton.rb +119 -39
- data/lib/pdqtest/upgrade.rb +42 -42
- data/lib/pdqtest/util.rb +82 -2
- data/lib/pdqtest/version.rb +1 -2
- data/pdqtest.gemspec +8 -13
- data/res/{skeleton → acceptance}/init.bats +0 -0
- data/res/{skeleton → acceptance}/init__before.bats +0 -0
- data/res/{skeleton → acceptance}/init__setup.sh +0 -0
- data/res/skeleton/.puppet-lint.rc +5 -0
- data/res/skeleton/{dot_travis.yml → .travis.yml} +0 -0
- data/res/skeleton/Makefile +20 -5
- data/res/skeleton/make.ps1 +66 -0
- data/res/skeleton/spec/fixtures/hiera.yaml +13 -0
- data/res/skeleton/spec/fixtures/hieradata/test.yaml +11 -0
- data/res/templates/examples_init.pp.erb +1 -1
- metadata +47 -115
- data/lib/pdqtest/lint.rb +0 -31
- data/lib/pdqtest/rspec.rb +0 -69
- data/lib/pdqtest/syntax.rb +0 -20
- data/res/skeleton/Gemfile +0 -7
- data/res/skeleton/Rakefile +0 -3
- data/res/skeleton/dot_gitignore +0 -9
- data/res/skeleton/dot_rspec +0 -2
- data/res/skeleton/hiera.yaml +0 -7
- data/res/skeleton/spec_helper.rb +0 -4
- data/res/skeleton/test.yaml +0 -3
data/doc/upgrading.md
CHANGED
@@ -5,18 +5,23 @@ To upgrade the current version of PDQTest on your system:
|
|
5
5
|
gem update pdqtest
|
6
6
|
```
|
7
7
|
|
8
|
-
Each project you want to use the newer version of PDQTest on should then have
|
8
|
+
Each project you want to use the newer version of PDQTest on should then have
|
9
|
+
it's `Gemfile.project` updated to reference the latest version. Don't worry,
|
10
|
+
this is easy:
|
9
11
|
|
10
12
|
```shell
|
11
13
|
cd /my/cool/project/to/upgrade
|
12
14
|
pdqtest upgrade
|
13
|
-
bundle install
|
15
|
+
pdk bundle install
|
14
16
|
```
|
15
17
|
|
16
|
-
Note that since we're using bundler, you only have to upgrade the
|
18
|
+
Note that since we're using bundler, you only have to upgrade the puppet modules
|
19
|
+
you want to upgrade. Existing modules can continue to run any previous version
|
20
|
+
via `make` just fine. You are not forced to update all your modules in one go.
|
17
21
|
|
18
22
|
## Docker image
|
19
|
-
|
23
|
+
Updated docker images are periodically released and are required to run newer
|
24
|
+
PDQTest versions. When you get a message about missing docker containers run:
|
20
25
|
|
21
26
|
```shell
|
22
27
|
pdqtest setup
|
@@ -24,5 +29,119 @@ pdqtest setup
|
|
24
29
|
|
25
30
|
To obtain the latest version.
|
26
31
|
|
27
|
-
|
28
|
-
|
32
|
+
# PDQTest 1x -> 2x
|
33
|
+
PDQTest is now compatible with (and requires) PDK! By and large we let PDK do
|
34
|
+
its own thing and just wrap the output with emojis and run our own acceptance
|
35
|
+
tests.
|
36
|
+
|
37
|
+
See [PDK Integration](pdk.md) for details of how this works.
|
38
|
+
|
39
|
+
Since this is a major upgrade, you must re-init your project. Make sure all your
|
40
|
+
code is checked in to git,
|
41
|
+
[install PDK](https://puppet.com/docs/pdk/1.x/pdk_install.html) then run:
|
42
|
+
|
43
|
+
```shell
|
44
|
+
gem install pdqtest
|
45
|
+
cd /my/project
|
46
|
+
pdqtest init
|
47
|
+
pdk bundle install
|
48
|
+
bundle exec pdqtest setup
|
49
|
+
```
|
50
|
+
|
51
|
+
## Custom facts
|
52
|
+
If you were previous using custom facts in the `spec/merge_facts` directory,
|
53
|
+
these need to be converted to yaml and moved to `spec/default_facts.yml`. This
|
54
|
+
will give you compatibility between PDK unit tests and PDQTest acceptance tests.
|
55
|
+
|
56
|
+
## RSpec tests (inc hiera data)
|
57
|
+
PDQTest doesn't deal with RSPec tests any more, we let PDK do all the work by
|
58
|
+
shelling out to call `pdk test unit`:
|
59
|
+
|
60
|
+
* If you were using PDQTest for your hiera data during the RSpec lifecycle,
|
61
|
+
update your tests to do what PDK tells you to do
|
62
|
+
* Existing `spec/fixtures/hiera.yaml` and `spec/fixtures/test.yaml` files will
|
63
|
+
continue to work during acceptance tests and the `hiera.yaml` file has been
|
64
|
+
upgraded for hiera 5 compatibility. You will have to reconfigure your
|
65
|
+
hierarchy if you were using more files then just `test.yaml`
|
66
|
+
|
67
|
+
Old PDQTest generated RSpec tests will fail due to missing dependency on
|
68
|
+
[puppet_factset](https://rubygems.org/gems/puppet_factset) gem which is now no
|
69
|
+
longer required (by anything 😁).
|
70
|
+
|
71
|
+
You can enable this gem in PDK by adding it to `Gemfile.project` and running
|
72
|
+
`pdk bundle install` or you can just rewrite your tests using the new PDK format
|
73
|
+
which looks like this:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
require 'spec_helper'
|
77
|
+
|
78
|
+
describe 'CHANGETHISTOYOURCLASSNAME' do
|
79
|
+
on_supported_os.each do |os, os_facts|
|
80
|
+
context "on #{os}" do
|
81
|
+
let(:facts) { os_facts }
|
82
|
+
|
83
|
+
it { is_expected.to compile }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
```
|
88
|
+
|
89
|
+
If your in a hurry and have good acceptance tests, another quick fix would be to
|
90
|
+
just delete the RSpec tests and rely purely on real-world testing. You will miss
|
91
|
+
fast-failure due to invalid puppet code if you do this though, since we have to
|
92
|
+
launch a container and run puppet to see if your code compiles.
|
93
|
+
|
94
|
+
You can use PDK to generate these tests, see the PDK manual for details of how.
|
95
|
+
|
96
|
+
## `/.fixtures.yml` and `/fixtures.yml`
|
97
|
+
`/.fixtures.yml` is back in PDQTest 2.0 (it's presence was an error in PDQTest
|
98
|
+
1.x) and `/fixtures.yaml` is no longer used.
|
99
|
+
|
100
|
+
If you would like to use test fixtures from git, add them to `.fixtures.yml` and
|
101
|
+
you can continue to use them as before. The rest of the file is generated for
|
102
|
+
you automatically based on `metadata.json` to support integration with PDK.
|
103
|
+
|
104
|
+
[More info on dependencies](puppet_module_dependencies.md)
|
105
|
+
|
106
|
+
## Old PDQtest 1x integration points
|
107
|
+
* `/spec/spec_helper.rb`
|
108
|
+
* `/Gemfile`
|
109
|
+
* `/Rakefile`
|
110
|
+
* `/.rspec`
|
111
|
+
We will do our best to detect any previous PDQTest generated versions of these
|
112
|
+
files. If known versions are found, we will upgrade you to the PDK version. If
|
113
|
+
an unknown file is found we will stop and ask you to move it out of the way
|
114
|
+
first. PDK will be responsible for these files now-on.
|
115
|
+
|
116
|
+
### How to resolve `unknown/modified file` errors during upgrade
|
117
|
+
1. Move your existing file out of the way
|
118
|
+
2. Run `pdqtest init`
|
119
|
+
3. See per-file upgrade notes below
|
120
|
+
|
121
|
+
#### `/Gemfile`
|
122
|
+
Add any custom gems/`Gemfile` magic to `gemfile.project` and it will be evaluated
|
123
|
+
during `pdk bundle install`
|
124
|
+
|
125
|
+
### PDK Managed files
|
126
|
+
PDK regenerates files it manages you run `pdk update`. To customise these files
|
127
|
+
and have your changes persist between updates, you need to add them to
|
128
|
+
`.sync.yml` which allows you to override _some_ settings in the
|
129
|
+
[PDK default templates](https://github.com/puppetlabs/pdk-templates/).
|
130
|
+
|
131
|
+
If the templates don't support the customisation you want, the advice from
|
132
|
+
Puppet is to fork and customise that repository, then configure PDK to use it.
|
133
|
+
|
134
|
+
Consult the PDK documentation for instructions on how to do this.
|
135
|
+
|
136
|
+
## `/Gemfile.project`
|
137
|
+
New file used for configuring which PDQTest gem to use (replaces customisation
|
138
|
+
of `Gemfile`)
|
139
|
+
|
140
|
+
## `/.gitignore`
|
141
|
+
We no longer install or manage `.gitignore` for you and we don't upgrade it
|
142
|
+
either. PDK ships a default version and we use that if the initial file is
|
143
|
+
missing.
|
144
|
+
|
145
|
+
## `/cut` mountpoint
|
146
|
+
Previous versions of PDQTest mounted code at `/cut` (Code Under Test), the new
|
147
|
+
mountpoint is the more obvious `/testcase` and `/cut` no longer works.
|
data/doc/windows.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Windows
|
2
|
+
PDQTest now supports windows! There are a few gotchas though:
|
3
|
+
|
4
|
+
* The docker volume doesn't play nice with puppet/ruby: Whole app breaks if
|
5
|
+
`/lib` directory present, so we have to _copy_ the files into the container
|
6
|
+
this is of course very slow. You must run `refresh.ps1` inside the container
|
7
|
+
to refresh the files if your doing TDD on your main workstation.
|
8
|
+
* You must run PDQTest from `powershell.exe` and NOT `PowerShell ISE` or you
|
9
|
+
encounter [PDK-1168](https://tickets.puppetlabs.com/browse/PDK-1168)
|
10
|
+
* Keep an eye on how many windows containers are running `docker ps` - things
|
11
|
+
seem to choke up if you have more then a handful
|
12
|
+
* You **must** develop your modules on your **guest** filesystem (eg not at
|
13
|
+
`c:\vagrant` if your running windows 10 in a VM on linux):
|
14
|
+
[PDK-1169](https://tickets.puppetlabs.com/browse/PDK-1169)
|
15
|
+
|
16
|
+
## FAQ
|
17
|
+
Q: How do I just get a shell inside my container?
|
18
|
+
|
19
|
+
A:
|
20
|
+
```shell
|
21
|
+
.\make shellnopuppet
|
22
|
+
```
|
23
|
+
|
24
|
+
Q: How do I see GUI apps that are running in my container?
|
25
|
+
|
26
|
+
A: Beats me. Maybe there's a way to do something with RDP? The idea of windows
|
27
|
+
containers seems to be to run CLI applications/services and interact with them
|
28
|
+
through powershell or over the network. If anyone has a better answer let me
|
29
|
+
know
|
30
|
+
|
31
|
+
Q: what's going on with `.bat` files?
|
32
|
+
|
33
|
+
A:They seem to work but you need to pass the full filename to docker run, eg:
|
34
|
+
|
35
|
+
```shell
|
36
|
+
docker exec XXX foo.bat
|
37
|
+
```
|
38
|
+
|
39
|
+
not
|
40
|
+
|
41
|
+
```shell
|
42
|
+
docker exec XXX foo
|
43
|
+
```
|
44
|
+
_where XXX is the ID of your container. Use `docker ps` to get a listing.
|
45
|
+
|
46
|
+
Q: My module refuses to be found or work! (class not found...)
|
47
|
+
|
48
|
+
A: Beats me.. This came up during testing but I haven't investigated further.
|
49
|
+
Make sure you have a `depenedencies` section in `metadata.json` even if its
|
50
|
+
empty or puppet seems to break (unverified)
|
51
|
+
|
@@ -24,6 +24,7 @@ RUN yum install -y cronie \
|
|
24
24
|
gpm-libs \
|
25
25
|
policycoreutils \
|
26
26
|
policycoreutils-restorecond && yum clean all
|
27
|
+
RUN echo "metadata_expire=never" >> /etc/yum.conf
|
27
28
|
|
28
29
|
# fix locale
|
29
30
|
RUN echo 'LANG=en_US.UTF-8' > /etc/locale.conf
|
@@ -48,12 +49,12 @@ RUN git clone https://github.com/bats-core/bats-core /usr/local/bats
|
|
48
49
|
# r10k
|
49
50
|
RUN /opt/puppetlabs/puppet/bin/gem install r10k
|
50
51
|
|
51
|
-
# git refresh (for processing .fixtures.yml git modules)
|
52
|
-
RUN /opt/puppetlabs/puppet/bin/gem install git_refresh
|
53
|
-
|
54
52
|
# testcase (our module)
|
55
53
|
RUN mkdir /testcase
|
56
54
|
VOLUME /testcase
|
57
55
|
|
56
|
+
# hiera
|
57
|
+
RUN mkdir -p /spec/fixtures/
|
58
|
+
|
58
59
|
# alternate shudown for systemd
|
59
60
|
STOPSIGNAL SIGRTMIN+3
|
@@ -1,3 +1,3 @@
|
|
1
1
|
all:
|
2
2
|
# requires experimental mode - see https://github.com/docker/docker/tree/master/experimental#use-docker-experimental
|
3
|
-
bash -c 'docker build --squash -t declarativesystems/pdqtest-
|
3
|
+
bash -c 'docker build --squash -t declarativesystems/pdqtest-centos:$$(date -I)-0 .'
|
@@ -53,12 +53,12 @@ RUN git clone https://github.com/bats-core/bats-core /usr/local/bats
|
|
53
53
|
# librarian
|
54
54
|
RUN /opt/puppetlabs/puppet/bin/gem install r10k
|
55
55
|
|
56
|
-
# git refresh (for processing .fixtures.yml git modules)
|
57
|
-
RUN /opt/puppetlabs/puppet/bin/gem install git_refresh
|
58
|
-
|
59
56
|
# testcase (our module)
|
60
57
|
RUN mkdir /testcase
|
61
58
|
VOLUME /testcase
|
62
59
|
|
60
|
+
# hiera
|
61
|
+
RUN mkdir -p /spec/fixtures/
|
62
|
+
|
63
63
|
# alternate shudown for systemd
|
64
64
|
STOPSIGNAL SIGRTMIN+3
|
@@ -0,0 +1,26 @@
|
|
1
|
+
FROM microsoft/windowsservercore
|
2
|
+
|
3
|
+
RUN powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://pm.puppet.com/puppet-agent/2018.1.4/5.5.6/repos/windows/puppet-agent-5.5.6-x64.msi', 'c:\puppet_agent.msi') }"
|
4
|
+
RUN msiexec /qn /norestart /i c:\puppet_agent.msi
|
5
|
+
RUN mkdir C:\testcase
|
6
|
+
RUN mkdir C:\spec
|
7
|
+
RUN mkdir C:\spec\fixtures
|
8
|
+
RUN mkdir C:\spec\fixtures\hieradata
|
9
|
+
|
10
|
+
|
11
|
+
VOLUME C:\\testcase
|
12
|
+
|
13
|
+
# the path from "command prompt with puppet"
|
14
|
+
ENV PATH="C:\Program Files\Puppet Labs\Puppet\puppet\bin;C:\Program Files\Puppet Labs\Puppet\facter\bin;C:\Program Files\Puppet Labs\Puppet\hiera\bin;C:\Program Files\Puppet Labs\Puppet\mcollective\bin;C:\Program Files\Puppet Labs\Puppet\bin;C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin;C:\Program Files\Puppet Labs\Puppet\sys\tools\bin;C:\Program Files\Docker\Docker\Resources\bin;C:\tools\ruby25\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\Puppet Labs\Puppet\bin;c:\windows:\c:\windows\system32;C:\Program Files (x86)\vim\vim80"
|
15
|
+
|
16
|
+
# install chocolatey
|
17
|
+
RUN @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
|
18
|
+
|
19
|
+
RUN choco install vim git /y
|
20
|
+
RUN git clone https://github.com/declarativesystems/pats c:\pats
|
21
|
+
RUN copy c:\pats\pats.ps1 c:\windows
|
22
|
+
|
23
|
+
|
24
|
+
# we dont have systemd/sysvinit on windows so just use notepad to keep the
|
25
|
+
# container open (nasty hack)
|
26
|
+
ENTRYPOINT notepad
|
data/exe/pdqtest
CHANGED
@@ -11,18 +11,21 @@ end
|
|
11
11
|
require 'pdqtest'
|
12
12
|
require 'pdqtest/emoji'
|
13
13
|
require 'pdqtest/instance'
|
14
|
-
require 'pdqtest/rspec'
|
15
14
|
require 'pdqtest/util'
|
16
15
|
require 'pdqtest/skeleton'
|
17
|
-
require 'pdqtest/lint'
|
18
|
-
require 'pdqtest/syntax'
|
19
16
|
require 'pdqtest/core'
|
20
17
|
require 'pdqtest/upgrade'
|
18
|
+
require 'pdqtest/pdk'
|
21
19
|
require 'escort'
|
20
|
+
require 'pdqtest/logger'
|
21
|
+
require 'pdqtest/fastcheck'
|
22
22
|
|
23
23
|
# display help if nothing specified
|
24
24
|
ARGV.push('-h') if ARGV.empty?
|
25
25
|
|
26
|
+
# Setup our own hacky logger
|
27
|
+
|
28
|
+
|
26
29
|
Escort::App.create do |app|
|
27
30
|
app.version PDQTest::VERSION
|
28
31
|
app.summary "pdqtest"
|
@@ -64,12 +67,21 @@ Escort::App.create do |app|
|
|
64
67
|
:default => false,
|
65
68
|
)
|
66
69
|
|
70
|
+
opts.opt(:debug,
|
71
|
+
'Extra debug messages (also needs --verbosity debug for stack traces)',
|
72
|
+
:long => '--debug',
|
73
|
+
:type => :boolean,
|
74
|
+
:default => false,
|
75
|
+
)
|
67
76
|
end
|
68
77
|
|
69
78
|
app.command :all do |command|
|
70
79
|
command.summary "All"
|
71
80
|
command.description "Run all tests"
|
72
81
|
command.action do |options, arguments|
|
82
|
+
PDQTest::Logger.logger
|
83
|
+
$logger.level = :debug if options[:global][:options][:debug]
|
84
|
+
|
73
85
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
74
86
|
PDQTest::Puppet.skip_second_run(options[:global][:options][:skip_idempotency])
|
75
87
|
|
@@ -78,20 +90,48 @@ Escort::App.create do |app|
|
|
78
90
|
PDQTest::Instance.set_docker_image(options[:global][:options][:image_name])
|
79
91
|
|
80
92
|
PDQTest::Core.run([
|
81
|
-
lambda {PDQTest::
|
82
|
-
lambda {PDQTest::
|
83
|
-
lambda {PDQTest::
|
93
|
+
lambda {PDQTest::Pdk.run("validate 'metadata,puppet'")},
|
94
|
+
lambda {PDQTest::Puppet.install_modules},
|
95
|
+
lambda {PDQTest::Pdk.run("test unit")},
|
84
96
|
lambda {PDQTest::Instance.run},
|
97
|
+
lambda {system("bundle exec puppet strings generate --format=markdown")},
|
98
|
+
lambda {PDQTest::Pdk.run("build --force")},
|
99
|
+
])
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
app.command :fast do |command|
|
104
|
+
command.summary "Fast"
|
105
|
+
command.description "Run basic lint/syntax and acceptance tests (skips rspec)"
|
106
|
+
command.action do |options, arguments|
|
107
|
+
PDQTest::Logger.logger
|
108
|
+
$logger.level = :debug if options[:global][:options][:debug]
|
109
|
+
|
110
|
+
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
111
|
+
PDQTest::Puppet.skip_second_run(options[:global][:options][:skip_idempotency])
|
112
|
+
|
113
|
+
PDQTest::Instance.set_privileged(options[:global][:options][:privileged])
|
114
|
+
PDQTest::Instance.set_keep_container(options[:global][:options][:keep_container])
|
115
|
+
PDQTest::Instance.set_docker_image(options[:global][:options][:image_name])
|
116
|
+
|
117
|
+
PDQTest::Core.run([
|
118
|
+
lambda {PDQTest::Fastcheck.run},
|
119
|
+
lambda {PDQTest::Puppet.install_modules},
|
120
|
+
lambda {PDQTest::Instance.run},
|
121
|
+
lambda {system("bundle exec puppet strings generate --format=markdown")},
|
85
122
|
])
|
86
123
|
end
|
87
124
|
end
|
88
125
|
|
89
126
|
app.command :rspec do |command|
|
90
127
|
command.summary "RSpec"
|
91
|
-
command.description "Run the RSpec tests"
|
128
|
+
command.description "Run the RSpec tests (`pdk test unit` with emojis)"
|
92
129
|
command.action do |options, arguments|
|
130
|
+
PDQTest::Logger.logger
|
131
|
+
$logger.level = :debug if options[:global][:options][:debug]
|
132
|
+
|
93
133
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
94
|
-
PDQTest::Core.run(lambda {PDQTest::
|
134
|
+
PDQTest::Core.run(lambda {PDQTest::Pdk.run("test unit")})
|
95
135
|
end
|
96
136
|
end
|
97
137
|
|
@@ -108,6 +148,9 @@ Escort::App.create do |app|
|
|
108
148
|
)
|
109
149
|
end
|
110
150
|
command.action do |options, arguments|
|
151
|
+
PDQTest::Logger.logger
|
152
|
+
$logger.level = :debug if options[:global][:options][:debug]
|
153
|
+
|
111
154
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
112
155
|
PDQTest::Puppet.skip_second_run(options[:global][:options][:skip_idempotency])
|
113
156
|
PDQTest::Instance.set_privileged(options[:global][:options][:privileged])
|
@@ -122,17 +165,11 @@ Escort::App.create do |app|
|
|
122
165
|
command.summary "Initialise testing"
|
123
166
|
command.description "Install skeleton testing configuration into this module"
|
124
167
|
command.action do |options, arguments|
|
125
|
-
PDQTest::
|
126
|
-
|
127
|
-
end
|
128
|
-
end
|
168
|
+
PDQTest::Logger.logger
|
169
|
+
$logger.level = :debug if options[:global][:options][:debug]
|
129
170
|
|
130
|
-
app.command :generate_rspec do |command|
|
131
|
-
command.summary "Generate RSpec"
|
132
|
-
command.description "For each class in the module, generate basic RSpec tests"
|
133
|
-
command.action do |options, arguments|
|
134
171
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
135
|
-
PDQTest::
|
172
|
+
PDQTest::Skeleton.init
|
136
173
|
end
|
137
174
|
end
|
138
175
|
|
@@ -148,6 +185,9 @@ Escort::App.create do |app|
|
|
148
185
|
)
|
149
186
|
end
|
150
187
|
command.action do |options, arguments|
|
188
|
+
PDQTest::Logger.logger
|
189
|
+
$logger.level = :debug if options[:global][:options][:debug]
|
190
|
+
|
151
191
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
152
192
|
example = options[:global][:commands][:generate_acceptance][:options][:example]
|
153
193
|
|
@@ -160,6 +200,9 @@ Escort::App.create do |app|
|
|
160
200
|
command.summary "Shell"
|
161
201
|
command.description "Open a shell inside a docker container identical to the test environment before anything has run"
|
162
202
|
command.action do |options, arguments|
|
203
|
+
PDQTest::Logger.logger
|
204
|
+
$logger.level = :debug if options[:global][:options][:debug]
|
205
|
+
|
163
206
|
PDQTest::Instance.set_docker_image(options[:global][:options][:image_name])
|
164
207
|
PDQTest::Instance.shell
|
165
208
|
end
|
@@ -167,20 +210,13 @@ Escort::App.create do |app|
|
|
167
210
|
|
168
211
|
app.command :syntax do |command|
|
169
212
|
command.summary "Syntax"
|
170
|
-
command.description "Check for syntax errors"
|
213
|
+
command.description "Check for syntax errors (`pdk validate metadata,puppet` with emojis)"
|
171
214
|
command.action do |options, arguments|
|
172
|
-
PDQTest::
|
173
|
-
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
app.command :lint do |command|
|
178
|
-
command.summary "Lint"
|
179
|
-
command.description "Check for lint errors"
|
215
|
+
PDQTest::Logger.logger
|
216
|
+
$logger.level = :debug if options[:global][:options][:debug]
|
180
217
|
|
181
|
-
command.action do |options, arguments|
|
182
218
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
183
|
-
PDQTest::Core.run(lambda {PDQTest::
|
219
|
+
PDQTest::Core.run(lambda {PDQTest::Pdk.run("validate 'metadata,puppet'")})
|
184
220
|
end
|
185
221
|
end
|
186
222
|
|
@@ -189,6 +225,9 @@ Escort::App.create do |app|
|
|
189
225
|
command.description "Install the docker container required for testing"
|
190
226
|
|
191
227
|
command.action do |options, arguments|
|
228
|
+
PDQTest::Logger.logger
|
229
|
+
$logger.level = :debug if options[:global][:options][:debug]
|
230
|
+
|
192
231
|
PDQTest::Core.run(lambda {
|
193
232
|
PDQTest::Docker::IMAGES.each { |key, image|
|
194
233
|
system("docker pull #{image}")
|
@@ -201,6 +240,9 @@ Escort::App.create do |app|
|
|
201
240
|
command.summary "Info"
|
202
241
|
command.description "Print info about this module"
|
203
242
|
command.action do |options, arguments|
|
243
|
+
PDQTest::Logger.logger
|
244
|
+
$logger.level = :debug if options[:global][:options][:debug]
|
245
|
+
|
204
246
|
PDQTest::Puppet.info
|
205
247
|
end
|
206
248
|
end
|
@@ -210,6 +252,9 @@ Escort::App.create do |app|
|
|
210
252
|
command.summary "Upgrade"
|
211
253
|
command.description "Upgrade the current module to use this version of PDQTest"
|
212
254
|
command.action do |options, arguments|
|
255
|
+
PDQTest::Logger.logger
|
256
|
+
$logger.level = :debug if options[:global][:options][:debug]
|
257
|
+
|
213
258
|
PDQTest::Upgrade.upgrade
|
214
259
|
end
|
215
260
|
end
|
data/lib/pdqtest/core.rb
CHANGED
@@ -8,7 +8,7 @@ module PDQTest
|
|
8
8
|
functions = Array(functions)
|
9
9
|
functions.each { |f|
|
10
10
|
if ! f.call
|
11
|
-
|
11
|
+
$logger.error "Error encountered running #{f.to_s}"
|
12
12
|
|
13
13
|
# epic fail, exit program
|
14
14
|
PDQTest::Emoji.final_status(false)
|