pdqtest 0.3.5 → 0.4.0

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
  SHA1:
3
- metadata.gz: 55f9c73918d6c1128abdef3472810ef1b9ae62f7
4
- data.tar.gz: a20905b57f5aedd8890fb2f5914aabff3516c526
3
+ metadata.gz: ac2a8fe5df5117bb7d74fb011f0f857fb07df03e
4
+ data.tar.gz: 11bc05363b086d465cd7598d17446d05a31c9d3a
5
5
  SHA512:
6
- metadata.gz: bc77dcba12d994aadd887977155db02d0dcb83f719f07976022314529e21da59b1e6cc6503e09e5df8061b3a8b4923628d5ddb1de0e84e2c43f1779046baba6a
7
- data.tar.gz: 78a5a29ada1309e9b63ba39d5455c3b46c437866c9b9eec6080ae6b965a3a99a941d6e4cab517116e4c60870731180e3dacee87e51c9e6efdda51a2f26613aff
6
+ metadata.gz: 640a8be2625c579bf0a461d1c6f894d18bc339ae641afe8aafbce00dd46b8f07420ede16f6fe97388c753effdeb1cecdef681ae0fda237975ab5be5279387324
7
+ data.tar.gz: 1f9775686e4b5aea26b2a7e21c7db4a6559b9fd10cac9a95c486e7f96e1927784b52f9a5a690a7a48ecc43090f651cf70dc24d029f66b5435b3dc363398e581d
data/README.md CHANGED
@@ -76,6 +76,8 @@ spec/merge_facts
76
76
 
77
77
  Inside the module being tested will result in all JSON files contained being merged into all OS specific factsets used for testing as generated by `pdqtest generate_rspec`. To put it simply, drop `.json` file(s) in this directory to add them to every factset.
78
78
 
79
+ These facts will be made automatically avaialable to facter when running acceptance testing
80
+
79
81
  ### All tests
80
82
  If you just want to run all tests:
81
83
 
@@ -96,14 +98,14 @@ pdqtest shell
96
98
  ```
97
99
 
98
100
  * Open a shell inside the docker container that would be used to run tests
99
- * Your code is available at `/cut`
101
+ * Your code is available at `/testcase`
100
102
 
101
103
  ```shell
102
104
  pdqtest --keep-container all
103
105
  ```
104
106
  * Run all tests, report pass/fail status
105
107
  * Keep the container Running
106
- * After testing, the container used to run tests will be left running and a message will be printed showing how to enter the container used for testing. Your code is avaiable at `/cut`
108
+ * After testing, the container used to run tests will be left running and a message will be printed showing how to enter the container used for testing. Your code is avaiable at `/testcase`
107
109
 
108
110
  ## About acceptance tests
109
111
  * Acceptance tests run within a Docker container managed by PDQTest
@@ -240,6 +242,7 @@ You should use pdqtest if you find it increases your productivity and enriches y
240
242
  * If you need a private key to access private repositories, set this up for your regular git command/ssh and `pdqtest` will reuse the settings
241
243
  * Be sure to annotate the examples you wish to acceptance test with the magic marker comment `#@PDQTest`
242
244
  * Sometimes you might get an error: `Could not resolve the dependencies.` when executing tests. This message is from librarian puppet and usually indicates a conflict between the `metadata.json` files somewhere in the set of modules you are attempting to use. Running the command `librarian-puppet install --path spec/fixtures/ --destructive --verbose` should give you enough information to resolve the error
245
+ * Be sure to run `make` or `bundle exec pdqtest all` to download dependencies when running acceptance tests. Previous versions (re)downloaded modules as required from inside docker but this step has been replaced with a simple symlink.
243
246
 
244
247
  ## Support
245
248
  This software is not supported by Puppet, Inc. Use at your own risk.
@@ -247,6 +250,9 @@ This software is not supported by Puppet, Inc. Use at your own risk.
247
250
  ## Contributing
248
251
  Bug reports and pull requests are welcome on GitHub at https://github.com/declarativesystems/pdqtest.
249
252
 
253
+ ## Upgrade notes
254
+ * Previous versions of PDQTest mounted code at `/cut` (Code Under Test), this will still work for a few versions but the preferred mountpoint is now the more obvious `/testcase`
255
+
250
256
  ### Running tests
251
257
  * PDQTest includes a comprehensive tests for core library functions. Please ensure tests pass before and after any PRs
252
258
  * Run all tests `bundle exec rake spec`
@@ -61,9 +61,14 @@ RUN /opt/puppetlabs/puppet/bin/gem install librarian-puppet
61
61
  # git refresh (for processing .fixtures.yml git modules)
62
62
  RUN /opt/puppetlabs/puppet/bin/gem install git_refresh
63
63
 
64
- # code under test
64
+ # testcase (our module)
65
+ RUN mkdir /testcase
66
+ VOLUME /testcase
67
+
68
+ # code under test (deprecated)
65
69
  RUN mkdir /cut
66
70
  VOLUME /cut
67
71
 
72
+
68
73
  # alternate shudown for systemd
69
74
  STOPSIGNAL SIGRTMIN+3
@@ -4,7 +4,7 @@ module PDQTest
4
4
  ERR = 1
5
5
  STATUS = 2
6
6
  ENV='export TERM=xterm LC_ALL=C PATH=/usr/local/bats/bin:/opt/puppetlabs/puppet/bin:$PATH;'
7
- IMAGE_NAME='geoffwilliams/pdqtest-centos:2017-04-04-0'
7
+ IMAGE_NAME='geoffwilliams/pdqtest-centos:2017-05-04-0'
8
8
 
9
9
 
10
10
  def self.wrap_cmd(cmd)
@@ -21,11 +21,13 @@ module PDQTest
21
21
  'Image' => IMAGE_NAME,
22
22
  'Volumes' => {
23
23
  test_dir => {pwd => 'rw'},
24
+ '/cut' => {pwd => 'rw'}, # DEPRECATED -FOR REMOVAL
24
25
  '/sys/fs/cgroup' => {'/sys/fs/cgroup' => 'ro'},
25
26
  },
26
27
  'HostConfig' => {
27
28
  "Binds": [
28
29
  "/sys/fs/cgroup:/sys/fs/cgroup:ro",
30
+ "#{pwd}:/cut:rw", # DEPRECATED -FOR REMOVAL
29
31
  "#{pwd}:#{test_dir}:rw",
30
32
  ],
31
33
  },
@@ -5,7 +5,7 @@ require 'escort'
5
5
 
6
6
  module PDQTest
7
7
  module Instance
8
- TEST_DIR='/cut'
8
+ TEST_DIR='/testcase'
9
9
  @@keep_container = false
10
10
  @@active_container = nil
11
11
 
@@ -1,6 +1,7 @@
1
1
  require 'pdqtest/puppet'
2
2
  require 'pdqtest/docker'
3
3
  require 'pdqtest/instance'
4
+ require 'pdqtest/emoji'
4
5
  require 'escort'
5
6
  require 'yaml'
6
7
 
@@ -47,7 +48,20 @@ module PDQTest
47
48
  end
48
49
 
49
50
  def self.link_module
50
- "mkdir -p #{MODULE_DIR} && ln -s #{PDQTest::Instance::TEST_DIR} #{MODULE_DIR}/#{module_name}"
51
+ "test -e #{MODULE_DIR} || mkdir -p #{MODULE_DIR} && ln -s #{PDQTest::Instance::TEST_DIR} #{MODULE_DIR}/#{module_name}"
52
+ end
53
+
54
+ # Link all modules - this also saves re-downloading in the acceptance test
55
+ # environment. Of course it means that you must have already run `make` to
56
+ # download the modules on your host computer
57
+ def self.link_deps
58
+ "test -e #{MODULE_DIR} || mkdir -p #{MODULE_DIR} && ln -s #{PDQTest::Instance::TEST_DIR}/spec/fixtures/modules/* #{MODULE_DIR}"
59
+ end
60
+
61
+ # link /etc/facter/facts.d to /testcase/spec/merge_facts to allow additional
62
+ # facts supplied by user to work automatically
63
+ def self.link_merge_facts
64
+ "mkdir -p /etc/facter/ && ln -s #{PDQTest::Instance::TEST_DIR}/spec/merge_facts /etc/facter/facts.d"
51
65
  end
