pdqtest 1.9.9beta7 → 1.9.9beta8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd42c9920bb14bf63ba6dc6d021cb5bc2cb336aca20b76dcb41f8c19a317e545
4
- data.tar.gz: 295dec7313f15b1e59348ea7e1106b8a03523ee5efe5bacb61b7a1df0e8e48bd
3
+ metadata.gz: 318a1841d2bcfda00c332734315ddf1278163cd50f3ce406463e400dad95bbb2
4
+ data.tar.gz: 1502c06caeea59ac008f102a14d4691e2ca0c9c4387dfc83fe0236d897e0fb6f
5
5
  SHA512:
6
- metadata.gz: a886738ec27f9f20017f4a42d224b7a2b1edc62e3e55f5e8e472850abe61219e57766793c130d872389e1250b2000cf7fc5f703e0ca99569250ab71efabb8516
7
- data.tar.gz: 62b42b4dc521d8f2d36937ef910bceb3fe193d6ddb866bbf11fe29ffc5f0c5d090123f33344cc73a77c1f59299260152377394d96a24681c0e5f86787554b9db
6
+ metadata.gz: e33f2c4d47f585819125cd74c0dbad0e38798c800df5aad2c1524c83d0687d86edfec2999cdb21db8fd6ad6e810f3b4fb56d13b30c84c064416c5a9091dc42b7
7
+ data.tar.gz: 9d8ba622a7c9b62e0b5946a444f2e3b1d1b34d76e82b857afb28439cb8a2c823a6c426ea41a51defddd3fdc650c5c9ef2409b2553375462b96c74eb5228d1349
data/README.md CHANGED
@@ -2,32 +2,53 @@
2
2
 
3
3
  # PDQTest
4
4
 
