beaker-testmode_switcher 0.2.0 → 0.2.1

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: 0b6fa280da0e2d74f94c99172bbdc84a0fd136eb
4
- data.tar.gz: b7d5add69806870c20e23ee07e24412678c98dae
3
+ metadata.gz: 3e5e98040bb38ccc30cecf1a0c3105dcd152b82e
4
+ data.tar.gz: c6a864d09aec964392418110e6660402f2a37540
5
5
  SHA512:
6
- metadata.gz: 43b4c25be5bdd16a76c56d57e7e8935ccc5e58cb83fa275f57404fc20218d8f93c876389ed5e367d99622fdf161313f0a6922d54efb1f1bfc5fde0242f6318d2
7
- data.tar.gz: bb9b824bfd40e4dd11da7ca1bf3948cc83a3c1b61ab97c89ab96c48f706aec78f2f183418020ec3d0bd72d1b7c1a1a323f1b52063bf49ca7f0cd2e31ef3f4617
6
+ metadata.gz: ea53e552475d862693ff0a0b92cae19aea7cb235a4d290ba137d14ef0b6311f3d4003592db6cc8e333377a5b62ac388531399d7c1221b9ade06c5a3f1a4163f7
7
+ data.tar.gz: 5fd3d099591b07fc46cdc27f3d6b0c511da666d79a4c49c2d2b170ed119fee39c9156e0b7bdbb9f54d16cafbf7589d8143dc1721f9f07bf6577bc7d9e5da1fca
@@ -1,3 +1,5 @@
1
+ require: rubocop-rspec
2
+
1
3
  # increase the default metric limits to more realistic levels
2
4
  Metrics/BlockLength:
3
5
  Max: 200
@@ -28,7 +30,7 @@ Style/PercentLiteralDelimiters:
28
30
  Style/StringLiterals:
29
31
  Enabled: false
30
32
 
31
- Style/MultilineMethodCallBraceLayout:
33
+ Layout/MultilineMethodCallBraceLayout:
32
34
  Enabled: false
33
35
 
34
36
  Style/FrozenStringLiteralComment:
@@ -1,3 +1,7 @@
1
+ # 2017-06-02 Version 0.2.1
2
+ ### Summary
3
+ Fixes for shell_ex when running on Windows; and a minor README update.
4
+
1
5
  # 2017-03-03 Version 0.2.0
2
6
  ### Summary
3
7
  Make use of catch_changes, catch_failures, expect_changes and expect_failures. This makes beaker-testmode_switcher easier to integrate into modules.
