auger 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +11 -0
- data/LICENSE +22 -0
- data/README.md +339 -0
- data/Rakefile +104 -0
- data/VERSION +1 -0
- data/auger.gemspec +26 -0
- data/bin/aug +112 -0
- data/cfg/examples/elasticsearch.rb +75 -0
- data/cfg/examples/redis.rb +31 -0
- data/cfg/examples/riak.rb +42 -0
- data/cfg/examples/webserver.rb +56 -0
- data/lib/auger.rb +12 -0
- data/lib/auger/config.rb +22 -0
- data/lib/auger/connection.rb +39 -0
- data/lib/auger/project.rb +64 -0
- data/lib/auger/request.rb +40 -0
- data/lib/auger/result.rb +27 -0
- data/lib/auger/server.rb +13 -0
- data/lib/auger/test.rb +25 -0
- data/lib/auger/version.rb +3 -0
- data/lib/plugins/cql.rb +31 -0
- data/lib/plugins/dns.rb +44 -0
- data/lib/plugins/http.rb +68 -0
- data/lib/plugins/redis.rb +73 -0
- data/lib/plugins/socket.rb +30 -0
- data/lib/plugins/telnet.rb +37 -0
- metadata +171 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
module Auger
|
2
|
+
|
3
|
+
class Request
|
4
|
+
attr_accessor :tests, :before_tests_proc, :response, :arg
|
5
|
+
|
6
|
+
def self.load(arg, &block)
|
7
|
+
request = new(arg)
|
8
|
+
request.instance_eval(&block)
|
9
|
+
request
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(arg)
|
13
|
+
@arg = arg
|
14
|
+
@tests = []
|
15
|
+
end
|
16
|
+
|
17
|
+
def test(name, &block)
|
18
|
+
@tests << Test.new(name, block)
|
19
|
+
end
|
20
|
+
|
21
|
+
## callback to be run after request, but before tests
|
22
|
+
def before_tests(&block)
|
23
|
+
@before_tests_proc = block
|
24
|
+
end
|
25
|
+
|
26
|
+
## call plugin run() and return plugin-specfic response object or exception
|
27
|
+
def do_run(conn)
|
28
|
+
return conn if conn.is_a? Exception
|
29
|
+
begin
|
30
|
+
response = self.run(conn)
|
31
|
+
response = self.before_tests_proc.call(response) if self.before_tests_proc
|
32
|
+
response
|
33
|
+
rescue => e
|
34
|
+
e
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/lib/auger/result.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Auger
|
2
|
+
|
3
|
+
class Result
|
4
|
+
attr_accessor :test, :outcome
|
5
|
+
def initialize(test, outcome)
|
6
|
+
@test = test
|
7
|
+
@outcome = outcome
|
8
|
+
end
|
9
|
+
|
10
|
+
# def to_s
|
11
|
+
# case @outcome
|
12
|
+
# when MatchData then
|
13
|
+
# @outcome.captures.empty? ? "\u2713" : @outcome.captures.join(' ')
|
14
|
+
# when TrueClass then
|
15
|
+
# "\u2713"
|
16
|
+
# when FalseClass then
|
17
|
+
# "\u2717"
|
18
|
+
# when NilClass then
|
19
|
+
# "\u2717"
|
20
|
+
# else
|
21
|
+
# @outcome.to_s
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/auger/server.rb
ADDED
data/lib/auger/test.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Auger
|
2
|
+
|
3
|
+
class Test
|
4
|
+
attr_accessor :name, :block
|
5
|
+
|
6
|
+
def initialize(name, block)
|
7
|
+
@name = name
|
8
|
+
@block = block
|
9
|
+
end
|
10
|
+
|
11
|
+
## return Auger::Result object with outcome of test
|
12
|
+
def run(response)
|
13
|
+
outcome =
|
14
|
+
if response.is_a?(Exception) or @block.nil?
|
15
|
+
response
|
16
|
+
else
|
17
|
+
@block.call(response) rescue $!
|
18
|
+
end
|
19
|
+
|
20
|
+
Auger::Result.new(self, outcome)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/plugins/cql.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'cassandra-cql'
|
2
|
+
|
3
|
+
module Auger
|
4
|
+
|
5
|
+
class Project
|
6
|
+
def cql(port = 9160, &block)
|
7
|
+
@connections << Cql.load(port, &block)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Cql < Auger::Connection
|
12
|
+
def open(host, options)
|
13
|
+
CassandraCQL::Database.new "#{host}:#{options[:port]}", options
|
14
|
+
end
|
15
|
+
|
16
|
+
def close(db)
|
17
|
+
db.disconnect!
|
18
|
+
end
|
19
|
+
|
20
|
+
def execute(statement, &block)
|
21
|
+
@requests << CqlRequest.load(statement, &block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class CqlRequest < Auger::Request
|
26
|
+
def run(db)
|
27
|
+
db.execute(@arg)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/plugins/dns.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'net/dns'
|
2
|
+
|
3
|
+
module Auger
|
4
|
+
|
5
|
+
class Project
|
6
|
+
def dns(port = 53, &block)
|
7
|
+
@connections << Dns.load(port, &block)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Dns < Auger::Connection
|
12
|
+
def domain(&block)
|
13
|
+
@requests << DnsDomainRequest.load(nil, &block)
|
14
|
+
end
|
15
|
+
|
16
|
+
def open(host, options)
|
17
|
+
options[:nameserver] = host
|
18
|
+
dns = Net::DNS::Resolver.new(options)
|
19
|
+
dns.use_tcp = true if options[:use_tcp]
|
20
|
+
dns
|
21
|
+
end
|
22
|
+
|
23
|
+
def close(dns)
|
24
|
+
dns = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def query(name, &block)
|
28
|
+
@requests << DnsQueryRequest.load(name, &block)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class DnsDomainRequest < Auger::Request
|
33
|
+
def run(dns)
|
34
|
+
dns.domain
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class DnsQueryRequest < Auger::Request
|
39
|
+
def run(dns)
|
40
|
+
dns.query(@arg)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/lib/plugins/http.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require "net/http"
|
2
|
+
|
3
|
+
module Auger
|
4
|
+
|
5
|
+
class Project
|
6
|
+
def http(port = 80, &block)
|
7
|
+
@connections << Http.load(port, &block)
|
8
|
+
end
|
9
|
+
|
10
|
+
def https(port = 443, &block)
|
11
|
+
http = Http.load(port, &block)
|
12
|
+
http.ssl(true)
|
13
|
+
@connections << http
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
class Http < Auger::Connection
|
19
|
+
def get(url, &block)
|
20
|
+
@url = url
|
21
|
+
@requests << Auger::HttpRequest.load(url, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def open(host, options)
|
25
|
+
http = Net::HTTP.new(host, options[:port])
|
26
|
+
http.use_ssl = options[:ssl]
|
27
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if options[:insecure]
|
28
|
+
http.start
|
29
|
+
http
|
30
|
+
end
|
31
|
+
|
32
|
+
def close(http)
|
33
|
+
http.finish
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
class HttpRequest < Auger::Request
|
39
|
+
attr_accessor :headers, :user, :password
|
40
|
+
|
41
|
+
def initialize(url)
|
42
|
+
@headers = {}
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
def header(h)
|
47
|
+
key, value = h.split /\s*:\s*/
|
48
|
+
@headers[key] = value
|
49
|
+
end
|
50
|
+
|
51
|
+
def user(user)
|
52
|
+
@user = user
|
53
|
+
end
|
54
|
+
|
55
|
+
def password(password)
|
56
|
+
@password = password
|
57
|
+
end
|
58
|
+
|
59
|
+
def run(http)
|
60
|
+
get = Net::HTTP::Get.new(@arg)
|
61
|
+
get.basic_auth(@user, @password||'') if @user
|
62
|
+
@headers.each { |k,v| get[k] = v }
|
63
|
+
http.request(get)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#require 'redis/connection'
|
2
|
+
require 'redis'
|
3
|
+
|
4
|
+
module Auger
|
5
|
+
|
6
|
+
class Project
|
7
|
+
def redis(port = 6379, &block)
|
8
|
+
@connections << Auger::Redis.load(port, &block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Redis < Auger::Connection
|
13
|
+
def open(host, options)
|
14
|
+
::Redis.new options.merge({:host => host, :thread_safe => true})
|
15
|
+
end
|
16
|
+
|
17
|
+
def close(redis)
|
18
|
+
redis.quit
|
19
|
+
end
|
20
|
+
|
21
|
+
def ping(&block)
|
22
|
+
@requests << Auger::RedisPing.load(nil, &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def info(&block)
|
26
|
+
@requests << Auger::RedisInfo.load(nil, &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def dbsize(&block)
|
30
|
+
@requests << Auger::RedisDbsize.load(nil, &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
def get(key, &block)
|
34
|
+
@requests << Auger::RedisGet.load(key, &block)
|
35
|
+
end
|
36
|
+
|
37
|
+
def exists(key, &block)
|
38
|
+
@requests << Auger::RedisExists.load(key, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
class RedisPing < Auger::Request
|
44
|
+
def run(redis)
|
45
|
+
redis.ping
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class RedisInfo < Auger::Request
|
50
|
+
def run(redis)
|
51
|
+
redis.info
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class RedisDbsize < Auger::Request
|
56
|
+
def run(redis)
|
57
|
+
redis.dbsize
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class RedisGet < Auger::Request
|
62
|
+
def run(redis)
|
63
|
+
redis.get(@arg)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class RedisExists < Auger::Request
|
68
|
+
def run(redis)
|
69
|
+
redis.exists(@arg)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'socket'
|
2
|
+
|
3
|
+
module Auger
|
4
|
+
class Project
|
5
|
+
def socket(port, &block)
|
6
|
+
@connections << Socket.load(port, &block)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Socket < Auger::Connection
|
11
|
+
def open(host, options)
|
12
|
+
TCPSocket.open(host, options[:port]) rescue false
|
13
|
+
end
|
14
|
+
|
15
|
+
def close(socket)
|
16
|
+
socket.close if socket
|
17
|
+
end
|
18
|
+
|
19
|
+
def open?(&block)
|
20
|
+
@requests << SocketRequest.load(nil, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class SocketRequest < Auger::Request
|
25
|
+
def run(socket)
|
26
|
+
socket ? true : false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'net/telnet'
|
2
|
+
|
3
|
+
module Auger
|
4
|
+
class Project
|
5
|
+
def telnet(port = 23, &block)
|
6
|
+
@connections << Telnet.load(port, &block)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Telnet < Auger::Connection
|
11
|
+
def timeout(value)
|
12
|
+
@options[:timeout] = value.to_i
|
13
|
+
end
|
14
|
+
|
15
|
+
def open(host, options)
|
16
|
+
## telnet opts array needs capitalized strings as keys
|
17
|
+
opts = { 'Host' => host }
|
18
|
+
options.each { |key, value| opts[key.to_s.capitalize] = value }
|
19
|
+
Net::Telnet::new(opts)
|
20
|
+
end
|
21
|
+
|
22
|
+
def close(telnet)
|
23
|
+
telnet.close
|
24
|
+
end
|
25
|
+
|
26
|
+
def cmd(arg, &block)
|
27
|
+
@requests << TelnetRequest.load(arg, &block)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class TelnetRequest < Auger::Request
|
32
|
+
def run(telnet)
|
33
|
+
telnet.cmd(@arg)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: auger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ric Lister
|
9
|
+
- Grant Heffernan
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-06-05 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: json
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.7.3
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.7.3
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: redis
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 3.0.1
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.0.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: net-dns
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.7.1
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.7.1
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rainbow
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.1.4
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.1.4
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: host_range
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 0.0.1
|
87
|
+
type: :runtime
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 0.0.1
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: cassandra-cql
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.0.4
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.0.4
|
111
|
+
description: ! 'Auger: test-driven ops'
|
112
|
+
email:
|
113
|
+
- rlister@gmail.com
|
114
|
+
- heffergm@gmail.com
|
115
|
+
executables:
|
116
|
+
- aug
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- .gitignore
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- VERSION
|
126
|
+
- auger.gemspec
|
127
|
+
- bin/aug
|
128
|
+
- cfg/examples/elasticsearch.rb
|
129
|
+
- cfg/examples/redis.rb
|
130
|
+
- cfg/examples/riak.rb
|
131
|
+
- cfg/examples/webserver.rb
|
132
|
+
- lib/auger.rb
|
133
|
+
- lib/auger/config.rb
|
134
|
+
- lib/auger/connection.rb
|
135
|
+
- lib/auger/project.rb
|
136
|
+
- lib/auger/request.rb
|
137
|
+
- lib/auger/result.rb
|
138
|
+
- lib/auger/server.rb
|
139
|
+
- lib/auger/test.rb
|
140
|
+
- lib/auger/version.rb
|
141
|
+
- lib/plugins/cql.rb
|
142
|
+
- lib/plugins/dns.rb
|
143
|
+
- lib/plugins/http.rb
|
144
|
+
- lib/plugins/redis.rb
|
145
|
+
- lib/plugins/socket.rb
|
146
|
+
- lib/plugins/telnet.rb
|
147
|
+
homepage: https://rubygems.org/gems/auger
|
148
|
+
licenses: []
|
149
|
+
post_install_message:
|
150
|
+
rdoc_options: []
|
151
|
+
require_paths:
|
152
|
+
- lib
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ! '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
none: false
|
161
|
+
requirements:
|
162
|
+
- - ! '>='
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 1.8.23
|
168
|
+
signing_key:
|
169
|
+
specification_version: 3
|
170
|
+
summary: App && infrastructure testing DSL
|
171
|
+
test_files: []
|