kitchen-verifier-serverspec 0.6.1 → 0.6.2

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: 4b527b35a5f9ac533376c0944ae890fc485f4273
4
- data.tar.gz: bdee2f6e29bec19c5b34b883e2de16b2218a2101
3
+ metadata.gz: 5dfea35acb9f08d0ff7b162fb7b6640d96ca1da0
4
+ data.tar.gz: 66aed88576ddb5452b3661692cb41d89f787e38c
5
5
  SHA512:
6
- metadata.gz: 25be95cebe0c1412ceb1cd32fd7a8c4ff0564d5621de252f79a57778221038f2a6d606c2dd0eec03c7339c3895c3f42f207c3edee36ac59efa30daf2560e757b
7
- data.tar.gz: fad9cbf49743c65b07325c675df00cdc8d21f68eec13427434471c9bf0e394853c3eb033cbaec844b885768ca9eb6fb97b7f428b3d4fcde6429e49daf50c1a17
6
+ metadata.gz: 20ac9dc68138019c59bebb98cc82eaba8f1a8d9a4fa992911c396da0931993bb33ef44a313ee9565f4f5758be30dadc3d6117eef6f69e9610d63c1f75828d1b1
7
+ data.tar.gz: b853a8d7df3f57e3dbc629a661944b3cbe29e4bfc61b8cccc9895ed33ea7de65995bcb2a4455e7ea62c633155256e7e8ed92dbbbe7ee944943ed08762473b20a
data/README.md CHANGED
@@ -80,12 +80,16 @@ There are three ways to run verifier serverspec:
80
80
  * Remotely directly on the server running serverspec in ssh mode
81
81
  * Locally on your workstation running serverspec in ssh mode
82
82
 
83
- Verifier Serverspec allows the serverspec files to be anywhere in the repository.This means that you can use spec files that follow ansiblespec or puppet beaker locations.
83
+ Verifier Serverspec allows the serverspec files to be anywhere in the repository or in the test-kitchen default location i.e /test/integration. This means that you can use spec files that follow ansiblespec or puppet beaker locations.
84
84
 
85
85
  ### Spec File Location and Updating
86
86
 
87
- Verfier Serverspec does not copy the the serverspec files. They are assumed to be there in the repository and to have been copied to the server via the provisioner. This means if you change a spec file you need to run converge again to get the spec files copied to the server. Verifier Serverspec doesn't copy spec files in the test/integration directory like the busser serverspec that is supplied by chef.
87
+ When remote_exec is set to true (the default) the following rules apply for getting the spec files to the remote server instance.
88
88
 
89
+ if default_pattern is set to true then Verifier Serverspec copies the spec files in the test/integration directory like the busser serverspec that is supplied by chef.
90
+
91
+ if default_pattern is set to false (the default) then Verfier Serverspec does not copy the the serverspec files. They are assumed to be there in the repository and to have been copied to the server via the provisioner. This means in this case if you change a spec file you need to run converge again to get the spec files copied to the server.
92
+ A future enhancement maybe to copy these files so the provisioner doesn't have to be called when they are changed.
89
93
 
90
94
 
91
95
  ## Remotely directly on server running serverspec in exec mode
@@ -54,10 +54,20 @@ module Kitchen
54
54
  sleep_if_set
55
55
  merge_state_to_env(state)
56
56
  if config[:remote_exec]
57
+ if config[:default_pattern]
58
+ create_sandbox
59
+ sandbox_dirs = Dir.glob(File.join(sandbox_path, '*'))
60
+ end
57
61
  instance.transport.connection(state) do |conn|
58
62
  conn.execute(install_command)
63
+ if config[:default_pattern]
64
+ info("Transferring files to #{instance.to_str}")
65
+ conn.upload(sandbox_dirs, config[:root_path])
66
+ debug('Transfer complete')
67
+ end
59
68
  conn.execute(serverspec_commands)
60
69
  end
70
+ cleanup_sandbox if config[:default_pattern]
61
71
  else
62
72
  config[:default_path] = Dir.pwd if config[:default_path] == '/tmp/kitchen'
63
73
  install_command
@@ -77,6 +87,12 @@ module Kitchen
77
87
  install_command
78
88
  end
79
89
 
90
+ # (see Base#create_sandbox)
91
+ def create_sandbox
92
+ super
93
+ prepare_suites
94
+ end
95
+
80
96
  def serverspec_commands
81
97
  if config[:remote_exec]
82
98
  if custom_serverspec_command
@@ -253,8 +269,13 @@ module Kitchen
253
269
  def rspec_commands
254
270
  info('Running Serverspec')
255
271
  if config[:default_pattern]
256
- info("Using default pattern #{config[:test_base_path]}/#{config[:suite_name]}/serverspec/*_spec.rb")
257
- config[:patterns] = ["#{config[:test_base_path]}/#{config[:suite_name]}/serverspec/*_spec.rb"]
272
+ if config[:remote_exec]
273
+ info("Using default pattern #{config[:root_path]}/serverspec/*_spec.rb")
274
+ config[:patterns] = ["#{config[:root_path]}/serverspec/*_spec.rb"]
275
+ else
276
+ info("Using default pattern #{config[:test_base_path]}/#{config[:suite_name]}/serverspec/*_spec.rb")
277
+ config[:patterns] = ["#{config[:test_base_path]}/#{config[:suite_name]}/serverspec/*_spec.rb"]
278
+ end
258
279
  end
259
280
  if config[:require_runner]
260
281
  "#{env_vars} #{sudo_env(rspec_cmd)} #{color} -f #{config[:format]} --default-path #{config[:default_path]} #{rspec_path_option} #{config[:extra_flags]}"
@@ -382,6 +403,41 @@ module Kitchen
382
403
  end
383
404
  config[:shellout_opts].merge!(env_state)
384
405
  end
406
+
407
+ def chef_data_dir?(base, file)
408
+ file =~ %r{^#{base}/(data|data_bags|environments|nodes|roles)/}
409
+ end
410
+
411
+ # Returns an Array of test suite filenames for the related suite currently
412
+ # residing on the local workstation. Any special provisioner-specific
413
+ # directories (such as a Chef roles/ directory) are excluded.
414
+ #
415
+ # @return [Array<String>] array of suite files
416
+ # @api private
417
+ def local_suite_files
418
+ base = File.join(config[:test_base_path], config[:suite_name])
419
+ glob = File.join(base, '*/**/*')
420
+ Dir.glob(glob).reject do |f|
421
+ chef_data_dir?(base, f) || File.directory?(f)
422
+ end
423
+ end
424
+
425
+ # Copies all test suite files into the suites directory in the sandbox.
426
+ def prepare_suites
427
+ base = File.join(config[:test_base_path], config[:suite_name])
428
+ debug("Creating local sandbox of all test suite files in #{base}")
429
+ local_suite_files.each do |src|
430
+ dest = File.join(sandbox_suites_dir, src.sub("#{base}/", ''))
431
+ FileUtils.mkdir_p(File.dirname(dest))
432
+ FileUtils.cp(src, dest, :preserve => true)
433
+ end
434
+ end
435
+
436
+ # @return [String] path to suites directory under sandbox path
437
+ # @api private
438
+ def sandbox_suites_dir
439
+ File.join(sandbox_path, 'suites')
440
+ end
385
441
  end
386
442
  end
387
443
  end
@@ -1,5 +1,5 @@
1
1
  module Kitchen
2
2
  module Verifier
3
- SERVERSPEC_VERSION = '0.6.1'.freeze
3
+ SERVERSPEC_VERSION = '0.6.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-verifier-serverspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neill Turner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-16 00:00:00.000000000 Z
11
+ date: 2016-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen