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 +4 -4
- data/.travis.yml +2 -3
- data/CHANGELOG.md +12 -0
- data/README.md +5 -5
- data/beaker-testmode_switcher.gemspec +0 -2
- data/lib/beaker/testmode_switcher/beaker_runners.rb +13 -6
- data/lib/beaker/testmode_switcher/local_runner.rb +9 -3
- data/lib/beaker/testmode_switcher/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec3225e801b5af3ffb139c419e33d48567da102e
|
4
|
+
data.tar.gz: 0fcf5b39a4f30a8082a2c96c7aabf57b13fdb84a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 583f09db223c94c6071b262bdb4898bb9e06ef7fe03ecea1fd77e416014cb32e369cf2fb436dbb603a8ff531796ec528036f87857e79052f290e82ed61924139
|
7
|
+
data.tar.gz: 60d24646077a43f5a1407d71ef8836d6a8811af011326850b69fcb5abea31f72037dd76b3fe3e410604fd63e63136bb51cadf35323664110f7ea5170867dea56
|
data/.travis.yml
CHANGED
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`, `:
|
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
|
|
@@ -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
|
-
|
22
|
+
owner = options[:owner] || 'root'
|
23
23
|
group = options[:group] || 'root'
|
24
|
-
file_content.
|
25
|
-
file_content.
|
26
|
-
file_content.
|
27
|
-
apply_manifest_on default, "file { '#{file_path}': ensure => present, content =>
|
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
|
-
|
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[:
|
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.
|
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
|
-
|
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}"
|
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.
|
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:
|
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.
|
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.
|