52
66
 
53
67
  def self.install_deps
@@ -228,40 +242,59 @@ module PDQTest
228
242
  end
229
243
 
230
244
  def self.run(container, example=nil)
245
+ # we must always have ./spec/fixtures/modules because we need to create a
246
+ # symlink back to the main module inside here...
247
+ # (spec/fixtures/modules/foo -> /testcase)
248
+ if ! Dir.exists?('spec/fixtures/modules')
249
+ Escort::Logger.output.puts
250
+ "creating empty spec/fixtures/modules, if you module fails to run due "
251
+ "to missing dependencies run `make` or `pdqtest all` to retrieve them"
252
+ FileUtils.mkdir_p('spec/fixtures/modules')
253
+ end
254
+
231
255
  status = true
232
- Escort::Logger.output.puts "...fetch deps"
233
- cmd = install_deps
256
+ Escort::Logger.output.puts "...linking dependencies"
257
+ cmd = link_deps
234
258
  res = PDQTest::Docker.exec(container, cmd)
235
259
  status &= PDQTest::Docker.exec_status(res)
236
260
  if status
237
- Escort::Logger.output.puts "...linking"
261
+ Escort::Logger.output.puts "...linking testcase (this module)"
238
262
  cmd = link_module
239
263
  res = PDQTest::Docker.exec(container, cmd)
240
264
  status &= PDQTest::Docker.exec_status(res)
241
265
  if status
242
- Escort::Logger.output.puts "...run tests"
243
- if example
244
- status &= run_example(container, example)
245
- if ! status
246
- Escort::Logger.error.error "Example #{example} failed!"
266
+ Escort::Logger.output.puts "...linking spec/merge_facts"
267
+ cmd = link_merge_facts
268
+ res = PDQTest::Docker.exec(container, cmd)
269
+ status &= PDQTest::Docker.exec_status(res)
270
+ if status
271
+ Escort::Logger.output.puts "...run tests"
272
+ if example
273
+ status &= run_example(container, example)
274
+ if ! status
275
+ Escort::Logger.error.error "Example #{example} failed!"
276
+ end
277
+ else
278
+ find_examples.each { |e|
279
+ if status
280
+ status &= run_example(container, e)
281
+ if ! status
282
+ Escort::Logger.error.error "Example #{e} failed! - skipping rest of tests"
283
+ end
284
+ end
285
+ }
247
286
  end
248
287
  else
249
- find_examples.each { |e|
250
- if status
251
- status &= run_example(container, e)
252
- if ! status
253
- Escort::Logger.error.error "Example #{e} failed! - skipping rest of tests"
254
- end
255
- end
256
- }
288
+ PDQTest::Docker.log_all(res)
289
+ Escort::Logger.error.error "Error linking ./spec/merge_facts directory, see previous error, command was: #{cmd}"
257
290
  end
258
291
  else
259
292
  PDQTest::Docker.log_all(res)
260
- Escort::Logger.error.error "Error linking module, see previous error, command was: #{cmd}"
293
+ Escort::Logger.error.error "Error linking testcase (this) module, see previous error, command was: #{cmd}"
261
294
  end
262
295
  else
263
296
  PDQTest::Docker.log_all(res)
264
- Escort::Logger.error.error "Error installing dependencies, see previous error, command was: #{cmd}"
297
+ Escort::Logger.error.error "Error linking module, see previous error, command was: #{cmd}"
265
298
  end
266
299
 
267
300
  PDQTest::Emoji.partial_status(status, 'Puppet')
@@ -1,3 +1,3 @@
1
1
  module PDQTest
2
- VERSION = "0.3.5"
2
+ VERSION = "0.4.0"
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: 0.3.5
4
+ version: 0.4.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-04-29 00:00:00.000000000 Z
11
+ date: 2017-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler