praegustator 0.2.0 → 0.3.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 +8 -8
- data/Gemfile +1 -2
- data/Gemfile.lock +76 -111
- data/features/praegustator.feature +9 -1
- data/features/support/env.rb +1 -1
- data/features/support/setup.rb +3 -0
- data/features_setup/setup/.zero-knife.rb +1 -1
- data/lib/praegustator.rb +11 -1
- data/lib/praegustator/cli.rb +8 -3
- data/lib/praegustator/executor.rb +7 -1
- data/lib/praegustator/reporter.rb +74 -0
- data/lib/praegustator/setup.rb +14 -10
- data/lib/praegustator/version.rb +1 -1
- data/lib/praegustator/wrappers/chef.rb +1 -0
- data/lib/praegustator/wrappers/server_spec.rb +35 -41
- data/praegustator.gemspec +3 -2
- data/readme.md +1 -1
- data/spec/praegustator/cli_spec.rb +10 -9
- data/spec/praegustator/executor_spec.rb +25 -0
- data/spec/spec_helper.rb +1 -0
- metadata +25 -9
- data/lib/praegustator/wrappers/output_parser.rb +0 -21
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2ZkOGNiMDIzNmFkNGM2N2I2MzM4ZDMyMTcwNjhiYzA0Y2VjMjQ5Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGY5ZWRlYjQ5ZWQ5NGIwZjBjZGMxMDQzYTZjY2RiOWE5MGI1ODUyNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2RhYjU1ZDYyZTI1ZTFmM2QwYzc3OGI3NjdiMTcwN2NkMjk1YThkOWZkNTIz
|
10
|
+
NzQ1M2QzYWZkZTgyNDI4Mjg3NjZhODM4N2ZkMjA4OGY2MTEzY2M4MDU2NGNm
|
11
|
+
MzUzZjY0NmNmMTlkZWYzYTU0NzFiMDcwODIxY2I0MjcyNDdiYjQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDZmNDM0MTMwZWJlNzMxNDNiMjg1ZjU0NmU1MDVmZTJiY2Y5OWE5MjlhNTFj
|
14
|
+
MDAxMGE5ZWM0MTAwZjQ5ZWIyNjM3OWFkMWQ1MjBmMmYzMTljZmEzY2RkZDBh
|
15
|
+
ZGMwZjUzNjZhNDhkMzdhNDE5YTEyMmY1NDZiMzk0ZmY5M2U0YmE=
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,109 +1,88 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
praegustator (0.2.0)
|
5
|
+
chef (>= 11.4.4)
|
6
|
+
colorize
|
7
|
+
rspec (>= 2.13.0)
|
8
|
+
serverspec
|
9
|
+
thor
|
10
|
+
|
1
11
|
GEM
|
2
12
|
remote: https://rubygems.org/
|
3
13
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
akami (1.2.0)
|
9
|
-
gyoku (>= 0.4.0)
|
10
|
-
nokogiri (>= 1.4.0)
|
11
|
-
berkshelf (2.0.10)
|
12
|
-
activesupport (~> 3.2.0)
|
13
|
-
addressable (~> 2.3.4)
|
14
|
-
buff-shell_out (~> 0.1)
|
15
|
-
chozo (>= 0.6.1)
|
16
|
-
faraday (>= 0.8.5)
|
17
|
-
hashie (>= 2.0.2)
|
18
|
-
minitar (~> 0.5.4)
|
19
|
-
rbzip2 (~> 0.2.0)
|
20
|
-
retryable (~> 1.3.3)
|
21
|
-
ridley (~> 1.5.0)
|
22
|
-
solve (>= 0.5.0)
|
23
|
-
thor (~> 0.18.0)
|
24
|
-
buff-config (0.4.0)
|
25
|
-
buff-extensions (~> 0.3)
|
26
|
-
varia_model (~> 0.1)
|
27
|
-
buff-extensions (0.5.0)
|
28
|
-
buff-ignore (1.1.0)
|
29
|
-
buff-ruby_engine (0.1.0)
|
30
|
-
buff-shell_out (0.1.1)
|
31
|
-
buff-ruby_engine (~> 0.1.0)
|
14
|
+
aruba (0.5.3)
|
15
|
+
childprocess (>= 0.3.6)
|
16
|
+
cucumber (>= 1.1.1)
|
17
|
+
rspec-expectations (>= 2.7.0)
|
32
18
|
builder (3.2.2)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
19
|
+
chef (11.6.0)
|
20
|
+
erubis
|
21
|
+
highline (>= 1.6.9)
|
22
|
+
json (>= 1.4.4, <= 1.7.7)
|
23
|
+
mixlib-authentication (>= 1.3.0)
|
24
|
+
mixlib-cli (~> 1.3.0)
|
25
|
+
mixlib-config (>= 1.1.2)
|
26
|
+
mixlib-log (>= 1.3.0)
|
27
|
+
mixlib-shellout
|
28
|
+
net-ssh (~> 2.6)
|
29
|
+
net-ssh-multi (~> 1.1.0)
|
30
|
+
ohai (>= 0.6.0)
|
31
|
+
rest-client (>= 1.0.4, < 1.7.0)
|
32
|
+
yajl-ruby (~> 1.1)
|
33
|
+
childprocess (0.3.9)
|
34
|
+
ffi (~> 1.0, >= 1.0.11)
|
42
35
|
coderay (1.0.9)
|
36
|
+
colorize (0.6.0)
|
37
|
+
cucumber (1.3.10)
|
38
|
+
builder (>= 2.1.2)
|
39
|
+
diff-lcs (>= 1.1.3)
|
40
|
+
gherkin (~> 2.12)
|
41
|
+
multi_json (>= 1.7.5, < 2.0)
|
42
|
+
multi_test (>= 0.0.2)
|
43
43
|
diff-lcs (1.2.5)
|
44
44
|
erubis (2.7.0)
|
45
|
-
faraday (0.8.8)
|
46
|
-
multipart-post (~> 1.2.0)
|
47
45
|
ffi (1.9.3)
|
48
46
|
fuubar (1.2.1)
|
49
47
|
rspec (~> 2.0)
|
50
48
|
rspec-instafail (~> 0.2.0)
|
51
49
|
ruby-progressbar (~> 1.0)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
httpclient (2.3.4.1)
|
58
|
-
httpi (0.9.7)
|
59
|
-
rack
|
60
|
-
i18n (0.6.5)
|
61
|
-
json (1.8.1)
|
62
|
-
little-plugger (1.1.3)
|
63
|
-
logging (1.8.1)
|
64
|
-
little-plugger (>= 1.1.3)
|
65
|
-
multi_json (>= 1.3.6)
|
50
|
+
gherkin (2.12.2)
|
51
|
+
multi_json (~> 1.3)
|
52
|
+
highline (1.6.20)
|
53
|
+
ipaddress (0.8.0)
|
54
|
+
json (1.7.7)
|
66
55
|
method_source (0.8.2)
|
67
|
-
|
68
|
-
minitar (0.5.4)
|
56
|
+
mime-types (2.0)
|
69
57
|
mixlib-authentication (1.3.0)
|
70
58
|
mixlib-log
|
59
|
+
mixlib-cli (1.3.0)
|
60
|
+
mixlib-config (2.0.0)
|
71
61
|
mixlib-log (1.6.0)
|
62
|
+
mixlib-shellout (1.2.0)
|
72
63
|
multi_json (1.8.2)
|
73
|
-
|
74
|
-
net-http-persistent (2.9)
|
64
|
+
multi_test (0.0.2)
|
75
65
|
net-ssh (2.7.0)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
66
|
+
net-ssh-gateway (1.2.0)
|
67
|
+
net-ssh (>= 2.6.5)
|
68
|
+
net-ssh-multi (1.1)
|
69
|
+
net-ssh (>= 2.1.4)
|
70
|
+
net-ssh-gateway (>= 0.99.0)
|
71
|
+
ohai (6.20.0)
|
72
|
+
ipaddress
|
73
|
+
mixlib-cli
|
74
|
+
mixlib-config
|
75
|
+
mixlib-log
|
76
|
+
mixlib-shellout
|
77
|
+
systemu (~> 2.5.2)
|
78
|
+
yajl-ruby
|
80
79
|
pry (0.9.12.2)
|
81
80
|
coderay (~> 1.0.5)
|
82
81
|
method_source (~> 0.8)
|
83
82
|
slop (~> 3.4)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
ridley (1.5.3)
|
88
|
-
addressable
|
89
|
-
buff-config (~> 0.2)
|
90
|
-
buff-extensions (~> 0.3)
|
91
|
-
buff-ignore (~> 1.1)
|
92
|
-
buff-shell_out (~> 0.1)
|
93
|
-
celluloid (~> 0.14.0)
|
94
|
-
celluloid-io (~> 0.14.0)
|
95
|
-
erubis
|
96
|
-
faraday (>= 0.8.4)
|
97
|
-
hashie (>= 2.0.2)
|
98
|
-
json (>= 1.7.7)
|
99
|
-
mixlib-authentication (>= 1.3.0)
|
100
|
-
net-http-persistent (>= 2.8)
|
101
|
-
net-ssh
|
102
|
-
nio4r (>= 0.5.0)
|
103
|
-
retryable
|
104
|
-
solve (>= 0.4.4)
|
105
|
-
varia_model (~> 0.1)
|
106
|
-
winrm (~> 1.1.0)
|
83
|
+
rake (10.1.0)
|
84
|
+
rest-client (1.6.7)
|
85
|
+
mime-types (>= 1.16)
|
107
86
|
rspec (2.14.1)
|
108
87
|
rspec-core (~> 2.14.0)
|
109
88
|
rspec-expectations (~> 2.14.0)
|
@@ -114,39 +93,25 @@ GEM
|
|
114
93
|
rspec-instafail (0.2.4)
|
115
94
|
rspec-mocks (2.14.4)
|
116
95
|
ruby-progressbar (1.2.0)
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
gyoku (>= 0.4.0)
|
122
|
-
httpi (~> 0.9)
|
123
|
-
nokogiri (>= 1.4.0)
|
124
|
-
nori (~> 1.0)
|
125
|
-
wasabi (~> 1.0)
|
96
|
+
serverspec (0.11.5)
|
97
|
+
highline
|
98
|
+
net-ssh
|
99
|
+
rspec (>= 2.13.0)
|
126
100
|
slop (3.4.6)
|
127
|
-
|
101
|
+
systemu (2.5.2)
|
128
102
|
thor (0.18.1)
|
129
|
-
|
130
|
-
uuidtools (2.1.4)
|
131
|
-
varia_model (0.2.0)
|
132
|
-
buff-extensions (~> 0.2)
|
133
|
-
hashie (>= 2.0.2)
|
134
|
-
wasabi (1.0.0)
|
135
|
-
nokogiri (>= 1.4.0)
|
136
|
-
winrm (1.1.3)
|
137
|
-
gssapi (~> 1.0.0)
|
138
|
-
httpclient (~> 2.2, >= 2.2.0.2)
|
139
|
-
logging (~> 1.6, >= 1.6.1)
|
140
|
-
nokogiri (~> 1.5)
|
141
|
-
rubyntlm (~> 0.1.1)
|
142
|
-
savon (= 0.9.5)
|
143
|
-
uuidtools (~> 2.1.2)
|
103
|
+
yajl-ruby (1.1.0)
|
144
104
|
|
145
105
|
PLATFORMS
|
146
106
|
ruby
|
147
107
|
|
148
108
|
DEPENDENCIES
|
149
|
-
|
109
|
+
aruba
|
110
|
+
bundler (~> 1.3)
|
111
|
+
cucumber
|
150
112
|
fuubar
|
113
|
+
praegustator!
|
151
114
|
pry
|
152
|
-
|
115
|
+
rake
|
116
|
+
rspec (>= 2.13.0)
|
117
|
+
rspec-mocks
|
@@ -3,6 +3,14 @@ Feature: Praegustator
|
|
3
3
|
As a CLI
|
4
4
|
I want to check the apache installed
|
5
5
|
|
6
|
-
Scenario:
|
6
|
+
Scenario: validate
|
7
7
|
When I run `praeg validate`
|
8
8
|
Then the output should contain "should be installed"
|
9
|
+
|
10
|
+
Scenario: taste
|
11
|
+
When I run `praeg taste role:* nginx`
|
12
|
+
Then the output should contain "should be installed"
|
13
|
+
|
14
|
+
Scenario: no node found
|
15
|
+
When I run `praeg taste role:foo nginx`
|
16
|
+
Then the output should contain "no node found for search criteria: role:foo\n"
|
data/features/support/env.rb
CHANGED
data/features/support/setup.rb
CHANGED
data/lib/praegustator.rb
CHANGED
@@ -5,11 +5,13 @@ require 'praegustator/test_suite'
|
|
5
5
|
require 'praegustator/dsl'
|
6
6
|
require 'praegustator/wrappers/chef'
|
7
7
|
require 'praegustator/node'
|
8
|
+
require 'praegustator/reporter'
|
8
9
|
require 'praegustator/setup'
|
9
10
|
require 'yaml'
|
10
11
|
require 'colorize'
|
11
12
|
|
12
13
|
module Praegustator
|
14
|
+
@reporter = Praegustator::Reporter.new
|
13
15
|
@config = {
|
14
16
|
'log_level' => 'info',
|
15
17
|
'search_driver' => 'chef',
|
@@ -25,6 +27,11 @@ module Praegustator
|
|
25
27
|
'user' => 'root',
|
26
28
|
'pasword' => nil,
|
27
29
|
'keys' => []
|
30
|
+
},
|
31
|
+
'report' => {
|
32
|
+
'show_summary' => true,
|
33
|
+
'show_passed' => true,
|
34
|
+
'show_failed' => true
|
28
35
|
}
|
29
36
|
}
|
30
37
|
|
@@ -43,6 +50,10 @@ module Praegustator
|
|
43
50
|
@config
|
44
51
|
end
|
45
52
|
|
53
|
+
def self.reporter
|
54
|
+
@reporter
|
55
|
+
end
|
56
|
+
|
46
57
|
private
|
47
58
|
def self.configure(opts = {})
|
48
59
|
valid_keys = @config.keys
|
@@ -50,7 +61,6 @@ module Praegustator
|
|
50
61
|
end
|
51
62
|
end
|
52
63
|
|
53
|
-
|
54
64
|
module RSpec
|
55
65
|
module Core
|
56
66
|
class Runner
|
data/lib/praegustator/cli.rb
CHANGED
@@ -3,6 +3,9 @@ require 'praegustator'
|
|
3
3
|
|
4
4
|
module Praegustator
|
5
5
|
class CLI < Thor
|
6
|
+
def self.exit_on_failure?
|
7
|
+
true
|
8
|
+
end
|
6
9
|
|
7
10
|
desc "taste", "test an check against a chef query"
|
8
11
|
long_desc <<-LONGDESC
|
@@ -12,9 +15,8 @@ module Praegustator
|
|
12
15
|
def taste(query,check)
|
13
16
|
config_file_path = Dir.pwd+"/.praegustator.yml"
|
14
17
|
Praegustator.configure_with config_file_path
|
15
|
-
|
16
|
-
|
17
|
-
Praegustator::Executor.new.execute(recipes)
|
18
|
+
Praegustator::Executor.new.execute_check(query,check)
|
19
|
+
exit 1 if Praegustator.reporter.status == 'failed'
|
18
20
|
end
|
19
21
|
|
20
22
|
desc "validate", "validate infrastructure by executing checks defined in recipe files"
|
@@ -24,6 +26,9 @@ module Praegustator
|
|
24
26
|
recipes_dir = Praegustator.config['spec']['recipes_dir']
|
25
27
|
recipes = Dir[Dir.pwd+"/#{recipes_dir}/**/*_recipe.rb"] if recipes.empty?
|
26
28
|
Praegustator::Executor.new.execute(recipes)
|
29
|
+
|
30
|
+
Praegustator.reporter.status
|
31
|
+
exit 1 if Praegustator.reporter.status == 'failed'
|
27
32
|
end
|
28
33
|
|
29
34
|
desc "init" , "setup praegustator"
|
@@ -2,12 +2,18 @@ require 'praegustator'
|
|
2
2
|
|
3
3
|
module Praegustator
|
4
4
|
class Executor
|
5
|
+
def initialize
|
6
|
+
end
|
5
7
|
def execute(recipes)
|
6
8
|
recipes.each do |recipe|
|
7
9
|
suits = Praegustator::Dsl.new.parse_file(recipe)
|
8
10
|
suits.each(&:execute)
|
9
11
|
end
|
10
12
|
end
|
13
|
+
def execute_check(query,check)
|
14
|
+
suite = Praegustator::TestSuite.new(query)
|
15
|
+
suite.check check
|
16
|
+
suite.execute
|
17
|
+
end
|
11
18
|
end
|
12
19
|
end
|
13
|
-
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Praegustator
|
2
|
+
class Reporter
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@test_suite_restults = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def status
|
9
|
+
@status
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_spec_result node,json
|
13
|
+
print_status node.ipaddress , json[:summary][:failure_count] > 0
|
14
|
+
return if json[:examples].nil?
|
15
|
+
@test_suite_restults[node] = json
|
16
|
+
print_summary node.query, json[:summary]
|
17
|
+
print_passed json[:examples].select{|e| e[:status] =='passed'}.map{|e| e[:full_description]}
|
18
|
+
print_failures json[:examples].select{|e| e[:status] =='failed'}.map{|e| e[:full_description]}
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def print_status ipaddress , failed
|
23
|
+
if failed
|
24
|
+
$stdout.puts "[Failed] #{ipaddress}".colorize(:red)
|
25
|
+
else
|
26
|
+
$stdout.puts "[Passed] #{ipaddress}".colorize(:green)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def print_summary query , summary
|
31
|
+
return if !Praegustator.config['report']['show_summary']
|
32
|
+
$stdout.puts ""
|
33
|
+
$stdout.puts " Summary:".colorize(:blue)
|
34
|
+
$stdout.puts " Chef Query: #{query}".colorize(:blue)
|
35
|
+
$stdout.puts " Duration: #{summary[:duration]}".colorize(:blue)
|
36
|
+
$stdout.puts " Total Checks: #{summary[:example_count]}".colorize(:blue)
|
37
|
+
$stdout.puts " Failed Checks: #{summary[:failure_count]}".colorize(:blue)
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def print_all_summary
|
42
|
+
duration = @test_suite_restults
|
43
|
+
example_count = @test_suite_restults
|
44
|
+
failure_count = @test_suite_restults
|
45
|
+
$stdout.puts ""
|
46
|
+
$stdout.puts " Summary:".colorize(:blue)
|
47
|
+
$stdout.puts " Duration: #{duration}".colorize(:blue)
|
48
|
+
$stdout.puts " Total Checks: #{example_count}".colorize(:blue)
|
49
|
+
$stdout.puts " Failed Checks: #{failure_count}".colorize(:blue)
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
def print_passed specs
|
55
|
+
return if !Praegustator.config['report']['show_passed']
|
56
|
+
return if specs.empty?
|
57
|
+
$stdout.puts ""
|
58
|
+
$stdout.puts " (#{specs.count}) Passed:".colorize(:green)
|
59
|
+
specs.each do |spec|
|
60
|
+
$stdout.puts " #{spec}".colorize(:green)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def print_failures specs
|
65
|
+
return if !Praegustator.config['report']['show_failed']
|
66
|
+
return if specs.empty?
|
67
|
+
$stdout.puts ""
|
68
|
+
$stdout.puts " (#{specs.count}) Failures:".colorize(:red)
|
69
|
+
specs.each do |spec|
|
70
|
+
$stdout.puts " #{spec}".colorize(:red)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/praegustator/setup.rb
CHANGED
@@ -36,16 +36,20 @@ end
|
|
36
36
|
knife_location = '~/.chef/knife.rb' if knife_location == ''
|
37
37
|
|
38
38
|
content = <<-EOF
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
|
39
|
+
spec:
|
40
|
+
recipes_dir: "#{dir}/"
|
41
|
+
checks_dir: "#{dir}/checks/"
|
42
|
+
chef:
|
43
|
+
knife_location: "#{knife_location}"
|
44
|
+
#ssh:
|
45
|
+
# user: "root"
|
46
|
+
# pasword: nil
|
47
|
+
# keys: [ "~/.ssh/id_rsa" ]
|
48
|
+
report:
|
49
|
+
show_summary: true
|
50
|
+
show_passed: true
|
51
|
+
show_failed: true
|
52
|
+
EOF
|
49
53
|
create_file ".praegustator.yml",content
|
50
54
|
end
|
51
55
|
|
data/lib/praegustator/version.rb
CHANGED
@@ -9,6 +9,7 @@ module Praegustator
|
|
9
9
|
::Chef::Config.from_file(File.expand_path(Praegustator.config['chef']['knife_location']))
|
10
10
|
chef_query = ::Chef::Search::Query.new
|
11
11
|
nodes = chef_query.search('node',query).first rescue []
|
12
|
+
$stdout.puts "no node found for search criteria: #{query}" if nodes.empty?
|
12
13
|
nodes.map{|n| Praegustator::Node.new n.name , n.ipaddress ,query}
|
13
14
|
end
|
14
15
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'praegustator'
|
2
|
-
require 'praegustator/wrappers/output_parser'
|
3
2
|
require 'net/ssh'
|
4
3
|
require 'serverspec'
|
5
4
|
require 'rspec/core/formatters/json_formatter'
|
@@ -11,52 +10,47 @@ include Serverspec::Helper::DetectOS
|
|
11
10
|
module Praegustator
|
12
11
|
module Wrappers
|
13
12
|
class ServerSpec
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def execute suite
|
14
|
+
suite.nodes.each do |node|
|
15
|
+
ENV['TARGET_HOST'] = node.ipaddress
|
16
|
+
spec_files = suite.checks.keys.map{|check| "#{Dir.pwd}/#{Praegustator.config['spec']['checks_dir']}/#{check}.rb" }
|
17
|
+
run_rspec suite, node, spec_files
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
|
-
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
private
|
22
|
+
def run_rspec suite, node, spec_files
|
23
|
+
formatter = RSpec::Core::Formatters::JsonFormatter.new(nil)
|
24
|
+
RSpec.clear_remaining_example_groups
|
25
|
+
load 'serverspec.rb'
|
26
|
+
begin
|
27
|
+
params = suite.params
|
28
|
+
params[:current_node] = node
|
29
|
+
RSpec.configure do |config|
|
30
|
+
config.host = ENV['TARGET_HOST']
|
31
|
+
options = Net::SSH::Config.for(config.host)
|
32
|
+
user = options[:user] || Praegustator.config['ssh']['user']
|
33
|
+
options[:keys] = Praegustator.config['ssh']['keys'] if options[:keys].nil?
|
34
|
+
options[:timeout] = 10
|
35
|
+
config.ssh = Net::SSH.start(config.host, user, options)
|
36
|
+
config.os = backend.check_os
|
37
|
+
set_property params
|
38
|
+
config.output = $stdout
|
39
|
+
config.color_enabled = true
|
40
|
+
config.tty = true
|
41
|
+
reporter = RSpec::Core::Reporter.new(formatter)
|
42
|
+
config.instance_variable_set(:@reporter, reporter)
|
43
|
+
end
|
26
44
|
begin
|
27
|
-
|
28
|
-
params[:current_node] = n
|
29
|
-
RSpec.configure do |c|
|
30
|
-
c.host = ENV['TARGET_HOST']
|
31
|
-
options = Net::SSH::Config.for(c.host)
|
32
|
-
user = options[:user] || Praegustator.config['ssh']['user']
|
33
|
-
options[:keys] = Praegustator.config['ssh']['keys'] if options[:keys].nil?
|
34
|
-
options[:timeout] = 10
|
35
|
-
c.ssh = Net::SSH.start(c.host, user, options)
|
36
|
-
c.os = backend.check_os
|
37
|
-
set_property params
|
38
|
-
c.output = $stdout
|
39
|
-
c.color_enabled = true
|
40
|
-
c.tty = true
|
41
|
-
if Praegustator.config['log_level'] == 'debug'
|
42
|
-
formatter = RSpec::Core::Formatters::DocumentationFormatter.new(c.output)
|
43
|
-
end
|
44
|
-
reporter = RSpec::Core::Reporter.new(formatter)
|
45
|
-
c.instance_variable_set(:@reporter, reporter)
|
46
|
-
end
|
47
|
-
spec_files = suite.checks.keys.map{|check| "#{Dir.pwd}/#{Praegustator.config['spec']['checks_dir']}/#{check}.rb" }
|
48
|
-
begin
|
49
|
-
RSpec::Core::Runner.run_patched(spec_files, $stderr, $stdout)
|
50
|
-
rescue Exception => e
|
51
|
-
$stderr.puts "!! spec execution failed #{e.message}"
|
52
|
-
end
|
53
|
-
if Praegustator.config['log_level'] != 'debug'
|
54
|
-
@parser.parse n,formatter.output_hash
|
55
|
-
end
|
45
|
+
RSpec::Core::Runner.run_patched(spec_files, $stderr, $stdout)
|
56
46
|
rescue Exception => e
|
57
47
|
$stderr.puts e.backtrace.join("\n")
|
58
|
-
$stderr.puts "!!
|
48
|
+
$stderr.puts "!! spec execution failed #{e.message}"
|
59
49
|
end
|
50
|
+
Praegustator.reporter.add_spec_result node,formatter.output_hash
|
51
|
+
rescue Exception => e
|
52
|
+
$stderr.puts e.backtrace.join("\n")
|
53
|
+
$stderr.puts "!! failed for #{node.ipaddress} : #{e.message}"
|
60
54
|
end
|
61
55
|
end
|
62
56
|
end
|
data/praegustator.gemspec
CHANGED
@@ -20,13 +20,14 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency "thor"
|
22
22
|
spec.add_runtime_dependency "rspec", ">= 2.13.0"
|
23
|
-
spec.add_runtime_dependency "chef"
|
23
|
+
spec.add_runtime_dependency "chef" , ">= 11.4.4"
|
24
24
|
spec.add_runtime_dependency "serverspec"
|
25
25
|
spec.add_runtime_dependency "colorize"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.3"
|
28
28
|
spec.add_development_dependency "rake"
|
29
|
-
spec.add_development_dependency "rspec", "
|
29
|
+
spec.add_development_dependency "rspec", ">= 2.13.0"
|
30
|
+
spec.add_development_dependency "rspec-mocks"
|
30
31
|
spec.add_development_dependency "cucumber"
|
31
32
|
spec.add_development_dependency "aruba"
|
32
33
|
end
|
data/readme.md
CHANGED
@@ -2,22 +2,23 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Praegustator::CLI do
|
4
4
|
describe "#taste" do
|
5
|
+
it "execute_check from executor" do
|
6
|
+
Praegustator::Executor.any_instance.should_receive(:execute_check)
|
7
|
+
Praegustator::CLI.new.taste("foo","bar")
|
8
|
+
end
|
5
9
|
end
|
6
10
|
|
7
11
|
describe "#validate" do
|
8
|
-
|
9
|
-
Praegustator::Executor.any_instance.
|
12
|
+
it "execute from executor" do
|
13
|
+
Praegustator::Executor.any_instance.should_receive(:execute)
|
14
|
+
Praegustator::CLI.new.validate("foo","bar")
|
10
15
|
end
|
11
|
-
subject { Praegustator::CLI.new.validate("foo") }
|
12
|
-
it { should eq 'foo' }
|
13
16
|
end
|
14
17
|
|
15
18
|
describe "#init" do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
Praegustator::CLI.new.init("foo")
|
20
|
-
end
|
19
|
+
it "sets knife_location" do
|
20
|
+
Praegustator::Setup.any_instance.should_receive(:init).with("foo")
|
21
|
+
Praegustator::CLI.new.init("foo")
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Praegustator::Executor do
|
4
|
+
before :each do
|
5
|
+
Praegustator::Wrappers::Chef.stub(:search)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#execute" do
|
9
|
+
it "calls execute in test suits" do
|
10
|
+
execute_count =0
|
11
|
+
Praegustator::TestSuite.any_instance.stub(:execute) do |arg|
|
12
|
+
execute_count+=1
|
13
|
+
end
|
14
|
+
Praegustator::Executor.new.execute [File.dirname(__FILE__)+"/resources/sample/suits/staging.rb", File.dirname(__FILE__)+"/resources/sample/suits/default.rb"]
|
15
|
+
execute_count.should == 6
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#execute_check" do
|
20
|
+
it "call execute in test suite" do
|
21
|
+
Praegustator::TestSuite.any_instance.should_receive(:execute)
|
22
|
+
Praegustator::Executor.new.execute_check "foo","bar"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: praegustator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- timusg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 11.4.4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 11.4.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: serverspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,16 +112,30 @@ dependencies:
|
|
112
112
|
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ! '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 2.13.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ! '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 2.13.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec-mocks
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: cucumber
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,16 +198,17 @@ files:
|
|
184
198
|
- lib/praegustator/dsl.rb
|
185
199
|
- lib/praegustator/executor.rb
|
186
200
|
- lib/praegustator/node.rb
|
201
|
+
- lib/praegustator/reporter.rb
|
187
202
|
- lib/praegustator/setup.rb
|
188
203
|
- lib/praegustator/test_suite.rb
|
189
204
|
- lib/praegustator/version.rb
|
190
205
|
- lib/praegustator/wrappers/chef.rb
|
191
|
-
- lib/praegustator/wrappers/output_parser.rb
|
192
206
|
- lib/praegustator/wrappers/server_spec.rb
|
193
207
|
- praegustator.gemspec
|
194
208
|
- readme.md
|
195
209
|
- spec/praegustator/cli_spec.rb
|
196
210
|
- spec/praegustator/dsl_spec.rb
|
211
|
+
- spec/praegustator/executor_spec.rb
|
197
212
|
- spec/praegustator/resources/sample/config/praegustator.yml
|
198
213
|
- spec/praegustator/resources/sample/suits/default.rb
|
199
214
|
- spec/praegustator/resources/sample/suits/staging.rb
|
@@ -231,6 +246,7 @@ test_files:
|
|
231
246
|
- features/support/setup.rb
|
232
247
|
- spec/praegustator/cli_spec.rb
|
233
248
|
- spec/praegustator/dsl_spec.rb
|
249
|
+
- spec/praegustator/executor_spec.rb
|
234
250
|
- spec/praegustator/resources/sample/config/praegustator.yml
|
235
251
|
- spec/praegustator/resources/sample/suits/default.rb
|
236
252
|
- spec/praegustator/resources/sample/suits/staging.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'praegustator'
|
2
|
-
require 'colorize'
|
3
|
-
|
4
|
-
module Praegustator
|
5
|
-
module Wrappers
|
6
|
-
class OutputParser
|
7
|
-
def parse node,json
|
8
|
-
$stdout.puts "Node: #{node.ipaddress.colorize(:blue)} ChefQuery: #{node.query.colorize(:blue)}"
|
9
|
-
$stdout.puts " Checks:"
|
10
|
-
return if json[:examples].nil?
|
11
|
-
json[:examples].each do |e|
|
12
|
-
if e[:status] == 'passed'
|
13
|
-
$stdout.puts " #{e[:full_description]} : #{e[:status]}".colorize(:green)
|
14
|
-
else
|
15
|
-
$stdout.puts " #{e[:full_description]} : #{e[:status]}".colorize(:red)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|