praegustator 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +5 -0
- data/lib/praegustator.rb +1 -1
- data/lib/praegustator/setup.rb +9 -3
- data/lib/praegustator/test_suite.rb +11 -4
- data/lib/praegustator/version.rb +1 -1
- data/lib/praegustator/wrappers/server_spec.rb +8 -5
- data/readme.md +15 -2
- data/spec/praegustator/dsl_spec.rb +1 -1
- data/spec/praegustator/resources/sample/suits/staging.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWNmNzAyMjllY2JjYjc1MWI4Y2VhMGNlZDVhODIwMTZmN2U2MDM3Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWFlOTQzODcyNWRkOGE1MDI3NGJiMTAyYzYyZGZhMjcwMDM0Y2RiOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzE1YzQ0YTc5OGYyNGY1MmUzZDQ0ZTQwZjA5MDRmNGY5NWJmOTgxZjYyOWMx
|
10
|
+
MzU4YTk1YjIxN2I3NWVhYzFhMDQ1MzhmMmNiZDZhM2NjMmViNWI3MTViODc1
|
11
|
+
ZWM5NGNiYTBlMWNiNWY5NjdiOWY5MzljMWU5N2RiMDhmZjhmYzY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGI4Y2JkYjE3ODY4ZmU0YzFhMzQ2NTJlNzNlYzkyY2EzZDYyZDljNDA0ODBj
|
14
|
+
MjM5NDk0NzMxNTNiMGEyOTM1YTkwZmJlYjYxOGY4M2VmZTdjZjVjNWY0Yzlj
|
15
|
+
NzFhYWE2MjhmMzg3MWVhYzFkMDA1NjAyNDQ0NjA2MzJkYTcwYTQ=
|
data/.travis.yml
ADDED
data/lib/praegustator.rb
CHANGED
@@ -33,7 +33,7 @@ module Praegustator
|
|
33
33
|
config = YAML::load(IO.read(path_to_yaml_file))
|
34
34
|
rescue Psych::SyntaxError
|
35
35
|
p "error while parsing yaml configuration file. using defaults."; return
|
36
|
-
rescue
|
36
|
+
rescue Errno::ENOENT
|
37
37
|
p "yaml configuration file couldn't be found. using defaults."; return
|
38
38
|
end
|
39
39
|
configure(config) if config
|
data/lib/praegustator/setup.rb
CHANGED
@@ -3,10 +3,10 @@ require 'praegustator'
|
|
3
3
|
module Praegustator
|
4
4
|
class Setup
|
5
5
|
def init(spec_dir)
|
6
|
+
create_settings spec_dir
|
6
7
|
mkdir(spec_dir)
|
7
8
|
create_spec spec_dir
|
8
9
|
create_recepie spec_dir
|
9
|
-
create_settings spec_dir
|
10
10
|
end
|
11
11
|
|
12
12
|
def mkdir dir
|
@@ -24,18 +24,23 @@ module Praegustator
|
|
24
24
|
content = <<-EOF
|
25
25
|
role("*")do
|
26
26
|
check "basic_commands"
|
27
|
+
properties :user => "root"
|
27
28
|
end
|
28
29
|
EOF
|
29
30
|
create_file "#{dir}/test_recipe.rb",content
|
30
31
|
end
|
31
32
|
|
32
33
|
def create_settings dir
|
34
|
+
puts "please enter knife's location (default ~/.chef/knife.rb) : "
|
35
|
+
knife_location = $stdin.gets.chomp
|
36
|
+
knife_location = '~/.chef/knife.rb' if knife_location == ''
|
37
|
+
|
33
38
|
content = <<-EOF
|
34
39
|
spec:
|
35
40
|
recipes_dir: "#{dir}/"
|
36
41
|
checks_dir: "#{dir}/checks/"
|
37
42
|
chef:
|
38
|
-
knife_location: "
|
43
|
+
knife_location: "#{knife_location}"
|
39
44
|
# ssh:
|
40
45
|
# user: "root"
|
41
46
|
# pasword: nil
|
@@ -46,8 +51,9 @@ end
|
|
46
51
|
|
47
52
|
def create_spec dir
|
48
53
|
content = <<-EOF
|
54
|
+
user = property[:user]
|
49
55
|
describe command('whoami') do
|
50
|
-
it { should return_stdout
|
56
|
+
it { should return_stdout user }
|
51
57
|
end
|
52
58
|
|
53
59
|
describe command('cat /etc/resolv.conf') do
|
@@ -1,20 +1,27 @@
|
|
1
1
|
require "praegustator"
|
2
2
|
module Praegustator
|
3
3
|
class TestSuite
|
4
|
-
attr_accessor :nodes
|
4
|
+
attr_accessor :nodes, :checks, :params
|
5
|
+
|
5
6
|
def initialize(query)
|
6
7
|
@query = query
|
7
8
|
@checks = {}
|
9
|
+
@params = {}
|
8
10
|
@nodes = Praegustator::Wrappers::Chef.search query
|
9
11
|
end
|
10
|
-
|
12
|
+
|
13
|
+
def check(name)
|
11
14
|
@checks[name] = {}
|
12
|
-
@checks[name][:opts] = opts
|
13
15
|
end
|
16
|
+
|
17
|
+
def properties(params)
|
18
|
+
@params = params
|
19
|
+
end
|
20
|
+
|
14
21
|
def execute
|
15
22
|
# lazy load
|
16
23
|
require 'praegustator/wrappers/server_spec'
|
17
|
-
Praegustator::Wrappers::ServerSpec.new.execute
|
24
|
+
Praegustator::Wrappers::ServerSpec.new.execute self
|
18
25
|
end
|
19
26
|
end
|
20
27
|
end
|
data/lib/praegustator/version.rb
CHANGED
@@ -17,14 +17,15 @@ module Praegustator
|
|
17
17
|
end
|
18
18
|
|
19
19
|
|
20
|
-
def execute
|
21
|
-
nodes.each do |n|
|
20
|
+
def execute suite
|
21
|
+
suite.nodes.each do |n|
|
22
22
|
ENV['TARGET_HOST'] = n.ipaddress
|
23
23
|
formatter = RSpec::Core::Formatters::JsonFormatter.new(nil)
|
24
|
-
#RSpec.reset
|
25
24
|
RSpec.clear_remaining_example_groups
|
26
25
|
load 'serverspec.rb'
|
27
26
|
begin
|
27
|
+
params = suite.params
|
28
|
+
params[:current_node] = n
|
28
29
|
RSpec.configure do |c|
|
29
30
|
c.host = ENV['TARGET_HOST']
|
30
31
|
options = Net::SSH::Config.for(c.host)
|
@@ -33,6 +34,7 @@ module Praegustator
|
|
33
34
|
options[:timeout] = 10
|
34
35
|
c.ssh = Net::SSH.start(c.host, user, options)
|
35
36
|
c.os = backend.check_os
|
37
|
+
set_property params
|
36
38
|
c.output = $stdout
|
37
39
|
c.color_enabled = true
|
38
40
|
c.tty = true
|
@@ -42,16 +44,17 @@ module Praegustator
|
|
42
44
|
reporter = RSpec::Core::Reporter.new(formatter)
|
43
45
|
c.instance_variable_set(:@reporter, reporter)
|
44
46
|
end
|
45
|
-
spec_files = checks.keys.map{|check| "#{Dir.pwd}/#{Praegustator.config['spec']['checks_dir']}/#{check}.rb" }
|
47
|
+
spec_files = suite.checks.keys.map{|check| "#{Dir.pwd}/#{Praegustator.config['spec']['checks_dir']}/#{check}.rb" }
|
46
48
|
begin
|
47
49
|
RSpec::Core::Runner.run_patched(spec_files, $stderr, $stdout)
|
48
|
-
rescue
|
50
|
+
rescue Exception => e
|
49
51
|
$stderr.puts "!! spec execution failed #{e.message}"
|
50
52
|
end
|
51
53
|
if Praegustator.config['log_level'] != 'debug'
|
52
54
|
@parser.parse n,formatter.output_hash
|
53
55
|
end
|
54
56
|
rescue Exception => e
|
57
|
+
$stderr.puts e.backtrace.join("\n")
|
55
58
|
$stderr.puts "!! failed for #{n.ipaddress} : #{e.message}"
|
56
59
|
end
|
57
60
|
end
|
data/readme.md
CHANGED
@@ -20,21 +20,27 @@ check against them, whereas checks are rspec files with server-spec matchers def
|
|
20
20
|
|
21
21
|
sample recipe for praegustator:
|
22
22
|
|
23
|
-
``` ruby
|
23
|
+
``` ruby
|
24
|
+
#sample_recipe.rb
|
24
25
|
environment :staging
|
25
26
|
|
26
27
|
role("web-server") do
|
27
28
|
check "application/nginx"
|
28
29
|
check "application/puma"
|
29
30
|
check "application/s3cmd"
|
31
|
+
properties name: "foo"
|
30
32
|
end
|
31
33
|
```
|
32
34
|
The `role` method mark all nodes with that role . Within the
|
33
35
|
block passed to `role` you can declare checks using the `check` method.
|
36
|
+
arbitrary hash can be passed to checks usin `properties` method, also
|
37
|
+
current node under test is added automatically to properties hash.
|
34
38
|
|
35
39
|
Where check are server spec files:
|
36
40
|
|
37
|
-
``` ruby
|
41
|
+
``` ruby
|
42
|
+
#{spec_dir}/application/nginx.rb
|
43
|
+
|
38
44
|
describe package('nginx') do
|
39
45
|
it { should be_installed }
|
40
46
|
end
|
@@ -43,6 +49,13 @@ describe service('nginx') do
|
|
43
49
|
it { should be_enabled }
|
44
50
|
it { should be_running }
|
45
51
|
end
|
52
|
+
|
53
|
+
app_name = property[:name]
|
54
|
+
ip_address = property[:current_node].ipaddress
|
55
|
+
|
56
|
+
describe file("/etc/nginx/conf.d/#{app_name}.conf") do
|
57
|
+
it { should contain "server_name #{ip_address}" }
|
58
|
+
end
|
46
59
|
```
|
47
60
|
|
48
61
|
## `praeg` command
|
@@ -35,7 +35,7 @@ describe Praegustator::Dsl do
|
|
35
35
|
first_suite = suits.first
|
36
36
|
checks = first_suite.instance_variable_get(:@checks)
|
37
37
|
checks["nginx"].should_not nil
|
38
|
-
|
38
|
+
first_suite.params[:target].should == "10.210.10.1"
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
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.2.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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -160,6 +160,7 @@ extra_rdoc_files: []
|
|
160
160
|
files:
|
161
161
|
- .gitignore
|
162
162
|
- .rspec
|
163
|
+
- .travis.yml
|
163
164
|
- Gemfile
|
164
165
|
- Gemfile.lock
|
165
166
|
- Rakefile
|