dnapi 1.1.74.jruby192.c

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/lib/dnapi.rb +54 -0
  2. data/lib/dnapi/app.rb +130 -0
  3. data/lib/dnapi/component.rb +50 -0
  4. data/lib/dnapi/component_possessor.rb +49 -0
  5. data/lib/dnapi/components/addons.rb +26 -0
  6. data/lib/dnapi/components/apache.rb +13 -0
  7. data/lib/dnapi/components/cloudkick.rb +13 -0
  8. data/lib/dnapi/components/encrypted_backup.rb +12 -0
  9. data/lib/dnapi/components/exim.rb +10 -0
  10. data/lib/dnapi/components/monitor.rb +12 -0
  11. data/lib/dnapi/components/nagios.rb +28 -0
  12. data/lib/dnapi/components/newrelic.rb +12 -0
  13. data/lib/dnapi/components/passenger3.rb +13 -0
  14. data/lib/dnapi/components/ruby.rb +234 -0
  15. data/lib/dnapi/components/ssmtp.rb +10 -0
  16. data/lib/dnapi/components/stunneled.rb +13 -0
  17. data/lib/dnapi/components/volume.rb +32 -0
  18. data/lib/dnapi/cron.rb +5 -0
  19. data/lib/dnapi/db_stack.rb +92 -0
  20. data/lib/dnapi/ebuild_dep.rb +5 -0
  21. data/lib/dnapi/environment.rb +327 -0
  22. data/lib/dnapi/extensions.rb +32 -0
  23. data/lib/dnapi/gem_dep.rb +9 -0
  24. data/lib/dnapi/instance.rb +69 -0
  25. data/lib/dnapi/monitoring.rb +22 -0
  26. data/lib/dnapi/recipe.rb +27 -0
  27. data/lib/dnapi/ssl_cert.rb +13 -0
  28. data/lib/dnapi/stack.rb +111 -0
  29. data/lib/dnapi/struct.rb +149 -0
  30. data/lib/dnapi/test.rb +114 -0
  31. data/lib/dnapi/test/ext.rb +32 -0
  32. data/lib/dnapi/test/sweatshop.rb +148 -0
  33. data/lib/dnapi/version.rb +3 -0
  34. data/lib/dnapi/vhost.rb +24 -0
  35. data/spec/app_spec.rb +68 -0
  36. data/spec/component_spec.rb +66 -0
  37. data/spec/components/addons_spec.rb +33 -0
  38. data/spec/components/cloudkick_spec.rb +17 -0
  39. data/spec/components/nagios_spec.rb +42 -0
  40. data/spec/components/nodejs_spec.rb +27 -0
  41. data/spec/components/passenger3_spec.rb +12 -0
  42. data/spec/components/ruby_spec.rb +321 -0
  43. data/spec/components/stunneled.rb +15 -0
  44. data/spec/components/volume_spec.rb +21 -0
  45. data/spec/db_stack_spec.rb +111 -0
  46. data/spec/environment_spec.rb +227 -0
  47. data/spec/instance_spec.rb +52 -0
  48. data/spec/proxies.rb +143 -0
  49. data/spec/proxies_spec.rb +76 -0
  50. data/spec/spec_helper.rb +2 -0
  51. data/spec/stack_spec.rb +105 -0
  52. data/spec/struct_spec.rb +100 -0
  53. metadata +181 -0
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe DNApi::Components::NodeJS do
4
+ before do
5
+ @environment = DNApi::Environment.new
6
+ @nodejs = @environment.add_component(:nodejs)
7
+ end
8
+
9
+ describe "#label" do
10
+ it "should have the right label" do
11
+ described_class.label.should == 'Node.js - 0.6.1'
12
+ @nodejs.label.should == 'Node.js - 0.6.1'
13
+ end
14
+ end
15
+
16
+ describe "#name" do
17
+ it { @nodejs.name.should == 'Node.js' }
18
+ end
19
+
20
+ describe "#version" do
21
+ it { @nodejs.version.should == '0.6' }
22
+ end
23
+
24
+ describe "#patch_level" do
25
+ it { @nodejs.patch_level.should == '1' }
26
+ end
27
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe DNApi::Components::Passenger3 do
4
+ before :each do
5
+ @environment = DNApi::Environment.new
6
+ @environment.add_component :passenger3
7
+ end
8
+
9
+ it 'is the win' do
10
+ @environment.should have_component(:passenger3)
11
+ end
12
+ end
@@ -0,0 +1,321 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe DNApi::Components::Ruby186 do
4
+ before do
5
+ @environment = DNApi::Environment.new
6
+ @ruby = @environment.add_component(:ruby_186)
7
+ end
8
+
9
+ describe "#label" do
10
+ it "should have the right label" do
11
+ described_class.label.should == 'Ruby 1.8.6'
12
+ @ruby.label.should == 'Ruby 1.8.6'
13
+ end
14
+ end
15
+
16
+ describe "#name" do
17
+ it 'is Ruby' do
18
+ @ruby.name.should == 'Ruby'
19
+ end
20
+ end
21
+
22
+ describe "#version" do
23
+ it 'is 1.8.6' do
24
+ @ruby.version.should == '1.8.6'
25
+ end
26
+ end
27
+
28
+ describe "#patch_level" do
29
+ it 'is 420' do
30
+ @ruby.patch_level.should == '420'
31
+ end
32
+ end
33
+
34
+ describe "#rubygems_version" do
35
+ it 'is 1.4.2' do
36
+ @ruby.rubygems_version.should == '1.4.2'
37
+ end
38
+ end
39
+ end
40
+
41
+ describe DNApi::Components::Ruby187 do
42
+ before do
43
+ @environment = DNApi::Environment.new
44
+ @ruby = @environment.add_component(:ruby_187)
45
+ end
46
+
47
+ describe "#label" do
48
+ it "should have the right label" do
49
+ described_class.label.should == 'Ruby 1.8.7'
50
+ @ruby.label.should == 'Ruby 1.8.7'
51
+ end
52
+ end
53
+
54
+ describe "#name" do
55
+ it 'is Ruby' do
56
+ @ruby.name.should == 'Ruby'
57
+ end
58
+ end
59
+
60
+ describe "#version" do
61
+ it 'is 1.8.7' do
62
+ @ruby.version.should == '1.8.7'
63
+ end
64
+ end
65
+
66
+ describe "#patch_level" do
67
+ it 'is 352' do
68
+ @ruby.patch_level.should == '352'
69
+ end
70
+ end
71
+
72
+ describe "#rubygems_version" do
73
+ it 'is 1.5.2' do
74
+ @ruby.rubygems_version.should == '1.5.2'
75
+ end
76
+ end
77
+ end
78
+
79
+ describe DNApi::Components::REE do
80
+ before do
81
+ @environment = DNApi::Environment.new
82
+ @ruby = @environment.add_component(:ree)
83
+ end
84
+
85
+ describe "#label" do
86
+ it "should have the right label" do
87
+ described_class.label.should == 'REE 2011.03'
88
+ @ruby.label.should == 'REE 2011.03'
89
+ end
90
+ end
91
+
92
+ describe "#name" do
93
+ it 'is REE' do
94
+ @ruby.name.should == 'REE'
95
+ end
96
+ end
97
+
98
+ describe "#version" do
99
+ it 'is 1.8.7' do
100
+ @ruby.version.should == '1.8.7'
101
+ end
102
+ end
103
+
104
+ describe "#patch_level" do
105
+ it 'is 2011.03' do
106
+ @ruby.patch_level.should == '2011.03'
107
+ end
108
+ end
109
+
110
+ describe "#rubygems_version" do
111
+ it 'is 1.5.2' do
112
+ @ruby.rubygems_version.should == '1.5.2'
113
+ end
114
+ end
115
+ end
116
+
117
+ describe DNApi::Components::Ruby192 do
118
+ before :each do
119
+ @environment = DNApi::Environment.new
120
+ @ruby = @environment.add_component(:ruby_192)
121
+ end
122
+
123
+ describe "#label" do
124
+ it ' is "Ruby 1.9.2"' do
125
+ described_class.label.should == 'Ruby 1.9.2'
126
+ @ruby.label.should == 'Ruby 1.9.2'
127
+ end
128
+ end
129
+
130
+ describe "#name" do
131
+ it 'is Ruby' do
132
+ @ruby.name.should == 'Ruby'
133
+ end
134
+ end
135
+
136
+ describe "#version" do
137
+ it 'is 1.9.2' do
138
+ @ruby.version.should == '1.9.2'
139
+ end
140
+ end
141
+
142
+ describe "#patch_level" do
143
+ it 'is 290' do
144
+ @ruby.patch_level.should == '290-r1'
145
+ end
146
+ end
147
+
148
+ describe "#rubygems_version" do
149
+ it 'is 1.5.2' do
150
+ @ruby.rubygems_version.should == '1.5.2'
151
+ end
152
+ end
153
+ end
154
+
155
+ describe DNApi::Components::Ruby193 do
156
+ before :each do
157
+ @environment = DNApi::Environment.new
158
+ @ruby = @environment.add_component(:ruby_193)
159
+ end
160
+
161
+ describe "#label" do
162
+ it ' is "Ruby 1.9.3"' do
163
+ described_class.label.should == 'Ruby 1.9.3'
164
+ @ruby.label.should == 'Ruby 1.9.3'
165
+ end
166
+ end
167
+
168
+ describe "#name" do
169
+ it 'is Ruby' do
170
+ @ruby.name.should == 'Ruby'
171
+ end
172
+ end
173
+
174
+ describe "#version" do
175
+ it 'is 1.9.3' do
176
+ @ruby.version.should == '1.9.3'
177
+ end
178
+ end
179
+
180
+ describe "#patch_level" do
181
+ it 'is p0' do
182
+ @ruby.patch_level.should == 'p0'
183
+ end
184
+ end
185
+
186
+ describe "#rubygems_version" do
187
+ it 'is 1.8.11' do
188
+ @ruby.rubygems_version.should == '1.8.11'
189
+ end
190
+ end
191
+
192
+ describe "#ruby_version" do
193
+ it "is 1.9.3_rc1" do
194
+ @ruby.ruby_version.should == '1.9.3_p0'
195
+ end
196
+ end
197
+ end
198
+
199
+ describe DNApi::Components::Rubinius do
200
+ before do
201
+ @environment = DNApi::Environment.new
202
+ @ruby = @environment.add_component(:rubinius)
203
+ end
204
+
205
+ describe "#label" do
206
+ it "should have the right label" do
207
+ described_class.label.should == 'Rubinius 1.2.4'
208
+ @ruby.label.should == 'Rubinius 1.2.4'
209
+ end
210
+ end
211
+
212
+ describe "#name" do
213
+ it 'is Rubinius' do
214
+ @ruby.name.should == 'Rubinius'
215
+ end
216
+ end
217
+
218
+ describe "#version" do
219
+ it 'is 1.2.3' do
220
+ @ruby.version.should == '1.2.4'
221
+ end
222
+ end
223
+
224
+ describe "#patch_level" do
225
+ it 'is nil' do
226
+ @ruby.patch_level.should be_nil
227
+ end
228
+ end
229
+
230
+ describe "#rubygems_version" do
231
+ it 'is 1.5.2' do
232
+ @ruby.rubygems_version.should == '1.5.2'
233
+ end
234
+ end
235
+ end
236
+
237
+ describe 'JRuby' do
238
+ [DNApi::Components::JRuby187, DNApi::Components::JRuby192].each do |jruby|
239
+ describe jruby do
240
+ before do
241
+ @environment = DNApi::Environment.new
242
+ @ruby = @environment.add_component(jruby.key_id)
243
+ end
244
+
245
+ describe "#label" do
246
+ it "should have the right label" do
247
+ described_class.label.should == "JRuby 1.6.5 #{jruby.compat_version}"
248
+ @ruby.label.should == "JRuby 1.6.5 #{jruby.compat_version}"
249
+ end
250
+ end
251
+
252
+ describe "#name" do
253
+ it 'is JRuby' do
254
+ @ruby.name.should == 'JRuby'
255
+ end
256
+ end
257
+
258
+ describe "#version" do
259
+ it 'is 1.6.5' do
260
+ @ruby.version.should == '1.6.5'
261
+ end
262
+ end
263
+
264
+ describe "#patch_level" do
265
+ it 'is nil' do
266
+ @ruby.patch_level.should be_nil
267
+ end
268
+ end
269
+
270
+ describe "#rubygems_version" do
271
+ it 'is 1.5.1' do
272
+ @ruby.rubygems_version.should == '1.5.1'
273
+ end
274
+ end
275
+ end
276
+ end
277
+ end
278
+
279
+ describe DNApi::Components::RubyVersion do
280
+ describe ".all" do
281
+ it "should return all ruby versions" do
282
+ [ DNApi::Components::Ruby186,
283
+ DNApi::Components::Ruby187,
284
+ DNApi::Components::REE,
285
+ DNApi::Components::JRuby187,
286
+ DNApi::Components::JRuby192,
287
+ DNApi::Components::Rubinius,
288
+ DNApi::Components::Ruby192,
289
+ DNApi::Components::Ruby193 ].each do |ruby_version|
290
+ DNApi::Components::RubyVersion.all.should include(ruby_version)
291
+ end
292
+ end
293
+ end
294
+
295
+ it "should return the app server stacks that support it on app_server_stacks" do
296
+ DNApi::Components::RubyVersion.all.each do |ruby_version|
297
+ ruby_version.new.app_server_stacks.should_not be_empty
298
+ ruby_version.new.app_server_stacks.each do |app_server_stack|
299
+ app_server_stack.ruby_versions.should include(ruby_version)
300
+ end
301
+ end
302
+ end
303
+
304
+ it "knows the version of the package to install" do
305
+ DNApi::Components::RubyVersion.all.each {|r| r.new.should respond_to(:ruby_version)}
306
+ end
307
+
308
+ it "knows the name of the package to install" do
309
+ DNApi::Components::RubyVersion.all.each {|r| r.new.should respond_to(:ruby_flavor)}
310
+ end
311
+
312
+ it "knows the name of the ruby module to install" do
313
+ DNApi::Components::RubyVersion.all.each {|r| r.new.should respond_to(:ruby_module)}
314
+ end
315
+
316
+ it "includes the mysql_adapter legacy method to deal with old versions of the cookbooks" do
317
+ non_encoding_aware = DNApi::Components::RubyVersion.all - DNApi::Components::RubyVersion.encoding_aware
318
+ non_encoding_aware.each {|r| r.new.mysql_adapter.should == 'mysql'}
319
+ DNApi::Components::RubyVersion.encoding_aware.each {|r| r.new.mysql_adapter.should == 'mysql2'}
320
+ end
321
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe DNApi::Components::Stunneled do
4
+ before :each do
5
+ @environment = DNApi::Environment.new
6
+ @environment.add_component :stunneled
7
+ end
8
+
9
+ context "An Environment" do
10
+ it 'has the component' do
11
+ @environment.should have_component(:stunneled)
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,21 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe DNApi::Components::Volume do
4
+ before :each do
5
+ @environment = DNApi::Environment.new
6
+ @instance = @environment.build_instance(:id => 'default', :role => :app_master)
7
+ @volume = @instance.add_component(:ebs_volume,
8
+ :mountpoint => '/data',
9
+ :size => 5 * 1024 * 1024,
10
+ :warn_at_percent => 10,
11
+ :fail_at_percent => 5)
12
+ end
13
+
14
+ it 'computes the correct warn_at' do
15
+ @volume.warn_at.should == 524288
16
+ end
17
+
18
+ it 'computes the correct fail_at' do
19
+ @volume.fail_at.should == 262144
20
+ end
21
+ end
@@ -0,0 +1,111 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "DNApi::DbStack" do
4
+ it "knows if it is mysql" do
5
+ DNApi::DbStack::Mysql.should be_mysql
6
+ DNApi::DbStack::Mysql5_1.should_not be_mysql
7
+ DNApi::DbStack::Mysql5_5.should_not be_mysql
8
+ DNApi::DbStack::Postgres.should_not be_mysql
9
+ DNApi::DbStack::Postgres9.should_not be_mysql
10
+ DNApi::DbStack::Postgres91.should_not be_mysql
11
+ end
12
+
13
+ it "knows if it is mysql5_1" do
14
+ DNApi::DbStack::Mysql.should_not be_mysql5_1
15
+ DNApi::DbStack::Mysql5_1.should be_mysql5_1
16
+ DNApi::DbStack::Mysql5_5.should_not be_mysql5_1
17
+ DNApi::DbStack::Postgres.should_not be_mysql5_1
18
+ DNApi::DbStack::Postgres9.should_not be_mysql5_1
19
+ DNApi::DbStack::Postgres91.should_not be_mysql5_1
20
+ end
21
+
22
+ it "knows if it is mysql5_5" do
23
+ DNApi::DbStack::Mysql.should_not be_mysql5_5
24
+ DNApi::DbStack::Mysql5_1.should_not be_mysql5_5
25
+ DNApi::DbStack::Mysql5_5.should be_mysql5_5
26
+ DNApi::DbStack::Postgres.should_not be_mysql5_5
27
+ DNApi::DbStack::Postgres9.should_not be_mysql5_5
28
+ DNApi::DbStack::Postgres91.should_not be_mysql5_5
29
+ end
30
+
31
+ it "knows if it is postgres" do
32
+ DNApi::DbStack::Mysql.should_not be_postgres
33
+ DNApi::DbStack::Mysql5_1.should_not be_postgres
34
+ DNApi::DbStack::Mysql5_5.should_not be_postgres
35
+ DNApi::DbStack::Postgres.should be_postgres
36
+ DNApi::DbStack::Postgres9.should_not be_postgres
37
+ DNApi::DbStack::Postgres91.should_not be_postgres
38
+ end
39
+
40
+ it "knows if it is postgres 9" do
41
+ DNApi::DbStack::Mysql.should_not be_postgres9
42
+ DNApi::DbStack::Mysql5_1.should_not be_postgres9
43
+ DNApi::DbStack::Mysql5_5.should_not be_postgres9
44
+ DNApi::DbStack::Postgres.should_not be_postgres9
45
+ DNApi::DbStack::Postgres9.should be_postgres9
46
+ DNApi::DbStack::Postgres91.should_not be_postgres9
47
+ end
48
+
49
+ it "knows if it is postgres 91" do
50
+ DNApi::DbStack::Mysql.should_not be_postgres9_1
51
+ DNApi::DbStack::Mysql5_1.should_not be_postgres9_1
52
+ DNApi::DbStack::Mysql5_5.should_not be_postgres9_1
53
+ DNApi::DbStack::Postgres.should_not be_postgres9_1
54
+ DNApi::DbStack::Postgres9.should_not be_postgres9_1
55
+ DNApi::DbStack::Postgres91.should be_postgres9_1
56
+ end
57
+
58
+ it "knows if it supports replication" do
59
+ DNApi::DbStack::Mysql.supports_replication?.should be_true
60
+ DNApi::DbStack::Mysql5_1.supports_replication?.should be_true
61
+ DNApi::DbStack::Mysql5_5.supports_replication?.should be_true
62
+ DNApi::DbStack::Postgres.supports_replication?.should be_false
63
+ DNApi::DbStack::Postgres9.supports_replication?.should be_true
64
+ DNApi::DbStack::Postgres91.supports_replication?.should be_true
65
+ end
66
+
67
+ it "knows its backup command" do
68
+ DNApi::DbStack::Mysql.backup_command.should == 'eybackup --quiet'
69
+ DNApi::DbStack::Mysql5_1.backup_command.should == 'eybackup -e mysql --quiet'
70
+ DNApi::DbStack::Mysql5_5.backup_command.should == 'eybackup -e mysql --quiet'
71
+ DNApi::DbStack::Postgres.backup_command.should == 'eybackup -e postgresql --quiet'
72
+ DNApi::DbStack::Postgres9.backup_command.should == 'eybackup -e postgresql --quiet'
73
+ DNApi::DbStack::Postgres9.backup_command.should == 'eybackup -e postgresql --quiet'
74
+ end
75
+
76
+ it "has a meaningful label" do
77
+ DNApi::DbStack::Mysql.label.should == 'MySQL 5.0.x'
78
+ DNApi::DbStack::Mysql5_1.label.should == 'MySQL 5.1.x'
79
+ DNApi::DbStack::Mysql5_5.label.should == 'MySQL 5.5.x'
80
+ DNApi::DbStack::Postgres.label.should == 'PostgreSQL 8.3.x'
81
+ DNApi::DbStack::Postgres9.label.should == 'PostgreSQL 9.0.x'
82
+ DNApi::DbStack::Postgres91.label.should == 'PostgreSQL 9.1.x'
83
+ end
84
+
85
+ context "selects the adapter for each component" do
86
+ it "is always postgresql for PostgreSQL stack" do
87
+ DNApi::Components::RubyVersion.all.each do |component|
88
+ DNApi::DbStack::Postgres.adapter_for(component.new).should == 'postgresql'
89
+ DNApi::DbStack::Postgres9.adapter_for(component.new).should == 'postgresql'
90
+ DNApi::DbStack::Postgres9.adapter_for(component.new).should == 'postgresql'
91
+ end
92
+ end
93
+
94
+ it "is mysql2 for Mysql with Ruby19 and Rubinius" do
95
+ encoding_aware = DNApi::Components::RubyVersion.encoding_aware
96
+ db_stacks = [DNApi::DbStack::Mysql, DNApi::DbStack::Mysql5_1, DNApi::DbStack::Mysql5_5]
97
+
98
+ encoding_aware.each do |component|
99
+ db_stacks.each do |db_stack|
100
+ db_stack.adapter_for(component.new).should == 'mysql2'
101
+ end
102
+ end
103
+
104
+ (DNApi::Components::RubyVersion.all - encoding_aware).each do |component|
105
+ db_stacks.each do |db_stack|
106
+ db_stack.adapter_for(component.new).should == 'mysql'
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end