@@ -7,11 +11,11 @@ Make use of catch_changes, catch_failures, expect_changes and expect_failures. T
7
11
  - Fix docs issue where `execute_manifest` options were listed under `resource
8
12
 
9
13
  # 2017-01-19 - Version 0.1.1
10
- ###Summary
14
+ ### Summary
11
15
 
12
16
  This release adds a feature that provides control of specific nodes you would like to run an agent run on. Previously it was only possible to run on the default node.
13
17
 
14
- ###Features
18
+ ### Features
15
19
  - Add execute_manifest_on() function
16
20
  - Add MAINTAINERS file
17
21
  - Addressing Rubocop errors
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ group :test do
9
9
  gem 'rake', '~> 10.0'
10
10
  gem 'rspec', '~> 3' unless ENV['TEST_FRAMEWORK'] && ENV['TEST_FRAMEWORK'] == 'beaker' # Don't install rpsec if the module is in beaker only mode
11
11
  gem 'rubocop', require: false
12
+ gem 'rubocop-rspec', require: false
12
13
  end
13
14
 
14
15
  group :development do
data/Guardfile CHANGED
@@ -2,8 +2,7 @@
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
4
  ## Uncomment and set this to only include directories you want to watch
5
- directories %w(lib spec) \
6
- .select { |d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist") }
5
+ directories(%w(lib spec).select { |d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist") })
7
6
 
8
7
  ## Note: if you are using the `directories` clause above and you are not
9
8
  ## watching the project directory ('.'), then you will want to move
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Beaker::TestmodeSwitcher
2
2
 
3
- When testing modules with beaker, you need to choose up-front whether to drive the tests using `puppet apply` or a master/agent setup. While choosing the apply approach is tempting due to the reduced resource usage, everyone is running master/agent setups, and those have subtle differences to `puppet apply` that might trip up your code. To solve this dilemma, use this gem to choose the test mode at runtime!
3
+ When testing modules and other Puppet software with beaker, you need to choose up-front whether to drive the tests using `puppet apply` directly on an agent VM; or using a master/agent setup; or by running the code directly on your workstation. While choosing the apply approach is tempting due to the reduced resource usage, most Puppet deployments are running master/agent setups, and those have subtle differences to `puppet apply` that might trip up your code. To solve this dilemma, use this gem to choose the test mode at runtime!
4
4
 
5
- Beaker::TestmodeSwitcher supports running tests in master/agent mode, or using `puppet apply` or locally without any setup.
5
+ Beaker::TestmodeSwitcher supports running tests in master/agent mode, or using `puppet apply` on an agent host, or locally without any setup.
6
6
 
7
7
  ## Usage
8
8
 
9
- Set up you module for beaker testing as usual. Additionally add
9
+ Set up your module for beaker testing as usual. Additionally add
10
10
 
11
11
  ```ruby
12
12
  gem 'beaker-testmode_switcher'
@@ -22,9 +22,9 @@ to your `spec/spec_helper_acceptance.rb` to enable the DSL extensions. Instead o
22
22
 
23
23
  The `BEAKER_TESTMODE` environment variable determines how the tests are run:
24
24
 
25
- * `local`: No VMs are provisioned and tests are run with `puppet apply` using the context of your test runner. This mode uses the least resources and is great for development, but may require running the tests as root and could trash the system.
26
- * `apply`: VMs are provisioned as normal (determined by the nodeset) and tests are run with `puppet apply` on the specified node. This mode only requires a single VM and is great for running the tests in an isolated environment. When the nodeset has more than one node, exactly one has to have the 'default' role assigned. This will be the node to execute the manifests.
27
- * `agent`: VMs are provisioned as normal (determined by the nodeset). When running tests, the manifest is uploaded to the master and a full `puppet agent` run is kicked off on the specified node. This mode requires multiple VMs and a more involved provisioning step, but the tests run in a very production-like environment to ensure highest fidelity of the test results. The nodeset needs to contain one node with the 'master' role assigned. This will be the node to receive the manifest. When the nodeset has more than one node, exactly one has to have the 'default' role assigned. This will be the node to execute the puppet agent.
25
+ * `local`: No VMs are provisioned and tests are run using the context of your test runner. This mode is great for development, but may require running the tests as root and may cause unwanted system changes to your workstation.
26
+ * `apply`: VMs are provisioned as normal (determined by the nodeset) and tests of Puppet manifests are run with `puppet apply` on the specified node. This mode only requires a single VM and is great for running the tests in an isolated environment. When the nodeset has more than one node, exactly one has to have the 'default' role assigned. This will be the node to execute the manifests.
27
+ * `agent`: VMs are provisioned as normal (determined by the nodeset). When running tests with Puppet manifests, the manifest is uploaded to the master and a `puppet agent` run is kicked off on the specified node. This mode requires multiple VMs and a more involved provisioning step, but the tests run in a more production-like environment to ensure highest fidelity of the test results. The nodeset needs to contain one node with the 'master' role assigned. This will be the node to receive the manifest. When the nodeset has more than one node, exactly one has to have the 'default' role assigned. This will be the node to execute the puppet agent.
28
28
 
29
29
  ## Acceptance tests
30
30
 
@@ -89,7 +89,11 @@ Other helpful methods:
89
89
 
90
90
  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.
91
91
 
92
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
92
+ To install this gem onto your local machine, run `bundle exec rake install`.
93
+
94
+ ### Releasing
95
+
96
+ To release a new version, update the version number in `lib/beaker/testmode_switcher/version.rb`, update CHANGELOG.md, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
93
97
 
94
98
  ## Contributing
95
99
 
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ def beaker_command
4
4
  cmd_parts = []
5
5
  cmd_parts << "beaker"
6
6
  cmd_parts << "--debug"
7
- cmd_parts << "--test spec/test"
7
+ cmd_parts << "--tests spec/test"
8
8
  cmd_parts << "--load-path lib"
9
9
  cmd_parts.flatten.join(" ")
10
10
  end
@@ -24,13 +24,14 @@ task :beaker do
24
24
  abort "Beaker test failed" unless system(beaker_command) == true
25
25
  end
26
26
 
27
- task :rubocop do
28
- require 'rubocop/rake_task'
29
- RuboCop::RakeTask.new
27
+ require 'rubocop/rake_task'
28
+ RuboCop::RakeTask.new(:rubocop) do |task|
29
+ # These make the rubocop experience maybe slightly less terrible
30
+ task.options = ['-D', '-S', '-E']
30
31
  end
31
32
 
32
33
  begin
33
- task default: [:spec, :rubocop]
34
+ task default: %i[spec rubocop]
34
35
  rescue LoadError => error
35
36
  raise "LoadError for default rake target. [#{error}] "
36
37
  end
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'beaker/testmode_switcher/version'
@@ -5,7 +5,7 @@ module Beaker
5
5
  # include this module into your namespace to access the DSL parts of TestmodeSwitcher
6
6
  module DSL
7
7
  # pass through methods to the runner
8
- [:create_remote_file_ex, :scp_to_ex, :shell_ex, :resource, :execute_manifest, :execute_manifest_on].each do |name|
8
+ %i[create_remote_file_ex scp_to_ex shell_ex resource execute_manifest execute_manifest_on].each do |name|
9
9
  define_method(name) do |*args|
10
10
  Beaker::TestmodeSwitcher.runner(hosts, logger).send(name, *args)
11
11
  end
@@ -117,7 +117,12 @@ module Beaker
117
117
  ready[0].each do |f|
118
118
  fileno = f.fileno
119
119
  begin
120
- data = f.read_nonblock(1024)
120
+ begin
121
+ data = f.read_nonblock(1024)
122
+ rescue IO::WaitReadable, Errno::EINTR
123
+ IO.select([f])
124
+ retry
125
+ end
121
126
  until data.empty?
122
127
  $stdout.write(data)
123
128
 
@@ -138,10 +143,14 @@ module Beaker
138
143
  data = f.read_nonblock(1024)
139
144
  rescue IO::EAGAINWaitReadable
140
145
  data = ""
146
+ rescue IO::WaitReadable, Errno::EINTR
147
+ IO.select([f])
148
+ retry
141
149
  end
142
150
  end
143
- rescue EOFError # rubocop:disable Lint/HandleExceptions: expected exception
151
+ rescue EOFError, Errno::EBADF # rubocop:disable Lint/HandleExceptions: expected exception
144
152
  # pass on EOF
153
+ # Also pass on Errno::EBADF (Bad File Descriptor) as it is thrown for Ruby 2.1.9 on Windows
145
154
  end
146
155
  end
147
156
  end
@@ -1,6 +1,6 @@
1
1
  module Beaker
2
2
  # central definition of this gem's version
3
3
  module TestmodeSwitcher
4
- VERSION = "0.2.0".freeze
4
+ VERSION = "0.2.1".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.2.0
4
+ version: 0.2.1
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-03-03 00:00:00.000000000 Z
15
+ date: 2017-06-02 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.6.8
91
+ rubygems_version: 2.5.1
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.