barking_iguana-compound 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/barking_iguana-compound.gemspec +1 -0
- data/docs/CHANGELOG.md +3 -0
- data/docs/TODO.md +11 -5
- data/examples/simple/Gemfile.lock +5 -3
- data/examples/simple/test/compound/simple/000-setup/playbook.yml +1 -1
- data/examples/simple/test/compound/simple/001-replay/_ansible/play_spec.rb +7 -0
- data/examples/simple/test/compound/simple/001-replay/example-host/example_spec.rb +5 -0
- data/examples/simple/test/compound/simple/001-replay/playbook.yml +10 -0
- data/lib/barking_iguana/compound/ansible/playbook.rb +15 -8
- data/lib/barking_iguana/compound/ansible/results_parser.rb +26 -0
- data/lib/barking_iguana/compound/ansible_spec.rb +56 -0
- data/lib/barking_iguana/compound/server_spec.rb +2 -2
- data/lib/barking_iguana/compound/test_stage.rb +43 -5
- data/lib/barking_iguana/compound/version.rb +1 -1
- data/lib/barking_iguana/compound.rb +3 -0
- data/resources/ansible_spec_helper.rb +1 -0
- data/{lib/barking_iguana/compound/spec_helper.rb → resources/server_spec_helper.rb} +0 -0
- metadata +23 -4
- data/resources/spec_helper.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4102d07d853b0631a982911f35b114ba5efd7cc
|
4
|
+
data.tar.gz: 83af11d838771d6f83056556f37d74a8ab4345f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01055224b326b78a45d016547f9644f7f1d82b2db2b9245b1e3813372df67194bb699a9354b622f3f631c51f2d6cbcd3e754bd960b0c75b20c4d5df6e16175d3
|
7
|
+
data.tar.gz: 29539c1a69fa7a4006818855d357e5aa6ed568bcb93c834f5ae0cddca7adff749205ba9a1b2cbfc2f890fb271b04ca9b3f256bab77f178bf31c4a44722b78c56
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
|
36
36
|
spec.add_dependency 'barking_iguana-logging'
|
37
37
|
spec.add_dependency 'barking_iguana-benchmark'
|
38
|
+
spec.add_dependency 'barking_iguana-fork_calls'
|
38
39
|
spec.add_dependency 'mixlib-shellout'
|
39
40
|
spec.add_dependency 'rspec-wait'
|
40
41
|
spec.add_dependency 'ansible_spec'
|
data/docs/CHANGELOG.md
CHANGED
@@ -4,6 +4,9 @@ Entries are in reverse chronological order.
|
|
4
4
|
|
5
5
|
## *0.1.12* (Current Development)
|
6
6
|
|
7
|
+
* Initial support for testing the results of the playbook run, to check for
|
8
|
+
number of changes applied by `ansible-playbook`.
|
9
|
+
|
7
10
|
## *0.1.11* (2017-01-17)
|
8
11
|
|
9
12
|
* Increase wait time for Ansible Playbook run to 1 hour instead of teh default
|
data/docs/TODO.md
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
# TODO
|
2
2
|
|
3
3
|
* We can add machines to different networks because even though we require
|
4
|
-
`10.8.*`, the networks created are `/24`'s. These should either be `/16`
|
5
|
-
avoid surprises, or we should make the CIDR configurable, or we should
|
6
|
-
example showing this behaviour.
|
4
|
+
`10.8.*`, the networks created are `/24`'s. These should either be `/16`
|
5
|
+
to avoid surprises, or we should make the CIDR configurable, or we should
|
6
|
+
give an example showing this behaviour.
|
7
7
|
|
8
|
-
* Tests. So ironic that a testing tool has no tests. For release 1.0.0 we
|
8
|
+
* Tests. So ironic that a testing tool has no tests. For release 1.0.0 we
|
9
|
+
need tests.
|
9
10
|
|
10
|
-
* We should support the ansible remote user attributes in the inventory, for
|
11
|
+
* We should support the ansible remote user attributes in the inventory, for
|
12
|
+
each host.
|
11
13
|
|
12
14
|
* Rewrite the InventoryParser so it's understandable!
|
13
15
|
|
14
16
|
* Make command timeouts customiseable.
|
17
|
+
|
18
|
+
* Stop paying attention to `~/.ssh/known_hosts` inside the tests. If these
|
19
|
+
host keys exist we end up with test failures, even though we _do_ expected
|
20
|
+
these to change.
|
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../
|
3
3
|
specs:
|
4
|
-
barking_iguana-compound (0.1.
|
4
|
+
barking_iguana-compound (0.1.11)
|
5
5
|
ansible_spec
|
6
6
|
barking_iguana-benchmark
|
7
|
+
barking_iguana-fork_calls
|
7
8
|
barking_iguana-logging
|
8
9
|
colorize
|
9
10
|
hostlist_expression
|
@@ -20,13 +21,14 @@ GEM
|
|
20
21
|
serverspec (>= 2.0.0)
|
21
22
|
winrm
|
22
23
|
barking_iguana-benchmark (0.1.1)
|
24
|
+
barking_iguana-fork_calls (0.1.0)
|
23
25
|
barking_iguana-logging (0.1.7)
|
24
26
|
barking_iguana-otk
|
25
27
|
term-ansicolor
|
26
28
|
barking_iguana-otk (0.1.0)
|
27
29
|
builder (3.2.3)
|
28
30
|
colorize (0.8.1)
|
29
|
-
diff-lcs (1.
|
31
|
+
diff-lcs (1.3)
|
30
32
|
erubis (2.7.0)
|
31
33
|
ffi (1.9.17)
|
32
34
|
gssapi (1.2.0)
|
@@ -73,7 +75,7 @@ GEM
|
|
73
75
|
rspec-its
|
74
76
|
specinfra (~> 2.53)
|
75
77
|
sfl (2.3)
|
76
|
-
specinfra (2.66.
|
78
|
+
specinfra (2.66.5)
|
77
79
|
net-scp
|
78
80
|
net-ssh (>= 2.7, < 5.0)
|
79
81
|
net-telnet
|
@@ -48,13 +48,8 @@ module BarkingIguana
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def run
|
51
|
-
|
52
|
-
|
53
|
-
options[:live_stream] = io if io
|
54
|
-
options[:timeout] = 3600
|
55
|
-
c = Mixlib::ShellOut.new(command, options)
|
56
|
-
c.run_command
|
57
|
-
c.error!
|
51
|
+
command.run_command
|
52
|
+
command.error!
|
58
53
|
self
|
59
54
|
ensure
|
60
55
|
clean_up
|
@@ -62,6 +57,18 @@ module BarkingIguana
|
|
62
57
|
|
63
58
|
private
|
64
59
|
|
60
|
+
def command
|
61
|
+
@command ||= Mixlib::ShellOut.new(command_line, command_options)
|
62
|
+
end
|
63
|
+
|
64
|
+
def command_options
|
65
|
+
options = {}
|
66
|
+
options[:cwd] = run_from if run_from
|
67
|
+
options[:live_stream] = io if io
|
68
|
+
options[:timeout] = 3600
|
69
|
+
options
|
70
|
+
end
|
71
|
+
|
65
72
|
def clean_up
|
66
73
|
return unless run_from
|
67
74
|
FileUtils.remove_file wrapper_playbook, true
|
@@ -86,7 +93,7 @@ module BarkingIguana
|
|
86
93
|
end
|
87
94
|
end
|
88
95
|
|
89
|
-
def
|
96
|
+
def command_line
|
90
97
|
c = ["env ANSIBLE_RETRY_FILES_ENABLED=no ansible-playbook #{playbook_paths}"]
|
91
98
|
inventory_paths.each do |i|
|
92
99
|
c << "-i #{i}"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module BarkingIguana
|
2
|
+
module Compound
|
3
|
+
module Ansible
|
4
|
+
class ResultsParser
|
5
|
+
attr_accessor :file
|
6
|
+
private :file=, :file
|
7
|
+
|
8
|
+
def initialize file
|
9
|
+
self.file = file
|
10
|
+
end
|
11
|
+
|
12
|
+
def recap
|
13
|
+
OpenStruct.new total_changes: total_changes
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def total_changes
|
19
|
+
recap_text = File.read(file).split(/^PLAY RECAP \**$/)[-1].strip
|
20
|
+
matches = recap_text.scan(/ changed=(\d+) /)
|
21
|
+
matches[0].map(&:to_i).inject(&:+)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module BarkingIguana
|
2
|
+
module Compound
|
3
|
+
class AnsibleSpec
|
4
|
+
extend Forwardable
|
5
|
+
attr_accessor :stage
|
6
|
+
|
7
|
+
def initialize stage
|
8
|
+
self.stage = stage
|
9
|
+
end
|
10
|
+
|
11
|
+
include BarkingIguana::Logging::Helper
|
12
|
+
include BarkingIguana::Benchmark
|
13
|
+
|
14
|
+
def run
|
15
|
+
unless File.exists? ansible_test_directory
|
16
|
+
logger.debug { "#{ansible_test_directory} doesn't exist, assuming no ansible tests for this stage" }
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
command = "bundle exec ruby -S rspec -r #{spec_helper} #{test_files.join(' ')}"
|
21
|
+
c = Mixlib::ShellOut.new command, live_stream: logger, cwd: control_repo_dir, env: env
|
22
|
+
benchmark command do
|
23
|
+
c.run_command
|
24
|
+
end
|
25
|
+
logger.info { "ansible tests exited with status #{c.exitstatus}" }
|
26
|
+
c.error!
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def test_files
|
32
|
+
Dir.glob File.expand_path '**/*_spec.rb', ansible_test_directory
|
33
|
+
end
|
34
|
+
|
35
|
+
def env
|
36
|
+
{
|
37
|
+
ANSIBLE_RESULTS_FILE: ansible_results_file
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def spec_helper
|
42
|
+
File.expand_path '../../../../resources/ansible_spec_helper.rb', __FILE__
|
43
|
+
end
|
44
|
+
|
45
|
+
def ansible_test_directory
|
46
|
+
File.expand_path '_ansible', root_dir
|
47
|
+
end
|
48
|
+
|
49
|
+
def_delegator :stage, :test
|
50
|
+
def_delegator :stage, :stage_directory, :root_dir
|
51
|
+
def_delegator :stage, :results_file, :ansible_results_file
|
52
|
+
def_delegator :test, :suite
|
53
|
+
def_delegator :suite, :control_directory, :control_repo_dir
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -35,7 +35,7 @@ module BarkingIguana
|
|
35
35
|
def host_tests
|
36
36
|
hosts.inject({}) do |a,e|
|
37
37
|
name = e.name
|
38
|
-
glob = "#{root_dir}
|
38
|
+
glob = "#{root_dir}/#{name}/**/*_spec.rb"
|
39
39
|
logger.debug { "Host glob for #{name.inspect} = #{glob.inspect}" }
|
40
40
|
tests = Dir.glob glob
|
41
41
|
logger.debug { "Host tests for #{name.inspect} = #{tests.inspect}" }
|
@@ -50,7 +50,7 @@ module BarkingIguana
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def spec_helper
|
53
|
-
File.expand_path '../../../../resources/
|
53
|
+
File.expand_path '../../../../resources/server_spec_helper.rb', __FILE__
|
54
54
|
end
|
55
55
|
|
56
56
|
def_delegator :stage, :test
|
@@ -68,9 +68,17 @@ module BarkingIguana
|
|
68
68
|
@generated_inventory ||= generate_inventory
|
69
69
|
end
|
70
70
|
|
71
|
+
def tmp_dir *sub_path
|
72
|
+
@tmp_dir ||= Dir.mktmpdir
|
73
|
+
return @tmp_dir if sub_path.empty?
|
74
|
+
full_path = File.expand_path File.join(sub_path), @tmp_dir
|
75
|
+
FileUtils.mkdir_p full_path
|
76
|
+
full_path
|
77
|
+
end
|
78
|
+
|
71
79
|
def generate_inventory
|
72
80
|
benchmark "#{name}: generating inventory for test stage" do
|
73
|
-
|
81
|
+
tmp_dir('inventory').tap do |d|
|
74
82
|
logger.debug { "#{name}: inventory directory is #{d.inspect}" }
|
75
83
|
connection_file = File.expand_path 'connection', d
|
76
84
|
Ansible::InventoryWriter.new(connection_file).tap do |i|
|
@@ -96,7 +104,11 @@ module BarkingIguana
|
|
96
104
|
end
|
97
105
|
|
98
106
|
def playbook
|
99
|
-
Ansible.playbook(playbook_path, run_from: control_directory).inventory(generated_inventory).stream_to(
|
107
|
+
Ansible.playbook(playbook_path, run_from: control_directory).inventory(generated_inventory).stream_to(playbook_logger).verbosity(ansible_verbosity).diff
|
108
|
+
end
|
109
|
+
|
110
|
+
def playbook_logger
|
111
|
+
@playbook_logger ||= BarkingIguana::ForkCalls.fork_to(logger, results_logger)
|
100
112
|
end
|
101
113
|
|
102
114
|
def setup
|
@@ -123,15 +135,41 @@ module BarkingIguana
|
|
123
135
|
FileUtils.rm_r generated_inventory
|
124
136
|
end
|
125
137
|
|
126
|
-
def
|
127
|
-
|
138
|
+
def clean_up
|
139
|
+
logger.debug { "Removing temporary directory for stage #{name} from #{tmp_dir}" }
|
140
|
+
FileUtils.rm_r tmp_dir
|
128
141
|
end
|
129
142
|
|
130
143
|
def_delegator :original_inventory, :hosts
|
131
144
|
def_delegator :test, :suite
|
132
145
|
def_delegator :test, :host_manager
|
133
146
|
def_delegator :suite, :control_directory
|
134
|
-
|
147
|
+
|
148
|
+
def verify
|
149
|
+
server_spec.run
|
150
|
+
ansible_spec.run
|
151
|
+
end
|
152
|
+
|
153
|
+
def results_file
|
154
|
+
@results_file ||= File.expand_path('playbook.out', tmp_dir('results', 'ansible'))
|
155
|
+
end
|
156
|
+
|
157
|
+
private
|
158
|
+
|
159
|
+
def server_spec
|
160
|
+
@server_spec ||= ServerSpec.new(self)
|
161
|
+
end
|
162
|
+
|
163
|
+
def ansible_spec
|
164
|
+
@ansible_spec ||= AnsibleSpec.new(self)
|
165
|
+
end
|
166
|
+
|
167
|
+
def results_logger
|
168
|
+
@results_logger ||= ::Logger.new(results_file).tap do |l|
|
169
|
+
l.level = ::Logger::DEBUG
|
170
|
+
l.formatter = lambda { |_, _, _, message| message }
|
171
|
+
end
|
172
|
+
end
|
135
173
|
end
|
136
174
|
end
|
137
175
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'barking_iguana/logging'
|
2
2
|
require 'barking_iguana/benchmark'
|
3
|
+
require 'barking_iguana/fork_calls'
|
3
4
|
|
4
5
|
require 'erb'
|
5
6
|
require 'forwardable'
|
@@ -13,11 +14,13 @@ require 'barking_iguana/compound/ansible'
|
|
13
14
|
require 'barking_iguana/compound/ansible/inventory'
|
14
15
|
require 'barking_iguana/compound/ansible/inventory_parser'
|
15
16
|
require 'barking_iguana/compound/ansible/inventory_writer'
|
17
|
+
require 'barking_iguana/compound/ansible/results_parser'
|
16
18
|
require 'barking_iguana/compound/ansible/playbook'
|
17
19
|
require 'barking_iguana/compound/command_line_client'
|
18
20
|
require 'barking_iguana/compound/environment'
|
19
21
|
require 'barking_iguana/compound/host_manager'
|
20
22
|
require 'barking_iguana/compound/host'
|
23
|
+
require 'barking_iguana/compound/ansible_spec'
|
21
24
|
require 'barking_iguana/compound/server_spec'
|
22
25
|
require 'barking_iguana/compound/test_stage'
|
23
26
|
require 'barking_iguana/compound/test'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'barking_iguana/compound'
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barking_iguana-compound
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig R Webster
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: barking_iguana-fork_calls
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: mixlib-shellout
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,6 +203,9 @@ files:
|
|
189
203
|
- examples/simple/Rakefile
|
190
204
|
- examples/simple/test/compound/simple/000-setup/example-host/example_spec.rb
|
191
205
|
- examples/simple/test/compound/simple/000-setup/playbook.yml
|
206
|
+
- examples/simple/test/compound/simple/001-replay/_ansible/play_spec.rb
|
207
|
+
- examples/simple/test/compound/simple/001-replay/example-host/example_spec.rb
|
208
|
+
- examples/simple/test/compound/simple/001-replay/playbook.yml
|
192
209
|
- examples/simple/test/compound/simple/Vagrantfile
|
193
210
|
- examples/simple/test/compound/simple/inventory
|
194
211
|
- exe/compound
|
@@ -198,19 +215,21 @@ files:
|
|
198
215
|
- lib/barking_iguana/compound/ansible/inventory_parser.rb
|
199
216
|
- lib/barking_iguana/compound/ansible/inventory_writer.rb
|
200
217
|
- lib/barking_iguana/compound/ansible/playbook.rb
|
218
|
+
- lib/barking_iguana/compound/ansible/results_parser.rb
|
219
|
+
- lib/barking_iguana/compound/ansible_spec.rb
|
201
220
|
- lib/barking_iguana/compound/command_line_client.rb
|
202
221
|
- lib/barking_iguana/compound/environment.rb
|
203
222
|
- lib/barking_iguana/compound/host.rb
|
204
223
|
- lib/barking_iguana/compound/host_manager.rb
|
205
224
|
- lib/barking_iguana/compound/server_spec.rb
|
206
|
-
- lib/barking_iguana/compound/spec_helper.rb
|
207
225
|
- lib/barking_iguana/compound/test.rb
|
208
226
|
- lib/barking_iguana/compound/test_stage.rb
|
209
227
|
- lib/barking_iguana/compound/test_suite.rb
|
210
228
|
- lib/barking_iguana/compound/vagrant.rb
|
211
229
|
- lib/barking_iguana/compound/version.rb
|
212
230
|
- resources/Vagrantfile.erb
|
213
|
-
- resources/
|
231
|
+
- resources/ansible_spec_helper.rb
|
232
|
+
- resources/server_spec_helper.rb
|
214
233
|
homepage: https://github.com/barkingiguana/compound
|
215
234
|
licenses: []
|
216
235
|
metadata:
|