lbspec 0.0.4 → 0.0.5

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
@@ -67,6 +67,39 @@ describe 'vhost_c:443' do
67
67
  end
68
68
 
69
69
  ```
70
+ ## How it works
71
+ ### #transfer
72
+
73
+ 1. ssh to nodes
74
+ 2. cupture probe
75
+ 3. access with probe
76
+ 4. judge
77
+
78
+ ![#tranfer works][1]
79
+
80
+ ## Configuration
81
+ ### #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.
83
+ ```ruby
84
+ RSpec.configuration.lbspec_capture_command =
85
+ lambda do |port, prove|
86
+ port_str = port > 0 ? "port #{port}" : ''
87
+ "sudo ngrep #{prove} #{port_str} | grep -v \"match:\""
88
+ end
89
+
90
+ RSpec.configuration.lbspec_https_request_command =
91
+ lambda do |addr, port, path, prove|
92
+ uri = 'https://' + "#{addr}:#{port}#{path}?#{prove}"
93
+ system("curl -o /dev/null -sk #{uri}")
94
+ end
95
+ ```
96
+ You can replace following items.
97
+
98
+ - `lbspec_capture_command` with `|port, prove|`
99
+ - `lbspec_udp_request_command` with `|addr, port, prove|`
100
+ - `lbspec_tcp_request_command` with `|addr, port, prove|`
101
+ - `lbspec_http_request_command` with `|addr, port, path, prove|`
102
+ - `lbspec_https_request_command` with `|addr, port, path, prove|`
70
103
 
71
104
  ## Contributing
72
105
 
@@ -75,3 +108,6 @@ end
75
108
  3. Commit your changes (`git commit -am 'Add some feature'`)
76
109
  4. Push to the branch (`git push origin my-new-feature`)
77
110
  5. Create new Pull Request
111
+
112
+
113
+ [1]: images/transfer_overview.gif
@@ -0,0 +1,520 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
+
4
+ <svg
5
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
6
+ xmlns:cc="http://creativecommons.org/ns#"
7
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8
+ xmlns:svg="http://www.w3.org/2000/svg"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ xmlns:xlink="http://www.w3.org/1999/xlink"
11
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
12
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
13
+ width="744.09448819"
14
+ height="1052.3622047"
15
+ id="svg2"
16
+ version="1.1"
17
+ inkscape:version="0.48.4 r9939"
18
+ sodipodi:docname="overview.svg">
19
+ <sodipodi:namedview
20
+ id="base"
21
+ pagecolor="#ffffff"
22
+ bordercolor="#666666"
23
+ borderopacity="1.0"
24
+ inkscape:pageopacity="0.0"
25
+ inkscape:pageshadow="2"
26
+ inkscape:zoom="1.4510949"
27
+ inkscape:cx="184.15599"
28
+ inkscape:cy="676.17692"
29
+ inkscape:document-units="px"
30
+ inkscape:current-layer="layer2"
31
+ showgrid="false"
32
+ inkscape:window-width="1274"
33
+ inkscape:window-height="760"
34
+ inkscape:window-x="113"
35
+ inkscape:window-y="17"
36
+ inkscape:window-maximized="0" />
37
+ <defs
38
+ id="defs4">
39
+ <marker
40
+ style="overflow:visible;"
41
+ id="Arrow2Lend"
42
+ refX="0.0"
43
+ refY="0.0"
44
+ orient="auto"
45
+ inkscape:stockid="Arrow2Lend">
46
+ <path
47
+ transform="scale(1.1) rotate(180) translate(1,0)"
48
+ d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
49
+ style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;"
50
+ id="path4059" />
51
+ </marker>
52
+ <marker
53
+ style="overflow:visible;"
54
+ id="Arrow1Mend"
55
+ refX="0.0"
56
+ refY="0.0"
57
+ orient="auto"
58
+ inkscape:stockid="Arrow1Mend">
59
+ <path
60
+ transform="scale(0.4) rotate(180) translate(10,0)"
61
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
62
+ d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
63
+ id="path4047" />
64
+ </marker>
65
+ <marker
66
+ style="overflow:visible;"
67
+ id="Arrow1Lend"
68
+ refX="0.0"
69
+ refY="0.0"
70
+ orient="auto"
71
+ inkscape:stockid="Arrow1Lend">
72
+ <path
73
+ transform="scale(0.8) rotate(180) translate(12.5,0)"
74
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
75
+ d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
76
+ id="path4041" />
77
+ </marker>
78
+ <marker
79
+ style="overflow:visible;"
80
+ id="Arrow1Mende"
81
+ refX="0.0"
82
+ refY="0.0"
83
+ orient="auto"
84
+ inkscape:stockid="Arrow1Mende">
85
+ <path
86
+ transform="scale(0.4) rotate(180) translate(10,0)"
87
+ style="marker-start:none;stroke:#0000ff;stroke-width:1.0pt;fill:#0000ff;fill-rule:evenodd"
88
+ d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
89
+ id="path3669" />
90
+ </marker>
91
+ <marker
92
+ style="overflow:visible;"
93
+ id="Arrow1MendW"
94
+ refX="0.0"
95
+ refY="0.0"
96
+ orient="auto"
97
+ inkscape:stockid="Arrow1MendW">
98
+ <path
99
+ transform="scale(0.4) rotate(180) translate(10,0)"
100
+ style="marker-start:none;stroke:#0000ff;stroke-width:1.0pt;fill:#0000ff;fill-rule:evenodd"
101
+ d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
102
+ id="path3819" />
103
+ </marker>
104
+ <marker
105
+ style="overflow:visible;"
106
+ id="Arrow1Mendu"
107
+ refX="0.0"
108
+ refY="0.0"
109
+ orient="auto"
110
+ inkscape:stockid="Arrow1Mendu">
111
+ <path
112
+ transform="scale(0.4) rotate(180) translate(10,0)"
113
+ style="marker-start:none;stroke:#0000ff;stroke-width:1.0pt;fill:#0000ff;fill-rule:evenodd"
114
+ d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
115
+ id="path3972" />
116
+ </marker>
117
+ </defs>
118
+ <metadata
119
+ id="metadata7">
120
+ <rdf:RDF>
121
+ <cc:Work
122
+ rdf:about="">
123
+ <dc:format>image/svg+xml</dc:format>
124
+ <dc:type
125
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
126
+ <dc:title></dc:title>
127
+ </cc:Work>
128
+ </rdf:RDF>
129
+ </metadata>
130
+ <g
131
+ id="layer1"
132
+ inkscape:groupmode="layer"
133
+ inkscape:label="base"
134
+ style="display:inline">
135
+ <g
136
+ transform="translate(-58,-14)"
137
+ id="g3972">
138
+ <g
139
+ id="g3964">
140
+ <rect
141
+ ry="0.2563507"
142
+ y="442.78577"
143
+ x="188.86682"
144
+ height="49.465992"
145
+ width="98.798752"
146
+ id="rect2987"
147
+ style="fill:none;stroke:#157de2;stroke-width:1.20124829;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
148
+ <text
149
+ sodipodi:linespacing="125%"
150
+ id="text3779"
151
+ y="464.49237"
152
+ x="238.48006"
153
+ style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill-opacity:1;stroke:#157de2;stroke-opacity:1;font-family:Sans;-inkscape-font-specification:Sans"
154
+ xml:space="preserve"><tspan
155
+ style="font-size:12px"
156
+ y="464.49237"
157
+ x="238.48006"
158
+ id="tspan3781"
159
+ sodipodi:role="line">executing</tspan><tspan
160
+ style="font-size:12px"
161
+ id="tspan3783"
162
+ y="479.49237"
163
+ x="238.48006"
164
+ sodipodi:role="line">machine</tspan></text>
165
+ </g>
166
+ </g>
167
+ <flowRoot
168
+ style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
169
+ id="flowRoot3809"
170
+ xml:space="preserve"><flowRegion
171
+ id="flowRegion3811"><rect
172
+ y="304.01443"
173
+ x="365.71429"
174
+ height="46.853077"
175
+ width="140.55923"
176
+ id="rect3813" /></flowRegion><flowPara
177
+ id="flowPara3815" /></flowRoot> <flowRoot
178
+ style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
179
+ id="flowRoot3836"
180
+ xml:space="preserve"><flowRegion
181
+ id="flowRegion3838"><rect
182
+ y="304.01443"
183
+ x="386.53787"
184
+ height="62.470768"
185
+ width="152.27249"
186
+ id="rect3840" /></flowRegion><flowPara
187
+ id="flowPara3842" /></flowRoot> <flowRoot
188
+ style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
189
+ id="flowRoot3844"
190
+ xml:space="preserve"><flowRegion
191
+ id="flowRegion3846"><rect
192
+ y="309.22034"
193
+ x="382.63345"
194
+ height="67.676666"
195
+ width="163.98576"
196
+ id="rect3848" /></flowRegion><flowPara
197
+ id="flowPara3850" /></flowRoot> <g
198
+ transform="translate(0,-6.0493393)"
199
+ id="g3948">
200
+ <image
201
+ y="297.02881"
202
+ x="129.52431"
203
+ id="image3776"
204
+ xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHwAAAByCAYAAACRFLXOAAAABHNCSVQICAgIfAhkiAAAAbpJREFU eJzt0T1KA2EYReH3S8YoZBJdgD+LEO3EytLSDbgAwd5GrUUEC5djIe7DHxBsRB2RMaOfVcANjAM5 56lueeGks+vXfHnzFlWdQ7NpOEhxsDWOw+3xMC0fP+S6MfasK3oRF7vlUjGN/Xyy0vEltWXt9DE+ Jznu34u5Xtdn9L8MDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxgcxuAwBocxOIzBYQwOY3AYg8MY HMbgMAaHMTiMwWEMDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxgcxuAwBocxOIzBYQwOY3AYg8MY HMbgMAaHMTiMwWEMDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxgcxuAwBocxOIzBYQwOY3AYg8MY HMbgMAaHMTiMwWEMDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxgcxuAwBocxOIzBYQwOY3AYg8MY HMbgMAaHMTiMwWEMDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxTTcffSdPlDLcp/dlHOp6jqHBvn T50dUvsG/RSro2ZSHO0sflzdVgvfP5G6PqV29HuR9zdH9d56+fULNj8xJBu/RzMAAAAASUVORK5C YII= "
205
+ height="61.382713"
206
+ width="100" />
207
+ <text
208
+ sodipodi:linespacing="125%"
209
+ id="text3852"
210
+ y="324.69379"
211
+ x="179.90517"
212
+ style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill-opacity:1;stroke:#157de2;stroke-opacity:1;font-family:Sans;-inkscape-font-specification:Sans"
213
+ xml:space="preserve"><tspan
214
+ sodipodi:role="line"
215
+ id="tspan3858"
216
+ x="179.90517"
217
+ y="324.69379"
218
+ style="font-size:12px">virtual</tspan><tspan
219
+ sodipodi:role="line"
220
+ x="179.90517"
221
+ y="339.69379"
222
+ id="tspan3866"
223
+ style="font-size:12px">host</tspan></text>
224
+ </g>
225
+ <g
226
+ id="g4019">
227
+ <image
228
+ width="100"
229
+ height="52.679085"
230
+ xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHwAAAByCAYAAACRFLXOAAAABHNCSVQICAgIfAhkiAAAAbpJREFU eJzt0T1KA2EYReH3S8YoZBJdgD+LEO3EytLSDbgAwd5GrUUEC5djIe7DHxBsRB2RMaOfVcANjAM5 56lueeGks+vXfHnzFlWdQ7NpOEhxsDWOw+3xMC0fP+S6MfasK3oRF7vlUjGN/Xyy0vEltWXt9DE+ Jznu34u5Xtdn9L8MDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxgcxuAwBocxOIzBYQwOY3AYg8MY HMbgMAaHMTiMwWEMDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxgcxuAwBocxOIzBYQwOY3AYg8MY HMbgMAaHMTiMwWEMDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxgcxuAwBocxOIzBYQwOY3AYg8MY HMbgMAaHMTiMwWEMDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxgcxuAwBocxOIzBYQwOY3AYg8MY HMbgMAaHMTiMwWEMDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxTTcffSdPlDLcp/dlHOp6jqHBvn T50dUvsG/RSro2ZSHO0sflzdVgvfP5G6PqV29HuR9zdH9d56+fULNj8xJBu/RzMAAAAASUVORK5C YII= "
231
+ id="image3872"
232
+ x="352.18152"
233
+ y="249.68309" />
234
+ <text
235
+ sodipodi:linespacing="125%"
236
+ id="text3876"
237
+ y="280.49628"
238
+ x="402.18445"
239
+ style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill-opacity:1;stroke:#157de2;stroke-opacity:1;font-family:Sans;-inkscape-font-specification:Sans"
240
+ xml:space="preserve"><tspan
241
+ y="280.49628"
242
+ x="402.18445"
243
+ sodipodi:role="line"
244
+ id="tspan3878"
245
+ style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;font-family:Sans;-inkscape-font-specification:Sans">node_a</tspan></text>
246
+ </g>
247
+ <path
248
+ inkscape:connector-curvature="0"
249
+ id="path3970"
250
+ d="m 351.0327,275.36218 c 0,0 0,0 -121.9723,47 123.9396,56 123.9396,56 123.9396,56"
251
+ style="fill:none;stroke:#157de2;stroke-width:1.98358023;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1.98358018, 3.96716036;stroke-dashoffset:0" />
252
+ <g
253
+ transform="translate(0,100)"
254
+ id="g4024">
255
+ <image
256
+ y="249.68309"
257
+ x="352.18152"
258
+ id="image4026"
259
+ xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHwAAAByCAYAAACRFLXOAAAABHNCSVQICAgIfAhkiAAAAbpJREFU eJzt0T1KA2EYReH3S8YoZBJdgD+LEO3EytLSDbgAwd5GrUUEC5djIe7DHxBsRB2RMaOfVcANjAM5 56lueeGks+vXfHnzFlWdQ7NpOEhxsDWOw+3xMC0fP+S6MfasK3oRF7vlUjGN/Xyy0vEltWXt9DE+ Jznu34u5Xtdn9L8MDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxgcxuAwBocxOIzBYQwOY3AYg8MY HMbgMAaHMTiMwWEMDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxgcxuAwBocxOIzBYQwOY3AYg8MY HMbgMAaHMTiMwWEMDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxgcxuAwBocxOIzBYQwOY3AYg8MY HMbgMAaHMTiMwWEMDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxgcxuAwBocxOIzBYQwOY3AYg8MY HMbgMAaHMTiMwWEMDmNwGIPDGBzG4DAGhzE4jMFhDA5jcBiDwxTTcffSdPlDLcp/dlHOp6jqHBvn T50dUvsG/RSro2ZSHO0sflzdVgvfP5G6PqV29HuR9zdH9d56+fULNj8xJBu/RzMAAAAASUVORK5C YII= "
260
+ height="52.679085"
261
+ width="100" />
262
+ <text
263
+ xml:space="preserve"
264
+ style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill-opacity:1;stroke:#157de2;stroke-opacity:1;font-family:Sans;-inkscape-font-specification:Sans"
265
+ x="402.18445"
266
+ y="280.49628"
267
+ id="text4028"
268
+ sodipodi:linespacing="125%"><tspan
269
+ style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;font-family:Sans;-inkscape-font-specification:Sans"
270
+ id="tspan4030"
271
+ sodipodi:role="line"
272
+ x="402.18445"
273
+ y="280.49628">node_b</tspan></text>
274
+ </g>
275
+ </g>
276
+ <g
277
+ style="display:none"
278
+ inkscape:label="step1"
279
+ id="layer2"
280
+ inkscape:groupmode="layer">
281
+ <path
282
+ inkscape:connector-curvature="0"
283
+ id="path4033"
284
+ d="m 181,430.36218 c 171,-144 171,-144 171,-144"
285
+ 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)" />
286
+ <path
287
+ inkscape:connector-curvature="0"
288
+ id="path4695"
289
+ d="m 185,429.36218 c 174,-49 174,-49 174,-49"
290
+ 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(#Arrow1Mendu)" />
291
+ <text
292
+ sodipodi:linespacing="125%"
293
+ id="text4881"
294
+ y="232.36218"
295
+ x="134"
296
+ 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;font-family:Sans;-inkscape-font-specification:Sans Bold"
297
+ xml:space="preserve"><tspan
298
+ y="232.36218"
299
+ x="134"
300
+ id="tspan4883"
301
+ sodipodi:role="line">1. ssh to nodes</tspan></text>
302
+ </g>
303
+ <g
304
+ inkscape:groupmode="layer"
305
+ id="layer7"
306
+ inkscape:label="step1-2"
307
+ style="display:none">
308
+ <path
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
+ d="m 181,430.36218 c 171,-144 171,-144 171,-144"
311
+ id="path4133"
312
+ inkscape:connector-curvature="0" />
313
+ <path
314
+ 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(#Arrow1Mendu);display:inline"
315
+ d="m 185,429.36218 c 174,-49 174,-49 174,-49"
316
+ id="path4136"
317
+ inkscape:connector-curvature="0" />
318
+ </g>
319
+ <g
320
+ style="display:none"
321
+ inkscape:label="step2"
322
+ id="layer3"
323
+ inkscape:groupmode="layer">
324
+ <text
325
+ xml:space="preserve"
326
+ 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"
327
+ x="134"
328
+ y="232.36218"
329
+ id="text4886"
330
+ sodipodi:linespacing="125%"><tspan
331
+ sodipodi:role="line"
332
+ id="tspan4888"
333
+ x="134"
334
+ y="232.36218">2. cupture probe</tspan></text>
335
+ <text
336
+ sodipodi:linespacing="125%"
337
+ id="text5458"
338
+ y="310.64789"
339
+ x="330.18588"
340
+ 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"
341
+ xml:space="preserve"><tspan
342
+ y="310.64789"
343
+ x="330.18588"
344
+ id="tspan5460"
345
+ sodipodi:role="line">probe=123456</tspan></text>
346
+ <text
347
+ xml:space="preserve"
348
+ 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"
349
+ x="330.18588"
350
+ y="410.64789"
351
+ id="text5462"
352
+ sodipodi:linespacing="125%"><tspan
353
+ sodipodi:role="line"
354
+ id="tspan5464"
355
+ x="330.18588"
356
+ y="410.64789">probe=123456</tspan></text>
357
+ </g>
358
+ <g
359
+ inkscape:groupmode="layer"
360
+ id="layer6"
361
+ inkscape:label="step2-3"
362
+ style="display:none">
363
+ <text
364
+ xml:space="preserve"
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"
366
+ x="330.18588"
367
+ y="310.64789"
368
+ id="text4120"
369
+ sodipodi:linespacing="125%"><tspan
370
+ sodipodi:role="line"
371
+ id="tspan4122"
372
+ x="330.18588"
373
+ y="310.64789">probe=123456</tspan></text>
374
+ <text
375
+ sodipodi:linespacing="125%"
376
+ id="text4124"
377
+ y="410.64789"
378
+ x="330.18588"
379
+ 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"
380
+ xml:space="preserve"><tspan
381
+ y="410.64789"
382
+ x="330.18588"
383
+ id="tspan4126"
384
+ sodipodi:role="line">probe=123456</tspan></text>
385
+ </g>
386
+ <g
387
+ style="display:none"
388
+ inkscape:label="step3"
389
+ id="layer4"
390
+ inkscape:groupmode="layer">
391
+ <text
392
+ sodipodi:linespacing="125%"
393
+ id="text4893"
394
+ y="232.36218"
395
+ x="134"
396
+ 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"
397
+ xml:space="preserve"><tspan
398
+ y="232.36218"
399
+ x="134"
400
+ id="tspan4895"
401
+ sodipodi:role="line">3. access with probe</tspan></text>
402
+ <text
403
+ xml:space="preserve"
404
+ 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"
405
+ x="330.18588"
406
+ y="310.64789"
407
+ id="text5466"
408
+ sodipodi:linespacing="125%"><tspan
409
+ sodipodi:role="line"
410
+ id="tspan5468"
411
+ x="330.18588"
412
+ y="310.64789">probe=123456</tspan></text>
413
+ <text
414
+ sodipodi:linespacing="125%"
415
+ id="text5470"
416
+ y="410.64789"
417
+ x="330.18588"
418
+ 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"
419
+ xml:space="preserve"><tspan
420
+ y="410.64789"
421
+ x="330.18588"
422
+ id="tspan5472"
423
+ sodipodi:role="line">probe=123456</tspan></text>
424
+ <path
425
+ sodipodi:nodetypes="csc"
426
+ inkscape:connector-curvature="0"
427
+ id="path5493"
428
+ d="m 215.99312,447.7701 c 0,0 -37.11624,-101.00374 4.71601,-133.9346 51.92449,-40.8756 155.62822,-32.06884 155.62822,-32.06884"
429
+ style="fill:none;stroke:#0000ff;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-end:url(#Arrow1Mende)" />
430
+ <text
431
+ sodipodi:linespacing="125%"
432
+ id="text6053"
433
+ y="391.76321"
434
+ x="144.37521"
435
+ 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"
436
+ xml:space="preserve"><tspan
437
+ y="391.76321"
438
+ x="144.37521"
439
+ id="tspan6055"
440
+ sodipodi:role="line">probe=123456</tspan></text>
441
+ </g>
442
+ <g
443
+ inkscape:groupmode="layer"
444
+ id="layer8"
445
+ inkscape:label="step3-4"
446
+ style="display:none">
447
+ <text
448
+ sodipodi:linespacing="125%"
449
+ id="text4140"
450
+ y="310.64789"
451
+ x="330.18588"
452
+ 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"
453
+ xml:space="preserve"><tspan
454
+ y="310.64789"
455
+ x="330.18588"
456
+ id="tspan4142"
457
+ sodipodi:role="line">probe=123456</tspan></text>
458
+ <text
459
+ xml:space="preserve"
460
+ 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"
461
+ x="330.18588"
462
+ y="410.64789"
463
+ id="text4144"
464
+ sodipodi:linespacing="125%"><tspan
465
+ sodipodi:role="line"
466
+ id="tspan4146"
467
+ x="330.18588"
468
+ y="410.64789">probe=123456</tspan></text>
469
+ <text
470
+ xml:space="preserve"
471
+ 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"
472
+ x="144.37521"
473
+ y="391.76321"
474
+ id="text4148"
475
+ sodipodi:linespacing="125%"><tspan
476
+ sodipodi:role="line"
477
+ id="tspan4150"
478
+ x="144.37521"
479
+ y="391.76321">probe=123456</tspan></text>
480
+ </g>
481
+ <g
482
+ style="display:none"
483
+ inkscape:label="step4"
484
+ id="layer5"
485
+ inkscape:groupmode="layer">
486
+ <text
487
+ xml:space="preserve"
488
+ 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"
489
+ x="134"
490
+ y="232.36218"
491
+ id="text4900"
492
+ sodipodi:linespacing="125%"><tspan
493
+ sodipodi:role="line"
494
+ id="tspan4902"
495
+ x="134"
496
+ y="232.36218">4. judge</tspan></text>
497
+ <text
498
+ xml:space="preserve"
499
+ 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:#00ff00;display:inline;font-family:Sans;-inkscape-font-specification:Sans Bold"
500
+ x="144.07153"
501
+ y="392.03638"
502
+ id="text6057"
503
+ sodipodi:linespacing="125%"><tspan
504
+ sodipodi:role="line"
505
+ id="tspan6059"
506
+ x="144.07153"
507
+ y="392.03638">probe=123456</tspan></text>
508
+ <text
509
+ sodipodi:linespacing="125%"
510
+ id="text6067"
511
+ y="310.64789"
512
+ x="330.18588"
513
+ 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:#00ff00;display:inline;font-family:Sans;-inkscape-font-specification:Sans Bold"
514
+ xml:space="preserve"><tspan
515
+ y="310.64789"
516
+ x="330.18588"
517
+ id="tspan6069"
518
+ sodipodi:role="line">probe=123456</tspan></text>
519
+ </g>
520
+ </svg>
@@ -1,22 +1,54 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  require 'net/ssh'
3
+ require 'rspec/core'
3
4
  require 'rspec/expectations'
4
5
  require 'lbspec'
5
6
 
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
13
+ end
14
+
6
15
  RSpec::Matchers.define :transfer do |nodes|
7
16
  @ssh = []
8
17
  @threads = []
9
18
  @nodes_connected = []
19
+ @chain_str = ''
10
20
  @protocol = nil
11
21
  @application = nil
12
22
  @http_path = '/'
13
23
  @vhost_port = 80
14
24
  @node_port = 0
25
+
26
+ @capture_command = lambda do |port, prove|
27
+ port_str = port > 0 ? "port #{port}" : ''
28
+ "sudo ngrep #{prove} #{port_str} | grep -v \"match:\""
29
+ end
30
+
31
+ @udp_request_command = lambda do |addr, port, prove|
32
+ system("echo #{prove} | nc -u #{addr} #{port}")
33
+ end
34
+ @tcp_request_command = lambda do |addr, port, prove|
35
+ system("echo #{prove} | nc #{addr} #{port}")
36
+ end
37
+ @http_request_command = lambda do |addr, port, path, prove|
38
+ uri = 'http://' + "#{addr}:#{port}#{path}?#{prove}"
39
+ system("curl -o /dev/null -s #{uri}")
40
+ end
41
+ @https_request_command = lambda do |addr, port, path, prove|
42
+ uri = 'https://' + "#{addr}:#{port}#{path}?#{prove}"
43
+ system("curl -o /dev/null -sk #{uri}")
44
+ end
45
+
15
46
  @result = false
16
47
  Thread.abort_on_exception = true
17
48
 
18
49
  match do |vhost|
19
- @keyword = gen_keyword
50
+ @prove = Lbspec::Util.create_prove
51
+ override_commands
20
52
  capture_on_nodes nodes
21
53
  wait_nodes_connected nodes
22
54
  send_request vhost
@@ -26,32 +58,47 @@ RSpec::Matchers.define :transfer do |nodes|
26
58
 
27
59
  chain :port do |port|
28
60
  @node_port = port
61
+ @chain_str << " port #{port}"
29
62
  end
30
63
 
31
64
  chain :tcp do
32
65
  @protocol = :tcp
66
+ @chain_str << ' tcp'
33
67
  end
34
68
 
35
69
  chain :udp do
36
70
  @protocol = :udp
71
+ @chain_str << ' udp'
37
72
  end
38
73
 
39
74
  chain :http do
40
75
  @protocol = :tcp
41
76
  @application = :http
77
+ @chain_str << ' http'
42
78
  end
43
79
 
44
80
  chain :https do
45
81
  @protocol = :tcp
46
82
  @application = :https
83
+ @chain_str << ' https'
47
84
  end
48
85
 
49
86
  chain :path do |path|
50
87
  @http_path = path
88
+ @chain_str << " via #{path}"
51
89
  end
52
90
 
53
- def gen_keyword
54
- Lbspec::Util.gen_keyword
91
+ def override_commands
92
+ capture = RSpec.configuration.lbspec_capture_command
93
+ udp_request = RSpec.configuration.lbspec_udp_request_command
94
+ tcp_request = RSpec.configuration.lbspec_tcp_request_command
95
+ http_request = RSpec.configuration.lbspec_http_request_command
96
+ https_request = RSpec.configuration.lbspec_https_request_command
97
+ @capture_command = capture if capture
98
+ @udp_request_command = udp_request if udp_request
99
+ @tcp_request_command = tcp_request if tcp_request
100
+ @http_request_command = http_request if http_request
101
+ @https_request_command = https_request if https_request
55
102
  end
56
103
 
57
104
  def wait_nodes_connected(nodes)
@@ -80,23 +127,23 @@ RSpec::Matchers.define :transfer do |nodes|
80
127
  channel.request_pty do |chan, success|
81
128
  fail 'Could not obtain pty' unless success
82
129
  @nodes_connected.push(true)
83
- exec_capture(chan, capture_cmd)
130
+ exec_capture(chan)
84
131
  end
85
132
  end
86
133
 
87
- def exec_capture(channel, command)
88
- channel.exec capture_cmd do |ch, stream, data|
134
+ def exec_capture(channel)
135
+ command = capture_command(@node_port, @prove)
136
+ channel.exec command do |ch, stream, data|
89
137
  num_match = 0
90
138
  ch.on_data do |c, d|
91
- num_match += 1 if /#{@keyword}/ =~ d
139
+ num_match += 1 if /#{@prove}/ =~ d
92
140
  @result = true if num_match > 0
93
141
  end
94
142
  end
95
143
  end
96
144
 
97
- def capture_cmd
98
- port_str = @node_port > 0 ? "port #{@node_port}" : ''
99
- "sudo ngrep #{@keyword} #{port_str} | grep -v \"match:\""
145
+ def capture_command(port, prove)
146
+ @capture_command[port, prove]
100
147
  end
101
148
 
102
149
  def disconnect_nodes
@@ -113,41 +160,45 @@ RSpec::Matchers.define :transfer do |nodes|
113
160
  vhost_addr, vhost_port = addr_port[:addr], addr_port[:port]
114
161
  @vhost_port = vhost_port if vhost_port > 0
115
162
  if @application
116
- send_request_application(vhost_addr, @vhost_port)
163
+ send_request_application(vhost_addr, @vhost_port, @prove)
117
164
  else
118
- send_request_transport(vhost_addr, @vhost_port)
165
+ send_request_transport(vhost_addr, @vhost_port, @prove)
119
166
  end
120
167
  end
121
168
 
122
- def send_request_application(addr, port)
169
+ def send_request_application(addr, port, prove)
123
170
  case @application
124
171
  when :http
125
- uri = 'http://' + "#{addr}:#{port}#{@http_path}?#{@keyword}"
126
- system("curl -o /dev/null -s #{uri}")
172
+ @http_request_command[addr, port, @http_path, prove]
127
173
  when :https
128
- uri = 'https://' + "#{addr}:#{port}#{@http_path}?#{@keyword}"
129
- system("curl -o /dev/null -s -k #{uri}")
174
+ @https_request_command[addr, port, @http_path, prove]
130
175
  end
131
176
  end
132
177
 
133
- def send_request_transport(addr, port)
178
+ def send_request_transport(addr, port, prove)
134
179
  case @protocol
135
180
  when :udp
136
- system("echo #{@keyword} | nc -u #{addr} #{port}")
181
+ @udp_request_command[addr, port, prove]
137
182
  else
138
- system("echo #{@keyword} | nc #{addr} #{port}")
183
+ @tcp_request_command[addr, port, prove]
139
184
  end
140
185
  end
141
186
 
142
187
  description do
143
- "transfer requests to #{nodes}."
188
+ "transfer requests to #{nodes}#{@chain_str}."
144
189
  end
145
190
 
146
191
  failure_message_for_should do |vhost|
147
- "expected #{vhost} to transfer requests to #{nodes}, but did not."
192
+ result = "expected #{vhost} to transfer requests to"
193
+ result << nodes
194
+ result << @chain_str
195
+ result << ', but did not.'
148
196
  end
149
197
 
150
198
  failure_message_for_should_not do |vhost|
151
- "expected #{vhost} not to transfer requests to #{nodes}, but it did."
199
+ result = "expected #{vhost} not to transfer requests to"
200
+ result << nodes
201
+ result << @chain_str
202
+ result << ', but did.'
152
203
  end
153
204
  end
@@ -3,7 +3,7 @@
3
3
  module Lbspec
4
4
  # Lbspec::Util provides some utilities
5
5
  class Util
6
- def self.gen_keyword
6
+ def self.create_prove
7
7
  t = Time.now
8
8
  t.to_i.to_s + t.nsec.to_s
9
9
  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.4'
4
+ VERSION = '0.0.5'
5
5
  end
@@ -5,8 +5,8 @@ require 'net/ssh'
5
5
  describe Lbspec do
6
6
  describe '#transfer' do
7
7
  before(:each) do
8
- key = Lbspec::Util.gen_keyword
9
- Lbspec::Util.stub(:gen_keyword).and_return(key)
8
+ key = Lbspec::Util.create_prove
9
+ Lbspec::Util.stub(:create_prove).and_return(key)
10
10
  channel_connected = double('channel_connected')
11
11
  channel_connected.stub(:request_pty).and_yield(channel_connected, true)
12
12
  channel_connected.stub(:exec).and_yield(channel_connected, nil, nil)
@@ -49,5 +49,9 @@ describe Lbspec do
49
49
  it 'should test transfer vhost:443 and a node with https /test' do
50
50
  'vhost_a:443'.should transfer('node_a').https.path('/test')
51
51
  end
52
+ describe 'vhost_a:443' do
53
+ it { should transfer('node_a').https.path('/test') }
54
+ it { should transfer('node_a').port(80).tcp.https.path('/test') }
55
+ end
52
56
  end
53
57
  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.4
4
+ version: 0.0.5
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-08 00:00:00.000000000 Z
12
+ date: 2014-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -172,6 +172,8 @@ files:
172
172
  - LICENSE.txt
173
173
  - README.md
174
174
  - Rakefile
175
+ - images/transfer_overview.gif
176
+ - images/transfer_overview.svg
175
177
  - lbspec.gemspec
176
178
  - lib/lbspec.rb
177
179
  - lib/lbspec/transfer.rb
@@ -198,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
200
  version: '0'
199
201
  segments:
200
202
  - 0
201
- hash: 987805582344225460
203
+ hash: 2895181196576280225
202
204
  required_rubygems_version: !ruby/object:Gem::Requirement
203
205
  none: false
204
206
  requirements:
@@ -207,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
209
  version: '0'
208
210
  segments:
209
211
  - 0
210
- hash: 987805582344225460
212
+ hash: 2895181196576280225
211
213
  requirements: []
212
214
  rubyforge_project:
213
215
  rubygems_version: 1.8.21