lbspec 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/lbspec/capture.rb +1 -0
- data/lib/lbspec/request.rb +1 -0
- data/lib/lbspec/respond.rb +9 -0
- data/lib/lbspec/transfer.rb +10 -0
- data/lib/lbspec/util.rb +21 -8
- data/lib/lbspec/version.rb +1 -1
- data/spec/lbspec_util_spec.rb +6 -0
- metadata +7 -31
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 86e46129e9a44bc560ec269a223ae968e0bcb307
|
4
|
+
data.tar.gz: df753021edf7e751a0a8d3e84e6555fec95bb615
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9590196fd3c452ca5c776d1b58ac1bb4be30edc43e4fbb21e32028bee97993d9cbffffcd71cfc243cec368a52fdc718990c8921ae4f84d48fcca9130c6ebbcc5
|
7
|
+
data.tar.gz: 2c36467d20e08a8a11eb83ecf0138c1dad5ae7072f165ed419668fac40c69f9440f54b5302720448fd9d1a5e3c613d42f3ad4171278f770df6406bcb9a08dff4
|
data/lib/lbspec/capture.rb
CHANGED
data/lib/lbspec/request.rb
CHANGED
@@ -13,6 +13,7 @@ module Lbspec
|
|
13
13
|
@application = options[:application] ? options[:application] : nil
|
14
14
|
@path = options[:path] if options[:path]
|
15
15
|
@options = options[:options] ? options[:options] : {}
|
16
|
+
Util.log.debug("#{self.class} initialized #{inspect}")
|
16
17
|
end
|
17
18
|
|
18
19
|
def send(prove = nil)
|
data/lib/lbspec/respond.rb
CHANGED
@@ -6,6 +6,8 @@ require 'lbspec'
|
|
6
6
|
|
7
7
|
RSpec::Matchers.define :respond do |expect|
|
8
8
|
match do |vhost|
|
9
|
+
fail ArgumentError, '#respond must have non-nil argument' unless expect
|
10
|
+
log.debug("#respond(#{expect.inspect}) is called")
|
9
11
|
@expect = expect
|
10
12
|
request =
|
11
13
|
Lbspec::Request.new(vhost, @from,
|
@@ -40,16 +42,19 @@ RSpec::Matchers.define :respond do |expect|
|
|
40
42
|
end
|
41
43
|
|
42
44
|
chain :from do |from|
|
45
|
+
fail ArgumentError, '#from must have non-nil argument' unless from
|
43
46
|
@from = from
|
44
47
|
@chain_str = Lbspec::Util.add_string(@chain_str, " from #{from}")
|
45
48
|
end
|
46
49
|
|
47
50
|
chain :path do |path|
|
51
|
+
fail ArgumentError, '#path must have non-nil argument' unless path
|
48
52
|
@path = path
|
49
53
|
@chain_str = Lbspec::Util.add_string(@chain_str, " via #{path}")
|
50
54
|
end
|
51
55
|
|
52
56
|
chain :with do |string|
|
57
|
+
fail ArgumentError, '#with must have non-nil argument' unless string
|
53
58
|
@string = string
|
54
59
|
@chain_str = Lbspec::Util.add_string(@chain_str, " via #{string}")
|
55
60
|
end
|
@@ -77,4 +82,8 @@ RSpec::Matchers.define :respond do |expect|
|
|
77
82
|
result << ", but did#{negation}.\n" + "requested:\n"
|
78
83
|
result << request_str.gsub(/^/, ' ')
|
79
84
|
end
|
85
|
+
|
86
|
+
def log
|
87
|
+
Lbspec::Util.log
|
88
|
+
end
|
80
89
|
end
|
data/lib/lbspec/transfer.rb
CHANGED
@@ -6,6 +6,8 @@ require 'lbspec'
|
|
6
6
|
|
7
7
|
RSpec::Matchers.define :transfer do |nodes|
|
8
8
|
match do |vhost|
|
9
|
+
fail ArgumentError, '#transfer must have non-nil argument' unless nodes
|
10
|
+
log.debug("#transfer(#{nodes.inspect}) is called")
|
9
11
|
prove = Lbspec::Util.create_prove
|
10
12
|
capture =
|
11
13
|
Lbspec::Capture.new(nodes, @port, prove, @include_str)
|
@@ -21,6 +23,7 @@ RSpec::Matchers.define :transfer do |nodes|
|
|
21
23
|
end
|
22
24
|
|
23
25
|
chain :port do |port|
|
26
|
+
fail ArgumentError, '#port must have non-nil argument' unless port
|
24
27
|
@port = port
|
25
28
|
@chain_str = Lbspec::Util.add_string(@chain_str, " port #{port}")
|
26
29
|
end
|
@@ -48,16 +51,19 @@ RSpec::Matchers.define :transfer do |nodes|
|
|
48
51
|
end
|
49
52
|
|
50
53
|
chain :from do |from|
|
54
|
+
fail ArgumentError, '#from must have non-nil argument' unless from
|
51
55
|
@from = from
|
52
56
|
@chain_str = Lbspec::Util.add_string(@chain_str, " from #{from}")
|
53
57
|
end
|
54
58
|
|
55
59
|
chain :include do |str|
|
60
|
+
fail ArgumentError, '#include must have non-nil argument' unless str
|
56
61
|
@include_str = str
|
57
62
|
@chain_str = Lbspec::Util.add_string(@chain_str, " including #{str}")
|
58
63
|
end
|
59
64
|
|
60
65
|
chain :path do |path|
|
66
|
+
fail ArgumentError, '#path must have non-nil argument' unless path
|
61
67
|
@path = path
|
62
68
|
@chain_str = Lbspec::Util.add_string(@chain_str, " via #{path}")
|
63
69
|
end
|
@@ -98,4 +104,8 @@ RSpec::Matchers.define :transfer do |nodes|
|
|
98
104
|
result << o[:output].gsub(/^/, ' ') + "\n"
|
99
105
|
end
|
100
106
|
end
|
107
|
+
|
108
|
+
def log
|
109
|
+
Lbspec::Util.log
|
110
|
+
end
|
101
111
|
end
|
data/lib/lbspec/util.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
module Lbspec
|
4
4
|
# Lbspec::Util provides some utilities
|
5
5
|
class Util
|
6
|
+
@logger = nil
|
7
|
+
@log_level = Logger::ERROR
|
6
8
|
class << self
|
7
|
-
@logger = nil
|
8
|
-
@log_level = Logger::ERROR
|
9
9
|
attr_accessor :logger, :log_level
|
10
10
|
end
|
11
11
|
|
@@ -39,22 +39,35 @@ module Lbspec
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.exec_command(command, node = nil)
|
42
|
-
output = command + "\n"
|
43
42
|
if node
|
44
|
-
|
45
|
-
Net::SSH.start(node, ssh_user(node), options) do |ssh|
|
46
|
-
output << ssh.exec!(command).to_s
|
47
|
-
end
|
43
|
+
exec_command_remote(command, node)
|
48
44
|
else
|
49
|
-
|
45
|
+
exec_command_local(command)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.exec_command_remote(command, node = nil)
|
50
|
+
output = command + "\n"
|
51
|
+
log.debug("ssh to #{node}:#{command}")
|
52
|
+
options = { config: true, verbose: log_level }
|
53
|
+
Net::SSH.start(node, ssh_user(node), options) do |ssh|
|
54
|
+
output << ssh.exec!(command).to_s
|
50
55
|
end
|
51
56
|
end
|
52
57
|
|
58
|
+
def self.exec_command_local(command)
|
59
|
+
output = command + "\n"
|
60
|
+
log.debug("execute locally: #{command}")
|
61
|
+
output << `#{command}`.to_s
|
62
|
+
end
|
63
|
+
|
53
64
|
def self.ssh_user(node)
|
54
65
|
# if there is no user for the node in ~/.ssh/config
|
55
66
|
# use current user name for login
|
56
67
|
user = Net::SSH::Config.for(node)[:user]
|
57
68
|
user ? user : `whoami`.chomp
|
69
|
+
log.debug("ssh #{node} as user:#{user}")
|
70
|
+
user
|
58
71
|
end
|
59
72
|
end
|
60
73
|
end
|
data/lib/lbspec/version.rb
CHANGED
data/spec/lbspec_util_spec.rb
CHANGED
@@ -10,6 +10,12 @@ describe Lbspec::Util do
|
|
10
10
|
Lbspec::Util.logger.should eql('test')
|
11
11
|
end
|
12
12
|
end
|
13
|
+
describe '#log_level' do
|
14
|
+
it 'should set/get log_level' do
|
15
|
+
Lbspec::Util.log_level = Logger::WARN
|
16
|
+
Lbspec::Util.log_level.should eql(Logger::WARN)
|
17
|
+
end
|
18
|
+
end
|
13
19
|
describe '#log' do
|
14
20
|
before :each do
|
15
21
|
Lbspec::Util.logger = nil
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lbspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- OTA Hiroshi
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rubocop
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: coveralls
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: debugger
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ~>
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: highline
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ~>
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ~>
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -110,7 +97,6 @@ dependencies:
|
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: rspec
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
101
|
- - ~>
|
116
102
|
- !ruby/object:Gem::Version
|
@@ -118,7 +104,6 @@ dependencies:
|
|
118
104
|
type: :runtime
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
108
|
- - ~>
|
124
109
|
- !ruby/object:Gem::Version
|
@@ -126,7 +111,6 @@ dependencies:
|
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: net-ssh
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
115
|
- - ~>
|
132
116
|
- !ruby/object:Gem::Version
|
@@ -134,7 +118,6 @@ dependencies:
|
|
134
118
|
type: :runtime
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
122
|
- - ~>
|
140
123
|
- !ruby/object:Gem::Version
|
@@ -177,33 +160,26 @@ files:
|
|
177
160
|
homepage: https://github.com/otahi/lbspec
|
178
161
|
licenses:
|
179
162
|
- MIT
|
163
|
+
metadata: {}
|
180
164
|
post_install_message:
|
181
165
|
rdoc_options: []
|
182
166
|
require_paths:
|
183
167
|
- lib
|
184
168
|
required_ruby_version: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
169
|
requirements:
|
187
|
-
- -
|
170
|
+
- - '>='
|
188
171
|
- !ruby/object:Gem::Version
|
189
172
|
version: '0'
|
190
|
-
segments:
|
191
|
-
- 0
|
192
|
-
hash: -1965399059659681873
|
193
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
|
-
none: false
|
195
174
|
requirements:
|
196
|
-
- -
|
175
|
+
- - '>='
|
197
176
|
- !ruby/object:Gem::Version
|
198
177
|
version: '0'
|
199
|
-
segments:
|
200
|
-
- 0
|
201
|
-
hash: -1965399059659681873
|
202
178
|
requirements: []
|
203
179
|
rubyforge_project:
|
204
|
-
rubygems_version:
|
180
|
+
rubygems_version: 2.2.2
|
205
181
|
signing_key:
|
206
|
-
specification_version:
|
182
|
+
specification_version: 4
|
207
183
|
summary: Easily test your Loadbalancers with RSpec.
|
208
184
|
test_files:
|
209
185
|
- spec/lbspec_respond_spec.rb
|