bosh_cli 0.16 → 0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,8 @@ describe Bosh::Cli::Command::Base do
6
6
 
7
7
  before :each do
8
8
  @config = File.join(Dir.mktmpdir, "bosh_config")
9
- @cache = File.join(Dir.mktmpdir, "bosh_cache")
10
- @opts = { :config => @config, :cache_dir => @cache }
9
+ @cache = File.join(Dir.mktmpdir, "bosh_cache")
10
+ @opts = { :config => @config, :cache_dir => @cache }
11
11
  end
12
12
 
13
13
  describe Bosh::Cli::Command::Misc do
@@ -300,181 +300,48 @@ describe Bosh::Cli::Command::Base do
300
300
 
301
301
  end
302
302
 
303
- describe Bosh::Cli::Command::Blob do
303
+ describe Bosh::Cli::Command::BlobManagement do
304
304
  before :each do
305
- @cmd = Bosh::Cli::Command::Blob.new(@opts)
306
- @release_dir = Dir.mktmpdir
307
- @blob_dir = File.join(@release_dir, "blobs/")
308
- @cmd.stub!(:work_dir).and_return(@release_dir)
309
- @blobstore = mock("blobstore")
310
- @cmd.stub!(:blobstore).and_return(@blobstore)
311
- FileUtils.mkdir(@blob_dir)
305
+ @cmd = Bosh::Cli::Command::BlobManagement.new(@opts)
306
+ @blob_manager = mock("blob manager")
307
+ @release = mock("release")
308
+
309
+ @cmd.should_receive(:check_if_release_dir)
310
+ Bosh::Cli::Release.stub!(:new).and_return(@release)
311
+ Bosh::Cli::BlobManager.stub!(:new).with(@release).
312
+ and_return(@blob_manager)
312
313
  end
313
314
 
314
- after :each do
315
- FileUtils.rm_rf(@release_dir)
315
+ it "prints blobs status" do
316
+ @blob_manager.should_receive(:print_status)
317
+ @cmd.status
316
318
  end
317
319
 
318
- it "refuse to run outside of the release directory" do
319
- lambda {
320
- @cmd.upload_blob("foo")
321
- }.should raise_error(Bosh::Cli::CliExit,
322
- "Sorry, your current directory doesn't " +
323
- "look like release directory".red)
320
+ it "adds blob under provided directory" do
321
+ @blob_manager.should_receive(:add_blob).with("foo/bar.tgz", "bar/bar.tgz")
322
+ @cmd.add("foo/bar.tgz", "bar")
323
+ end
324
324
 
325
- lambda {
326
- @cmd.sync_blobs
327
- }.should raise_error(Bosh::Cli::CliExit,
328
- "Sorry, your current directory doesn't " +
329
- "look like release directory".red)
325
+ it "adds blob with no directory provided" do
326
+ @blob_manager.should_receive(:add_blob).with("foo/bar.tgz", "bar.tgz")
327
+ @cmd.add("foo/bar.tgz")
328
+ end
330
329
 
331
- lambda {
332
- @cmd.blobs_info
333
- }.should raise_error(Bosh::Cli::CliExit,
334
- "Sorry, your current directory doesn't " +
335
- "look like release directory".red)
336
- end
337
-
338
- it "refuse to upload blob outside of release/blobs" do
339
- Dir.chdir(@release_dir) do
340
- FileUtils.touch("test.tgz")
341
- @cmd.should_receive(:check_if_blobs_supported).and_return(true)
342
- blob_path = Pathname.new(@release_dir).realpath.to_s
343
- blobs_dir = Pathname.new(@blob_dir).realpath.to_s
344
- lambda {
345
- @cmd.upload_blob("test.tgz")
346
- }.should raise_error(Bosh::Cli::CliExit,
347
- "#{File.join(blob_path, "test.tgz")} is " +
348
- "NOT under #{blobs_dir}/")
349
- end
350
- end
351
-
352
- it "upload new blob to blobstore" do
353
- Dir.chdir(@release_dir) do
354
- FileUtils.mkdir("./blobs/test")
355
- blob = FileUtils.touch("./blobs/test/test.tgz")
356
- @cmd.should_receive(:get_blobs_index).and_return({})
357
- @cmd.should_receive(:check_if_blobs_supported).and_return(true)
358
- @blobstore.should_receive(:create).and_return(2)
359
- @cmd.upload_blob("./blobs/test/test.tgz")
360
- YAML.load_file("blob_index.yml").should == {
361
- "test/test.tgz" => {
362
- "object_id" => 2,
363
- "sha" => Digest::SHA1.file(blob.first).hexdigest
364
- }
365
- }
366
- end
367
- end
368
-
369
- it "should skip upload if blob already exists" do
370
- Dir.chdir(@release_dir) do
371
- FileUtils.mkdir("./blobs/test")
372
- blob = FileUtils.touch("./blobs/test/test.tgz")
373
- @cmd.should_receive(:check_if_blobs_supported).and_return(true)
374
- @cmd.should_receive(:get_blobs_index).and_return('test/test.tgz' => {
375
- "sha" => Digest::SHA1.file(blob.first).hexdigest,
376
- "object_id" => 2
377
- })
378
- @blobstore.should_not_receive(:create)
379
- @cmd.upload_blob("./blobs/test/test.tgz")
380
- end
381
- end
382
-
383
- it "should ask user if blob was modified" do
384
- Dir.chdir(@release_dir) do
385
- FileUtils.mkdir("./blobs/test")
386
- blob = FileUtils.touch("./blobs/test/test.tgz")
387
- @cmd.should_receive(:check_if_blobs_supported).and_return(true)
388
- @cmd.should_receive(:get_blobs_index).and_return('test/test.tgz' => {
389
- "sha" => 1,
390
- "object_id" => 2
391
- })
392
- @cmd.should_receive(:ask).and_return("no")
393
- @blobstore.should_not_receive(:create)
394
- @cmd.upload_blob("./blobs/test/test.tgz")
395
- end
396
- end
397
-
398
- it "should sync if file is not present" do
399
- Dir.chdir(@release_dir) do
400
- @cmd.should_receive(:check_if_blobs_supported).and_return(true)
401
- @cmd.should_receive(:get_blobs_index).and_return('test/test.tgz' => {
402
- "sha" => 1,
403
- "object_id" => 2
404
- })
405
- @cmd.should_receive(:fetch_blob).
406
- with(File.join(@release_dir, "blobs", "test/test.tgz"),
407
- { "sha" => 1, "object_id" => 2 })
408
- @cmd.sync_blobs
409
- end
410
- end
411
-
412
- it "should not sync if the same file is present" do
413
- Dir.chdir(@release_dir) do
414
- FileUtils.mkdir("./blobs/test")
415
- blob = FileUtils.touch("./blobs/test/test.tgz")
416
- @cmd.should_receive(:check_if_blobs_supported).and_return(true)
417
- @cmd.should_receive(:get_blobs_index).and_return('test/test.tgz' => {
418
- "sha" => Digest::SHA1.file(blob.first).hexdigest,
419
- "object_id" => 2
420
- })
421
- @cmd.should_not_receive(:fetch_blob)
422
- @cmd.sync_blobs
423
- end
424
- end
425
-
426
- it "should ask user if blob sha is different" do
427
- Dir.chdir(@release_dir) do
428
- FileUtils.mkdir("./blobs/test")
429
- blob = FileUtils.touch("./blobs/test/test.tgz")
430
- @cmd.should_receive(:check_if_blobs_supported).and_return(true)
431
- @cmd.should_receive(:get_blobs_index).and_return('test/test.tgz' => {
432
- "sha" => 1,
433
- "object_id" => 2
434
- })
435
- @cmd.should_receive(:ask).and_return("")
436
- @cmd.should_not_receive(:fetch_blob)
437
- @cmd.sync_blobs
438
- end
439
- end
440
-
441
- it "reports untracked blobs" do
442
- Dir.chdir(@release_dir) do
443
- FileUtils.mkdir("./blobs/test")
444
- FileUtils.touch("./blobs/test/test.tgz")
445
- @cmd.should_receive(:check_if_blobs_supported).and_return(true)
446
- @cmd.should_receive(:get_blobs_index).and_return({})
447
- @cmd.should_receive(:say).
448
- with("\nNew blobs ('bosh upload blob' to add): ".green)
449
- @cmd.should_receive(:say).with("test/test.tgz")
450
- @cmd.blobs_info
451
- end
452
- end
453
-
454
- it "reports modified blobs" do
455
- Dir.chdir(@release_dir) do
456
- FileUtils.mkdir("./blobs/test")
457
- FileUtils.touch("./blobs/test/test.tgz")
458
- @cmd.should_receive(:check_if_blobs_supported).and_return(true)
459
- @cmd.should_receive(:get_blobs_index).
460
- and_return({ "test/test.tgz" => { "sha" => 1, "object_id" => 2}})
461
- @cmd.should_receive(:say).
462
- with("\nModified blobs ('bosh upload blob' to update): ".green)
463
- @cmd.should_receive(:say).with("test/test.tgz")
464
- @cmd.blobs_info
465
- end
466
- end
467
-
468
- it "reports unsynced blobs" do
469
- Dir.chdir(@release_dir) do
470
- @cmd.should_receive(:check_if_blobs_supported).and_return(true)
471
- @cmd.should_receive(:get_blobs_index).
472
- and_return({ "test/test.tgz" => { "sha" => 1, "object_id" => 2}})
473
- @cmd.should_receive(:say).
474
- with("\nMissing blobs ('bosh sync blobs' to fetch) : ".green)
475
- @cmd.should_receive(:say).with("test/test.tgz")
476
- @cmd.blobs_info
477
- end
330
+ it "uploads blobs" do
331
+ @blob_manager.should_receive(:print_status)
332
+ @blob_manager.stub!(:blobs_to_upload).and_return(%w(foo bar baz))
333
+ @blob_manager.should_receive(:upload_blob).with("foo")
334
+ @blob_manager.should_receive(:upload_blob).with("bar")
335
+ @blob_manager.should_receive(:upload_blob).with("baz")
336
+
337
+ @cmd.should_receive(:confirmed?).exactly(3).times.and_return(true)
338
+ @cmd.upload
339
+ end
340
+
341
+ it "syncs blobs" do
342
+ @blob_manager.should_receive(:sync).ordered
343
+ @blob_manager.should_receive(:print_status).ordered
344
+ @cmd.sync
478
345
  end
479
346
  end
480
347
 
@@ -93,6 +93,11 @@ describe Bosh::Cli::Runner do
93
93
  test_cmd(["tasks"], :task, :list_running)
94
94
  test_cmd(["tasks", "recent"], :task, :list_recent)
95
95
  test_cmd(["tasks", "recent", "42"], :task, :list_recent, ["42"])
96
+
97
+ test_cmd(%w(blobs), :blob_management, :status)
98
+ test_cmd(%w(add blob foo bar), :blob_management, :add, %w(foo bar))
99
+ test_cmd(%w(upload blobs), :blob_management, :upload)
100
+ test_cmd(%w(sync blobs), :blob_management, :sync)
96
101
  end
97
102
 
98
103
  it "cancels running task and quits when ctrl-c is issued " +
metadata CHANGED
@@ -1,144 +1,207 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bosh_cli
3
- version: !ruby/object:Gem::Version
4
- version: '0.16'
3
+ version: !ruby/object:Gem::Version
4
+ hash: 41
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 17
9
+ version: "0.17"
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - VMware
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2012-04-11 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: json_pure
16
- requirement: &70285282483660 !ruby/object:Gem::Requirement
16
+
17
+ date: 2012-04-26 00:00:00 Z
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ prerelease: false
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
22
  none: false
18
- requirements:
23
+ requirements:
19
24
  - - ~>
20
- - !ruby/object:Gem::Version
25
+ - !ruby/object:Gem::Version
26
+ hash: 13
27
+ segments:
28
+ - 1
29
+ - 6
30
+ - 1
21
31
  version: 1.6.1
32
+ requirement: *id001
33
+ name: json_pure
22
34
  type: :runtime
35
+ - !ruby/object:Gem::Dependency
23
36
  prerelease: false
24
- version_requirements: *70285282483660
25
- - !ruby/object:Gem::Dependency
26
- name: highline
27
- requirement: &70285282482820 !ruby/object:Gem::Requirement
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
28
38
  none: false
29
- requirements:
39
+ requirements:
30
40
  - - ~>
31
- - !ruby/object:Gem::Version
41
+ - !ruby/object:Gem::Version
42
+ hash: 11
43
+ segments:
44
+ - 1
45
+ - 6
46
+ - 2
32
47
  version: 1.6.2
48
+ requirement: *id002
49
+ name: highline
33
50
  type: :runtime
51
+ - !ruby/object:Gem::Dependency
34
52
  prerelease: false
35
- version_requirements: *70285282482820
36
- - !ruby/object:Gem::Dependency
37
- name: progressbar
38
- requirement: &70285282481940 !ruby/object:Gem::Requirement
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
39
54
  none: false
40
- requirements:
55
+ requirements:
41
56
  - - ~>
42
- - !ruby/object:Gem::Version
57
+ - !ruby/object:Gem::Version
58
+ hash: 59
59
+ segments:
60
+ - 0
61
+ - 9
62
+ - 0
43
63
  version: 0.9.0
64
+ requirement: *id003
65
+ name: progressbar
44
66
  type: :runtime
