tools-cf-plugin 2.0.0 → 2.1.0
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/lib/tools-cf-plugin/dea-ads.rb +1 -1
- data/lib/tools-cf-plugin/tunnel/multi_line_stream.rb +10 -1
- data/lib/tools-cf-plugin/tunnel/tunnel-nats.rb +4 -0
- data/lib/tools-cf-plugin/tunnel/watch-logs.rb +10 -6
- data/lib/tools-cf-plugin/version.rb +1 -1
- data/lib/tools-cf-plugin/watch.rb +93 -28
- data/spec/dea-ads_spec.rb +29 -13
- data/spec/shell_spec.rb +3 -3
- data/spec/spec_helper.rb +0 -1
- data/spec/tunnel/base_spec.rb +39 -43
- data/spec/tunnel/multi_line_stream_spec.rb +31 -15
- data/spec/tunnel/stream_location_spec.rb +4 -7
- data/spec/tunnel/tunnel-nats_spec.rb +28 -31
- data/spec/tunnel/watch-logs_spec.rb +26 -24
- data/spec/watch_spec.rb +176 -235
- metadata +45 -39
data/spec/watch_spec.rb
CHANGED
@@ -5,39 +5,40 @@ describe CFTools::Watch do
|
|
5
5
|
|
6
6
|
let(:client) { fake_client :apps => [app] }
|
7
7
|
|
8
|
+
let(:payload) { "" }
|
9
|
+
let(:subject) { "" }
|
10
|
+
let(:messages) { [[payload, nil, subject]] }
|
11
|
+
|
8
12
|
before { stub_client }
|
9
13
|
|
10
|
-
before
|
11
|
-
stub(app).exists? { true }
|
12
|
-
end
|
14
|
+
before { app.stub(:exists? => true) }
|
13
15
|
|
14
16
|
before do
|
15
|
-
stub(
|
16
|
-
stub(
|
17
|
+
NATS.stub(:start).and_yield
|
18
|
+
NATS.stub(:subscribe).with(">") do |&blk|
|
19
|
+
messages.each do |msg|
|
20
|
+
blk.call(*msg)
|
21
|
+
end
|
22
|
+
end
|
17
23
|
end
|
18
24
|
|
19
25
|
it "subscribes all messages on NATS" do
|
20
|
-
|
26
|
+
expect(NATS).to receive(:subscribe).with(">")
|
21
27
|
cf %W[watch]
|
22
28
|
end
|
23
29
|
|
24
30
|
it "turns off output buffering" do
|
25
31
|
# this is dumb. i know. exercise for the reader. - AS
|
26
|
-
|
27
|
-
mock(io).sync = true
|
28
|
-
end
|
29
|
-
|
32
|
+
expect_any_instance_of(StringIO).to receive(:sync=).with(true)
|
30
33
|
cf %W[watch]
|
31
34
|
end
|
32
35
|
|
33
36
|
context "when no application is given" do
|
34
37
|
around { |example| Timecop.freeze(&example) }
|
35
38
|
|
36
|
-
|
37
|
-
stub(NATS).subscribe(">") do |_, block|
|
38
|
-
block.call("some-message", nil, "some.subject")
|
39
|
-
end
|
39
|
+
let(:messages) { [["some-message", nil, "some.subject"]] }
|
40
40
|
|
41
|
+
it "prints a timestamp, message, and raw body" do
|
41
42
|
cf %W[watch]
|
42
43
|
|
43
44
|
expect(output).to say(/#{Time.now.strftime("%r")}\s*some.subject\s*some-message/)
|
@@ -46,7 +47,7 @@ describe CFTools::Watch do
|
|
46
47
|
|
47
48
|
context "when no NATS server info is specified" do
|
48
49
|
it "connects on nats:nats@127.0.0.1:4222" do
|
49
|
-
|
50
|
+
expect(NATS).to receive(:start).with(hash_including(
|
50
51
|
:uri => "nats://nats:nats@127.0.0.1:4222"))
|
51
52
|
|
52
53
|
cf %W[watch]
|
@@ -55,7 +56,7 @@ describe CFTools::Watch do
|
|
55
56
|
|
56
57
|
context "when NATS server info is specified" do
|
57
58
|
it "connects to the given location using the given credentials" do
|
58
|
-
|
59
|
+
expect(NATS).to receive(:start).with(hash_including(
|
59
60
|
:uri => "nats://someuser:somepass@example.com:4242"))
|
60
61
|
|
61
62
|
cf %W[watch -h example.com -P 4242 -u someuser -p somepass]
|
@@ -63,14 +64,10 @@ describe CFTools::Watch do
|
|
63
64
|
end
|
64
65
|
|
65
66
|
context "when a malformed message comes in" do
|
66
|
-
|
67
|
-
stub(NATS).subscribe(">") do |_, block|
|
68
|
-
block.call("foo", nil, "some.subject")
|
69
|
-
end
|
67
|
+
let(:messages) { [["foo", nil, "some.subject"]] }
|
70
68
|
|
71
|
-
|
72
|
-
|
73
|
-
end
|
69
|
+
it "prints an error message and keeps on truckin'" do
|
70
|
+
described_class.any_instance.stub(:process_message).and_raise("hell")
|
74
71
|
|
75
72
|
cf %W[watch]
|
76
73
|
|
@@ -80,12 +77,14 @@ describe CFTools::Watch do
|
|
80
77
|
end
|
81
78
|
|
82
79
|
context "when a message comes in with a reply channel, followed by a reply" do
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
80
|
+
let(:messages) do
|
81
|
+
[
|
82
|
+
["foo", "some-reply", "some.subject"],
|
83
|
+
["some-response", nil, "some-reply"]
|
84
|
+
]
|
85
|
+
end
|
88
86
|
|
87
|
+
it "registers it in #requests" do
|
89
88
|
cf %W[watch]
|
90
89
|
|
91
90
|
expect(output).to say(/some\.subject \(1\)\s*foo/)
|
@@ -108,11 +107,9 @@ describe CFTools::Watch do
|
|
108
107
|
context "and a message containing the app's GUID is seen" do
|
109
108
|
around { |example| Timecop.freeze(&example) }
|
110
109
|
|
111
|
-
|
112
|
-
stub(NATS).subscribe(">") do |_, block|
|
113
|
-
block.call("some-message-mentioning-#{app.guid}", nil, "some.subject")
|
114
|
-
end
|
110
|
+
let(:messages) { [["some-message-mentioning-#{app.guid}", nil, "some.subject"]] }
|
115
111
|
|
112
|
+
it "prints a timestamp, message, and raw body" do
|
116
113
|
cf %W[watch myapp]
|
117
114
|
|
118
115
|
expect(output).to say(/#{Time.now.strftime("%r")}\s*some.subject\s*some-message-mentioning-#{app.guid}/)
|
@@ -120,11 +117,9 @@ describe CFTools::Watch do
|
|
120
117
|
end
|
121
118
|
|
122
119
|
context "when a message NOT containing the app's GUID is seen" do
|
123
|
-
|
124
|
-
stub(NATS).subscribe(">") do |_, block|
|
125
|
-
block.call("some-irrelevant-message", nil, "some.subject")
|
126
|
-
end
|
120
|
+
let(:messages) { [["some-irrelevant-message", nil, "some.subject"]] }
|
127
121
|
|
122
|
+
it "does not print it" do
|
128
123
|
cf %W[watch myapp]
|
129
124
|
|
130
125
|
expect(output).to_not say("some.subject")
|
@@ -133,6 +128,8 @@ describe CFTools::Watch do
|
|
133
128
|
end
|
134
129
|
|
135
130
|
context "when a message is seen with subject droplet.exited" do
|
131
|
+
let(:subject) { "droplet.exited" }
|
132
|
+
|
136
133
|
let(:payload) { <<PAYLOAD }
|
137
134
|
{
|
138
135
|
"exit_description": "",
|
@@ -147,10 +144,6 @@ describe CFTools::Watch do
|
|
147
144
|
PAYLOAD
|
148
145
|
|
149
146
|
it "pretty-prints the message body" do
|
150
|
-
stub(NATS).subscribe(">") do |_, block|
|
151
|
-
block.call(payload, nil, "droplet.exited")
|
152
|
-
end
|
153
|
-
|
154
147
|
cf %W[watch]
|
155
148
|
|
156
149
|
expect(output).to say("app: myapp, reason: STOPPED, index: 0")
|
@@ -158,6 +151,8 @@ PAYLOAD
|
|
158
151
|
end
|
159
152
|
|
160
153
|
context "when a message is seen with subject dea.heartbeat" do
|
154
|
+
let(:subject) { "dea.heartbeat" }
|
155
|
+
|
161
156
|
let(:payload) { <<PAYLOAD }
|
162
157
|
{
|
163
158
|
"prod": false,
|
@@ -196,10 +191,6 @@ PAYLOAD
|
|
196
191
|
|
197
192
|
context "and an application is given" do
|
198
193
|
it "prints only the application's entry" do
|
199
|
-
stub(NATS).subscribe(">") do |_, block|
|
200
|
-
block.call(payload, nil, "dea.heartbeat")
|
201
|
-
end
|
202
|
-
|
203
194
|
cf %W[watch myapp]
|
204
195
|
|
205
196
|
expect(output).to say("dea: 1, running: 1, crashed: 1")
|
@@ -208,24 +199,13 @@ PAYLOAD
|
|
208
199
|
end
|
209
200
|
|
210
201
|
context "when a message is seen with subject dea.advertise" do
|
211
|
-
|
212
|
-
it "prints nothing" do
|
213
|
-
stub(NATS).subscribe(">") do |_, block|
|
214
|
-
block.call("whatever-#{app.guid}", nil, "dea.advertise")
|
215
|
-
end
|
216
|
-
|
217
|
-
cf %W[watch myapp]
|
218
|
-
|
219
|
-
expect(output).to_not say("dea.advertise")
|
220
|
-
end
|
221
|
-
end
|
202
|
+
let(:subject) { "dea.advertise" }
|
222
203
|
|
223
|
-
|
224
|
-
let(:other_app) { fake :app, :name => "otherapp", :guid => "otherguid" }
|
204
|
+
let(:other_app) { fake :app, :name => "otherapp", :guid => "otherguid" }
|
225
205
|
|
226
|
-
|
206
|
+
let(:client) { fake_client :apps => [app, other_app] }
|
227
207
|
|
228
|
-
|
208
|
+
let(:payload) { <<PAYLOAD }
|
229
209
|
{
|
230
210
|
"app_id_to_count": {
|
231
211
|
"#{app.guid}": 1,
|
@@ -240,24 +220,50 @@ PAYLOAD
|
|
240
220
|
}
|
241
221
|
PAYLOAD
|
242
222
|
|
223
|
+
context "and app is given" do
|
224
|
+
it "prints nothing" do
|
225
|
+
cf %W[watch myapp]
|
226
|
+
|
227
|
+
expect(output).to_not say("dea.advertise")
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
context "and app is NOT given" do
|
243
232
|
before do
|
244
|
-
stub(
|
245
|
-
stub(
|
233
|
+
app.stub(:exists? => true)
|
234
|
+
other_app.stub(:exists? => false)
|
246
235
|
end
|
247
236
|
|
248
237
|
it "prints the dea, its stacks, available memory, and apps" do
|
249
|
-
stub(NATS).subscribe(">") do |_, block|
|
250
|
-
block.call(payload, nil, "dea.advertise")
|
251
|
-
end
|
252
|
-
|
253
238
|
cf %W[watch]
|
254
239
|
|
255
240
|
expect(output).to say("dea: 1, stacks: lucid64, available mem: 29G, apps: 1 x myapp, 2 x unknown")
|
256
241
|
end
|
242
|
+
|
243
|
+
context "and it does not include app counts" do
|
244
|
+
let(:payload) { <<PAYLOAD }
|
245
|
+
{
|
246
|
+
"available_memory": 30000,
|
247
|
+
"stacks": [
|
248
|
+
"lucid64"
|
249
|
+
],
|
250
|
+
"prod": false,
|
251
|
+
"id": "1-f158dcd026d1589853846a3859faf0ea"
|
252
|
+
}
|
253
|
+
PAYLOAD
|
254
|
+
|
255
|
+
it "prints 'none' for the app listing" do
|
256
|
+
cf %W[watch]
|
257
|
+
|
258
|
+
expect(output).to say("dea: 1, stacks: lucid64, available mem: 29G, apps: none")
|
259
|
+
end
|
260
|
+
end
|
257
261
|
end
|
258
262
|
end
|
259
263
|
|
260
264
|
context "when a message is seen with subject staging.advertise" do
|
265
|
+
let(:subject) { "staging.advertise" }
|
266
|
+
|
261
267
|
let(:payload) { <<PAYLOAD }
|
262
268
|
{
|
263
269
|
"available_memory": 27264,
|
@@ -269,10 +275,6 @@ PAYLOAD
|
|
269
275
|
PAYLOAD
|
270
276
|
|
271
277
|
it "prints the dea, its stacks, and its available memory" do
|
272
|
-
stub(NATS).subscribe(">") do |_, block|
|
273
|
-
block.call(payload, nil, "staging.advertise")
|
274
|
-
end
|
275
|
-
|
276
278
|
cf %W[watch]
|
277
279
|
|
278
280
|
expect(output).to say("dea: 1, stacks: lucid64, available mem: 27G")
|
@@ -280,6 +282,8 @@ PAYLOAD
|
|
280
282
|
end
|
281
283
|
|
282
284
|
context "when a message is seen with subject router.start" do
|
285
|
+
let(:subject) { "router.start" }
|
286
|
+
|
283
287
|
let(:payload) { <<PAYLOAD }
|
284
288
|
{
|
285
289
|
"hosts": [
|
@@ -290,10 +294,6 @@ PAYLOAD
|
|
290
294
|
PAYLOAD
|
291
295
|
|
292
296
|
it "prints the hosts" do
|
293
|
-
stub(NATS).subscribe(">") do |_, block|
|
294
|
-
block.call(payload, nil, "router.start")
|
295
|
-
end
|
296
|
-
|
297
297
|
cf %W[watch]
|
298
298
|
|
299
299
|
expect(output).to say("hosts: 10.10.16.15")
|
@@ -301,6 +301,8 @@ PAYLOAD
|
|
301
301
|
end
|
302
302
|
|
303
303
|
context "when a message is seen with subject router.register" do
|
304
|
+
let(:subject) { "router.register" }
|
305
|
+
|
304
306
|
context "when there's an associated DEA" do
|
305
307
|
let(:payload) { <<PAYLOAD }
|
306
308
|
{
|
@@ -318,10 +320,6 @@ PAYLOAD
|
|
318
320
|
PAYLOAD
|
319
321
|
|
320
322
|
it "prints the uris, host, and port" do
|
321
|
-
stub(NATS).subscribe(">") do |_, block|
|
322
|
-
block.call(payload, nil, "router.register")
|
323
|
-
end
|
324
|
-
|
325
323
|
cf %W[watch]
|
326
324
|
|
327
325
|
expect(output).to say("app: myapp, dea: 1, uris: my-app.com, my-app-2.com, host: 192.0.43.10, port: 61111")
|
@@ -342,10 +340,6 @@ PAYLOAD
|
|
342
340
|
}
|
343
341
|
PAYLOAD
|
344
342
|
it "prints the uris, host, and port" do
|
345
|
-
stub(NATS).subscribe(">") do |_, block|
|
346
|
-
block.call(payload, nil, "router.register")
|
347
|
-
end
|
348
|
-
|
349
343
|
cf %W[watch]
|
350
344
|
|
351
345
|
expect(output).to say("uris: my-app.com, my-app-2.com, host: 192.0.43.10, port: 61111")
|
@@ -354,6 +348,8 @@ PAYLOAD
|
|
354
348
|
end
|
355
349
|
|
356
350
|
context "when a message is seen with subject router.unregister" do
|
351
|
+
let(:subject) { "router.unregister" }
|
352
|
+
|
357
353
|
context "when there's an associated DEA" do
|
358
354
|
let(:payload) { <<PAYLOAD }
|
359
355
|
{
|
@@ -370,10 +366,6 @@ PAYLOAD
|
|
370
366
|
PAYLOAD
|
371
367
|
|
372
368
|
it "prints the dea, uris, host, and port" do
|
373
|
-
stub(NATS).subscribe(">") do |_, block|
|
374
|
-
block.call(payload, nil, "router.unregister")
|
375
|
-
end
|
376
|
-
|
377
369
|
cf %W[watch]
|
378
370
|
|
379
371
|
expect(output).to say("app: myapp, dea: 5, uris: my-app.com, host: 192.0.43.10, port: 61111")
|
@@ -394,10 +386,6 @@ PAYLOAD
|
|
394
386
|
PAYLOAD
|
395
387
|
|
396
388
|
it "prints the uris, host, and port" do
|
397
|
-
stub(NATS).subscribe(">") do |_, block|
|
398
|
-
block.call(payload, nil, "router.unregister")
|
399
|
-
end
|
400
|
-
|
401
389
|
cf %W[watch]
|
402
390
|
|
403
391
|
expect(output).to say("uris: my-app.com, host: 192.0.43.10, port: 61111")
|
@@ -406,6 +394,8 @@ PAYLOAD
|
|
406
394
|
end
|
407
395
|
|
408
396
|
context "when a message is seen with subject dea.*.start" do
|
397
|
+
let(:subject) { "dea.42-deadbeef.start" }
|
398
|
+
|
409
399
|
let(:payload) { <<PAYLOAD }
|
410
400
|
{
|
411
401
|
"index": 2,
|
@@ -433,20 +423,12 @@ PAYLOAD
|
|
433
423
|
PAYLOAD
|
434
424
|
|
435
425
|
it "filters the uuid from the subject" do
|
436
|
-
stub(NATS).subscribe(">") do |_, block|
|
437
|
-
block.call(payload, nil, "dea.42-deadbeef.start")
|
438
|
-
end
|
439
|
-
|
440
426
|
cf %W[watch]
|
441
427
|
|
442
428
|
expect(output).to say("dea.42.start")
|
443
429
|
end
|
444
430
|
|
445
431
|
it "prints the uris, host, and port" do
|
446
|
-
stub(NATS).subscribe(">") do |_, block|
|
447
|
-
block.call(payload, nil, "dea.42-deadbeef.start")
|
448
|
-
end
|
449
|
-
|
450
432
|
cf %W[watch]
|
451
433
|
|
452
434
|
expect(output).to say("app: myapp, dea: 42, index: 2, uris: myapp.com")
|
@@ -454,6 +436,8 @@ PAYLOAD
|
|
454
436
|
end
|
455
437
|
|
456
438
|
context "when a message is seen with subject droplet.updated" do
|
439
|
+
let(:subject) { "droplet.updated" }
|
440
|
+
|
457
441
|
let(:payload) { <<PAYLOAD }
|
458
442
|
{
|
459
443
|
"cc_partition": "default",
|
@@ -463,10 +447,6 @@ PAYLOAD
|
|
463
447
|
PAYLOAD
|
464
448
|
|
465
449
|
it "prints the app that was updated" do
|
466
|
-
stub(NATS).subscribe(">") do |_, block|
|
467
|
-
block.call(payload, nil, "droplet.updated")
|
468
|
-
end
|
469
|
-
|
470
450
|
cf %W[watch]
|
471
451
|
|
472
452
|
expect(output).to say("app: myapp")
|
@@ -475,6 +455,8 @@ PAYLOAD
|
|
475
455
|
end
|
476
456
|
|
477
457
|
context "when a message is seen with subject dea.stop" do
|
458
|
+
let(:subject) { "dea.stop" }
|
459
|
+
|
478
460
|
context "and it's stopping particular indices" do
|
479
461
|
let(:payload) { <<PAYLOAD }
|
480
462
|
{
|
@@ -488,10 +470,6 @@ PAYLOAD
|
|
488
470
|
PAYLOAD
|
489
471
|
|
490
472
|
it "prints that it's scaling down, and the affected indices" do
|
491
|
-
stub(NATS).subscribe(">") do |_, block|
|
492
|
-
block.call(payload, nil, "dea.stop")
|
493
|
-
end
|
494
|
-
|
495
473
|
cf %W[watch]
|
496
474
|
|
497
475
|
expect(output).to say("app: myapp, scaling down indices: 1, 2")
|
@@ -510,10 +488,6 @@ PAYLOAD
|
|
510
488
|
}
|
511
489
|
PAYLOAD
|
512
490
|
it "prints that it's killing extra instances" do
|
513
|
-
stub(NATS).subscribe(">") do |_, block|
|
514
|
-
block.call(payload, nil, "dea.stop")
|
515
|
-
end
|
516
|
-
|
517
491
|
cf %W[watch]
|
518
492
|
|
519
493
|
expect(output).to say("app: myapp, killing extra instances: a, b, c")
|
@@ -528,10 +502,6 @@ PAYLOAD
|
|
528
502
|
PAYLOAD
|
529
503
|
|
530
504
|
it "prints that it's killing extra instances" do
|
531
|
-
stub(NATS).subscribe(">") do |_, block|
|
532
|
-
block.call(payload, nil, "dea.stop")
|
533
|
-
end
|
534
|
-
|
535
505
|
cf %W[watch]
|
536
506
|
|
537
507
|
expect(output).to say("app: myapp, stopping application")
|
@@ -540,6 +510,8 @@ PAYLOAD
|
|
540
510
|
end
|
541
511
|
|
542
512
|
context "when a message is seen with subject dea.update" do
|
513
|
+
let(:subject) { "dea.update" }
|
514
|
+
|
543
515
|
let(:payload) { <<PAYLOAD }
|
544
516
|
{
|
545
517
|
"uris": [
|
@@ -551,10 +523,6 @@ PAYLOAD
|
|
551
523
|
PAYLOAD
|
552
524
|
|
553
525
|
it "prints the index being stopped" do
|
554
|
-
stub(NATS).subscribe(">") do |_, block|
|
555
|
-
block.call(payload, nil, "dea.update")
|
556
|
-
end
|
557
|
-
|
558
526
|
cf %W[watch]
|
559
527
|
|
560
528
|
expect(output).to say("app: myapp, uris: myapp.com, myotherroute.com")
|
@@ -562,6 +530,8 @@ PAYLOAD
|
|
562
530
|
end
|
563
531
|
|
564
532
|
context "when a message is seen with subject dea.find.droplet" do
|
533
|
+
let(:subject) { "dea.find.droplet" }
|
534
|
+
|
565
535
|
let(:payload) { <<PAYLOAD }
|
566
536
|
{
|
567
537
|
"version": "878318bf-64a0-4055-b79b-46871292ceb8",
|
@@ -594,22 +564,19 @@ PAYLOAD
|
|
594
564
|
PAYLOAD
|
595
565
|
|
596
566
|
it "prints the states being queried" do
|
597
|
-
stub(NATS).subscribe(">") do |_, block|
|
598
|
-
block.call(payload, nil, "dea.find.droplet")
|
599
|
-
end
|
600
|
-
|
601
567
|
cf %W[watch]
|
602
568
|
|
603
569
|
expect(output).to say("app: myapp, querying states: starting, running")
|
604
570
|
end
|
605
571
|
|
606
572
|
context "and we see the response" do
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
573
|
+
let(:messages) do
|
574
|
+
[ [payload, "some-inbox", "dea.find.droplet"],
|
575
|
+
[response_payload, nil, "some-inbox"]
|
576
|
+
]
|
577
|
+
end
|
612
578
|
|
579
|
+
it "pretty-prints the response" do
|
613
580
|
cf %W[watch]
|
614
581
|
|
615
582
|
expect(output).to say("reply to dea.find.droplet (1)\tdea: 1, index: 0, state: running, since: 2013-05-22 15:45:04 -0700")
|
@@ -618,6 +585,8 @@ PAYLOAD
|
|
618
585
|
end
|
619
586
|
|
620
587
|
context "when a message is seen with subject healthmanager.status" do
|
588
|
+
let(:subject) { "healthmanager.status" }
|
589
|
+
|
621
590
|
let(:payload) { <<PAYLOAD }
|
622
591
|
{
|
623
592
|
"version": "50512eed-674e-4991-9ada-a583633c0cd4",
|
@@ -636,22 +605,19 @@ PAYLOAD
|
|
636
605
|
PAYLOAD
|
637
606
|
|
638
607
|
it "prints the states being queried" do
|
639
|
-
stub(NATS).subscribe(">") do |_, block|
|
640
|
-
block.call(payload, nil, "healthmanager.status")
|
641
|
-
end
|
642
|
-
|
643
608
|
cf %W[watch]
|
644
609
|
|
645
610
|
expect(output).to say("app: myapp, querying states: flapping")
|
646
611
|
end
|
647
612
|
|
648
613
|
context "and we see the response" do
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
614
|
+
let(:messages) do
|
615
|
+
[ [payload, "some-inbox", "healthmanager.status"],
|
616
|
+
[response_payload, nil, "some-inbox"]
|
617
|
+
]
|
618
|
+
end
|
654
619
|
|
620
|
+
it "pretty-prints the response" do
|
655
621
|
cf %W[watch]
|
656
622
|
|
657
623
|
expect(output).to say("reply to healthmanager.status (1)\tindices: 1, 2")
|
@@ -660,7 +626,10 @@ PAYLOAD
|
|
660
626
|
end
|
661
627
|
|
662
628
|
context "when a message is seen with subject healthmanager.health" do
|
629
|
+
let(:subject) { "healthmanager.health" }
|
630
|
+
|
663
631
|
let(:other_app) { fake :app, :name => "otherapp" }
|
632
|
+
|
664
633
|
let(:client) { fake_client :apps => [app, other_app] }
|
665
634
|
|
666
635
|
let(:payload) { <<PAYLOAD }
|
@@ -694,26 +663,23 @@ PAYLOAD
|
|
694
663
|
}
|
695
664
|
PAYLOAD
|
696
665
|
|
697
|
-
before { stub(
|
666
|
+
before { other_app.stub(:exists? => true) }
|
698
667
|
|
699
668
|
it "prints the apps whose health being queried" do
|
700
|
-
stub(NATS).subscribe(">") do |_, block|
|
701
|
-
block.call(payload, nil, "healthmanager.health")
|
702
|
-
end
|
703
|
-
|
704
669
|
cf %W[watch]
|
705
670
|
|
706
671
|
expect(output).to say("querying health for: myapp, otherapp")
|
707
672
|
end
|
708
673
|
|
709
674
|
context "and we see the response" do
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
675
|
+
let(:messages) do
|
676
|
+
[ [payload, "some-inbox", "healthmanager.health"],
|
677
|
+
[response_payload, nil, "some-inbox"],
|
678
|
+
[other_response_payload, nil, "some-inbox"]
|
679
|
+
]
|
680
|
+
end
|
716
681
|
|
682
|
+
it "pretty-prints the response" do
|
717
683
|
cf %W[watch]
|
718
684
|
|
719
685
|
expect(output).to say("reply to healthmanager.health (1)\tapp: myapp, healthy: 2")
|
@@ -723,7 +689,10 @@ PAYLOAD
|
|
723
689
|
end
|
724
690
|
|
725
691
|
context "when a message is seen with subject dea.shutdown" do
|
692
|
+
let(:subject) { "dea.shutdown" }
|
693
|
+
|
726
694
|
let(:other_app) { fake :app, :name => "otherapp" }
|
695
|
+
|
727
696
|
let(:client) { fake_client :apps => [app, other_app] }
|
728
697
|
|
729
698
|
let(:payload) { <<PAYLOAD }
|
@@ -740,15 +709,11 @@ PAYLOAD
|
|
740
709
|
|
741
710
|
context "and the apps still exist" do
|
742
711
|
before do
|
743
|
-
stub(
|
744
|
-
stub(
|
712
|
+
app.stub(:exists? => true)
|
713
|
+
other_app.stub(:exists? => true)
|
745
714
|
end
|
746
715
|
|
747
716
|
it "prints the DEA and affected applications" do
|
748
|
-
stub(NATS).subscribe(">") do |_, block|
|
749
|
-
block.call(payload, nil, "dea.shutdown")
|
750
|
-
end
|
751
|
-
|
752
717
|
cf %W[watch]
|
753
718
|
|
754
719
|
expect(output).to say("dea: 0, apps: 1 x myapp, 2 x otherapp")
|
@@ -757,15 +722,11 @@ PAYLOAD
|
|
757
722
|
|
758
723
|
context "and an app no longer exists" do
|
759
724
|
before do
|
760
|
-
stub(
|
761
|
-
stub(
|
725
|
+
app.stub(:exists? => true)
|
726
|
+
other_app.stub(:exists? => false)
|
762
727
|
end
|
763
728
|
|
764
729
|
it "prints the DEA and affected applications" do
|
765
|
-
stub(NATS).subscribe(">") do |_, block|
|
766
|
-
block.call(payload, nil, "dea.shutdown")
|
767
|
-
end
|
768
|
-
|
769
730
|
cf %W[watch]
|
770
731
|
|
771
732
|
expect(output).to say(
|
@@ -775,6 +736,8 @@ PAYLOAD
|
|
775
736
|
end
|
776
737
|
|
777
738
|
context "when a message is seen with subject cloudcontrollers.hm.requests.*" do
|
739
|
+
let(:subject) { "cloudcontrollers.hm.requests.default" }
|
740
|
+
|
778
741
|
let(:last_updated) { Time.now }
|
779
742
|
|
780
743
|
context "and it is a STOP operation" do
|
@@ -791,20 +754,12 @@ PAYLOAD
|
|
791
754
|
PAYLOAD
|
792
755
|
|
793
756
|
it "trims the subject" do
|
794
|
-
stub(NATS).subscribe(">") do |_, block|
|
795
|
-
block.call(payload, nil, "cloudcontrollers.hm.requests.default")
|
796
|
-
end
|
797
|
-
|
798
757
|
cf %W[watch]
|
799
758
|
|
800
759
|
expect(output).to say(/\s+hm\.request\s+/)
|
801
760
|
end
|
802
761
|
|
803
762
|
it "prints the operation, last updated timestamp, and instances" do
|
804
|
-
stub(NATS).subscribe(">") do |_, block|
|
805
|
-
block.call(payload, nil, "cloudcontrollers.hm.requests.default")
|
806
|
-
end
|
807
|
-
|
808
763
|
cf %W[watch]
|
809
764
|
|
810
765
|
expect(output).to say(
|
@@ -812,85 +767,79 @@ PAYLOAD
|
|
812
767
|
end
|
813
768
|
end
|
814
769
|
|
815
|
-
context "
|
770
|
+
context "and it is a START operation" do
|
816
771
|
let(:payload) { <<PAYLOAD }
|
817
772
|
{
|
818
|
-
"
|
819
|
-
|
773
|
+
"indices": [
|
774
|
+
1,
|
775
|
+
3
|
820
776
|
],
|
821
|
-
"
|
822
|
-
"
|
823
|
-
"
|
824
|
-
"
|
825
|
-
"available_capacity": 100
|
777
|
+
"version": "some-version",
|
778
|
+
"last_updated": #{last_updated.to_i},
|
779
|
+
"op": "START",
|
780
|
+
"droplet": "#{app.guid}"
|
826
781
|
}
|
827
782
|
PAYLOAD
|
828
783
|
|
829
|
-
it "prints the
|
830
|
-
stub(NATS).subscribe(">") do |_, block|
|
831
|
-
block.call(payload, nil, "QaaS.announce")
|
832
|
-
end
|
833
|
-
|
784
|
+
it "prints the operation, last updated timestamp, and instances" do
|
834
785
|
cf %W[watch]
|
835
786
|
|
836
|
-
expect(output).to say(
|
787
|
+
expect(output).to say(
|
788
|
+
"app: myapp, operation: start, app last updated: #{last_updated}, indices: 1, 3")
|
837
789
|
end
|
838
790
|
end
|
791
|
+
end
|
839
792
|
|
840
|
-
|
841
|
-
|
793
|
+
context "when a message is seen with subject *.announce" do
|
794
|
+
let(:subject) { "QaaS.announce" }
|
795
|
+
|
796
|
+
let(:payload) { <<PAYLOAD }
|
842
797
|
{
|
843
|
-
|
844
|
-
"
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
"type": "QaaS-Provisioner"
|
798
|
+
"supported_versions": [
|
799
|
+
"n/a"
|
800
|
+
],
|
801
|
+
"plan": "1dolla",
|
802
|
+
"id": "quarters_as_a_service",
|
803
|
+
"capacity_unit": 1,
|
804
|
+
"max_capacity": 100,
|
805
|
+
"available_capacity": 100
|
852
806
|
}
|
853
807
|
PAYLOAD
|
854
808
|
|
855
|
-
|
856
|
-
|
857
|
-
block.call(payload, nil, "vcap.component.announce")
|
858
|
-
end
|
859
|
-
|
860
|
-
cf %W[watch]
|
809
|
+
it "prints the dea, its stacks, and its available memory" do
|
810
|
+
cf %W[watch]
|
861
811
|
|
862
|
-
|
863
|
-
end
|
812
|
+
expect(output).to say("id: quarters_as_a_service, plan: 1dolla, supported versions: n/a, capacity: (available: 100, max: 100, unit: 1)")
|
864
813
|
end
|
814
|
+
end
|
865
815
|
|
866
|
-
|
867
|
-
|
816
|
+
context "when a message is seen with subject vcap.component.announce" do
|
817
|
+
let(:subject) { "vcap.component.announce" }
|
818
|
+
|
819
|
+
let(:payload) { <<PAYLOAD }
|
868
820
|
{
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
821
|
+
"start": "2013-05-24 16:45:01 +0000",
|
822
|
+
"credentials": [
|
823
|
+
"cb68328a26f68416eabbad702c542000",
|
824
|
+
"0e6b5ec19df10c7ba2e7f36cdf33474e"
|
825
|
+
],
|
826
|
+
"host": "10.10.32.10:39195",
|
827
|
+
"uuid": "some-uuid",
|
828
|
+
"index": 0,
|
829
|
+
"type": "QaaS-Provisioner"
|
877
830
|
}
|
878
831
|
PAYLOAD
|
879
832
|
|
880
|
-
|
881
|
-
|
882
|
-
block.call(payload, nil, "cloudcontrollers.hm.requests.default")
|
883
|
-
end
|
884
|
-
|
885
|
-
cf %W[watch]
|
833
|
+
it "prints the type, index, host, start time" do
|
834
|
+
cf %W[watch]
|
886
835
|
|
887
|
-
|
888
|
-
"app: myapp, operation: start, app last updated: #{last_updated}, indices: 1, 3")
|
889
|
-
end
|
836
|
+
expect(output).to say("type: QaaS-Provisioner, index: 0, uuid: some-uuid, start time: 2013-05-24 16:45:01 +0000")
|
890
837
|
end
|
891
838
|
end
|
892
839
|
|
893
840
|
context "when a message is seen with subject vcap.component.discover" do
|
841
|
+
let(:subject) { "vcap.component.discover" }
|
842
|
+
|
894
843
|
let(:payload) { "" }
|
895
844
|
|
896
845
|
let(:response_payload) { <<PAYLOAD }
|
@@ -898,8 +847,8 @@ PAYLOAD
|
|
898
847
|
"uptime": "0d:23h:51m:21s",
|
899
848
|
"start": "2013-05-24 17:58:08 +0000",
|
900
849
|
"credentials": [
|
901
|
-
"
|
902
|
-
"
|
850
|
+
"user",
|
851
|
+
"pass"
|
903
852
|
],
|
904
853
|
"host": "1.2.3.4:8080",
|
905
854
|
"uuid": "4-deadbeef",
|
@@ -909,25 +858,22 @@ PAYLOAD
|
|
909
858
|
PAYLOAD
|
910
859
|
|
911
860
|
it "prints the states being queried" do
|
912
|
-
stub(NATS).subscribe(">") do |_, block|
|
913
|
-
block.call(payload, nil, "vcap.component.discover")
|
914
|
-
end
|
915
|
-
|
916
861
|
cf %W[watch]
|
917
862
|
|
918
863
|
expect(output).to say("vcap.component.discover")
|
919
864
|
end
|
920
865
|
|
921
866
|
context "and we see the response" do
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
867
|
+
let(:messages) do
|
868
|
+
[ [payload, "some-inbox", "vcap.component.discover"],
|
869
|
+
[response_payload, nil, "some-inbox"]
|
870
|
+
]
|
871
|
+
end
|
927
872
|
|
873
|
+
it "pretty-prints the response" do
|
928
874
|
cf %W[watch]
|
929
875
|
|
930
|
-
expect(output).to say("reply to vcap.component.discover (1)\ttype: DEA, index: 4,
|
876
|
+
expect(output).to say("reply to vcap.component.discover (1)\ttype: DEA, index: 4, uri: user:pass@1.2.3.4:8080, uptime: 0d:23h:51m:21s")
|
931
877
|
end
|
932
878
|
|
933
879
|
context "and there's no uptime" do
|
@@ -946,11 +892,6 @@ PAYLOAD
|
|
946
892
|
PAYLOAD
|
947
893
|
|
948
894
|
it "does not include it in the message" do
|
949
|
-
stub(NATS).subscribe(">") do |_, block|
|
950
|
-
block.call(payload, "some-inbox", "vcap.component.discover")
|
951
|
-
block.call(response_payload, nil, "some-inbox")
|
952
|
-
end
|
953
|
-
|
954
895
|
cf %W[watch]
|
955
896
|
|
956
897
|
expect(output).to say("reply to vcap.component.discover (1)\ttype: login, index: 1, host: 1.2.3.4:8080")
|