lbspec 0.0.5 → 0.0.6

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.
data/README.md CHANGED
@@ -66,6 +66,13 @@ describe 'vhost_c:443' do
66
66
  it { should transfer(['node_b','node_c']).port(80).https.path('/test/') }
67
67
  end
68
68
 
69
+ describe 'vhost_c:443' do
70
+ it do
71
+ should transfer(['node_b','node_c']).port(80).https.path('/test/')
72
+ .options(ignore_valid_ssl: true)
73
+ end
74
+ end
75
+
69
76
  ```
70
77
  ## How it works
71
78
  ### #transfer
@@ -79,7 +86,7 @@ end
79
86
 
80
87
  ## Configuration
81
88
  ### #transfer
82
- You can cnange how to capture probes and access to `vhost` with probes. You can replace default procedures to your procedures in spec_helpers or .spec files as follows.
89
+ You can change how to capture probes and access to `vhost` with probes. You can replace default procedures to your procedures in spec_helpers or .spec files as follows.
83
90
  ```ruby
84
91
  RSpec.configuration.lbspec_capture_command =
85
92
  lambda do |port, prove|
@@ -93,6 +100,16 @@ RSpec.configuration.lbspec_https_request_command =
93
100
  system("curl -o /dev/null -sk #{uri}")
94
101
  end
95
102
  ```
103
+ You can also use the procedures with `options` with a chain `options`.
104
+ ```ruby
105
+ RSpec.configuration.lbspec_https_request_command =
106
+ lambda do |addr, port, path, prove|
107
+ opt = @options[:timeout] ? " -m #{@options[:timeout]}" : ''
108
+ opt << (@options[:ignore_valid_ssl] ? ' -k' : '')
109
+ system("curl -o /dev/null -s #{opt} #{uri}")
110
+ end
111
+ ```
112
+
96
113
  You can replace following items.
97
114
 
98
115
  - `lbspec_capture_command` with `|port, prove|`
@@ -15,7 +15,7 @@
15
15
  id="svg2"
16
16
  version="1.1"
17
17
  inkscape:version="0.48.4 r9939"
18
- sodipodi:docname="overview.svg">
18
+ sodipodi:docname="transfer_overview.svg">
19
19
  <sodipodi:namedview
20
20
  id="base"
21
21
  pagecolor="#ffffff"
@@ -27,7 +27,7 @@
27
27
  inkscape:cx="184.15599"
28
28
  inkscape:cy="676.17692"
29
29
  inkscape:document-units="px"
30
- inkscape:current-layer="layer2"
30
+ inkscape:current-layer="layer5"
31
31
  showgrid="false"
32
32
  inkscape:window-width="1274"
33
33
  inkscape:window-height="760"
@@ -274,7 +274,7 @@
274
274
  </g>
275
275
  </g>
276
276
  <g
277
- style="display:none"
277
+ style="display:inline"
278
278
  inkscape:label="step1"
279
279
  id="layer2"
280
280
  inkscape:groupmode="layer">
@@ -304,7 +304,7 @@
304
304
  inkscape:groupmode="layer"
305
305
  id="layer7"
306
306
  inkscape:label="step1-2"
307
- style="display:none">
307
+ style="display:inline">
308
308
  <path
309
309
  style="fill:#0000ff;stroke:#0000ff;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-end:url(#Arrow1MendW);display:inline"
310
310
  d="m 181,430.36218 c 171,-144 171,-144 171,-144"
@@ -317,7 +317,7 @@
317
317
  inkscape:connector-curvature="0" />
318
318
  </g>
319
319
  <g
320
- style="display:none"
320
+ style="display:inline"
321
321
  inkscape:label="step2"
322
322
  id="layer3"
323
323
  inkscape:groupmode="layer">
@@ -359,7 +359,7 @@
359
359
  inkscape:groupmode="layer"
360
360
  id="layer6"
361
361
  inkscape:label="step2-3"
362
- style="display:none">
362
+ style="display:inline">
363
363
  <text
364
364
  xml:space="preserve"
365
365
  style="font-size:16px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Sans;-inkscape-font-specification:Sans Bold"
@@ -384,7 +384,7 @@
384
384
  sodipodi:role="line">probe=123456</tspan></text>
385
385
  </g>
386
386
  <g
387
- style="display:none"
387
+ style="display:inline"
388
388
  inkscape:label="step3"
389
389
  id="layer4"
390
390
  inkscape:groupmode="layer">
@@ -443,7 +443,7 @@
443
443
  inkscape:groupmode="layer"
444
444
  id="layer8"
445
445
  inkscape:label="step3-4"
446
- style="display:none">
446
+ style="display:inline">
447
447
  <text
448
448
  sodipodi:linespacing="125%"
449
449
  id="text4140"
@@ -479,7 +479,7 @@
479
479
  y="391.76321">probe=123456</tspan></text>
480
480
  </g>
481
481
  <g
482
- style="display:none"
482
+ style="display:inline"
483
483
  inkscape:label="step4"
484
484
  id="layer5"
485
485
  inkscape:groupmode="layer">
@@ -5,11 +5,11 @@ require 'rspec/expectations'
5
5
  require 'lbspec'
6
6
 
7
7
  RSpec.configure do |c|
8
- c.add_setting :lbspec_capture_command , :default => nil
9
- c.add_setting :lbspec_udp_request_command , :default => nil
10
- c.add_setting :lbspec_tcp_request_command , :default => nil
11
- c.add_setting :lbspec_http_request_command , :default => nil
12
- c.add_setting :lbspec_https_request_command, :default => nil
8
+ c.add_setting :lbspec_capture_command , default: nil
9
+ c.add_setting :lbspec_udp_request_command , default: nil
10
+ c.add_setting :lbspec_tcp_request_command , default: nil
11
+ c.add_setting :lbspec_http_request_command , default: nil
12
+ c.add_setting :lbspec_https_request_command, default: nil
13
13
  end
14
14
 
15
15
  RSpec::Matchers.define :transfer do |nodes|
@@ -22,6 +22,7 @@ RSpec::Matchers.define :transfer do |nodes|
22
22
  @http_path = '/'
23
23
  @vhost_port = 80
24
24
  @node_port = 0
25
+ @options = {}
25
26
 
26
27
  @capture_command = lambda do |port, prove|
27
28
  port_str = port > 0 ? "port #{port}" : ''
@@ -35,12 +36,15 @@ RSpec::Matchers.define :transfer do |nodes|
35
36
  system("echo #{prove} | nc #{addr} #{port}")
36
37
  end
37
38
  @http_request_command = lambda do |addr, port, path, prove|
39
+ opt = @options[:timeout] ? " -m #{@options[:timeout]}" : ''
38
40
  uri = 'http://' + "#{addr}:#{port}#{path}?#{prove}"
39
- system("curl -o /dev/null -s #{uri}")
41
+ system("curl -o /dev/null -s #{opt} #{uri}")
40
42
  end
41
43
  @https_request_command = lambda do |addr, port, path, prove|
44
+ opt = @options[:timeout] ? " -m #{@options[:timeout]}" : ''
45
+ opt << (@options[:ignore_valid_ssl] ? ' -k' : '')
42
46
  uri = 'https://' + "#{addr}:#{port}#{path}?#{prove}"
43
- system("curl -o /dev/null -sk #{uri}")
47
+ system("curl -o /dev/null -sk #{opt} #{uri}")
44
48
  end
45
49
 
46
50
  @result = false
@@ -88,6 +92,10 @@ RSpec::Matchers.define :transfer do |nodes|
88
92
  @chain_str << " via #{path}"
89
93
  end
90
94
 
95
+ chain :options do |options|
96
+ @options = options
97
+ end
98
+
91
99
  def override_commands
92
100
  capture = RSpec.configuration.lbspec_capture_command
93
101
  udp_request = RSpec.configuration.lbspec_udp_request_command
@@ -116,7 +124,7 @@ RSpec::Matchers.define :transfer do |nodes|
116
124
 
117
125
  def capture_on_node(node)
118
126
  @threads << Thread.new do
119
- Net::SSH.start(node, nil, :config => true) do |ssh|
127
+ Net::SSH.start(node, nil, config: true) do |ssh|
120
128
  @ssh << ssh
121
129
  ssh.open_channel { |channel| run_check channel }
122
130
  end
@@ -190,14 +198,14 @@ RSpec::Matchers.define :transfer do |nodes|
190
198
 
191
199
  failure_message_for_should do |vhost|
192
200
  result = "expected #{vhost} to transfer requests to"
193
- result << nodes
201
+ result << nodes.to_s
194
202
  result << @chain_str
195
203
  result << ', but did not.'
196
204
  end
197
205
 
198
206
  failure_message_for_should_not do |vhost|
199
207
  result = "expected #{vhost} not to transfer requests to"
200
- result << nodes
208
+ result << nodes.to_s
201
209
  result << @chain_str
202
210
  result << ', but did.'
203
211
  end
data/lib/lbspec/util.rb CHANGED
@@ -12,7 +12,7 @@ module Lbspec
12
12
  splits = addr_port_str.split(':')
13
13
  addr = splits.first
14
14
  port = splits.last.to_i if /\d+/ =~ splits.last
15
- { :addr => addr, :port => port }
15
+ { addr: addr, port: port }
16
16
  end
17
17
  end
18
18
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  # Lbspec is an RSpec plugin for easy Loadbalancer testing.
3
3
  module Lbspec
4
- VERSION = '0.0.5'
4
+ VERSION = '0.0.6'
5
5
  end
data/rubocop-todo.yml CHANGED
@@ -1,2 +0,0 @@
1
- HashSyntax:
2
- EnforcedStyle: hash_rockets
@@ -23,7 +23,7 @@ describe Lbspec do
23
23
  'vhost_a'.should transfer('node_a')
24
24
  end
25
25
  it 'should test transfer nodes' do
26
- 'vhost_a'.should transfer(%w{node_a node_b})
26
+ 'vhost_a'.should transfer(%w(node_a node_b))
27
27
  end
28
28
  it 'should test transfer a node on port 80' do
29
29
  'vhost_a'.should transfer('node_a').port(80)
@@ -53,5 +53,15 @@ describe Lbspec do
53
53
  it { should transfer('node_a').https.path('/test') }
54
54
  it { should transfer('node_a').port(80).tcp.https.path('/test') }
55
55
  end
56
+ describe 'vhost_a:443' do
57
+ it do
58
+ should transfer('node_a').https.path('/test')
59
+ .options(ignore_valid_ssl: true)
60
+ end
61
+ it do
62
+ should transfer('node_a').https.path('/test')
63
+ .options(ignore_valid_ssl: false, timeout: 5)
64
+ end
65
+ end
56
66
  end
57
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lbspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-13 00:00:00.000000000 Z
12
+ date: 2014-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -200,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
200
  version: '0'
201
201
  segments:
202
202
  - 0
203
- hash: 2895181196576280225
203
+ hash: -3960315955505799530
204
204
  required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  none: false
206
206
  requirements:
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  version: '0'
210
210
  segments:
211
211
  - 0
212
- hash: 2895181196576280225
212
+ hash: -3960315955505799530
213
213
  requirements: []
214
214
  rubyforge_project:
215
215
  rubygems_version: 1.8.21