67
+ - !ruby/object:Gem::Dependency
45
68
  prerelease: false
46
- version_requirements: *70285282481940
47
- - !ruby/object:Gem::Dependency
48
- name: httpclient
49
- requirement: &70285282480760 !ruby/object:Gem::Requirement
69
+ version_requirements: &id004 !ruby/object:Gem::Requirement
50
70
  none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 15
75
+ segments:
76
+ - 2
77
+ - 2
78
+ - 4
54
79
  version: 2.2.4
55
80
  - - <=
56
- - !ruby/object:Gem::Version
81
+ - !ruby/object:Gem::Version
82
+ hash: 15
83
+ segments:
84
+ - 2
85
+ - 2
86
+ - 4
57
87
  version: 2.2.4
88
+ requirement: *id004
89
+ name: httpclient
58
90
  type: :runtime
91
+ - !ruby/object:Gem::Dependency
59
92
  prerelease: false
60
- version_requirements: *70285282480760
61
- - !ruby/object:Gem::Dependency
62
- name: terminal-table
63
- requirement: &70285282477300 !ruby/object:Gem::Requirement
93
+ version_requirements: &id005 !ruby/object:Gem::Requirement
64
94
  none: false
65
- requirements:
95
+ requirements:
66
96
  - - ~>
67
- - !ruby/object:Gem::Version
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 1
101
+ - 4
102
+ - 2
68
103
  version: 1.4.2
104
+ requirement: *id005
105
+ name: terminal-table
69
106
  type: :runtime
107
+ - !ruby/object:Gem::Dependency
70
108
  prerelease: false
71
- version_requirements: *70285282477300
72
- - !ruby/object:Gem::Dependency
73
- name: blobstore_client
74
- requirement: &70285282476580 !ruby/object:Gem::Requirement
109
+ version_requirements: &id006 !ruby/object:Gem::Requirement
75
110
  none: false
76
- requirements:
111
+ requirements:
77
112
  - - ~>
78
- - !ruby/object:Gem::Version
113
+ - !ruby/object:Gem::Version
114
+ hash: 9
115
+ segments:
116
+ - 0
117
+ - 3
118
+ - 13
79
119
  version: 0.3.13
120
+ requirement: *id006
121
+ name: blobstore_client
80
122
  type: :runtime
123
+ - !ruby/object:Gem::Dependency
81
124
  prerelease: false
82
- version_requirements: *70285282476580
83
- - !ruby/object:Gem::Dependency
84
- name: net-ssh
85
- requirement: &70285282475380 !ruby/object:Gem::Requirement
125
+ version_requirements: &id007 !ruby/object:Gem::Requirement
86
126
  none: false
87
- requirements:
127
+ requirements:
88
128
  - - ~>
89
- - !ruby/object:Gem::Version
129
+ - !ruby/object:Gem::Version
130
+ hash: 5
131
+ segments:
132
+ - 2
133
+ - 2
134
+ - 1
90
135
  version: 2.2.1
136
+ requirement: *id007
137
+ name: net-ssh
91
138
  type: :runtime
139
+ - !ruby/object:Gem::Dependency
92
140
  prerelease: false
93
- version_requirements: *70285282475380
94
- - !ruby/object:Gem::Dependency
95
- name: net-ssh-gateway
96
- requirement: &70285282474540 !ruby/object:Gem::Requirement
141
+ version_requirements: &id008 !ruby/object:Gem::Requirement
97
142
  none: false
98
- requirements:
143
+ requirements:
99
144
  - - ~>
100
- - !ruby/object:Gem::Version
145
+ - !ruby/object:Gem::Version
146
+ hash: 19
147
+ segments:
148
+ - 1
149
+ - 1
150
+ - 0
101
151
  version: 1.1.0
152
+ requirement: *id008
153
+ name: net-ssh-gateway
102
154
  type: :runtime
155
+ - !ruby/object:Gem::Dependency
103
156
  prerelease: false
104
- version_requirements: *70285282474540
105
- - !ruby/object:Gem::Dependency
106
- name: net-scp
107
- requirement: &70285282473460 !ruby/object:Gem::Requirement
157
+ version_requirements: &id009 !ruby/object:Gem::Requirement
108
158
  none: false
109
- requirements:
159
+ requirements:
110
160
  - - ~>
111
- - !ruby/object:Gem::Version
161
+ - !ruby/object:Gem::Version
162
+ hash: 31
163
+ segments:
164
+ - 1
165
+ - 0
166
+ - 4
112
167
  version: 1.0.4
