tools-cf-plugin 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tools-cf-plugin/plugin.rb +3 -1
- data/lib/tools-cf-plugin/tunnel/base.rb +133 -0
- data/lib/tools-cf-plugin/tunnel/log_entry.rb +46 -0
- data/lib/tools-cf-plugin/tunnel/multi_line_stream.rb +100 -0
- data/lib/tools-cf-plugin/tunnel/stream_location.rb +37 -0
- data/lib/tools-cf-plugin/tunnel/watch.rb +52 -0
- data/lib/tools-cf-plugin/tunnel/watch_logs.rb +122 -0
- data/lib/tools-cf-plugin/version.rb +1 -1
- data/lib/tools-cf-plugin/watch.rb +53 -17
- data/spec/tunnel/base_spec.rb +180 -0
- data/spec/tunnel/log_entry_spec.rb +109 -0
- data/spec/tunnel/multi_line_stream_spec.rb +80 -0
- data/spec/tunnel/stream_location_spec.rb +59 -0
- data/spec/tunnel/watch_logs_spec.rb +117 -0
- data/spec/watch_spec.rb +114 -24
- metadata +62 -8
data/spec/watch_spec.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe CFTools::Watch do
|
4
|
-
let(:fake_home_dir) { "#{SPEC_ROOT}/fixtures/fake_home_dir" }
|
5
|
-
|
6
|
-
stub_home_dir_with { fake_home_dir }
|
7
|
-
|
8
4
|
let(:app) { fake :app, :name => "myapp", :guid => "myappguid" }
|
9
5
|
|
10
6
|
let(:client) { fake_client :apps => [app] }
|
@@ -49,9 +45,9 @@ describe CFTools::Watch do
|
|
49
45
|
end
|
50
46
|
|
51
47
|
context "when no NATS server info is specified" do
|
52
|
-
it "connects on nats:nats@
|
48
|
+
it "connects on nats:nats@127.0.0.1:4222" do
|
53
49
|
mock(NATS).start(hash_including(
|
54
|
-
:uri => "nats://nats:nats@
|
50
|
+
:uri => "nats://nats:nats@127.0.0.1:4222"))
|
55
51
|
|
56
52
|
cf %W[watch]
|
57
53
|
end
|
@@ -92,8 +88,8 @@ describe CFTools::Watch do
|
|
92
88
|
|
93
89
|
cf %W[watch]
|
94
90
|
|
95
|
-
expect(output).to say(
|
96
|
-
expect(output).to say(
|
91
|
+
expect(output).to say(/some\.subject \(1\)\s*foo/)
|
92
|
+
expect(output).to say(/`- reply to some\.subject \(1\)\s+some-response/)
|
97
93
|
end
|
98
94
|
end
|
99
95
|
|
@@ -308,16 +304,16 @@ PAYLOAD
|
|
308
304
|
context "when there's an associated DEA" do
|
309
305
|
let(:payload) { <<PAYLOAD }
|
310
306
|
{
|
311
|
-
"private_instance_id": "e4a5ee2330c81fd7611eba7dbedbb499a00ae1b79f97f40a3603c8bff6fbcc6f",
|
312
|
-
"tags": {},
|
313
|
-
"port": 61111,
|
314
|
-
"host": "192.0.43.10",
|
315
|
-
"uris": [
|
316
|
-
|
317
|
-
|
318
|
-
],
|
319
|
-
"app": "#{app.guid}",
|
320
|
-
"dea": "1-4b293b726167fbc895af5a7927c0973a"
|
307
|
+
"private_instance_id": "e4a5ee2330c81fd7611eba7dbedbb499a00ae1b79f97f40a3603c8bff6fbcc6f",
|
308
|
+
"tags": {},
|
309
|
+
"port": 61111,
|
310
|
+
"host": "192.0.43.10",
|
311
|
+
"uris": [
|
312
|
+
"my-app.com",
|
313
|
+
"my-app-2.com"
|
314
|
+
],
|
315
|
+
"app": "#{app.guid}",
|
316
|
+
"dea": "1-4b293b726167fbc895af5a7927c0973a"
|
321
317
|
}
|
322
318
|
PAYLOAD
|
323
319
|
|
@@ -466,14 +462,14 @@ PAYLOAD
|
|
466
462
|
|
467
463
|
PAYLOAD
|
468
464
|
|
469
|
-
it "prints
|
465
|
+
it "prints the app that was updated" do
|
470
466
|
stub(NATS).subscribe(">") do |_, block|
|
471
467
|
block.call(payload, nil, "droplet.updated")
|
472
468
|
end
|
473
469
|
|
474
470
|
cf %W[watch]
|
475
471
|
|
476
|
-
expect(output).to say("
|
472
|
+
expect(output).to say("app: myapp")
|
477
473
|
expect(output).to_not say("cc_partition")
|
478
474
|
end
|
479
475
|
end
|
@@ -755,8 +751,7 @@ PAYLOAD
|
|
755
751
|
|
756
752
|
cf %W[watch]
|
757
753
|
|
758
|
-
expect(output).to say(
|
759
|
-
"dea: 0, apps: 1 x myapp (#{app.guid}), 2 x otherapp (#{other_app.guid})")
|
754
|
+
expect(output).to say("dea: 0, apps: 1 x myapp, 2 x otherapp")
|
760
755
|
end
|
761
756
|
end
|
762
757
|
|
@@ -774,7 +769,7 @@ PAYLOAD
|
|
774
769
|
cf %W[watch]
|
775
770
|
|
776
771
|
expect(output).to say(
|
777
|
-
"dea: 0, apps: 1 x myapp
|
772
|
+
"dea: 0, apps: 1 x myapp, 2 x unknown (#{other_app.guid})")
|
778
773
|
end
|
779
774
|
end
|
780
775
|
end
|
@@ -802,7 +797,7 @@ PAYLOAD
|
|
802
797
|
|
803
798
|
cf %W[watch]
|
804
799
|
|
805
|
-
expect(output).to say(
|
800
|
+
expect(output).to say(/\s+hm\.request\s+/)
|
806
801
|
end
|
807
802
|
|
808
803
|
it "prints the operation, last updated timestamp, and instances" do
|
@@ -842,6 +837,32 @@ PAYLOAD
|
|
842
837
|
end
|
843
838
|
end
|
844
839
|
|
840
|
+
context "when a message is seen with subject vcap.component.announce" do
|
841
|
+
let(:payload) { <<PAYLOAD }
|
842
|
+
{
|
843
|
+
"start": "2013-05-24 16:45:01 +0000",
|
844
|
+
"credentials": [
|
845
|
+
"cb68328a26f68416eabbad702c542000",
|
846
|
+
"0e6b5ec19df10c7ba2e7f36cdf33474e"
|
847
|
+
],
|
848
|
+
"host": "10.10.32.10:39195",
|
849
|
+
"uuid": "some-uuid",
|
850
|
+
"index": 0,
|
851
|
+
"type": "QaaS-Provisioner"
|
852
|
+
}
|
853
|
+
PAYLOAD
|
854
|
+
|
855
|
+
it "prints the type, index, host, start time" do
|
856
|
+
stub(NATS).subscribe(">") do |_, block|
|
857
|
+
block.call(payload, nil, "vcap.component.announce")
|
858
|
+
end
|
859
|
+
|
860
|
+
cf %W[watch]
|
861
|
+
|
862
|
+
expect(output).to say("type: QaaS-Provisioner, index: 0, uuid: some-uuid, start time: 2013-05-24 16:45:01 +0000")
|
863
|
+
end
|
864
|
+
end
|
865
|
+
|
845
866
|
context "and it is a START operation" do
|
846
867
|
let(:payload) { <<PAYLOAD }
|
847
868
|
{
|
@@ -868,4 +889,73 @@ PAYLOAD
|
|
868
889
|
end
|
869
890
|
end
|
870
891
|
end
|
892
|
+
|
893
|
+
context "when a message is seen with subject vcap.component.discover" do
|
894
|
+
let(:payload) { "" }
|
895
|
+
|
896
|
+
let(:response_payload) { <<PAYLOAD }
|
897
|
+
{
|
898
|
+
"uptime": "0d:23h:51m:21s",
|
899
|
+
"start": "2013-05-24 17:58:08 +0000",
|
900
|
+
"credentials": [
|
901
|
+
"d34f205a31232eef040d1e39ebdd631a",
|
902
|
+
"701e1a68a811a1ac8c137a70db08c1a8"
|
903
|
+
],
|
904
|
+
"host": "1.2.3.4:8080",
|
905
|
+
"uuid": "4-deadbeef",
|
906
|
+
"index": 4,
|
907
|
+
"type": "DEA"
|
908
|
+
}
|
909
|
+
PAYLOAD
|
910
|
+
|
911
|
+
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
|
+
cf %W[watch]
|
917
|
+
|
918
|
+
expect(output).to say("vcap.component.discover")
|
919
|
+
end
|
920
|
+
|
921
|
+
context "and we see the response" do
|
922
|
+
it "pretty-prints the response" do
|
923
|
+
stub(NATS).subscribe(">") do |_, block|
|
924
|
+
block.call(payload, "some-inbox", "vcap.component.discover")
|
925
|
+
block.call(response_payload, nil, "some-inbox")
|
926
|
+
end
|
927
|
+
|
928
|
+
cf %W[watch]
|
929
|
+
|
930
|
+
expect(output).to say("reply to vcap.component.discover (1)\ttype: DEA, index: 4, host: 1.2.3.4:8080, uptime: 0d:23h:51m:21s")
|
931
|
+
end
|
932
|
+
|
933
|
+
context "and there's no uptime" do
|
934
|
+
let(:response_payload) { <<PAYLOAD }
|
935
|
+
{
|
936
|
+
"start": "2013-05-24 17:58:08 +0000",
|
937
|
+
"credentials": [
|
938
|
+
"d34f205a31232eef040d1e39ebdd631a",
|
939
|
+
"701e1a68a811a1ac8c137a70db08c1a8"
|
940
|
+
],
|
941
|
+
"host": "1.2.3.4:8080",
|
942
|
+
"uuid": "1-deadbeef",
|
943
|
+
"index": 1,
|
944
|
+
"type": "login"
|
945
|
+
}
|
946
|
+
PAYLOAD
|
947
|
+
|
948
|
+
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
|
+
cf %W[watch]
|
955
|
+
|
956
|
+
expect(output).to say("reply to vcap.component.discover (1)\ttype: login, index: 1, host: 1.2.3.4:8080")
|
957
|
+
end
|
958
|
+
end
|
959
|
+
end
|
960
|
+
end
|
871
961
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tools-cf-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
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: 2013-05-
|
12
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cfoundry
|
@@ -43,6 +43,44 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bosh_cli
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.5.0.pre.3
|
54
|
+
- - <
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '1.6'
|
57
|
+
type: :runtime
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 1.5.0.pre.3
|
65
|
+
- - <
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.6'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: net-ssh
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
46
84
|
- !ruby/object:Gem::Dependency
|
47
85
|
name: rake
|
48
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,7 +200,7 @@ dependencies:
|
|
162
200
|
requirements:
|
163
201
|
- - ~>
|
164
202
|
- !ruby/object:Gem::Version
|
165
|
-
version: '1.
|
203
|
+
version: '1.7'
|
166
204
|
type: :development
|
167
205
|
prerelease: false
|
168
206
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -170,23 +208,23 @@ dependencies:
|
|
170
208
|
requirements:
|
171
209
|
- - ~>
|
172
210
|
- !ruby/object:Gem::Version
|
173
|
-
version: '1.
|
211
|
+
version: '1.7'
|
174
212
|
- !ruby/object:Gem::Dependency
|
175
213
|
name: blue-shell
|
176
214
|
requirement: !ruby/object:Gem::Requirement
|
177
215
|
none: false
|
178
216
|
requirements:
|
179
|
-
- -
|
217
|
+
- - ~>
|
180
218
|
- !ruby/object:Gem::Version
|
181
|
-
version:
|
219
|
+
version: 0.1.0
|
182
220
|
type: :development
|
183
221
|
prerelease: false
|
184
222
|
version_requirements: !ruby/object:Gem::Requirement
|
185
223
|
none: false
|
186
224
|
requirements:
|
187
|
-
- -
|
225
|
+
- - ~>
|
188
226
|
- !ruby/object:Gem::Version
|
189
|
-
version:
|
227
|
+
version: 0.1.0
|
190
228
|
- !ruby/object:Gem::Dependency
|
191
229
|
name: fakefs
|
192
230
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,9 +250,20 @@ extra_rdoc_files: []
|
|
212
250
|
files:
|
213
251
|
- Rakefile
|
214
252
|
- lib/tools-cf-plugin/plugin.rb
|
253
|
+
- lib/tools-cf-plugin/tunnel/base.rb
|
254
|
+
- lib/tools-cf-plugin/tunnel/log_entry.rb
|
255
|
+
- lib/tools-cf-plugin/tunnel/multi_line_stream.rb
|
256
|
+
- lib/tools-cf-plugin/tunnel/stream_location.rb
|
257
|
+
- lib/tools-cf-plugin/tunnel/watch.rb
|
258
|
+
- lib/tools-cf-plugin/tunnel/watch_logs.rb
|
215
259
|
- lib/tools-cf-plugin/version.rb
|
216
260
|
- lib/tools-cf-plugin/watch.rb
|
217
261
|
- spec/spec_helper.rb
|
262
|
+
- spec/tunnel/base_spec.rb
|
263
|
+
- spec/tunnel/log_entry_spec.rb
|
264
|
+
- spec/tunnel/multi_line_stream_spec.rb
|
265
|
+
- spec/tunnel/stream_location_spec.rb
|
266
|
+
- spec/tunnel/watch_logs_spec.rb
|
218
267
|
- spec/watch_spec.rb
|
219
268
|
homepage: http://github.com/cloudfoundry/tools-cf-plugin
|
220
269
|
licenses: []
|
@@ -242,4 +291,9 @@ specification_version: 3
|
|
242
291
|
summary: Cloud Foundry tooling commands.
|
243
292
|
test_files:
|
244
293
|
- spec/spec_helper.rb
|
294
|
+
- spec/tunnel/base_spec.rb
|
295
|
+
- spec/tunnel/log_entry_spec.rb
|
296
|
+
- spec/tunnel/multi_line_stream_spec.rb
|
297
|
+
- spec/tunnel/stream_location_spec.rb
|
298
|
+
- spec/tunnel/watch_logs_spec.rb
|
245
299
|
- spec/watch_spec.rb
|