5
- PDQTest - Puppet Docker Quick-test - is the quickest and easiest way to test your puppet modules. PDQTest features tests for:
6
- * Linting
7
- * Syntax
8
- * RSpec
9
- * Acceptance ([BATS-core](https://github.com/bats-core/bats-core))
5
+ PDQTest - Puppet Docker Quick-test - is the quickest and easiest way to test
6
+ your puppet modules for Linux and Windows.
10
7
 
11
- And can generate code to retrofit testing to a new or existing module, along with skeleton RSpec and acceptance tests to get you started.
8
+ PDQTest features:
9
+ * Static analysis testing (PDK):
10
+ * Metadata
11
+ * Syntax
12
+ * Linting
13
+ * RSpec
14
+ * Acceptance testing for Linux and Windows:
15
+ * [BATS-core](https://github.com/bats-core/bats-core)
16
+ * [PATS](https://github.com/declarativesystems/pats) (Experimental)
12
17
 
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.
18
+ PDQTest acceptance tests can be retrofitted to and PDK enabled module by running
19
+ `pdqtest init`.
20
+
21
+ PDQTest runs static analysis tests within the machine it is running from and
22
+ then loads a docker container to perform acceptance testing, sharing the puppet
23
+ module and cached dependencies from your host.
24
+
25
+ This way you can destructively test your module without risking the host.
14
26
 
15
27
  ![demo](doc/demo.gif)
16
28
  _Adding PDQTest to a project and running acceptance tests in Docker_
17
29
 
30
+ ## PDQTest 2.0 Release notes
31
+ PDQTest 2.0 new features:
32
+ * [PDK Support](doc/pdk.md)
33
+ * [Windows support](doc/windows.md)
34
+ * [PDQTest 1.x -> 2.x Upgrade guide](doc/upgrade_1_2.md)
35
+
18
36
  ## PDQTest Manual
19
37
  1. [Installation](doc/installation.md)
20
38
  1. [Enabling testing](doc/enabling_testing.md)
21
39
  1. [Running tests](doc/running_tests.md)
22
- 1. [Test generation](doc/test_generation.md)
23
40
  1. [Acceptance tests](doc/acceptance_tests.md)
41
+ 1. [Windows](doc/windows.md)
42
+ 1. [PDK Integration](doc/pdk.md)
24
43
  1. [Puppet module dependencies](doc/puppet_module_dependencies.md)
44
+ 1. [Test generation](doc/test_generation.md)
25
45
  1. [Puppet facts](doc/puppet_facts.md)
26
46
  1. [Hiera](doc/hiera.md)
27
47
  1. [Caching](doc/caching.md)
28
- 1. [Upgrading](doc/upgrading.md)
29
48
  1. [Emoji](doc/emoji.md)
30
- 1. [Examples](doc/examples.md)
49
+ 1. [Upgrading](doc/upgrading.md)
31
50
  1. [Tips and tricks](doc/tips_and_tricks.md)
32
51
  1. [Troubleshooting](doc/troubleshooting.md)
52
+ 1. [Examples](doc/examples.md)
33
53
  1. [Development](doc/development.md)
54
+ 1. [PDQTest 1.x -> 2.x Upgrade guide](doc/upgrade_1_2.md)
@@ -1,14 +1,39 @@
1
1
  # Acceptance tests
2
- * Acceptance tests run within a Docker container managed by PDQTest
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
- * There are three supported docker images:
5
- * Centos 7
6
- * Ubuntu 16.04
7
- * Windows (microsoft/windowsservercore)
8
- * Centos is used by default
9
- * Ubuntu will be used if your `metadata.json` declares compatibility with Ubuntu
10
- * Windows will be used if your `metadata.json` declares compatibility with
11
- Windows
2
+ Acceptance tests run Puppet in apply mode inside a Docker container managed by
3
+ PDQTest.
4
+
5
+ The Docker container breaks all the rules of Docker and runs a full version of
6
+ Systemd to allow complete testing of Puppet code in the most portable way
7
+ to basically treat docker as a high speed VM... This is deliberate - PDQTest
8
+ exists to get results, not be a perfect Docker app.
9
+
10
+ There are three supported docker images:
11
+ * Centos 7
12
+ * Ubuntu 16.04
13
+ * Windows (microsoft/windowsservercore)
14
+
15
+ Centos is used by default, all other images are activated by the
16
+ `operatingsystem_support` element of `metadata.json`:
17
+
18
+ **Windows**
19
+ ```json
20
+ "operatingsystem_support": [
21
+ {
22
+ "operatingsystem": "windows"
23
+ }
24
+ ],
25
+ ```
26
+
27
+ **Ubuntu**
28
+ ```json
29
+ "operatingsystem_support": [
30
+ {
31
+ "operatingsystem": "Ubuntu"
32
+ },
33
+ ],
34
+ ```
35
+
36
+ Notes:
12
37
  * Centos is great for mocking systems like AIX... if you replace OS binaries as
13
38
  required in the `__setup.sh` scripts
14
39
  * If you have a specific container you want to use, pass `--image-name` on the
@@ -19,25 +44,25 @@
19
44
  [Debugging failed builds](#debugging-failed-builds)
20
45
  * See the [docker_images](../docker_images) folder for examples
21
46
 
22
- ### Test workflow
47
+ ## Test workflow
23
48
  1. Scan for all example files under `/examples`. Files must end in `.pp` and
24
49
  contain the magic marker `#@PDQTest` or `#@PDQTestWin` to be processed
25
50
  2. If example files are present, start the docker container
26
51
  3. For each example file:
27
52
  * Check for a file at `/spec/acceptance/EXAMPLE_NAME__setup.(sh|ps1)`, If it
28
53
  exists, run it inside the container. This is a useful place to install
29
- preqrequisites, edit files, install mock services, clean up after other
30
- tests, etc.
54
+ preqrequisites, edit files, install mock services, replace OS binaries,
55
+ clean up after other tests, etc.
31
56
  * Check for a file at `/spec/acceptance/EXAMPLE_NAME__before.(bats|pats)`, If
32
57
  it exists run BATS or PATS against it. This is normally used to check the
33
58
  system state is clean or that any test prerequisites have been setup
34
- correctly
59
+ correctly (most of the time you can skip this)
35
60
  * Run `puppet apply` on the example file twice (to check idempotency)
36
61
  * Check for a file at `/spec/acceptance/EXAMPLE_NAME.(bats|pats)`, If it
37
- exists run BATS against it. This is normally used to check the state of the
38
- system after running puppet. You can do things like check services are
39
- running, check files edited correctly, or basically anything that you can
40
- write in bash!
62
+ exists run BATS/PATS against it. This is normally used to check the state
63
+ of the system after running puppet. You can do things like check services
64
+ are running, check files edited correctly, or basically anything that you
65
+ can write in bash (or PowerShell)!
41
66
  4. Destroy the container unless we were asked to keep it with `--keep-container`
42
67
 
43
68
  Note: `EXAMPLE_NAME` is the example filename minus the directory and `.pp`, eg
@@ -55,7 +80,7 @@ the `EXAMPLE_NAME` for `examples/foo.pp` would just be `foo`.
55
80
  ### BATS tests
56
81
  If you've never seen a [BATS](https://github.com/bats-core/bats-core) test
57
82
  before and have previously been writing server spec code, you'll probably kick
58
- youself when you see how simple they are.
83
+ yourself when you see how simple they are.
59
84
 
60
85
  BATS lets you run tests anywhere you can run BASH.
61
86
 
@@ -113,14 +138,15 @@ At present you would need to run `pdqtest` twice - once in a Windows environment
113
138
  and again in Linux.
114
139
 
115
140
  This is because Docker doesn't let us run Windows and Linux on the same platform
116
- at the same time (Because it's not magic...).
141
+ at the same time (Because it's not magic... Actually newer Docker versions do
142
+ support this on Windows by running Docker in muliple VMs...).
117
143
 
118
144
  This probably isn't as big an issue as it looks since most projects are going to
119
145
  cater to one specific OS family.
120
146
 
121
147
  #### Worked Example
122
- Lets say you have two examples, `foo.pp` and `init.pp`. In this case, the full
123
- range of files to create for acceptance testing would look like this:
148
+ Lets say you have two examples, `foo.pp` and `init.pp`. The files for acceptance
149
+ testing would look like this:
124
150
 
125
151
  ```
126
152
  mycoolmodule
@@ -139,33 +165,43 @@ mycoolmodule
139
165
  ├── ...
140
166
  ```
141
167
 
142
- ### Debugging failed builds
143
- PDQTest makes it easy to debug failed builds:
168
+ When we run acceptance tests PDQTest will create a new container and then run:
169
+ 1. `sh /testcase/spec/acceptance/foo_setup.sh`
170
+ 2. `bats /testcase/spec/acceptance/foo__before.bats`
171
+ 3. `puppet apply /testcase/examples/foo.pp`
172
+ 4. `puppet apply /testcase/examples/foo.pp`
173
+ 5. `bats /testcase/spec/acceptance/foo.bats`
174
+ 6. `sh /testcase/spec/acceptance/init_setup.sh`
175
+ 7. `bats /testcase/spec/acceptance/init__before.bats`
176
+ 8. `puppet apply /testcase/examples/init.pp`
177
+ 9. `puppet apply /testcase/examples/init.pp`
178
+ 10. `bats /testcase/spec/acceptance/init.bats`
179
+
180
+ Errors at any stage of the process will cause the test suite to abort once the
181
+ error is returned.
144
182
 
145
- ```shell
146
- # Centos
147
- pdqtest shell
148
-
149
- # Ubuntu
150
- pdqtest --image-name declarativesystems/pdqtest-ubuntu:2018-08-29-0 shell
183
+ ### Debugging failed builds
184
+ PDQTest provides two targets to debug failed builds:
185
+ 1. `make shell`/`.\make.ps1 shell` - Load a new docker container, run all tests,
186
+ then print a message showing how to get a shell
187
+ 2. `make shellnopuppet`/`.\make.ps1 shellnopuppet` - Load a new docker container
188
+ and transport into it, without running Puppet
189
+
190
+ You may also want to run PDQTest directly to use a different image (Ubuntu)
191
+ se `--image-name` to use a different image (Ubuntu)
192
+
193
+ ```json
194
+ cd .pdqtest
195
+ bundle exec pdqtest --image-name declarativesystems/pdqtest-ubuntu:2018-08-29-0 shell
151
196
  ```
152
197
 
153
- * Opens a shell inside the default docker container that would be used to run
154
- tests
198
+ Inside the container:
155
199
  * Your code is available at `/testcase`
156
- * Use `--image-name` to use a different image (Ubuntu)
200
+ * Any puppet modules you have installed at `/spec/fixtures/modules` will be
201
+ available (note that `pdk build` removes these)
202
+ * Hiera and custom facts will be installed if configured
157
203
 
158
-
159
- ```shell
160
- pdqtest --keep-container all
161
- ```
162
- * Runs all tests, report pass/fail status
163
- * Keeps the container Running
164
- * After testing, the container used to run tests will be left running and a
165
- message will be printed showing how to enter the container used for testing.
166
- Your code is avaiable at `/testcase`
167
- * User is responsible for cleaning up the containers created in this mode
168
- * Shortcut: `make shell` or `.\make.ps1 shell`
204
+ User is responsible for cleaning up the containers created in this mode
169
205
 
170
206
  ### Docker privileged mode
171
207
  Sometimes you need to run in Docker privileged mode to enable tests to work -
data/doc/caching.md CHANGED
@@ -3,8 +3,10 @@ PDQTest will attempt to cache:
3
3
  * Puppet modules (via r10k) in `~/.r10k/cache`
4
4
  * The yum cache in `~/.pdqtest/cache/yum`
5
5
 
6
- Note that since the yum cache is writen to via a docker volume from the
7
- container your running tests in, the files in this directory will be root owned.
6
+ Note that since the yum cache is written to via a docker volume from the
7
+ container your running tests in, the files in this directory will be `root`
8
+ owned.
9
+
8
10
  If you need to clear your cache for whatever reason, delete the
9
- `~/.pdqtest/cache` directory (you will likely need `sudo`) and PDQtest will
10
- recreate it next time it runs.
11
+ `~/.pdqtest/cache` directory (you will need `sudo`) and PDQtest will recreate it
12
+ next time it runs.
data/doc/development.md CHANGED
@@ -3,14 +3,17 @@
3
3
  PRs welcome :) Please ensure suitable tests cover any new functionality and
4
4
  that all tests are passing before and after your development work.
5
5
 
6
- ## Support
7
- Interested in commercial support of PDQTest? Please email
8
- sales@declarativesystems.com to discuss your needs.
9
-
10
6
  ## Debugging
11
- * run with `--verbosity debug`
7
+ * run with `--verbosity debug` _and_ `--debug` (transitional while we sort out
8
+ logging in escort)
12
9
  * Debug docker API calls: `export EXCON_DEBUG=debug` or `set EXCON_DEBUG=debug`
13
10
  then run `pdqtest` as normal
11
+
12
+ **Example**
13
+ ```shell
14
+ cd .pdqtest
15
+ bundle exec pdqtest --debug --verbosity debug all
16
+ ```
14
17
 
15
18
  ## Contributing
16
19
  Bug reports and pull requests are welcome on GitHub at
@@ -24,3 +27,13 @@ https://github.com/declarativesystems/pdqtest.
24
27
  * Run specific test case `bundle exec rspec ./spec/SPEC/FILE/TO/RUN.rb:99`
25
28
  (where 99 is the line number of the test)
26
29
  * If your using RubyMine, you can just right-click -> debug
30
+
31
+ ## Why not use `pdk bundle exec` instead of having your own `Gemfile`?
32
+ I tried this originally and couldn't get it working. There's seems to be some
33
+ kind of memory error from trying to run `pdk` inside `pdk`. In the end, separate
34
+ `Gemfile`s turned out to be simpler and more robust. For full details see
35
+ [PDK Integration](pdk.md).
36
+
37
+ ## Support
38
+ Interested in commercial support of PDQTest? Please email
39
+ sales@declarativesystems.com to discuss your needs.
data/doc/emoji.md CHANGED
@@ -15,14 +15,14 @@ On windows, we fallback to output emoticons instead of Emoji
15
15
 
16
16
  ### Progress
17
17
 
18
- | Symbol | Meaning | Platform |
19
- | --- | --- | --- |
20
- | Progress: Test passed | `😬` | `:-)` |
21
- | Progress: Test failed | `💣` | `●~*` |
22
- | Overall Status: All tests passed | `😎` | `=D` |
23
- | Overall Status: One or more tests failed | `💩` | `><(((*>` |
24
- | Slow operation | `🐌` | `(-_-)zzz` |
25
- | Platform issue/limitation | - | `(-_-)` |
18
+ | Description | Linux | Windows |
19
+ | --- | --- | --- |
20
+ | Progress: Test passed | `😬` | `:-)` |
21
+ | Progress: Test failed | `💣` | `●~*` |
22
+ | Overall Status: All tests passed | `😎` | `=D` |
23
+ | Overall Status: One or more tests failed | `💩` | `><(((*>` |
24
+ | Slow operation | `🐌` | `(-_-)zzz` |
25
+ | Platform issue/limitation | - | `(-_-)` |
26
26
 
27
27
 
28
28
  ## Disabling emoji
@@ -1,23 +1,47 @@
1
- # Enabling testing
1
+ # Enabling testing
2
+ PDQTest is enabled and configured on a per-project basis.
3
+
4
+ ### New projects
5
+ New projects should be created using PDK: `pdk new module`.
6
+
7
+ ### Enabling
2
8
  To add PDQTest to a new or existing puppet module, run the commands:
3
9
 
10
+ **Linux**
4
11
  ```shell
5
12
  pdqtest init
6
- pdk bundle install
13
+ make pdqtestbundle
14
+ make setup
15
+ ```
16
+
17
+ **Windows**
18
+ ```shell
19
+ pdqtest init
20
+ .\make.ps1 pdqtestbundle
21
+ .\make.ps1 setup
7
22
  ```
8
23
 
9
24
  From the top level directory of your puppet module. This will install PDQTest
10
- into the `Gemfile.project` (for PDK's bundler), and generate an example set of
11
- acceptance tests.
25
+ into the `.pdqtest/Gemfile` and generate an example set of acceptance tests.
26
+
27
+ The `make setup` step downloads Docker images for your test platform:
12
28
 
13
- You **must** run `pdk bundle install` to install PDQTest into PDK's bundle and
14
- you **must not* run `bundle install` (ever!).
29
+ **Linux**
30
+ * Centos
31
+ * Ubuntu
15
32
 
16
- For more info see (PDK-1172)[https://tickets.puppetlabs.com/browse/PDK-1172]
33
+ **Windows**
34
+ * Windows (Windows-Servercore)
35
+
36
+ PDQTest now integrates with and requires PDK, so ideally your module was
37
+ previously generated with `pdk new module`. If this was not the case, PDQTest
38
+ will install the minimal integrations required to also enable PDK on the module.
17
39
 
18
40
  PDK must already be present on the system for this to work.
19
41
 
20
42
  Note: Your puppet module *must* have a valid `metatadata.json` file. Create
21
- one before running `pdqtest init` if you don't already have one. If your
22
- creating a puppet module from scratch, try `pdk new module` to create a
43
+ one by running `pdk convert` before running `pdqtest init` if you don't already
44
+ have one.
45
+
46
+ If your creating a puppet module from scratch, try `pdk new module` to create a
23
47
  complete module skeleton that includes a valid version of this file.
data/doc/hiera.md CHANGED
@@ -1,15 +1,17 @@
1
1
  # Hiera
2
2
  Under normal circumstances, only a `profile` module would be consuming Hiera
3
- data directly using the `hiera()` function, and its suggested by many that these
4
- too fall back to automatic data binding parameters rather then use the `hiera()`
5
- function directly. In this case it makes more sense to use the excellent
3
+ data directly using the `lookup()` function, and its suggested by Puppet that
4
+ most of these fall back to automatic data binding parameters rather then using
5
+ the function directly.
6
+
7
+ In this case it makes more sense to use the excellent
6
8
  [Onceover](https://github.com/dylanratcliffe/onceover) tool to perform
7
9
  end-to-end testing of your Hiera data, puppet control repository and
8
10
  roles/profile modules.
9
11
 
10
12
  That said, there may be occasions where you need to mock hiera data:
11
13
  * You have implemented Roles and Profiles as a namespace inside a team module
12
- (for multi-tennanting)
14
+ (for multi-tenanting)
13
15
  * You have a module that performs `lookup()` lookups directly
14
16
  * You intend to drive your module by adding data to hiera and including a class
15
17
  to make something happen
@@ -18,8 +20,8 @@ That said, there may be occasions where you need to mock hiera data:
18
20
  able to test it
19
21
 
20
22
  ## Alternative method
21
- In some cases where it may be easiest to directly inject strings in lieu of
22
- setting up a fake hiera:
23
+ In most cases it may be easiest to directly inject strings in lieu of setting up
24
+ a fake hiera:
23
25
 
24
26
  ### RSpec Tests
25
27
  ```ruby
@@ -42,7 +44,7 @@ class { "foo":
42
44
  Note that you would need to duplicate your hard-coded mock data between the
43
45
  rspec tests and any acceptance tests.
44
46
 
45
- In the more complex cases it may instead be desireable to mock the hiera data in
47
+ In the more complex cases it may instead be desirable to mock the hiera data in
46
48
  order to enable Puppet's regular lookup systems to work.
47
49
 
48
50
  ## Mocking Hiera (RSpec tests)
data/doc/installation.md CHANGED
@@ -31,6 +31,18 @@ PDQTest and Docker.
31
31
  `docker` group. You will need to log out and back in again after doing this
32
32
  8. Install the PDQTest docker images by typing `pdqtest setup`
33
33
 
34
+ ## Mac instructions
35
+ **UNTESTED! Do you own a mac? Please let me know what works**
36
+
37
+ Instructions should be as Linux, but from memory, I had to run:
38
+
39
+ ```shell
40
+ eval "$(docker-machine env default)"
41
+ ```
42
+
43
+ to configure the shell last time I owned a mac. If things have moved on since
44
+ then, let me know what else is needed (possibly including a patch)
45
+
34
46
  ## Windows Instructions
35
47
 
36
48
  1. You will need Windows 10 (Windows 10 Enterprise, Professional, or Education)
@@ -61,6 +73,6 @@ PDQTest and Docker.
61
73
  5. Install PDK: `choco install pdk`
62
74
  6. Install bundler `gem install bundler`
63
75
 
64
- **Be sure to read the [Windows notes](windows.md) for guidance on how to run tests
65
- on Windows**
76
+ **Be sure to read the [Windows notes](windows.md) for guidance on how to run
77
+ tests on Windows**
66
78