bosh-cloudfoundry 0.2.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.
Files changed (47) hide show
  1. data/.gitignore +18 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +6 -0
  5. data/Guardfile +10 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +242 -0
  8. data/Rakefile +33 -0
  9. data/bosh-cloudfoundry.gemspec +29 -0
  10. data/config/defaults.yml +6 -0
  11. data/lib/bosh-cloudfoundry.rb +34 -0
  12. data/lib/bosh-cloudfoundry/bosh_release_manager.rb +141 -0
  13. data/lib/bosh-cloudfoundry/config.rb +6 -0
  14. data/lib/bosh-cloudfoundry/config/common_config.rb +27 -0
  15. data/lib/bosh-cloudfoundry/config/dea_config.rb +150 -0
  16. data/lib/bosh-cloudfoundry/config/microbosh_config.rb +106 -0
  17. data/lib/bosh-cloudfoundry/config/postgresql_service_config.rb +185 -0
  18. data/lib/bosh-cloudfoundry/config/redis_service_config.rb +179 -0
  19. data/lib/bosh-cloudfoundry/config/system_config.rb +60 -0
  20. data/lib/bosh-cloudfoundry/config_options.rb +362 -0
  21. data/lib/bosh-cloudfoundry/gerrit_patches_helper.rb +47 -0
  22. data/lib/bosh-cloudfoundry/providers.rb +19 -0
  23. data/lib/bosh-cloudfoundry/providers/aws.rb +75 -0
  24. data/lib/bosh-cloudfoundry/system_deployment_manifest_renderer.rb +286 -0
  25. data/lib/bosh-cloudfoundry/version.rb +5 -0
  26. data/lib/bosh/cli/commands/cf.rb +668 -0
  27. data/spec/assets/.gitkeep +0 -0
  28. data/spec/assets/cf-release/jobs/cloud_controller/templates/runtimes.yml +150 -0
  29. data/spec/assets/deployments/aws-core-1-m1.small-free-redis.yml +221 -0
  30. data/spec/assets/deployments/aws-core-1-m1.xlarge-free-postgresql-2-m1.small-free-postgresql.yml +248 -0
  31. data/spec/assets/deployments/aws-core-2-m1.xlarge-dea.yml +195 -0
  32. data/spec/assets/deployments/aws-core-only.yml +178 -0
  33. data/spec/assets/deployments/aws-core-with-nfs.yml +192 -0
  34. data/spec/functional/.gitkeep +0 -0
  35. data/spec/spec_helper.rb +41 -0
  36. data/spec/unit/.gitkeep +0 -0
  37. data/spec/unit/bosh_release_manager_spec.rb +36 -0
  38. data/spec/unit/cf_command_spec.rb +280 -0
  39. data/spec/unit/config/common_config_spec.rb +21 -0
  40. data/spec/unit/config/dea_config_spec.rb +92 -0
  41. data/spec/unit/config/microbosh_config_spec.rb +11 -0
  42. data/spec/unit/config/postgresql_service_config_spec.rb +103 -0
  43. data/spec/unit/config/redis_service_config_spec.rb +103 -0
  44. data/spec/unit/config/system_config_spec.rb +29 -0
  45. data/spec/unit/config_options_spec.rb +64 -0
  46. data/spec/unit/system_deployment_manifest_renderer_spec.rb +93 -0
  47. metadata +246 -0
File without changes
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
+
3
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
4
+
5
+ require "rubygems"
6
+ require "bundler"
7
+ Bundler.setup(:default, :test)
8
+
9
+ $:.unshift(File.expand_path("../../lib", __FILE__))
10
+
11
+ require "rspec/core"
12
+ require "cli" # BOSH CLI
13
+ require "bosh/cli/commands/cf" # "bosh cf COMMAND" commands added to bosh CLI
14
+
15
+ def spec_asset(filename)
16
+ File.expand_path("../assets/#{filename}", __FILE__)
17
+ end
18
+
19
+ def files_match(filename, expected_filename)
20
+ file = File.read(filename)
21
+ expected_file = File.read(expected_filename)
22
+ file.should == expected_file
23
+ end
24
+
25
+ RSpec.configure do |c|
26
+ c.before(:each) do
27
+ Bosh::Cli::Config.interactive = false
28
+ Bosh::Cli::Config.colorize = false
29
+ Bosh::Cli::Config.output = StringIO.new
30
+ end
31
+
32
+ c.color_enabled = true
33
+ end
34
+
35
+ def get_tmp_file_path(content)
36
+ tmp_file = File.open(File.join(Dir.mktmpdir, "tmp"), "w")
37
+ tmp_file.write(content)
38
+ tmp_file.close
39
+
40
+ tmp_file.path
41
+ end
File without changes
@@ -0,0 +1,36 @@
1
+ # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
+
3
+ require File.expand_path("../../spec_helper", __FILE__)
4
+
5
+ describe Bosh::CloudFoundry::BoshReleaseManager do
6
+ include Bosh::CloudFoundry::BoshReleaseManager
7
+ include FileUtils
8
+
9
+ attr_reader :system_config
10
+
11
+ before do
12
+ @system_dir = File.join(Dir.mktmpdir, "systems", "production")
13
+ mkdir_p(@system_dir)
14
+ @system_config = Bosh::CloudFoundry::Config::SystemConfig.new(@system_dir)
15
+ end
16
+
17
+ describe "switch release types" do
18
+ it "from final to dev" do
19
+ @system_config.release_name = "appcloud"
20
+ @system_config.release_version = "latest"
21
+ @system_config.save
22
+ switch_to_development_release
23
+ @system_config.release_name.should == "appcloud-dev"
24
+ @system_config.release_version.should == "latest"
25
+ end
26
+
27
+ it "from dev to final" do
28
+ @system_config.release_name = "appcloud-dev"
29
+ @system_config.release_version = "latest"
30
+ @system_config.save
31
+ switch_to_final_release
32
+ @system_config.release_name.should == "appcloud"
33
+ @system_config.release_version.should == "latest"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,280 @@
1
+ # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
+
3
+ require File.expand_path("../../spec_helper", __FILE__)
4
+
5
+ describe Bosh::Cli::Command::Base do
6
+ include FileUtils
7
+
8
+ before :each do
9
+ @config = File.join(Dir.mktmpdir, "bosh_config")
10
+ @common_config = File.join(Dir.mktmpdir, "bosh_common_config")
11
+ @cache = File.join(Dir.mktmpdir, "bosh_cache")
12
+ @systems_dir = File.join(Dir.mktmpdir, "systems")
13
+ @releases_dir = File.join(Dir.mktmpdir, "releases")
14
+ @stemcells_dir = File.join(Dir.mktmpdir, "stemcells")
15
+ @repos_dir = File.join(Dir.mktmpdir, "repos")
16
+ FileUtils.mkdir_p(@systems_dir)
17
+ FileUtils.mkdir_p(@releases_dir)
18
+ FileUtils.mkdir_p(@stemcells_dir)
19
+ FileUtils.mkdir_p(@repos_dir)
20
+ end
21
+
22
+ describe Bosh::Cli::Command::CloudFoundry do
23
+
24
+ before :each do
25
+ @cmd = Bosh::Cli::Command::CloudFoundry.new(nil)
26
+ @cmd.add_option(:non_interactive, true)
27
+ @cmd.add_option(:config, @config)
28
+ @cmd.add_option(:common_config, @common_config)
29
+ @cmd.add_option(:cache_dir, @cache)
30
+ @cmd.add_option(:base_systems_dir, @systems_dir)
31
+ end
32
+
33
+ it "sets/gets the target system" do
34
+ @cmd.system.should be_nil
35
+ FileUtils.mkdir_p(File.join(@systems_dir, "production"))
36
+ @cmd.set_system("production")
37
+ File.basename(@cmd.system).should == "production"
38
+ File.should be_directory(@cmd.system)
39
+ end
40
+
41
+ it "downloads stemcell and uploads it" do
42
+ @cmd.stub!(:bosh_target).and_return("http://9.8.7.6:25555")
43
+ @cmd.stub!(:bosh_target_uuid).and_return("DIRECTOR_UUID")
44
+ @cmd.should_receive(:`).
45
+ with("bosh public stemcells --tags aws,stable | grep ' bosh-stemcell-' | awk '{ print $2 }' | sort -r | head -n 1").
46
+ and_return("bosh-stemcell-aws-0.6.7.tgz")
47
+ @cmd.should_receive(:sh).
48
+ with("bosh -n --color download public stemcell bosh-stemcell-aws-0.6.7.tgz")
49
+ @cmd.should_receive(:sh).
50
+ with("bosh -n --color upload stemcell #{@stemcells_dir}/bosh-stemcell-aws-0.6.7.tgz")
51
+
52
+ @cmd.add_option(:stemcells_dir, @stemcells_dir)
53
+ @cmd.add_option(:repos_dir, @repos_dir)
54
+ @cmd.upload_stemcell
55
+ end
56
+
57
+ it "creates bosh stemcell and uploads it" do
58
+ mkdir_p(File.join(@repos_dir, "bosh", "agent"))
59
+ @cmd.stub!(:bosh_target).and_return("http://9.8.7.6:25555")
60
+ @cmd.stub!(:bosh_target_uuid).and_return("DIRECTOR_UUID")
61
+ @cmd.should_receive(:sh).with("git pull origin master")
62
+ @cmd.should_receive(:sh).with("bundle install --without development test")
63
+ @cmd.should_receive(:sh).with("sudo bundle exec rake stemcell:basic['aws']")
64
+ @cmd.should_receive(:sh).with("sudo chown -R vcap:vcap /var/tmp/bosh/agent-*")
65
+ @cmd.should_receive(:validate_stemcell_created_successfully)
66
+ @cmd.should_receive(:move_and_return_created_stemcell).
67
+ and_return(File.join(@stemcells_dir, "bosh-stemcell-aws-0.6.7.tgz"))
68
+ @cmd.should_receive(:sh).
69
+ with("bosh -n --color upload stemcell #{@stemcells_dir}/bosh-stemcell-aws-0.6.7.tgz")
70
+
71
+ @cmd.add_option(:stemcells_dir, @stemcells_dir)
72
+ @cmd.add_option(:repos_dir, @repos_dir)
73
+ @cmd.add_option(:custom, true)
74
+ @cmd.upload_stemcell
75
+ end
76
+
77
+ it "updates/creates/uploads final cf-release" do
78
+ cf_release_dir = File.join(@releases_dir, "cf-release")
79
+ FileUtils.mkdir_p(cf_release_dir)
80
+ @cmd.common_config.cf_release_dir = cf_release_dir
81
+
82
+ @cmd.should_receive(:sh).with("git pull origin master")
83
+ script = <<-BASH.gsub(/^ /, '')
84
+ grep -rI "github.com" * .gitmodules | awk 'BEGIN {FS=":"} { print($1) }' | uniq while read file
85
+ do
86
+ echo "changing - $file"
87
+ sed -i 's#git://github.com#https://github.com#g' $file
88
+ sed -i 's#git@github.com:#https://github.com:#g' $file
89
+ done
90
+ BASH
91
+ @cmd.should_receive(:sh).with("sed -i 's#git@github.com:#https://github.com/#g' .gitmodules")
92
+ @cmd.should_receive(:sh).with("sed -i 's#git://github.com#https://github.com#g' .gitmodules")
93
+ @cmd.should_receive(:sh).with("git submodule update --init --recursive")
94
+ @cmd.should_receive(:`).with("tail -n 1 releases/index.yml | awk '{print $2}'").
95
+ and_return("126")
96
+ @cmd.should_receive(:sh).with("bosh -n --color upload release releases/appcloud-126.yml")
97
+ @cmd.upload_release
98
+ end
99
+
100
+ it "updates/creates/uploads development/edge cf-release" do
101
+ cf_release_dir = File.join(@releases_dir, "cf-release")
102
+ FileUtils.mkdir_p(cf_release_dir)
103
+ @cmd.common_config.cf_release_dir = cf_release_dir
104
+ @cmd.add_option(:dev, true)
105
+
106
+ @cmd.should_receive(:sh).with("git pull origin master")
107
+ script = <<-BASH.gsub(/^ /, '')
108
+ grep -rI "github.com" * .gitmodules | awk 'BEGIN {FS=":"} { print($1) }' | uniq while read file
109
+ do
110
+ echo "changing - $file"
111
+ sed -i 's#git://github.com#https://github.com#g' $file
112
+ sed -i 's#git@github.com:#https://github.com:#g' $file
113
+ done
114
+ BASH
115
+ @cmd.should_receive(:sh).with("sed -i 's#git@github.com:#https://github.com/#g' .gitmodules")
116
+ @cmd.should_receive(:sh).with("sed -i 's#git://github.com#https://github.com#g' .gitmodules")
117
+ @cmd.should_receive(:sh).with("git submodule update --init --recursive")
118
+ @cmd.should_receive(:write_dev_config_file).with("appcloud-dev")
119
+ @cmd.should_receive(:sh).with("bosh create release --with-tarball --force")
120
+ @cmd.should_receive(:sh).with("bosh -n --color upload release")
121
+ @cmd.upload_release
122
+ end
123
+
124
+ def generate_new_system(cmd = nil)
125
+ cmd ||= begin
126
+ cmd = Bosh::Cli::Command::CloudFoundry.new(nil)
127
+ cmd.add_option(:non_interactive, true)
128
+ cmd.add_option(:config, @config)
129
+ cmd.add_option(:common_config, @common_config)
130
+ cmd.add_option(:cache_dir, @cache)
131
+ cmd.add_option(:base_systems_dir, @systems_dir)
132
+ cmd
133
+ end
134
+
135
+ cmd.stub!(:bosh_target).and_return("http://9.8.7.6:25555")
136
+ cmd.stub!(:bosh_target_uuid).and_return("DIRECTOR_UUID")
137
+ cmd.should_receive(:generate_common_password).and_return('c1oudc0wc1oudc0w')
138
+ cmd.should_receive(:bosh_releases).exactly(1).times.and_return([
139
+ {"name"=>"appcloud", "versions"=>["124", "126"], "in_use"=>[]},
140
+ {"name"=>"appcloud-dev", "versions"=>["124.1-dev", "126.1-dev"], "in_use"=>[]},
141
+ ])
142
+ cmd.should_receive(:validate_dns_a_record).with("api.mycompany.com", '1.2.3.4').and_return(true)
143
+ cmd.should_receive(:validate_dns_a_record).with("demoapp.mycompany.com", '1.2.3.4').and_return(true)
144
+ cmd.should_receive(:bosh_stemcell_versions).exactly(4).times.and_return(['0.6.4'])
145
+ cmd.should_receive(:render_system)
146
+
147
+ provider = Bosh::CloudFoundry::Providers::AWS.new
148
+ ports = {
149
+ ssh: 22, http: 80, https: 433,
150
+ postgres: 2544, resque: 3456,
151
+ nats: 4222, router: 8080, uaa: 8100
152
+ }
153
+ provider.should_receive(:create_security_group).with("cloudfoundry-production", ports)
154
+ Bosh::CloudFoundry::Providers.should_receive(:for_bosh_provider_name).and_return(provider)
155
+
156
+ cmd.add_option(:core_ip, '1.2.3.4')
157
+ cmd.add_option(:root_dns, 'mycompany.com')
158
+ cmd.add_option(:cf_release, 'appcloud')
159
+ cmd.add_option(:core_server_flavor, 'm1.large')
160
+ cmd.add_option(:admin_emails, ['drnic@starkandwayne.com'])
161
+
162
+ cmd.common_config.cf_release_dir = @releases_dir
163
+ cmd.common_config.stemcells_dir = @stemcells_dir
164
+
165
+ cmd.system.should be_nil
166
+ cmd.prepare_system("production")
167
+
168
+ # expected from generate_new_system via Command#render_system
169
+ mkdir_p(File.join(cmd.system, "deployments"))
170
+ end
171
+
172
+ it "creates new system" do
173
+ generate_new_system(@cmd)
174
+ File.basename(@cmd.system).should == "production"
175
+ end
176
+
177
+ it "new system has common random password" do
178
+ generate_new_system(@cmd)
179
+ @cmd.system_config.common_password.should == "c1oudc0wc1oudc0w"
180
+ end
181
+
182
+ it "sets 3 x m1.large dea server" do
183
+ generate_new_system
184
+
185
+ @cmd.should_receive(:render_system)
186
+
187
+ @cmd.stub!(:bosh_target).and_return("http://9.8.7.6:25555")
188
+ @cmd.add_option(:flavor, 'm1.xlarge')
189
+ @cmd.change_deas(3)
190
+
191
+ @cmd.system_config.dea.should == { "count" => 3, "flavor" => 'm1.xlarge' }
192
+ end
193
+
194
+ it "fails for unknown service" do
195
+ generate_new_system
196
+ @cmd.stub!(:bosh_target).and_return("http://9.8.7.6:25555")
197
+ expect {
198
+ @cmd.add_service_node("UNKNOWN")
199
+ }.to raise_error(Bosh::Cli::CliError)
200
+ end
201
+
202
+ it "add 4 postgresql nodes" do
203
+ generate_new_system
204
+
205
+ @cmd.should_receive(:render_system)
206
+
207
+ @cmd.stub!(:bosh_target).and_return("http://9.8.7.6:25555")
208
+ @cmd.add_option(:flavor, 'm1.large')
209
+ @cmd.add_service_node("postgresql", 4)
210
+
211
+ @cmd.system_config.postgresql.size.should == 1
212
+ postgresql_config = @cmd.system_config.postgresql.first
213
+ postgresql_config["flavor"].should == "m1.large"
214
+ postgresql_config["count"].should == 4
215
+ end
216
+
217
+ it "add 2 redis nodes" do
218
+ generate_new_system
219
+
220
+ @cmd.should_receive(:render_system)
221
+
222
+ @cmd.stub!(:bosh_target).and_return("http://9.8.7.6:25555")
223
+ @cmd.add_option(:flavor, 'm1.large')
224
+ @cmd.add_service_node("redis", 2)
225
+
226
+ @cmd.system_config.redis.size.should == 1
227
+ redis_config = @cmd.system_config.redis.first
228
+ redis_config["flavor"].should == "m1.large"
229
+ redis_config["count"].should == 2
230
+ end
231
+
232
+ it "shows the common internal password" do
233
+ generate_new_system
234
+ @cmd.system_config.common_password.should == 'c1oudc0wc1oudc0w'
235
+ @cmd.show_password
236
+ end
237
+
238
+ # create some 'deployments/*.yml' files and
239
+ # assert that bosh attempted to deploy each one:
240
+ # bosh deployment deployments/aaa.yml
241
+ # bosh deploy
242
+ it "deploys all the manifests" do
243
+ generate_new_system
244
+ chdir(@cmd.system + "/deployments") do
245
+ cp(spec_asset("deployments/aws-core-only.yml"), "aws-core-only.yml")
246
+ cp(spec_asset("deployments/aws-core-2-m1.xlarge-dea.yml"), "deas.yml")
247
+ end
248
+ @cmd.should_receive(:set_deployment).exactly(2).times
249
+ @cmd.should_receive(:sh).with("bosh -n --color deploy").exactly(2).times
250
+ @cmd.deploy
251
+ end
252
+
253
+ it "watches nats traffic within CF deployment" do
254
+ generate_new_system
255
+ @cmd.should_receive(:deployment_manifest_path).with("core").
256
+ and_return(spec_asset("deployments/aws-core-only.yml"))
257
+ @cmd.should_receive(:sh).with("nats-sub '*.*' -s nats://nats:c1oudc0wc1oudc0w@1.2.3.4:4222")
258
+ @cmd.watch_nats
259
+ end
260
+
261
+ it "merges gerrit patches" do
262
+ generate_new_system
263
+ @cmd.should_receive(:create_and_change_into_patches_branch)
264
+ @cmd.should_receive(:sh).
265
+ with("git pull http://reviews.cloudfoundry.org/cf-release refs/changes/84/13084/4")
266
+ @cmd.should_receive(:create_and_upload_dev_release)
267
+ @cmd.merge_gerrit("refs/changes/84/13084/4")
268
+ end
269
+
270
+ it "returns bosh_release_versions" do
271
+ @cmd.should_receive(:bosh_releases).exactly(3).times.and_return([
272
+ {"name"=>"appcloud", "versions"=>["124", "126"], "in_use"=>[]},
273
+ {"name"=>"appcloud-dev", "versions"=>["124.1-dev", "126.1-dev"], "in_use"=>[]},
274
+ ])
275
+ @cmd.bosh_release_versions("appcloud").should == ["124", "126"]
276
+ @cmd.bosh_release_versions("appcloud-dev").should == ["124.1-dev", "126.1-dev"]
277
+ @cmd.bosh_release_versions("XXX").should == []
278
+ end
279
+ end
280
+ end
@@ -0,0 +1,21 @@
1
+ # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
+
3
+ require File.expand_path("../../../spec_helper", __FILE__)
4
+
5
+ describe Bosh::CloudFoundry::Config::CommonConfig do
6
+ before(:each) do
7
+ @dir = Dir.mktmpdir("common_config_spec")
8
+ end
9
+
10
+ after(:each) do
11
+ FileUtils.remove_entry_secure @dir
12
+ end
13
+
14
+ it "should default base_systems_dir and create it" do
15
+ config_file = File.join(@dir, "config.yml")
16
+ config = Bosh::CloudFoundry::Config::CommonConfig.new(config_file)
17
+
18
+ base_systems_dir = config.base_systems_dir
19
+ base_systems_dir.should == nil
20
+ end
21
+ end
@@ -0,0 +1,92 @@
1
+ # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
+
3
+ require File.expand_path("../../../spec_helper", __FILE__)
4
+
5
+ # The specification of how a user's DEA choices (count & flavor)
6
+ # are converted into deployment manifest configuration
7
+ describe Bosh::CloudFoundry::Config::DeaConfig do
8
+ include FileUtils
9
+
10
+ before do
11
+ @systems_dir = Dir.mktmpdir("system_config")
12
+ @system_dir = File.join(@systems_dir, "production")
13
+ mkdir_p(@system_dir)
14
+ @system_config = Bosh::CloudFoundry::Config::SystemConfig.new(@system_dir)
15
+ @system_config.bosh_provider = "aws"
16
+ @manifest = YAML.load_file(spec_asset("deployments/aws-core-only.yml"))
17
+ end
18
+
19
+ # find a specificly named job in the manifest
20
+ def job(name)
21
+ @manifest["jobs"].find { |job| job["name"] == name }
22
+ end
23
+
24
+ # find a specificly named resource pool in the manifest
25
+ def resource_pool(name)
26
+ @manifest["resource_pools"].find { |res| res["name"] == name }
27
+ end
28
+
29
+ describe "0 deas" do
30
+ subject { Bosh::CloudFoundry::Config::DeaConfig.build_from_system_config(@system_config) }
31
+ it "has 0 dea servers" do
32
+ subject.dea_server_count.should == 0
33
+ end
34
+ it "converted into a colocated dea on the core job" do
35
+ subject.add_core_jobs_to_manifest(@manifest)
36
+ job("core")["template"].should be_include("dea")
37
+ end
38
+ it "should not add a resoure pool called 'dea'" do
39
+ subject.add_resource_pools_to_manifest(@manifest)
40
+ @manifest["resource_pools"].size.should == 1
41
+ end
42
+ it "should not add a job called 'dea'" do
43
+ subject.add_jobs_to_manifest(@manifest)
44
+ @manifest["jobs"].size.should == 1
45
+ job("dea").should be_nil
46
+ end
47
+ it "sets the properties.dea.max_memory" do
48
+ subject.merge_manifest_properties(@manifest)
49
+ @manifest["properties"]["dea"].should_not be_nil
50
+ @manifest["properties"]["dea"]["max_memory"].should_not be_nil
51
+ @manifest["properties"]["dea"]["max_memory"].should == 512
52
+ end
53
+ end
54
+ describe "5 x m1.xlarge deas on AWS" do
55
+ subject do
56
+ @system_config.dea = { "count" => 5, "flavor" => 'm1.xlarge' }
57
+ Bosh::CloudFoundry::Config::DeaConfig.build_from_system_config(@system_config)
58
+ end
59
+ it "has 5 dea servers" do
60
+ subject.dea_server_count.should == 5
61
+ end
62
+ it "has dea servers of flavor 'm1.xlarge'" do
63
+ subject.dea_server_flavor.should == 'm1.xlarge'
64
+ end
65
+ it "does not add colocated job to core job" do
66
+ subject.add_core_jobs_to_manifest(@manifest)
67
+ job("core").should_not be_include("dea")
68
+ end
69
+ it "should add a resoure pool called 'dea'" do
70
+ subject.add_resource_pools_to_manifest(@manifest)
71
+ @manifest["resource_pools"].size.should == 2
72
+ resource_pool("dea").should_not be_nil
73
+ resource_pool("dea")["size"].should == 5
74
+ resource_pool("dea")["cloud_properties"]["instance_type"].should == "m1.xlarge"
75
+ end
76
+ it "converts 1 dea into an explicit dea job" do
77
+ subject.add_jobs_to_manifest(@manifest)
78
+ job("dea").should_not be_nil
79
+ job("dea")["template"].should == ["dea"]
80
+ job("dea")["instances"].should == 5
81
+ end
82
+ it "sets the properties.dea.max_memory for each m1.xlarge server" do
83
+ Bosh::CloudFoundry::Providers.should_receive(:for_bosh_provider_name).
84
+ and_return(Bosh::CloudFoundry::Providers::AWS.new)
85
+ # m1.xlarge has 15G RAM
86
+ subject.merge_manifest_properties(@manifest)
87
+ @manifest["properties"]["dea"].should_not be_nil
88
+ @manifest["properties"]["dea"]["max_memory"].should_not be_nil
89
+ @manifest["properties"]["dea"]["max_memory"].should == 15060
90
+ end
91
+ end
92
+ end