168
+ requirement: *id009
169
+ name: net-scp
113
170
  type: :runtime
171
+ - !ruby/object:Gem::Dependency
114
172
  prerelease: false
115
- version_requirements: *70285282473460
116
- - !ruby/object:Gem::Dependency
117
- name: netaddr
118
- requirement: &70285282472680 !ruby/object:Gem::Requirement
173
+ version_requirements: &id010 !ruby/object:Gem::Requirement
119
174
  none: false
120
- requirements:
175
+ requirements:
121
176
  - - ~>
122
- - !ruby/object:Gem::Version
177
+ - !ruby/object:Gem::Version
178
+ hash: 3
179
+ segments:
180
+ - 1
181
+ - 5
182
+ - 0
123
183
  version: 1.5.0
184
+ requirement: *id010
185
+ name: netaddr
124
186
  type: :runtime
125
- prerelease: false
126
- version_requirements: *70285282472680
127
187
  description: BOSH command-line tool for release engineering and deployment
128
188
  email: support@vmware.com
129
- executables:
189
+ executables:
130
190
  - bosh
131
191
  extensions: []
192
+
132
193
  extra_rdoc_files: []
133
- files:
194
+
195
+ files:
134
196
  - bin/bosh
135
197
  - lib/cli.rb
198
+ - lib/cli/blob_manager.rb
136
199
  - lib/cli/cache.rb
137
200
  - lib/cli/changeset_helper.rb
138
201
  - lib/cli/command_definition.rb
139
202
  - lib/cli/commands/base.rb
140
203
  - lib/cli/commands/biff.rb
141
- - lib/cli/commands/blob.rb
204
+ - lib/cli/commands/blob_management.rb
142
205
  - lib/cli/commands/cloudcheck.rb
143
206
  - lib/cli/commands/deployment.rb
144
207
  - lib/cli/commands/job.rb
@@ -223,6 +286,7 @@ files:
223
286
  - spec/spec_helper.rb
224
287
  - spec/unit/base_command_spec.rb
225
288
  - spec/unit/biff_spec.rb
289
+ - spec/unit/blob_manager_spec.rb
226
290
  - spec/unit/cache_spec.rb
227
291
  - spec/unit/cli_commands_spec.rb
228
292
  - spec/unit/config_spec.rb
@@ -245,35 +309,38 @@ files:
245
309
  - spec/unit/versions_index_spec.rb
246
310
  homepage: http://www.vmware.com
247
311
  licenses: []
312
+
248
313
  post_install_message:
249
314
  rdoc_options: []
250
- require_paths:
315
+
316
+ require_paths:
251
317
  - lib
252
- required_ruby_version: !ruby/object:Gem::Requirement
318
+ required_ruby_version: !ruby/object:Gem::Requirement
253
319
  none: false
254
- requirements:
255
- - - ! '>='
256
- - !ruby/object:Gem::Version
257
- version: '0'
258
- segments:
320
+ requirements:
321
+ - - ">="
322
+ - !ruby/object:Gem::Version
323
+ hash: 3
324
+ segments:
259
325
  - 0
260
- hash: -21086111877987397
261
- required_rubygems_version: !ruby/object:Gem::Requirement
326
+ version: "0"
327
+ required_rubygems_version: !ruby/object:Gem::Requirement
262
328
  none: false
263
- requirements:
264
- - - ! '>='
265
- - !ruby/object:Gem::Version
266
- version: '0'
267
- segments:
329
+ requirements:
330
+ - - ">="
331
+ - !ruby/object:Gem::Version
332
+ hash: 3
333
+ segments:
268
334
  - 0
269
- hash: -21086111877987397
335
+ version: "0"
270
336
  requirements: []
337
+
271
338
  rubyforge_project:
272
- rubygems_version: 1.8.12
339
+ rubygems_version: 1.8.17
273
340
  signing_key:
274
341
  specification_version: 3
275
342
  summary: BOSH CLI
276
- test_files:
343
+ test_files:
277
344
  - spec/assets/biff/bad_gateway_config.yml
278
345
  - spec/assets/biff/good_simple_config.yml
279
346
  - spec/assets/biff/good_simple_golden_config.yml
@@ -316,6 +383,7 @@ test_files:
316
383
  - spec/spec_helper.rb
317
384
  - spec/unit/base_command_spec.rb
318
385
  - spec/unit/biff_spec.rb
386
+ - spec/unit/blob_manager_spec.rb
319
387
  - spec/unit/cache_spec.rb
320
388
  - spec/unit/cli_commands_spec.rb
321
389
  - spec/unit/config_spec.rb