bosh_cli 0.19.4 → 0.19.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.
@@ -13,14 +13,23 @@ describe Bosh::Cli::Command::Biff do
13
13
  @biff.delete_temp_diff_files
14
14
  end
15
15
 
16
+ it "throws an error when there is an IP out of range" do
17
+ config_file = spec_asset("biff/ip_out_of_range.yml")
18
+ template_file = spec_asset("biff/good_simple_template.erb")
19
+ @biff.stub!(:deployment).and_return(config_file)
20
+ lambda {
21
+ @biff.biff(template_file)
22
+ }.should raise_error(Bosh::Cli::CliExit, "IP range '2..9' is not within the bounds of network 'default', which only has 1 IPs.")
23
+ end
24
+
16
25
  it "throws an error when there is more than one subnet for default" do
17
26
  config_file = spec_asset("biff/multiple_subnets_config.yml")
18
27
  template_file = spec_asset("biff/network_only_template.erb")
19
28
  @biff.stub!(:deployment).and_return(config_file)
20
29
  lambda {
21
30
  @biff.biff(template_file)
22
- }.should raise_error(RuntimeError, "Biff doesn't know how to deal with " +
23
- "anything other than one subnet in default")
31
+ }.should raise_error(Bosh::Cli::CliExit, "Biff doesn't know how to deal " +
32
+ "with anything other than one subnet in default")
24
33
  end
25
34
 
26
35
  it "throws an error when the gateway is anything other than the first ip" do
@@ -29,8 +38,8 @@ describe Bosh::Cli::Command::Biff do
29
38
  @biff.stub!(:deployment).and_return(config_file)
30
39
  lambda {
31
40
  @biff.biff(template_file)
32
- }.should raise_error(RuntimeError, "Biff only supports configurations " +
33
- "where the gateway is the first IP (e.g. 172.31.196.1).")
41
+ }.should raise_error(Bosh::Cli::CliExit, "Biff only supports " +
42
+ "configurations where the gateway is the first IP (e.g. 172.31.196.1).")
34
43
  end
35
44
 
36
45
  it "throws an error when the range is not specified in the config" do
@@ -39,8 +48,8 @@ describe Bosh::Cli::Command::Biff do
39
48
  @biff.stub!(:deployment).and_return(config_file)
40
49
  lambda {
41
50
  @biff.biff(template_file)
42
- }.should raise_error(RuntimeError, "Biff requires each network to have " +
43
- "range and dns entries.")
51
+ }.should raise_error(Bosh::Cli::CliExit, "Biff requires each network to " +
52
+ "have range and dns entries.")
44
53
  end
45
54
 
46
55
  it "throws an error if there are no subnets" do
@@ -49,7 +58,7 @@ describe Bosh::Cli::Command::Biff do
49
58
  @biff.stub!(:deployment).and_return(config_file)
50
59
  lambda {
51
60
  @biff.biff(template_file)
52
- }.should raise_error(RuntimeError, "You must have subnets in default")
61
+ }.should raise_error(Bosh::Cli::CliExit, "You must have subnets in default")
53
62
  end
54
63
 
55
64
  it "outputs the required yaml when the input does not contain it" do
@@ -26,7 +26,7 @@ describe Bosh::Cli::Command::Base do
26
26
  it "normalizes target" do
27
27
  @cmd.target.should == nil
28
28
  @cmd.set_target("test")
29
- @cmd.target.should == "http://test"
29
+ @cmd.target.should == "http://test:25555"
30
30
  end
31
31
 
32
32
  it "respects director checks option when setting target" do
@@ -36,33 +36,33 @@ describe Bosh::Cli::Command::Base do
36
36
  mock_director = mock(Object)
37
37
  mock_director.stub!(:get_status).and_raise(Bosh::Cli::DirectorError)
38
38
  Bosh::Cli::Director.should_receive(:new).
39
- with("http://test").and_return(mock_director)
39
+ with("http://test:25555").and_return(mock_director)
40
40
  @cmd.set_target("test")
41
41
  }.should raise_error(Bosh::Cli::CliExit,
42
- "Cannot talk to director at 'http://test', " +
42
+ "Cannot talk to director at `http://test:25555', " +
43
43
  "please set correct target")
44
44
 
45
45
  @cmd.target.should == nil
46
46
 
47
- mock_director = mock(Object)
47
+ mock_director = mock(Bosh::Cli::Director)
48
48
  mock_director.stub!(:get_status).and_return("name" => "ZB")
49
49
  Bosh::Cli::Director.should_receive(:new).
50
- with("http://test").and_return(mock_director)
50
+ with("http://test:25555").and_return(mock_director)
51
51
  @cmd.set_target("test")
52
- @cmd.target.should == "http://test"
52
+ @cmd.target.should == "http://test:25555"
53
53
  end
54
54
 
55
55
  it "supports named targets" do
56
56
  @cmd.set_target("test", "mytarget")
57
- @cmd.target.should == "http://test"
57
+ @cmd.target.should == "http://test:25555"
58
58
 
59
59
  @cmd.set_target("foo", "myfoo")
60
60
 
61
61
  @cmd.set_target("mytarget")
62
- @cmd.target.should == "http://test"
62
+ @cmd.target.should == "http://test:25555"
63
63
 
64
64
  @cmd.set_target("myfoo")
65
- @cmd.target.should == "http://foo"
65
+ @cmd.target.should == "http://foo:25555"
66
66
  end
67
67
 
68
68
  it "logs user in" do
@@ -89,11 +89,11 @@ describe Bosh::Cli::Command::Base do
89
89
  mock_director.stub(:authenticated?).and_return(true)
90
90
 
91
91
  Bosh::Cli::Director.should_receive(:new).
92
- with("http://test").and_return(mock_director)
92
+ with("http://test:25555").and_return(mock_director)
93
93
  @cmd.set_target("test")
94
94
 
95
95
  Bosh::Cli::Director.should_receive(:new).
96
- with("http://test", "user", "pass").and_return(mock_director)
96
+ with("http://test:25555", "user", "pass").and_return(mock_director)
97
97
 
98
98
  @cmd.login("user", "pass")
99
99
  @cmd.logged_in?.should be_true
@@ -18,10 +18,6 @@ describe Bosh::Cli::Config do
18
18
  Bosh::Cli::Config.new(@config)
19
19
  end
20
20
 
21
- def logged_in?(cfg)
22
- cfg.username && cfg.password
23
- end
24
-
25
21
  it "should convert old deployment configs to the new config " +
26
22
  "when set_deployment is called" do
27
23
  add_config("target" => "localhost:8080", "deployment" => "test")
@@ -116,24 +112,14 @@ describe Bosh::Cli::Config do
116
112
  add_config(config)
117
113
  cfg = create_config
118
114
 
119
- logged_in?(cfg).should be_true
120
- cfg.username.should == "a"
121
- cfg.password.should == "b"
115
+ cfg.username("localhost:8080").should == "a"
116
+ cfg.password("localhost:8080").should == "b"
122
117
 
123
- config["target"] = "localhost:8081"
124
- add_config(config)
118
+ cfg.username("localhost:8081").should == "c"
119
+ cfg.password("localhost:8081").should == "d"
125
120
 
126
- cfg = create_config
127
- logged_in?(cfg).should be_true
128
- cfg.username.should == "c"
129
- cfg.password.should == "d"
130
-
131
- config["target"] = "localhost:8082"
132
- add_config(config)
133
- cfg = create_config
134
- logged_in?(cfg).should be_false
135
- cfg.username.should be_nil
136
- cfg.password.should be_nil
121
+ cfg.username("localhost:8083").should be_nil
122
+ cfg.password("localhost:8083").should be_nil
137
123
  end
138
124
 
139
125
  end
@@ -0,0 +1,117 @@
1
+ # Copyright (c) 2009-2012 VMware, Inc.
2
+
3
+ require "spec_helper"
4
+
5
+ describe Bosh::Cli::DeploymentHelper do
6
+
7
+ def make_cmd(options = {})
8
+ cmd = Bosh::Cli::Command::Base.new(options)
9
+ cmd.extend(Bosh::Cli::DeploymentHelper)
10
+ cmd
11
+ end
12
+
13
+ it "checks that actual director UUID matches the one in manifest" do
14
+ cmd = make_cmd
15
+ manifest = {
16
+ "name" => "mycloud",
17
+ "director_uuid" => "deadbeef"
18
+ }
19
+
20
+ manifest_file = Tempfile.new("manifest")
21
+ YAML.dump(manifest, manifest_file)
22
+ manifest_file.close
23
+ director = mock(Bosh::Cli::Director)
24
+
25
+ cmd.stub!(:deployment).and_return(manifest_file.path)
26
+ cmd.stub!(:director).and_return(director)
27
+
28
+ director.should_receive(:uuid).and_return("deadcafe")
29
+
30
+ expect {
31
+ cmd.prepare_deployment_manifest
32
+ }.to raise_error(/Target director UUID doesn't match/i)
33
+ end
34
+
35
+ it "resolves 'latest' release alias for multiple releases" do
36
+ cmd = make_cmd
37
+ manifest = {
38
+ "name" => "mycloud",
39
+ "director_uuid" => "deadbeef",
40
+ "releases" => [
41
+ {"name" => "foo", "version" => "latest"},
42
+ {"name" => "bar", "version" => "latest"},
43
+ {"name" => "baz", "version" => 3},
44
+ ]
45
+ }
46
+
47
+ manifest_file = Tempfile.new("manifest")
48
+ YAML.dump(manifest, manifest_file)
49
+ manifest_file.close
50
+ director = mock(Bosh::Cli::Director, :uuid => "deadbeef")
51
+
52
+ cmd.stub!(:deployment).and_return(manifest_file.path)
53
+ cmd.stub!(:director).and_return(director)
54
+
55
+ releases = [
56
+ {"name" => "foo", "versions" => %w(1 3.5.7-dev 2 3.5.2-dev)},
57
+ {"name" => "bar", "versions" => %w(4 2 3 1 1.1-dev 3.99-dev)},
58
+ {"name" => "baz", "versions" => %w(1 2 3 4 5 6 7)}
59
+ ]
60
+
61
+ director.should_receive(:list_releases).and_return(releases)
62
+
63
+ manifest = cmd.prepare_deployment_manifest
64
+ manifest["releases"][0]["version"].should == "3.5.7-dev"
65
+ manifest["releases"][1]["version"].should == 4 # cast to Integer!
66
+ manifest["releases"][2]["version"].should == 3
67
+ end
68
+
69
+ it "resolves 'latest' release alias for a single release" do
70
+ cmd = make_cmd
71
+ manifest = {
72
+ "name" => "mycloud",
73
+ "director_uuid" => "deadbeef",
74
+ "release" => {"name" => "foo", "version" => "latest"}
75
+ }
76
+
77
+ manifest_file = Tempfile.new("manifest")
78
+ YAML.dump(manifest, manifest_file)
79
+ manifest_file.close
80
+ director = mock(Bosh::Cli::Director, :uuid => "deadbeef")
81
+
82
+ cmd.stub!(:deployment).and_return(manifest_file.path)
83
+ cmd.stub!(:director).and_return(director)
84
+
85
+ releases = [
86
+ {"name" => "foo", "versions" => %w(1 3.5.7-dev 2 3.5.2-dev)},
87
+ ]
88
+
89
+ director.should_receive(:list_releases).and_return(releases)
90
+
91
+ manifest = cmd.prepare_deployment_manifest
92
+ manifest["release"]["version"].should == "3.5.7-dev"
93
+ end
94
+
95
+ it "treats having both 'releases' and 'release' as error" do
96
+ cmd = make_cmd
97
+ manifest = {
98
+ "name" => "mycloud",
99
+ "director_uuid" => "deadbeef",
100
+ "release" => {"name" => "foo", "version" => "latest"},
101
+ "releases" => []
102
+ }
103
+
104
+ manifest_file = Tempfile.new("manifest")
105
+ YAML.dump(manifest, manifest_file)
106
+ manifest_file.close
107
+ director = mock(Bosh::Cli::Director, :uuid => "deadbeef")
108
+
109
+ cmd.stub!(:deployment).and_return(manifest_file.path)
110
+ cmd.stub!(:director).and_return(director)
111
+
112
+ expect {
113
+ cmd.prepare_deployment_manifest
114
+ }.to raise_error(/manifest has both `release' and `releases'/i)
115
+ end
116
+
117
+ end
@@ -87,7 +87,7 @@ describe Bosh::Cli::PackageBuilder, "dev build" do
87
87
  lambda {
88
88
  builder.build
89
89
  }.should raise_error(Bosh::Cli::InvalidPackage,
90
- "`foo' has a glob that resolves " +
90
+ "Package `foo' has a glob that resolves " +
91
91
  "to an empty file list: bar")
92
92
  end
93
93
 
@@ -520,17 +520,35 @@ describe Bosh::Cli::PackageBuilder, "dev build" do
520
520
  it "supports alternative src directory" do
521
521
  add_file("src", "README.txt", "README contents")
522
522
  add_file("src", "lib/1.rb", "puts 'Hello world'")
523
+ add_file("src", "lib/2.rb", "puts 'Goodbye world'")
523
524
 
524
525
  builder = make_builder("A", %w(lib/*.rb README.*))
525
526
  s1 = builder.fingerprint
526
527
 
527
528
  add_file("src_alt", "README.txt", "README contents")
528
529
  add_file("src_alt", "lib/1.rb", "puts 'Hello world'")
530
+ add_file("src_alt", "lib/2.rb", "puts 'Goodbye world'")
529
531
 
530
- remove_files("src", %w(README.txt lib/1.rb))
532
+ remove_files("src", %w(lib/1.rb))
531
533
  builder.reload.fingerprint.should == s1
532
534
  end
533
535
 
536
+ it "checks if glob top level dir is present in src_alt but doesn't match" do
537
+ add_file("src", "README.txt", "README contents")
538
+ add_file("src", "lib/1.rb", "puts 'Hello world'")
539
+ add_file("src", "lib/2.rb", "puts 'Goodbye world'")
540
+
541
+ builder = make_builder("A", %w(lib/*.rb README.*))
542
+
543
+ FileUtils.mkdir(File.join(@release_dir, "src_alt", "lib"))
544
+
545
+ lambda {
546
+ builder.fingerprint
547
+ }.should raise_error("Package `A' has a glob that doesn't match " +
548
+ "in `src_alt' but matches in `src'. However " +
549
+ "`src_alt/lib' exists, so this might be an error.")
550
+ end
551
+
534
552
  it "doesn't allow glob to match files under more than one source directory" do
535
553
  add_file("src", "README.txt", "README contents")
536
554
  add_file("src", "lib/1.rb", "puts 'Hello world'")
@@ -545,8 +563,8 @@ describe Bosh::Cli::PackageBuilder, "dev build" do
545
563
 
546
564
  lambda {
547
565
  builder.reload.fingerprint
548
- }.should raise_error("`A' has a glob that resolves to " +
549
- "an empty file list: lib/*.rb")
566
+ }.should raise_error("Package `A' has a glob that resolves to " +
567
+ "an empty file list: lib/*.rb")
550
568
  end
551
569
 
552
570
  it "doesn't include the same path twice" do
@@ -42,12 +42,29 @@ describe Bosh::Cli::Runner do
42
42
  runner.options[:non_interactive].should == true
43
43
  end
44
44
 
45
+ it "allows specifying target, deployment and credentials via command line" do
46
+ runner = Bosh::Cli::Runner.new([
47
+ "--target", "foo",
48
+ "--deployment", "bar",
49
+ "--user", "baz",
50
+ "--password", "deadbeef"
51
+ ])
52
+ runner.parse_options!
53
+ runner.options[:target].should == "foo"
54
+ runner.options[:deployment].should == "bar"
55
+ runner.options[:username].should == "baz"
56
+ runner.options[:password].should == "deadbeef"
57
+ end
58
+
45
59
  it "dispatches commands to appropriate methods (nu school)" do
46
60
  test_cmd(["version"], :misc, :version)
47
61
  test_cmd(["status"], :misc, :status)
62
+ test_cmd(["alias", "test", "alias"], :misc, :set_alias, ["test", "alias"])
63
+ test_cmd(["aliases"], :misc, :list_aliases)
48
64
  test_cmd(["target"], :misc, :show_target)
49
65
  test_cmd(["target", "test"], :misc, :set_target, ["test"])
50
66
  test_cmd(["target", "test", "alias"], :misc, :set_target, ["test", "alias"])
67
+ test_cmd(["targets"], :misc, :list_targets)
51
68
  test_cmd(["deploy"], :deployment, :perform)
52
69
  test_cmd(["deployment"], :deployment, :show_current)
53
70
  test_cmd(["deployment", "test"], :deployment, :set_current, ["test"])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.4
4
+ version: 0.19.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: 2012-06-22 00:00:00.000000000 Z
12
+ date: 2012-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_pure
@@ -242,6 +242,7 @@ files:
242
242
  - spec/assets/biff/good_simple_config.yml
243
243
  - spec/assets/biff/good_simple_golden_config.yml
244
244
  - spec/assets/biff/good_simple_template.erb
245
+ - spec/assets/biff/ip_out_of_range.yml
245
246
  - spec/assets/biff/multiple_subnets_config.yml
246
247
  - spec/assets/biff/network_only_template.erb
247
248
  - spec/assets/biff/no_cc_config.yml
@@ -287,6 +288,7 @@ files:
287
288
  - spec/unit/core_ext_spec.rb
288
289
  - spec/unit/dependency_helper_spec.rb
289
290
  - spec/unit/deployment_manifest_compiler_spec.rb
291
+ - spec/unit/deployment_manifest_spec.rb
290
292
  - spec/unit/director_spec.rb
291
293
  - spec/unit/director_task_spec.rb
292
294
  - spec/unit/event_log_renderer_spec.rb
@@ -317,7 +319,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
317
319
  version: '0'
318
320
  segments:
319
321
  - 0
320
- hash: 1823880374092927602
322
+ hash: 1133822301070881682
321
323
  required_rubygems_version: !ruby/object:Gem::Requirement
322
324
  none: false
323
325
  requirements:
@@ -326,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
326
328
  version: '0'
327
329
  segments:
328
330
  - 0
329
- hash: 1823880374092927602
331
+ hash: 1133822301070881682
330
332
  requirements: []
331
333
  rubyforge_project:
332
334
  rubygems_version: 1.8.23
@@ -338,6 +340,7 @@ test_files:
338
340
  - spec/assets/biff/good_simple_config.yml
339
341
  - spec/assets/biff/good_simple_golden_config.yml
340
342
  - spec/assets/biff/good_simple_template.erb
343
+ - spec/assets/biff/ip_out_of_range.yml
341
344
  - spec/assets/biff/multiple_subnets_config.yml
342
345
  - spec/assets/biff/network_only_template.erb
343
346
  - spec/assets/biff/no_cc_config.yml
@@ -383,6 +386,7 @@ test_files:
383
386
  - spec/unit/core_ext_spec.rb
384
387
  - spec/unit/dependency_helper_spec.rb
385
388
  - spec/unit/deployment_manifest_compiler_spec.rb
389
+ - spec/unit/deployment_manifest_spec.rb
386
390
  - spec/unit/director_spec.rb
387
391
  - spec/unit/director_task_spec.rb
388
392
  - spec/unit/event_log_renderer_spec.rb