beaker-rspec 5.3.0 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjdkNWQ1OWQ5N2NiMjY5ZDExNzE0YTUxODMyZWFkYjBmYWEwMmRlMw==
4
+ NDYxN2NmZWJkNTMyMGNlNGNkMWI5NTcwMzQ2YzU0YzYxZjI5OTZlYw==
5
5
  data.tar.gz: !binary |-
6
- MzQ3Zjc0ZmUxNDVlYzk3Y2Q0YmYzNTAyMDI1ZmNlMmRmYjU1Y2UyNQ==
6
+ YzkxZjg3YTA1NWExYjU1OWQ5Zjg3OWU4MWRiNWY1NDNlMGY4YTE5NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODUxMmU0NzYwZjQ1MWU5OGUyMjU1NWJiMDdlY2ZiNDk4YWRlYTI2NmIzZWIx
10
- OTMwZGI3ZThmOTY3MzljMjI5NDIzYTI0NWU4ZmUxYjkxNWU0MmU4MzcxZTJl
11
- ZmMwMjc5ZTcyYjNmNjI1ODhlMWE0MzIxMDEwNjJhYzMzNGIwZGQ=
9
+ NDNhYWUyNjMzZGFjOWYyODViNTJlOGQ3ZWRiN2JiZmVkM2I2YjFhYzRlNWNj
10
+ YjNhNTg3ZjM3YTdkNzM2YzdkNDQ5YzI1ZWY5OTNmYzU0Y2Q3ZWVjNTE0MjY3
11
+ OWY1YjJmOTc2N2ExODZiNjNmMzFhYTA5ZTM3Zjc1MjQzMjcwMjU=
12
12
  data.tar.gz: !binary |-
13
- NzMyM2MwYjAyZGY2ZmU3MDYyMzRjYzViZDdmOTkyMjhjNTNiMzBlOWMwNmY2
14
- NGQyMjVjM2U4ZjUwZjA0ZGMzNWJmMzJiY2NlMDc1OWQ5MDEwY2I3ZTI5Mjcw
15
- OGZiMTIxNDQ5NjM3ZmJkYmNhMzFlMmI1MTViNjQyZTUxYWZkZDU=
13
+ Nzk0MWU5NDdhY2VkODlmOTEyZjAwOWI4NzcyMDRiYzgxZjJkMGM5ZTVmYjZi
14
+ ZGI3YjU1NjQwZjU4YTU0YzEzZTY4MTc3Y2IyMTBjN2M3MTA0ODhkZWQzMzQ2
15
+ MTQxOGVkYjQ0ZjFlM2VkZTExYzViZTUyMjVhMmFmZjIxNWQ4NGI=
data/HISTORY.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # default - History
2
2
  ## Tags
3
- * [LATEST - 13 Oct, 2015 (2ea88c14)](#LATEST)
3
+ * [LATEST - 9 Jun, 2016 (a25f1e77)](#LATEST)
4
+ * [5.3.0 - 13 Oct, 2015 (2efeb932)](#5.3.0)
4
5
  * [5.2.2 - 3 Sep, 2015 (69980e14)](#5.2.2)
5
6
  * [5.2.1 - 27 Aug, 2015 (49c45f61)](#5.2.1)
6
7
  * [5.2.0 - 15 Jul, 2015 (261dacdb)](#5.2.0)
@@ -23,7 +24,67 @@
23
24
  * [beaker-rspec1.0.0 - 3 Dec, 2013 (65e89ec9)](#beaker-rspec1.0.0)
24
25
 
25
26
  ## Details
26
- ### <a name = "LATEST">LATEST - 13 Oct, 2015 (2ea88c14)
27
+ ### <a name = "LATEST">LATEST - 9 Jun, 2016 (a25f1e77)
28
+
29
+ * (GEM) update beaker-rspec version to 5.4.0 (a25f1e77)
30
+
31
+ * Merge pull request #79 from richburroughs/master (4db37886)
32
+
33
+
34
+ ```
35
+ Merge pull request #79 from richburroughs/master
36
+
37
+ fixed an incomplete sentence in README.md
38
+ ```
39
+ * fixed an incomplete sentence in README.md (cfd9cbd6)
40
+
41
+ * Merge pull request #77 from oskar-flores/fix-serverspec-on-non-cygwin-node (a617f7bb)
42
+
43
+
44
+ ```
45
+ Merge pull request #77 from oskar-flores/fix-serverspec-on-non-cygwin-node
46
+
47
+ Add a check on windows part, to exec commands on a non cygwin environment
48
+ ```
49
+ * Merge pull request #78 from DavidS/bkr-577-update-readme (563ba7e7)
50
+
51
+
52
+ ```
53
+ Merge pull request #78 from DavidS/bkr-577-update-readme
54
+
55
+ (BKR-577) Update README to describe usage in detail
56
+ ```
57
+ * (BKR-577) Update README to describe usage in detail (18b307a7)
58
+
59
+ * Cleaning code as per @DavidS sugestion (c0142b57)
60
+
61
+ * Add a check on windows part, to exec commads on a non cywing environment (f483b063)
62
+
63
+ * fixed up recent README changes (2771b4b1)
64
+
65
+ * Merge pull request #71 from electrical/cleanup_ctrl_c (756de678)
66
+
67
+
68
+ ```
69
+ Merge pull request #71 from electrical/cleanup_ctrl_c
70
+
71
+ (BKR-345) Cleanup and quit on ctrl-c
72
+ ```
73
+ * Merge pull request #76 from DavidS/document-env (b3d4f839)
74
+
75
+
76
+ ```
77
+ Merge pull request #76 from DavidS/document-env
78
+
79
+ Document environment variables
80
+ ```
81
+ * Document environment variables (5ab74188)
82
+
83
+ * (BKR-345) Cleanup and quit on ctrl-c (90a74317)
84
+
85
+ ### <a name = "5.3.0">5.3.0 - 13 Oct, 2015 (2efeb932)
86
+
87
+ * (HISTORY) update beaker-rspec history for gem release 5.3.0 (2efeb932)
27
88
 
28
89
  * (GEM) update beaker-rspec version to 5.3.0 (2ea88c14)
29
90
 
data/README.md CHANGED
@@ -1,4 +1,154 @@
1
- beaker-rspec
2
- =======================
1
+ #beaker-rspec
3
2
 
4
- Bridge between puppet test harness (beaker) and rspec
3
+ beaker-rspec is a bridge between the puppet acceptance test harness ([beaker](https://github.com/puppetlabs/beaker)) and [rspec](https://github.com/rspec/rspec). It also integrates [serverspec](http://serverspec.org/).
4
+
5
+ #Typical Workflow
6
+
7
+ Beaker does setup and provision all nodes from your nodeset on each test run, and cleans up the VMs after use. During development on a module it can be very handy to keep the VMs available for inspection or reuse. Set `BEAKER_destroy=no` do skip the cleanup and `BEAKER_provision=no` once the VMs are created.
8
+
9
+ 1. Run tests with `BEAKER_destroy=no`, no setting for `BEAKER_provision`
10
+ * beaker-rspec will use spec/acceptance/nodesets/default.yml node file
11
+ * boxes will be newly provisioned
12
+ * boxes will be preserved post-testing
13
+ * Run tests with `BEAKER_destroy=no` and `BEAKER_provision=no`
14
+ * beaker-rspec will use spec/acceptance/nodesets/default.yml node file
15
+ * boxes will be re-used from previous run
16
+ * boxes will be preserved post-testing
17
+ * Nodes become corrupted with too many test runs/bad data and need to be refreshed then set `BEAKER_provision=yes`
18
+ * Testing is complete and you want to clean up, run once more with `BEAKER_destroy` unset
19
+ * you can also:
20
+
21
+ cd .vagrant/beaker_vagrant_files/default.yml ; vagrant destroy --force
22
+
23
+ ##Supported ENV variables
24
+
25
+ * `BEAKER_color`: set to `no` to disable color output
26
+ * `BEAKER_debug`: set to any value to enable beaker debug logging
27
+ * `BEAKER_destroy`: set to `no` to keep the VMs after the test run. Set to `onpass` to keep the VMs around only after a test failure.
28
+ * `BEAKER_keyfile`: specify alternate SSH key to access the test VMs
29
+ * `BEAKER_provision`: set to `no` to skip provisioning boxes before testing, beaker will then assume that boxes are already provisioned and reachable
30
+ * `BEAKER_set`: set to the name of the node file to be used during testing (exclude .yml file extension, it will be added by beaker-rspec). The file is assumed to be in module's spec/acceptance/nodesets directory.
31
+ * `BEAKER_setfile` - set to the full path to a node file be used during testing (be sure to include full path and file extensions, beaker-rspec will use this path without editing/altering it in any way)
32
+
33
+ For details on the specific mappings, the [setup code](https://github.com/puppetlabs/beaker-rspec/blob/2771b4b1864692690254a969680a57ff22ac0516/lib/beaker-rspec/spec_helper.rb#L26-L32) and the [beaker docs](https://github.com/puppetlabs/beaker/wiki/The-Command-Line).
34
+
35
+ #Building your Module Testing Environment
36
+
37
+ Using puppetlabs-mysql as an example module.
38
+
39
+ ##Clone the module repository of the module where you want to add tests
40
+
41
+ git clone https://github.com/puppetlabs/puppetlabs-mysql
42
+ cd puppetlabs-mysql
43
+
44
+ ##Install beaker-rspec
45
+
46
+ In module's top level directory edit the Gemfile. If there is a `:system_tests` or `:acceptance` group, add it there.
47
+
48
+ ```ruby
49
+ group :acceptance do
50
+ gem 'beaker-rspec'
51
+ end
52
+ ```
53
+
54
+ Then run
55
+
56
+ bundle install
57
+
58
+ ##Create node files
59
+
60
+ These files indicate the nodes (or hosts) that the tests will be run on. By default, any node file called `default.yml` will be used. You can override this using the `BEAKER_set` environment variable to indicate an alternate file. Do not provide full path or the '.yml' file extension to `BEAKER_set`, it is assumed to be located in 'spec/acceptance/nodesets/${NAME}.yml' by beaker-rspec. If you wish to use a completely different file location use `BEAKER_setfile` and set it to the full path (including file extension) of your hosts file.
61
+
62
+ Nodes are pulled from [Puppet Labs Vagrant Boxes](https://vagrantcloud.com/puppetlabs).
63
+
64
+ Example node files can be found here:
65
+
66
+ * [Puppet Labs example Vagrant node files](https://github.com/puppetlabs/beaker/blob/master/docs/Example-Vagrant-Hosts-Files.md)
67
+
68
+ Create the nodesets directory. From module's top level directory:
69
+
70
+ mkdir -p spec/acceptance/nodesets
71
+
72
+ Copy any nodesets that you wish to use into the nodesets directory.
73
+
74
+ ##Create the spec_helper_acceptance.rb
75
+
76
+ Create example file `spec_helper_acceptance.rb`:
77
+
78
+ ```ruby
79
+ require 'beaker-rspec'
80
+ require 'pry'
81
+
82
+ # Install Puppet on all hosts
83
+ hosts.each do |host|
84
+ on host, install_puppet
85
+ end
86
+
87
+ RSpec.configure do |c|
88
+ module_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
89
+
90
+ c.formatter = :documentation
91
+
92
+ c.before :suite do
93
+ # Install module to all hosts
94
+ hosts.each do |host|
95
+ install_dev_puppet_module_on(host, :source => module_root, :module_name => 'mysql',
96
+ :target_module_path => '/etc/puppet/modules')
97
+ # Install dependencies
98
+ on(host, puppet('module', 'install', 'puppetlabs-stdlib'))
99
+
100
+ # Add more setup code as needed
101
+ end
102
+ end
103
+ end
104
+ ```
105
+
106
+ Update spec_helper_acceptance.rb to reflect the module under test. You will need to set the correct module name and add any module dependencies. Place the file in the `spec` directory (in this case `puppetlabs-mysql/spec`)
107
+
108
+ ##Create spec tests for your module
109
+
110
+ Spec tests are written in [RSpec](http://rspec.info). You can also use [serverspec](http://serverspec.org/) matchers to test [resources](http://serverspec.org/resource_types.html).
111
+
112
+ Example spec file `spec/acceptance/mysql_account_delete_spec.rb`:
113
+
114
+ ```ruby
115
+ require 'spec_helper_acceptance'
116
+
117
+ describe 'mysql::server::account_security class' do
118
+ let(:manifest) {
119
+ <<-EOS
120
+ class { 'mysql::server': remove_default_accounts => true }
121
+ EOS
122
+ }
123
+
124
+ it 'should run without errors' do
125
+ result = apply_manifest(manifest)
126
+ expect(@result.exit_code).to eq 2
127
+ end
128
+
129
+ it 'should delete accounts' do
130
+ grants_results = shell("mysql -e 'show grants for root@127.0.0.1;'")
131
+ expect(grants_results.exit_code).to eq 1
132
+ end
133
+
134
+ it 'should delete databases' do
135
+ show_result = shell("mysql -e 'show databases;'")
136
+ expect(show_result.stdout).not_to match /test/
137
+ end
138
+
139
+ it 'should run a second time without changes' do
140
+ result = apply_manifest(manifest)
141
+ expect(@result.exit_code).to eq 0
142
+ end
143
+
144
+ describe package('mysql-server') do
145
+ it { is_expected.to be_installed }
146
+ end
147
+ end
148
+ ```
149
+
150
+ ##Run your spec tests
151
+
152
+ From module's top level directory
153
+
154
+ bundle exec rspec spec/acceptance
@@ -235,10 +235,20 @@ module Specinfra::Backend
235
235
  def run_command(cmd, opt = {})
236
236
  node = get_working_node
237
237
  script = create_script(cmd)
238
- on node, "rm -f script.ps1"
238
+ #when node is not cygwin rm -rf will fail so lets use native del instead
239
+ #There should be a better way to do this, but for now , this works
240
+ if node.is_cygwin?
241
+ delete_command = "rm -rf"
242
+ redirection = "< /dev/null"
243
+ else
244
+ delete_command = "del"
245
+ redirection = "< NUL"
246
+ end
247
+ on node, "#{delete_command} script.ps1"
239
248
  create_remote_file(node, 'script.ps1', script)
240
- # cygwin support /dev/null, if running from winrm would use < NULL
241
- ret = ssh_exec!(node, "powershell.exe -File script.ps1 < /dev/null")
249
+ #When using cmd on a pswindows node redirection should be set to < NUl
250
+ #when using a cygwing one, /dev/null should be fine
251
+ ret = ssh_exec!(node, "powershell.exe -File script.ps1 #{redirection}")
242
252
 
243
253
  if @example
244
254
  @example.metadata[:command] = script
@@ -47,6 +47,11 @@ RSpec.configure do |c|
47
47
  c.validate
48
48
  c.configure
49
49
 
50
+ trap "SIGINT" do
51
+ c.cleanup
52
+ exit!(1)
53
+ end
54
+
50
55
  # Destroy nodes if no preserve hosts
51
56
  c.after :suite do
52
57
  case options[:destroy]
@@ -1,5 +1,5 @@
1
1
  module BeakerRSpec
2
2
  module Version
3
- STRING = '5.3.0'
3
+ STRING = '5.4.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.0
4
+ version: 5.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-13 00:00:00.000000000 Z
11
+ date: 2016-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest