pdqtest 1.9.9beta7 → 1.9.9beta8

Sign up to get free protection for your applications and to get access to all the features.
data/doc/upgrade_1_2.md CHANGED
@@ -1,13 +1,177 @@
1
+ # PDQTest 1x -> 2x upgrade notes
2
+ PDQTest is now compatible with (and requires) PDK! By and large we let PDK do
3
+ its own thing and just wrap the output with emojis and run our own acceptance
4
+ tests.
5
+
6
+ See [PDK Integration](pdk.md) for details of how this works.
7
+
8
+ Since this is a major upgrade, you must re-init your project. Make sure all your
9
+ code is checked in to git,
10
+ [install PDK](https://puppet.com/docs/pdk/1.x/pdk_install.html) then run:
11
+
12
+ ```shell
13
+ gem install pdqtest
14
+ cd /my/project
15
+ pdqtest init
16
+ make pdqtestbundle
17
+ make setup
18
+ ```
19
+
20
+ ## Custom facts
21
+ If you were previous using custom facts in the `spec/merge_facts` directory,
22
+ these need to be converted to yaml and moved to `spec/default_facts.yml`. This
23
+ will give you compatibility between PDK unit tests and PDQTest acceptance tests.
24
+
25
+ ## RSpec tests (inc hiera data)
26
+ PDQTest doesn't deal with RSPec tests any more, we let PDK do all the work by
27
+ shelling out to call `pdk test unit`:
28
+
29
+ * If you were using PDQTest for your hiera data during the RSpec lifecycle,
30
+ update your tests to do what PDK tells you to do
31
+ * Existing `spec/fixtures/hiera.yaml` and `spec/fixtures/test.yaml` files will
32
+ continue to work during acceptance tests and the `hiera.yaml` file has been
33
+ upgraded for hiera 5 compatibility. You will have to reconfigure your
34
+ hierarchy if you were using more files then just `test.yaml`
35
+
36
+ PDQTest 1x generated RSpec tests will fail due to missing dependency on
37
+ [puppet_factset](https://rubygems.org/gems/puppet_factset) gem which is not used
38
+ for new PDK generated classes.
39
+
40
+ To fix you tests, either:
41
+
42
+ **Enable `puppet_factset` gem**
43
+
44
+ You can enable this gem in PDK by adding it to `Gemfile.project` and running:
45
+
46
+ *Linux*
47
+
48
+ ```shell
49
+ make Gemfile.local
50
+ ```
51
+
52
+ *Windows*
53
+
54
+ ```shell
55
+ .\make.ps1 Gemfile.local
56
+ ```
57
+
58
+ **Rewrite tests to new format**
59
+
60
+ PDK writes RSpec test using its own template which creates output like this:
61
+
62
+ ```ruby
63
+ require 'spec_helper'
64
+
65
+ describe 'CHANGETHISTOYOURCLASSNAME' do
66
+ on_supported_os.each do |os, os_facts|
67
+ context "on #{os}" do
68
+ let(:facts) { os_facts }
69
+
70
+ it { is_expected.to compile }
71
+ end
72
+ end
73
+ end
74
+ ```
75
+
76
+ **Delete your RSpec tests**
77
+
78
+ If your in a hurry and have good acceptance tests, another quick fix would be to
79
+ just delete the RSpec tests and rely purely on acceptance testing.
80
+
81
+ You will miss fast-failure due to invalid puppet code if you do this, and will
82
+ lose any specialised testing you had previously.
83
+
84
+
85
+ ## `.fixtures.yml` and `fixtures.yml`
86
+ `.fixtures.yml` is back in PDQTest 2.0 (it's presence was an error in PDQTest
87
+ 1.x) and `fixtures.yaml` is no longer used.
88
+
89
+ If you would like to use test fixtures from git, add them to `.fixtures.yml` and
90
+ you can continue to use them as before. The rest of the file is generated for
91
+ you automatically by PDQTest based on `metadata.json` to support integration
92
+ with PDK.
93
+
94
+ [More info on dependencies](puppet_module_dependencies.md)
95
+
96
+ ## Old PDQtest 1x integration points
97
+ * `/spec/spec_helper.rb`
98
+ * `/Gemfile`
99
+ * `/Rakefile`
100
+ * `/.rspec`
101
+ We will do our best to detect any previous PDQTest generated versions of these
102
+ files. If known versions are found, we will upgrade you to the PDK version. If
103
+ an unknown file is found we will stop and ask you to move it out of the way
104
+ first. PDK will be responsible for these files now-on.
105
+
106
+ ## How to resolve `unknown/modified file` errors during upgrade
107
+ 1. Move your existing file out of the way
108
+ 2. Run `pdqtest init`
109
+ 3. See per-file upgrade notes below
110
+
111
+ **`/Gemfile`**
112
+
113
+ Add any custom gems that used to be in `Gemfile` to `Gemfile.project` and they
114
+ will be evaluated during `pdk bundle install` and available during
115
+ `pdk test unit`.
116
+
117
+ To make gems available to PDQTest itself, add them to `.pdqtest/Gemfile`.
118
+
119
+ **Other files**
120
+
121
+ If the upgrade cannot detect where a file that needs replacing came from we ask
122
+ the user to move/delete it. Most other files can safely be updated without issue
123
+ but we ask you to confirm this.
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
+ ## Miscellaneous files/directories
137
+ ### `/.gitignore`
138
+ We no longer install or manage `.gitignore` for you and we don't upgrade it
139
+ either. PDK ships a default version and we use that if the initial file is
140
+ missing.
141
+
142
+ ### `/cut` mountpoint
143
+ Previous versions of PDQTest mounted code at `/cut` (Code Under Test), the new
144
+ mountpoint is the more obvious `/testcase` and `/cut` no longer works.
145
+
146
+ ## R10K cache issues
147
+ PDQTest < 2.0 configured the r10k cache via `.r10k.yaml` which caused
148
+ [#44](https://github.com/declarativesystems/pdqtest/issues/44). To fix this, we
149
+ now use the default r10k cache dir at `~/.r10k/cache` and don't write
150
+ `.r10k.yaml` any more. You should remove any `.r10k.yaml` files from your
151
+ project unless you need it for something specific.
152
+
153
+ ## PDK validation errors when puppet code valid
154
+ PDK scans the `/pkg` directory and will choke if old files are present there:
155
+ [PDK-1183](https://tickets.puppetlabs.com/browse/PDK-1183)
156
+
157
+ To remove them:
158
+
159
+ *Linux*
160
+
161
+ ```shell
162
+ make clean
163
+ ```
164
+
165
+ *Windows*
166
+ ```shell
167
+ .\make.ps1 shell
168
+ ```
169
+
170
+ ## What does a real update look like?
171
+ ```shell
1
172
  geoff@computer:~/tmp/ssh$ git checkout -b pdk
2
173
  Switched to a new branch 'pdk'
3
- geoff@computer:~/tmp/ssh$ pdqtest init
4
- Puppet metadata not found at metadata.json - not a valid puppet module
5
- geoff@computer:~/tmp/ssh$ ls
6
- total 72K
7
- 4.0K bitbucket-pipelines.yml 4.0K Gemfile 4.0K Makefile 4.0K Rakefile
8
- 4.0K CHANGELOG 4.0K Gemfile.lock 4.0K manifests 4.0K README.md
9
- 4.0K data 4.0K hiera.yaml 4.0K metadata.json 4.0K REFERENCE.md
10
- 4.0K examples 12K LICENSE 4.0K Puppetfile.lock 4.0K spec
174
+
11
175
  geoff@computer:~/tmp/ssh$ pdqtest init
12
176
  Doing one-time upgrade to PDK - Generating fresh set of files...
13
177
  pdk (INFO): Creating new module: x
@@ -22,6 +186,7 @@ Detected PDQTest 1.x file at Rakefile (will upgrade to PDK)
22
186
  Detected PDQTest 1.x file at .gitignore (will upgrade to PDK)
23
187
  Updated .sync.yml with {".travis.yml"=>{:unmanaged=>true}}
24
188
  enabling PDK in metadata.json
189
+
25
190
  geoff@computer:~/tmp/ssh$ git status
26
191
  On branch pdk
27
192
  Changes not staged for commit:
@@ -53,47 +218,7 @@ Untracked files:
53
218
  spec/fixtures/
54
219
 
55
220
  no changes added to commit (use "git add" and/or "git commit -a")
56
- geoff@computer:~/tmp/ssh$ cat Makefile
57
- all:
58
- cd .pdqtest && pwd && bundle exec pdqtest all
59
- $(MAKE) docs
60
-
61
- fast:
62
- cd .pdqtest && pwd && bundle exec pdqtest fast
63
-
64
- shell:
65
- cd .pdqtest && pwd && bundle exec pdqtest --keep-container acceptance
66
-
67
- setup:
68
- cd .pdqtest && pwd && bundle exec pdqtest setup
69
-
70
- shellnopuppet:
71
- cd .pdqtest && pwd && bundle exec pdqtest shell
72
-
73
- logical:
74
- cd .pdqtest && pwd && bundle exec pdqtest syntax
75
- cd .pdqtest && pwd && bundle exec pdqtest rspec
76
- $(MAKE) docs
77
-
78
- #nastyhack:
79
- # # fix for - https://tickets.puppetlabs.com/browse/PDK-1192
80
- # find vendor -iname '*.pp' -exec rm {} \;
81
221
 
82
- pdqtestbundle:
83
- # Install all gems into _normal world_ bundle so we can use all of em
84
- cd .pdqtest && pwd && bundle install
85
-
86
- docs:
87
- cd .pdqtest && pwd && bundle exec "cd ..&& puppet strings"
88
-
89
-
90
- Gemfile.local:
91
- echo "[🐌] Creating symlink and running pdk bundle..."
92
- ln -s Gemfile.project Gemfile.local
93
- $(MAKE) pdkbundle
94
-
95
- pdkbundle:
96
- pdk bundle install
97
222
  geoff@computer:~/tmp/ssh$ make pdqtestbundle
98
223
  # Install all gems into _normal world_ bundle so we can use all of em
99
224
  cd .pdqtest && pwd && bundle install
@@ -139,6 +264,7 @@ Using puppet-strings 2.1.0
139
264
  Using puppet-syntax 2.4.1
140
265
  Bundle complete! 5 Gemfile dependencies, 38 gems now installed.
141
266
  Use `bundle info [gemname]` to see where a bundled gem is installed.
267
+
142
268
  geoff@computer:~/tmp/ssh$ make
143
269
  cd .pdqtest && pwd && bundle exec pdqtest all
144
270
  /home/geoff/tmp/ssh/.pdqtest
@@ -155,3 +281,10 @@ Overall: 💩
155
281
  ABORTED - there are test failures! :(
156
282
  Makefile:2: recipe for target 'all' failed
157
283
  make: *** [all] Error 1
284
+ ```
285
+
286
+ See the error? That came from PDK validating our metadata... Looks like this
287
+ module had invalid metadata all along. At this point tests can be re-run any
288
+ time just by running `make`.
289
+
290
+ When all tests are passing again the update to PDQTest 2.0/PDK is complete.
data/doc/upgrading.md CHANGED
@@ -6,13 +6,23 @@ gem update pdqtest
6
6
  ```
7
7
 
8
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,
9
+ it's `.pdqtest/Gemfile` updated to reference the latest version. Don't worry,
10
10
  this is easy:
11
11
 
12
+ **Linux**
13
+
12
14
  ```shell
13
- cd /my/cool/project/to/upgrade
15
+ cd /your/project
14
16
  pdqtest upgrade
15
- pdk bundle install
17
+ make pdqtestbundle
18
+ ```
19
+
20
+ **Windows**
21
+
22
+ ```shell
23
+ cd /your/project
24
+ pdqtest upgrade
25
+ .\make.ps1 pdqtestbundle
16
26
  ```
17
27
 
18
28
  Note that since we're using bundler, you only have to upgrade the puppet modules
@@ -23,125 +33,25 @@ via `make` just fine. You are not forced to update all your modules in one go.
23
33
  Updated docker images are periodically released and are required to run newer
24
34
  PDQTest versions. When you get a message about missing docker containers run:
25
35
 
26
- ```shell
27
- pdqtest setup
28
- ```
29
-
30
- To obtain the latest version.
31
-
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:
36
+ **Linux**
42
37
 
43
38
  ```shell
44
- gem install pdqtest
45
- cd /my/project
46
- pdqtest init
47
- pdk bundle install
48
- bundle exec pdqtest setup
39
+ make setup
49
40
  ```
50
41
 
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:
42
+ **Windows**
74
43
 
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
44
+ ```shell
45
+ .\make.ps1 setup
87
46
  ```
88
47
 
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.
48
+ To obtain the latest version.
144
49
 
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.
50
+ ## What happens during `pdqtest upgrade`?
51
+ We update:
52
+ * Project gems in `.pdqtest/Gemfile`
53
+ * Our CI and CLI integrations:
54
+ * `Makefile`
55
+ * `make.ps1`
56
+ * `.travis.yml`
57
+ * `bitbucket-pipelines.yml`
data/doc/windows.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Windows
2
- PDQTest now supports windows! There are a few gotchas though:
2
+ PDQTest now supports Windows! There are a few gotchas though and this support is
3
+ still experimental:
3
4
 
4
5
  * The docker volume doesn't play nice with puppet/ruby: Whole app breaks if
5
6
  `/lib` directory present, so we have to _copy_ the files into the container
@@ -30,22 +31,18 @@ know
30
31
 
31
32
  Q: what's going on with `.bat` files?
32
33
 
33
- A:They seem to work but you need to pass the full filename to docker run, eg:
34
+ A:They seem to work but you need to pass the full filename to docker run (yes,
35
+ `puppet` is actually `puppet.bat` on an installed system), eg:
34
36
 
35
37
  ```shell
36
- docker exec XXX foo.bat
38
+ docker exec XXX puppet.bat apply c:\testcase\examples\init.pp
37
39
  ```
38
40
 
39
41
  not
40
42
 
41
43
  ```shell
42
- docker exec XXX foo
44
+ docker exec XXX puppet
43
45
  ```
44
46
  _where XXX is the ID of your container. Use `docker ps` to get a listing.
45
47
 
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
48
 
@@ -10,7 +10,7 @@ module PDQTest
10
10
  IMAGES = {
11
11
  :DEFAULT => 'declarativesystems/pdqtest-centos:2018-09-15-0',
12
12
  :UBUNTU => 'declarativesystems/pdqtest-ubuntu:2018-09-15-0',
13
- :WINDOWS => 'declarativesystems/pdqtest-windows:2018-09-29-0',
13
+ :WINDOWS => 'declarativesystems/pdqtest-windows:2018-09-30-0',
14
14
  }
15
15
 
16
16
  # volume paths are different for windows containers
@@ -39,9 +39,13 @@ module PDQTest
39
39
  ".travis.yml" => {
40
40
  "unmanaged" => true,
41
41
  },
42
+ "bitbucket-pipelines.yml" => {
43
+ "unmanaged" => true,
44
+ },
42
45
  ".gitignore" => {
43
46
  "paths" => [
44
47
  ".Puppetfile.pdqtest",
48
+ "refresh.ps1",
45
49
  ],
46
50
  },
47
51
  ".gitattributes" => {
@@ -1,3 +1,3 @@
1
1
  module PDQTest
2
- VERSION = "1.9.9beta7"
2
+ VERSION = "1.9.9beta8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdqtest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.9beta7
4
+ version: 1.9.9beta8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoff Williams
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-30 00:00:00.000000000 Z
11
+ date: 2018-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler