beaker-testmode_switcher 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7ff5d01994fcc8fd23b932a148f2652929885a9
4
- data.tar.gz: 1f09d49b242599f033255c7089837cf7a75fd19a
3
+ metadata.gz: ec3225e801b5af3ffb139c419e33d48567da102e
4
+ data.tar.gz: 0fcf5b39a4f30a8082a2c96c7aabf57b13fdb84a
5
5
  SHA512:
6
- metadata.gz: 29e63bc99d6a810af62c3695f6a9447e81c73428a38367b95534e9cb38c801ddc8896cc9f484c93ad182ad639136e0240963e06bb7dc154ec5b3bce49faaf79e
7
- data.tar.gz: 9ead4a0fc8906c2703c2fb66e7befd317fcd6b4b6a77c0684f9c777d18e0dcf2565fc38cba2c23ce6d9935af51e534d4d80c85bcc0b6ab979a859fafa373bfb5
6
+ metadata.gz: 583f09db223c94c6071b262bdb4898bb9e06ef7fe03ecea1fd77e416014cb32e369cf2fb436dbb603a8ff531796ec528036f87857e79052f290e82ed61924139
7
+ data.tar.gz: 60d24646077a43f5a1407d71ef8836d6a8811af011326850b69fcb5abea31f72037dd76b3fe3e410604fd63e63136bb51cadf35323664110f7ea5170867dea56
data/.travis.yml CHANGED
@@ -3,8 +3,7 @@ cache: bundler
3
3
  bundler_args: --without development
4
4
  rvm:
5
5
  - 2.4.1
6
- - 2.3.1
7
- - 2.1.6
6
+ - 2.1.9
8
7
  env:
9
- - TEST_FRAMEWORK="beaker-rspec"
8
+ - TEST_FRAMEWORK="rspec"
10
9
  - TEST_FRAMEWORK="beaker"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # 2018-03-07 Version 0.4.0
2
+ ### Summary
3
+ Adds the ability for execute_manifest_on to work in both agent and apply; improvements for create_remote_file_ex.
4
+
5
+ ### Features
6
+ - Adds support for `execute_manifest_on` with `BEAKER_TESTMODE` set to `apply`
7
+
8
+ ### BugFixes
9
+ - Fixes `create_remote_file_ex` so that opts accepts `:owner` instead of `:user`
10
+ - Improves content handling for `create_remote_file_ex`
11
+ - Minor fixes to option handling
12
+
1
13
  # 2017-06-08 Version 0.3.0
2
14
  ### Summary
3
15
  Adds a new parameter for shell_ex; and improvements for local test running.
data/README.md CHANGED
@@ -42,10 +42,10 @@ To run the tests `bundle exec rake`
42
42
 
43
43
  This experimental version supports only a minimal set of functionality from the beaker DSL:
44
44
 
45
- * `create_remote_file_ex(file_path, file_content, opts = {})`: Creates a file at `file_path` with the content specified in `file_content` on the default node. `opts` can have the keys `:mode`, `:user`, and `:group` to specify the permissions, owner, and group respectively.
45
+ * `create_remote_file_ex(file_path, file_content, opts = {})`: Creates a file at `file_path` with the content specified in `file_content` on the default node. `opts` can have the keys `:mode`, `:owner`, and `:group` to specify the permissions, owner, and group respectively.
46
+
47
+ * `execute_manifest_on(hosts, manifest, opts = {})`: Execute the manifest on all nodes. This will only work when `BEAKER_TESTMODE` is set to `agent` or `apply`, and is not yet supported for `local`.
46
48
 
47
- * `execute_manifest_on(hosts, manifest, opts = {})`: Execute the manifest on all nodes. This will only work when `BEAKER_TESTMODE`, is set to `agent` and it will run a `puppet agent` run.
48
-
49
49
  `opts` keys:
50
50
  * `:debug`, `:trace`, `:noop`: set to true to enable the puppet option of the same name.
51
51
  * `:dry_run`: set to true to skip executing the actual command.
@@ -56,7 +56,7 @@ This experimental version supports only a minimal set of functionality from the
56
56
  * `:expect_failures` enables detailed exit codes and causes a test failure if the puppet run indicates there were no failure during its execution.
57
57
 
58
58
  * `execute_manifest(manifest, opts = {})`: Execute the manifest on the default node. Depending on the `BEAKER_TESTMODE` environment variable, this may use `puppet agent` or `puppet apply`. Calls execute_manifest_on when `BEAKER_TESTMODE`=`agent`
59
-
59
+
60
60
  `opts` keys:
61
61
  * `:debug`, `:trace`, `:noop`: set to true to enable the puppet option of the same name.
62
62
  * `:dry_run`: set to true to skip executing the actual command.
@@ -91,7 +91,7 @@ Other helpful methods:
91
91
 
92
92
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
93
93
 
94
- To install this gem onto your local machine, run `bundle exec rake install`.
94
+ To install this gem onto your local machine, run `bundle exec rake install`.
95
95
 
96
96
  ### Releasing
97
97
 
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  lib = File.expand_path('../lib', __FILE__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require 'beaker/testmode_switcher/version'
@@ -19,12 +19,12 @@ module Beaker
19
19
  # create a remote file (using puppet apply) on the default host
20
20
  def create_remote_file_ex(file_path, file_content, options = {})
21
21
  mode = options[:mode] || '0644'
22
- user = options[:user] || 'root'
22
+ owner = options[:owner] || 'root'
23
23
  group = options[:group] || 'root'
24
- file_content.tr!(/\\/, '\\')
25
- file_content.tr!(/'/, "\\'")
26
- file_content.tr!(/\n/, '\\n')
27
- apply_manifest_on default, "file { '#{file_path}': ensure => present, content => '#{file_content}', mode => '#{mode}', user => '#{user}', group => '#{group}' }", catch_failures: true
24
+ file_content.gsub!(/\\/, '\\\\')
25
+ file_content.gsub!(/"/, '\\"')
26
+ file_content.gsub!(/\n/, '\n')
27
+ apply_manifest_on default, "file { '#{file_path}': ensure => present, content => \"#{file_content}\", mode => '#{mode}', owner => '#{owner}', group => '#{group}' }", catch_failures: true
28
28
  end
29
29
 
30
30
  # execute a puppet resource command on the default host
@@ -105,9 +105,16 @@ module Beaker
105
105
  class BeakerApplyRunner < BeakerRunnerBase
106
106
  # execute the manifest by running puppet apply on the default node
107
107
  def execute_manifest(manifest, opts = {})
108
+ execute_manifest_on(default, manifest, opts)
109
+ end
110
+
111
+ # execute the manifest by running puppet apply on all the hosts
112
+ def execute_manifest_on(hosts, manifest, opts = {})
108
113
  # acceptable_exit_codes and expect_changes are passed because we want detailed-exit-codes but want to
109
114
  # make our own assertions about the responses
110
- res = apply_manifest(
115
+
116
+ res = apply_manifest_on(
117
+ hosts,
111
118
  manifest,
112
119
  debug: opts[:debug],
113
120
  dry_run: opts[:dry_run],
@@ -14,7 +14,7 @@ module Beaker
14
14
  file_path_escaped = file_path.shellescape
15
15
  commands = []
16
16
  commands << "chmod #{opts[:mode].shellescape} #{file_path_escaped}" if opts[:mode]
17
- commands << "chown #{opts[:user].shellescape} #{file_path_escaped}" if opts[:user]
17
+ commands << "chown #{opts[:owner].shellescape} #{file_path_escaped}" if opts[:owner]
18
18
  commands << "chgrp #{opts[:group].shellescape} #{file_path_escaped}" if opts[:group]
19
19
  if commands.empty?
20
20
  success_result
@@ -28,12 +28,14 @@ module Beaker
28
28
  # it accepts the following keys: :dry_run, :environment, :trace, :noop, and :debug
29
29
  def execute_manifest(manifest, opts = {})
30
30
  puts "Applied manifest [#{manifest}]" if ENV['DEBUG_MANIFEST']
31
- cmd = ["bundle exec puppet apply -e #{manifest.delete("\n").shellescape} --detailed-exitcodes --modulepath spec/fixtures/modules --libdir lib"]
31
+ cmd = ["bundle exec puppet apply -e #{manifest.shellescape} --detailed-exitcodes --modulepath spec/fixtures/modules --libdir lib"]
32
32
  cmd << "--debug" if opts[:debug]
33
33
  cmd << "--noop" if opts[:noop]
34
34
  cmd << "--trace" if opts[:trace]
35
35
 
36
- res = use_local_shell(cmd.join(' '), opts)
36
+ raise ArgumentError, 'Can\'t handle environment key' if opts.key? :environment
37
+
38
+ res = use_local_shell(cmd.join(' '))
37
39
  handle_puppet_run_returned_exit_code(get_acceptable_puppet_run_exit_codes(opts), res.exit_code)
38
40
 
39
41
  res
@@ -53,6 +55,10 @@ module Beaker
53
55
  cmd << type.shellescape
54
56
  cmd << name.shellescape
55
57
 
58
+ opts.delete(:debug)
59
+ opts.delete(:noop)
60
+ opts.delete(:trace)
61
+
56
62
  if opts[:values]
57
63
  opts[:values].each do |k, v|
58
64
  cmd << "#{k.shellescape}=#{v.shellescape}"
@@ -1,6 +1,6 @@
1
1
  module Beaker
2
2
  # central definition of this gem's version
3
3
  module TestmodeSwitcher
4
- VERSION = "0.3.0".freeze
4
+ VERSION = "0.4.0".freeze
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-testmode_switcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2017-06-08 00:00:00.000000000 Z
15
+ date: 2018-03-08 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: beaker
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  requirements: []
90
90
  rubyforge_project:
91
- rubygems_version: 2.5.2
91
+ rubygems_version: 2.6.11
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Let's you run your puppet module tests in master/agent, apply or local mode.