poolparty 0.0.4 → 0.2.6

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 (247) hide show
  1. data/History.txt +25 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +203 -0
  4. data/PostInstall.txt +18 -0
  5. data/README.txt +21 -82
  6. data/Rakefile +25 -18
  7. data/bin/cloud +31 -0
  8. data/bin/cloud-add-keypair +23 -0
  9. data/bin/cloud-configure +31 -0
  10. data/bin/cloud-contract +27 -0
  11. data/bin/cloud-expand +27 -0
  12. data/bin/cloud-list +32 -0
  13. data/bin/cloud-maintain +36 -0
  14. data/bin/cloud-osxcopy +22 -0
  15. data/bin/cloud-provision +31 -0
  16. data/bin/cloud-refresh +26 -0
  17. data/bin/cloud-ssh +18 -0
  18. data/bin/cloud-start +32 -0
  19. data/bin/cloud-terminate +23 -0
  20. data/bin/pool +25 -27
  21. data/bin/pool-console +12 -0
  22. data/bin/pool-describe +9 -0
  23. data/bin/pool-list +28 -0
  24. data/bin/pool-provision +34 -0
  25. data/bin/pool-spec +17 -0
  26. data/bin/pool-start +32 -0
  27. data/bin/pool-start-monitor +1 -0
  28. data/config/hoe.rb +115 -0
  29. data/config/requirements.rb +15 -0
  30. data/examples/basic.rb +20 -0
  31. data/examples/plugin_without_plugin_directory.rb +13 -0
  32. data/examples/poolparty.rb +12 -0
  33. data/examples/with_apache_plugin.rb +22 -0
  34. data/generators/poolspec/USAGE +5 -0
  35. data/generators/poolspec/poolspec_generator.rb +65 -0
  36. data/generators/poolspec/templates/pool_spec_template.erb +9 -0
  37. data/lib/erlang/eb_server.erl +27 -0
  38. data/lib/poolparty.rb +56 -0
  39. data/lib/poolparty/base_packages/haproxy.rb +42 -0
  40. data/lib/poolparty/base_packages/heartbeat.rb +45 -0
  41. data/lib/poolparty/base_packages/poolparty.rb +36 -0
  42. data/lib/poolparty/base_packages/ruby.rb +43 -0
  43. data/lib/poolparty/core/array.rb +24 -0
  44. data/lib/{core → poolparty/core}/exception.rb +0 -0
  45. data/lib/poolparty/core/float.rb +13 -0
  46. data/lib/poolparty/core/hash.rb +29 -0
  47. data/lib/poolparty/core/kernel.rb +37 -0
  48. data/lib/{core → poolparty/core}/module.rb +18 -0
  49. data/lib/poolparty/core/my_open_struct.rb +18 -0
  50. data/lib/poolparty/core/object.rb +54 -0
  51. data/lib/poolparty/core/proc.rb +7 -0
  52. data/lib/poolparty/core/string.rb +72 -0
  53. data/lib/poolparty/core/symbol.rb +8 -0
  54. data/lib/{core → poolparty/core}/time.rb +15 -0
  55. data/lib/poolparty/exceptions/RemoteException.rb +12 -0
  56. data/lib/poolparty/exceptions/ResourceException.rb +7 -0
  57. data/lib/poolparty/exceptions/RuntimeException.rb +7 -0
  58. data/lib/poolparty/exceptions/SpecException.rb +7 -0
  59. data/lib/poolparty/exceptions/TemplateNotFound.rb +7 -0
  60. data/lib/poolparty/helpers/binary.rb +31 -0
  61. data/lib/poolparty/helpers/console.rb +30 -0
  62. data/lib/poolparty/helpers/display.rb +34 -0
  63. data/lib/poolparty/helpers/optioner.rb +64 -0
  64. data/lib/poolparty/helpers/provisioner_base.rb +250 -0
  65. data/lib/poolparty/helpers/provisioners/master.rb +136 -0
  66. data/lib/poolparty/helpers/provisioners/slave.rb +44 -0
  67. data/lib/poolparty/modules/cloud_resourcer.rb +89 -0
  68. data/lib/poolparty/modules/configurable.rb +34 -0
  69. data/lib/poolparty/modules/definable_resource.rb +59 -0
  70. data/lib/poolparty/modules/file_writer.rb +55 -0
  71. data/lib/poolparty/modules/method_missing_sugar.rb +53 -0
  72. data/lib/poolparty/modules/output.rb +13 -0
  73. data/lib/poolparty/modules/pretty_printer.rb +39 -0
  74. data/lib/{core/string.rb → poolparty/modules/s3_string.rb} +5 -22
  75. data/lib/{modules → poolparty/modules}/safe_instance.rb +0 -0
  76. data/lib/poolparty/monitors/base_monitor.rb +16 -0
  77. data/lib/poolparty/net/remote.rb +35 -0
  78. data/lib/poolparty/net/remote_bases/ec2.rb +148 -0
  79. data/lib/poolparty/net/remote_instance.rb +69 -0
  80. data/lib/poolparty/net/remoter.rb +224 -0
  81. data/lib/poolparty/net/remoter_base.rb +117 -0
  82. data/lib/poolparty/plugins/gem_package.rb +17 -0
  83. data/lib/poolparty/plugins/git.rb +41 -0
  84. data/lib/poolparty/plugins/line.rb +76 -0
  85. data/lib/poolparty/plugins/svn.rb +48 -0
  86. data/lib/poolparty/pool/base.rb +75 -0
  87. data/lib/poolparty/pool/cloud.rb +164 -0
  88. data/lib/poolparty/pool/custom_resource.rb +61 -0
  89. data/lib/poolparty/pool/loggable.rb +29 -0
  90. data/lib/poolparty/pool/plugin.rb +41 -0
  91. data/lib/poolparty/pool/plugin_model.rb +48 -0
  92. data/lib/poolparty/pool/pool.rb +55 -0
  93. data/lib/poolparty/pool/resource.rb +248 -0
  94. data/lib/poolparty/pool/resources/class_package.rb +64 -0
  95. data/lib/poolparty/pool/resources/conditional.rb +41 -0
  96. data/lib/poolparty/pool/resources/cron.rb +14 -0
  97. data/lib/poolparty/pool/resources/directory.rb +23 -0
  98. data/lib/poolparty/pool/resources/exec.rb +26 -0
  99. data/lib/poolparty/pool/resources/file.rb +23 -0
  100. data/lib/poolparty/pool/resources/gem.rb +14 -0
  101. data/lib/poolparty/pool/resources/host.rb +14 -0
  102. data/lib/poolparty/pool/resources/package.rb +14 -0
  103. data/lib/poolparty/pool/resources/remote_file.rb +22 -0
  104. data/lib/poolparty/pool/resources/service.rb +21 -0
  105. data/lib/poolparty/pool/resources/sshkey.rb +19 -0
  106. data/lib/poolparty/pool/resources/variable.rb +27 -0
  107. data/lib/poolparty/pool/script.rb +44 -0
  108. data/lib/poolparty/templates/authkeys +2 -0
  109. data/{config/monit/nginx.monit.conf → lib/poolparty/templates/cib.xml} +0 -0
  110. data/lib/poolparty/templates/fileserver.conf +4 -0
  111. data/lib/poolparty/templates/gem +25 -0
  112. data/{config/heartbeat.conf → lib/poolparty/templates/ha.cf} +3 -2
  113. data/{config → lib/poolparty/templates}/haproxy.conf +13 -6
  114. data/lib/poolparty/templates/namespaceauth.conf +19 -0
  115. data/lib/poolparty/templates/puppet.conf +17 -0
  116. data/lib/poolparty/version.rb +9 -0
  117. data/lib/poolpartycl.rb +3 -0
  118. data/poolparty.gemspec +56 -47
  119. data/script/destroy +14 -0
  120. data/script/generate +14 -0
  121. data/script/txt2html +82 -0
  122. data/setup.rb +1585 -0
  123. data/spec/poolparty/base_packages/haproxy_spec.rb +13 -0
  124. data/spec/poolparty/base_packages/heartbeat_spec.rb +30 -0
  125. data/spec/poolparty/bin/console_spec.rb +80 -0
  126. data/spec/poolparty/core/array_spec.rb +26 -0
  127. data/spec/poolparty/core/float.rb +13 -0
  128. data/spec/poolparty/core/hash_spec.rb +63 -0
  129. data/spec/poolparty/core/kernel_spec.rb +24 -0
  130. data/spec/poolparty/core/module_spec.rb +15 -0
  131. data/spec/poolparty/core/object_spec.rb +40 -0
  132. data/spec/poolparty/core/string_spec.rb +152 -0
  133. data/spec/poolparty/core/time_spec.rb +52 -0
  134. data/spec/poolparty/helpers/binary_spec.rb +26 -0
  135. data/spec/poolparty/helpers/display_spec.rb +13 -0
  136. data/spec/poolparty/helpers/optioner_spec.rb +39 -0
  137. data/spec/poolparty/helpers/provisioner_base_spec.rb +121 -0
  138. data/spec/poolparty/helpers/provisioners/master_spec.rb +54 -0
  139. data/spec/poolparty/helpers/provisioners/slave_spec.rb +28 -0
  140. data/spec/poolparty/modules/cloud_resourcer_spec.rb +135 -0
  141. data/spec/poolparty/modules/configurable_spec.rb +26 -0
  142. data/spec/poolparty/modules/definable_resource.rb +9 -0
  143. data/spec/poolparty/modules/file_writer_spec.rb +49 -0
  144. data/spec/poolparty/modules/s3_string_spec.rb +15 -0
  145. data/spec/poolparty/modules/tmp/willy/nilly.rb +1 -0
  146. data/spec/poolparty/net/remote_bases/ec2_spec.rb +92 -0
  147. data/spec/poolparty/net/remote_instance_spec.rb +70 -0
  148. data/spec/poolparty/net/remote_spec.rb +286 -0
  149. data/spec/poolparty/net/remoter_base_spec.rb +80 -0
  150. data/spec/poolparty/net/remoter_spec.rb +191 -0
  151. data/spec/poolparty/plugins/git_spec.rb +33 -0
  152. data/spec/poolparty/plugins/line_spec.rb +16 -0
  153. data/spec/poolparty/plugins/svn_spec.rb +16 -0
  154. data/spec/poolparty/pool/base_spec.rb +108 -0
  155. data/spec/poolparty/pool/cloud_spec.rb +299 -0
  156. data/spec/poolparty/pool/configurers/files/ruby_basic.rb +17 -0
  157. data/spec/poolparty/pool/configurers/files/ruby_plugins.rb +16 -0
  158. data/spec/poolparty/pool/configurers/ruby_spec.rb +58 -0
  159. data/spec/poolparty/pool/custom_resource_spec.rb +115 -0
  160. data/spec/poolparty/pool/example_spec.rb +112 -0
  161. data/spec/poolparty/pool/plugin_model_spec.rb +63 -0
  162. data/spec/poolparty/pool/plugin_spec.rb +85 -0
  163. data/spec/poolparty/pool/pool_spec.rb +83 -0
  164. data/spec/poolparty/pool/resource_spec.rb +224 -0
  165. data/spec/poolparty/pool/resources/class_package_spec.rb +84 -0
  166. data/spec/poolparty/pool/resources/conditional_spec.rb +38 -0
  167. data/spec/poolparty/pool/resources/cron_spec.rb +49 -0
  168. data/spec/poolparty/pool/resources/directory_spec.rb +40 -0
  169. data/spec/poolparty/pool/resources/exec_spec.rb +37 -0
  170. data/spec/poolparty/pool/resources/file_spec.rb +40 -0
  171. data/spec/poolparty/pool/resources/gem_spec.rb +16 -0
  172. data/spec/poolparty/pool/resources/host_spec.rb +28 -0
  173. data/spec/poolparty/pool/resources/package_spec.rb +44 -0
  174. data/spec/poolparty/pool/resources/remote_file_spec.rb +40 -0
  175. data/spec/poolparty/pool/resources/service_spec.rb +45 -0
  176. data/spec/poolparty/pool/resources/sshkey_spec.rb +48 -0
  177. data/spec/poolparty/pool/resources/variable_spec.rb +20 -0
  178. data/spec/poolparty/pool/script_spec.rb +51 -0
  179. data/spec/poolparty/pool/test_plugins/sshkey_test +2 -0
  180. data/{test/test_pool_party.rb → spec/poolparty/pool/test_plugins/virtual_host_template.erb} +0 -0
  181. data/spec/poolparty/pool/test_plugins/webserver.rb +46 -0
  182. data/spec/poolparty/poolparty_spec.rb +33 -0
  183. data/spec/poolparty/spec_helper.rb +120 -0
  184. data/tasks/cloud.rake +57 -0
  185. data/tasks/deployment.rake +34 -0
  186. data/tasks/development.rake +78 -0
  187. data/tasks/ec2.rake +20 -0
  188. data/tasks/environment.rake +7 -0
  189. data/tasks/instance.rake +63 -0
  190. data/tasks/server.rake +42 -0
  191. data/tasks/spec.rake +17 -0
  192. data/tasks/website.rake +17 -0
  193. data/test/test_generator_helper.rb +29 -0
  194. data/test/test_helper.rb +2 -0
  195. data/test/test_pool_spec_generator.rb +47 -0
  196. data/test/test_poolparty.rb +11 -0
  197. data/test_manifest.pp +538 -0
  198. data/website/index.html +107 -0
  199. data/website/index.txt +95 -0
  200. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  201. data/website/stylesheets/code.css +29 -0
  202. data/website/stylesheets/screen.css +147 -0
  203. data/website/template.html.erb +49 -0
  204. metadata +282 -101
  205. data/CHANGELOG +0 -4
  206. data/Manifest +0 -55
  207. data/bin/instance +0 -54
  208. data/config/config.yml +0 -23
  209. data/config/create_proxy_ami.sh +0 -582
  210. data/config/heartbeat_authkeys.conf +0 -2
  211. data/config/monit.conf +0 -8
  212. data/config/monit/haproxy.monit.conf +0 -7
  213. data/config/nginx.conf +0 -24
  214. data/lib/core/array.rb +0 -10
  215. data/lib/core/kernel.rb +0 -9
  216. data/lib/core/object.rb +0 -14
  217. data/lib/modules/callback.rb +0 -55
  218. data/lib/modules/ec2_wrapper.rb +0 -74
  219. data/lib/pool_party.rb +0 -69
  220. data/lib/pool_party/application.rb +0 -133
  221. data/lib/pool_party/init.rb +0 -4
  222. data/lib/pool_party/master.rb +0 -189
  223. data/lib/pool_party/monitors.rb +0 -13
  224. data/lib/pool_party/monitors/cpu.rb +0 -18
  225. data/lib/pool_party/monitors/memory.rb +0 -21
  226. data/lib/pool_party/monitors/web.rb +0 -18
  227. data/lib/pool_party/optioner.rb +0 -16
  228. data/lib/pool_party/os.rb +0 -11
  229. data/lib/pool_party/os/ubuntu.rb +0 -78
  230. data/lib/pool_party/remote_instance.rb +0 -180
  231. data/lib/pool_party/remoting.rb +0 -112
  232. data/lib/pool_party/scheduler.rb +0 -93
  233. data/lib/pool_party/tasks.rb +0 -220
  234. data/lib/s3/s3_object_store_folders.rb +0 -44
  235. data/spec/application_spec.rb +0 -32
  236. data/spec/callback_spec.rb +0 -65
  237. data/spec/helpers/ec2_mock.rb +0 -56
  238. data/spec/helpers/remote_instance_mock.rb +0 -11
  239. data/spec/kernel_spec.rb +0 -11
  240. data/spec/master_spec.rb +0 -147
  241. data/spec/monitor_spec.rb +0 -16
  242. data/spec/optioner_spec.rb +0 -22
  243. data/spec/poolparty_spec.rb +0 -8
  244. data/spec/remote_instance_spec.rb +0 -29
  245. data/spec/remoting_spec.rb +0 -75
  246. data/spec/spec_helper.rb +0 -38
  247. data/spec/string_spec.rb +0 -28
@@ -0,0 +1,299 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ include PoolParty::Cloud
4
+ class TestServiceClass
5
+ plugin :test_service do
6
+ def enable
7
+ has_file(:name => "/etc/poolparty/lobos")
8
+ end
9
+ end
10
+ end
11
+
12
+ describe "Cloud" do
13
+ before(:each) do
14
+ @obj = Object.new
15
+ @pool = pool :just_pool do; end
16
+ end
17
+ it "should respond to the pool method outside the block" do
18
+ @obj.respond_to?(:cloud).should == true
19
+ end
20
+ describe "global" do
21
+ before(:each) do
22
+ @cloud1 = cloud :pop do;end
23
+ end
24
+ it "should store the cloud in the global list of clouds" do
25
+ @obj.clouds.has_key?(:pop).should == true
26
+ end
27
+ it "should store the cloud" do
28
+ @obj.cloud(:pop).should == @cloud1
29
+ end
30
+ it "should have set the using base on intantiation to ec2" do
31
+ @cloud1.using_remoter?.should_not == nil
32
+ end
33
+ it "should say the remoter_base is ec2 (by default)" do
34
+ @cloud1.remote_base.should == PoolParty::Ec2
35
+ end
36
+ end
37
+ it "should return the cloud if the cloud key is already in the clouds list" do
38
+ @cld = cloud :pop do;end
39
+ @pool.cloud(:pop).should == @cld
40
+ end
41
+ describe "options" do
42
+ before(:each) do
43
+ reset!
44
+ @p = pool :options do
45
+ minimum_instances 100
46
+ access_key "access_key"
47
+ cloud :apple do
48
+ access_key "cloud_access_key"
49
+ end
50
+ end
51
+ @c = @p.cloud(:apple)
52
+ end
53
+ it "should be able to grab the cloud from the pool" do
54
+ @c.should == @p.cloud(:apple)
55
+ end
56
+ it "should take the options set on the pool" do
57
+ @p.minimum_instances.should == 100
58
+ end
59
+ it "should take the access_key option set from the cloud" do
60
+ @c.access_key.should == "cloud_access_key"
61
+ end
62
+ end
63
+ describe "block" do
64
+ before(:each) do
65
+ reset!
66
+ @cloud = Cloud.new(:test, @pool) do
67
+ # Inside cloud block
68
+ keypair "fake_keypair"
69
+ end
70
+ end
71
+
72
+ it "should be able to pull the pool from the cloud" do
73
+ @cloud.parent == @pool
74
+ end
75
+ it "should have services in an array" do
76
+ @cloud.services.class.should == Array
77
+ end
78
+ it "should have no services in the array when there are no services defined" do
79
+ @cloud.services.size.should == 0
80
+ end
81
+ it "should respond to a configure method" do
82
+ @cloud.respond_to?(:configure).should == true
83
+ end
84
+ describe "configuration" do
85
+ before(:each) do
86
+ reset!
87
+ @cloud2 = Cloud.new(:test, @pool) do
88
+ minimum_instances 1
89
+ maximum_instances 2
90
+ end
91
+ end
92
+ it "should be able to se the minimum_instances without the var" do
93
+ @cloud2.minimum_instances.should == 1
94
+ end
95
+ it "should be able to se the maximum_instances with the =" do
96
+ @cloud2.maximum_instances.should == 2
97
+ end
98
+ end
99
+ describe "options" do
100
+ it "should set the minimum_instances to 2" do
101
+ @cloud.minimum_instances.should == 2
102
+ end
103
+ it "should set the maximum_instances to 4" do
104
+ @cloud.maximum_instances.should == 4
105
+ end
106
+ it "should be able to set the minimum instances" do
107
+ @cloud.minimum_instances 3
108
+ @cloud.minimum_instances.should == 3
109
+ end
110
+ it "should be able to take a hash from configure and convert it to the options" do
111
+ @cloud.configure( {:minimum_instances => 1, :maximum_instances => 10, :keypair => "friend"} )
112
+ @cloud.keypair.should == "friend"
113
+ end
114
+ describe "minimum_instances/maximum_instances as a range" do
115
+ before(:each) do
116
+ reset!
117
+ @pool = pool :just_pool do
118
+ cloud :app do
119
+ instances 8..15
120
+ end
121
+ end
122
+ @cloud = @pool.cloud(:app)
123
+ end
124
+ it "should set the minimum based on the range" do
125
+ @cloud.minimum_instances.should == 8
126
+ end
127
+ it "should set the maximum based on the range set by instances" do
128
+ @cloud.maximum_instances.should == 15
129
+ end
130
+ end
131
+ describe "keypair" do
132
+ before(:each) do
133
+ reset!
134
+ end
135
+ it "should be able to define a keypair in the cloud" do
136
+ @c = cloud :app do
137
+ keypair "hotdog"
138
+ end
139
+ @c.keypair.should == "hotdog"
140
+ end
141
+ it "should take the pool parent's keypair if it's defined on the pool" do
142
+ pool :pool do
143
+ keypair "ney"
144
+ cloud :app do
145
+ end
146
+ cloud :group do
147
+ end
148
+ end
149
+ pool(:pool).cloud(:app).keypair.should == "ney"
150
+ pool(:pool).cloud(:group).keypair.should == "ney"
151
+ end
152
+ it "should generate a keypair based on the cloud name if none is defined" do
153
+ pool :pool do
154
+ cloud :app do
155
+ end
156
+ cloud :nickes do
157
+ end
158
+ end
159
+ pool(:pool).cloud(:app).keypair.should == "pool_app"
160
+ pool(:pool).cloud(:nickes).keypair.should == "pool_nickes"
161
+ end
162
+ end
163
+ describe "Manifest" do
164
+ before(:each) do
165
+ reset!
166
+ stub_list_from_remote_for(@cloud)
167
+ @cloud.instance_eval do
168
+ has_file(:name => "/etc/httpd/http.conf") do
169
+ content <<-EOE
170
+ hello my lady
171
+ EOE
172
+ end
173
+ has_gem(:name => "poolparty")
174
+ has_package(:name => "dummy")
175
+ end
176
+ end
177
+ it "should it should have the method build_manifest" do
178
+ @cloud.respond_to?(:build_manifest).should == true
179
+ end
180
+ it "should have 3 resources" do
181
+ @cloud.add_poolparty_base_requirements
182
+ @cloud.number_of_resources.should > 3
183
+ end
184
+ it "should receive add_poolparty_base_requirements before building the manifest" do
185
+ @cloud.should_receive(:add_poolparty_base_requirements).once
186
+ @cloud.build_manifest
187
+ end
188
+ describe "add_poolparty_base_requirements" do
189
+ before(:each) do
190
+ reset!
191
+ @cloud.instance_eval do
192
+ @heartbeat = nil
193
+ end
194
+ @hb = "heartbeat".class_constant.new(@cloud)
195
+ end
196
+ it "should call initialize on heartbeat (in add_poolparty_base_requirements)" do
197
+ @hb.class.should_receive(:new).and_return true
198
+ @cloud.add_poolparty_base_requirements
199
+ end
200
+ it "should call heartbeat on the cloud" do
201
+ @cloud.should_receive(:heartbeat).and_return true
202
+ @cloud.add_poolparty_base_requirements
203
+ end
204
+ it "should call Hearbeat.new" do
205
+ "heartbeat".class_constant.should_receive(:new).and_return @hb
206
+ @cloud.add_poolparty_base_requirements
207
+ end
208
+ it "should call enable on the plugin call" do
209
+ @hb = "heartbeat".class_constant
210
+ "heartbeat".class_constant.stub!(:new).and_return @hb
211
+
212
+ @cloud.add_poolparty_base_requirements
213
+ @cloud.heartbeat.should == @hb
214
+ end
215
+ describe "after adding" do
216
+ before(:each) do
217
+ stub_list_from_remote_for(@cloud)
218
+ @cloud.add_poolparty_base_requirements
219
+ end
220
+ it "should add resources onto the heartbeat class inside the cloud" do
221
+ @cloud.services.size.should > 0
222
+ end
223
+ it "should store the class heartbeat" do
224
+ @cloud.services.map {|a| a.class}.include?("heartbeat".class_constant).should == true
225
+ end
226
+ it "should have an array of resources on the heartbeat" do
227
+ @cloud.services.first.resources.class.should == Hash
228
+ end
229
+ describe "resources" do
230
+ before(:each) do
231
+ @cloud8 = Cloud.new(:tester, @pool) do
232
+ test_service
233
+ end
234
+ @service = @cloud8.services.first
235
+ @files = @service.resource(:file)
236
+ end
237
+ it "should have a file resource" do
238
+ @files.first.nil?.should == false
239
+ end
240
+ it "should have an array of lines" do
241
+ @files.class.should == Array
242
+ end
243
+ it "should not be empty" do
244
+ @files.should_not be_empty
245
+ end
246
+ end
247
+ end
248
+ end
249
+ describe "building" do
250
+ before(:each) do
251
+ str = "master 192.168.0.1
252
+ node1 192.168.0.2"
253
+ @sample_instances_list = [{:ip => "192.168.0.1", :name => "master"}, {:ip => "192.168.0.2", :name => "node1"}]
254
+ @ris = @sample_instances_list.map {|h| PoolParty::Remote::RemoteInstance.new(h, @cloud) }
255
+
256
+ @manifest = @cloud.build_manifest
257
+ end
258
+ it "should return a string when calling build_manifest" do
259
+ @manifest.class.should == String
260
+ end
261
+ it "should have a comment of # file in the manifest as described by the has_file" do
262
+ @manifest.should =~ /file \{/
263
+ end
264
+ it "should have the comment of a package in the manifest" do
265
+ @manifest.should =~ /package \{/
266
+ end
267
+ it "should have the comment for heartbeat in the manifest" do
268
+ @manifest.should =~ /class heartbeat/
269
+ end
270
+ it "should include the poolparty gem" do
271
+ @manifest.should =~ /package \{/
272
+ end
273
+ it "should include custom functions" do
274
+ @manifest.should =~ /define line\(\$file/
275
+
276
+ File.open("test_manifest.pp", "w+") {|f| f << @manifest}
277
+ end
278
+ it "should include the hosts for all the listed local instances" do
279
+ @manifest.should =~ /host \{\n\t\t"master":/
280
+ end
281
+ end
282
+ end
283
+ end
284
+
285
+ describe "instances" do
286
+ before(:each) do
287
+ @cloud3 = cloud :pop do;keypair "fake_keypair";end
288
+ stub_list_from_remote_for(@cloud3)
289
+ end
290
+ it "should respond to the method master" do
291
+ @cloud3.respond_to?(:master).should == true
292
+ end
293
+ it "should return a master that is not nil" do
294
+ @cloud3.master.should_not be_nil
295
+ end
296
+ end
297
+
298
+ end
299
+ end
@@ -0,0 +1,17 @@
1
+ pool :poolpartyrb do
2
+ plugin_directory "docs_plugins"
3
+
4
+ cloud :app do
5
+
6
+ # Configuration
7
+ configure({ :maximum_instances => 1,:keypair => "name" })
8
+ minimum_instances 1
9
+
10
+ apache do
11
+ enable_php
12
+ site("poolpartyrb.com")
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,16 @@
1
+ pool :poolpartyrb do
2
+
3
+ cloud :app do
4
+
5
+ apache do
6
+ enable_php
7
+
8
+ site({
9
+ :document_root => "/www/domain2",
10
+ :server_name => "domain2.com"
11
+ })
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,58 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require File.dirname(__FILE__) + '/../test_plugins/webserver'
3
+
4
+ describe "Configurer" do
5
+ before(:each) do
6
+ reset!
7
+ @basic = read_file(File.join(File.dirname(__FILE__), "files", "ruby_basic.rb"))
8
+ Script.inflate @basic
9
+ @conf = Object.new
10
+ end
11
+ it "should not be nil" do
12
+ @conf.should_not be_nil
13
+ end
14
+
15
+ describe "with a spec file" do
16
+ before(:each) do
17
+ @s = Script.new
18
+ Script.stub!(:new).and_return(@s)
19
+ @basic = read_file(File.join(File.dirname(__FILE__), "files", "ruby_basic.rb"))
20
+ end
21
+ it "should load the basic example configure" do
22
+ @s.should_receive(:inflate).and_return true
23
+ end
24
+ it "should call inflate on the pools" do
25
+ @s.pools.each {|a,b| b.should_receive(:inflate).and_return true }
26
+ end
27
+ describe "pool" do
28
+ before(:each) do
29
+ Script.inflate @basic
30
+ @pool = pool(:poolpartyrb)
31
+ end
32
+ end
33
+ describe "clouds" do
34
+ before(:each) do
35
+ reset!
36
+ Script.inflate @basic
37
+ @cloud = pool(:poolpartyrb).cloud(:app)
38
+ end
39
+ it "should contain a list of the clouds within the pool (:app)" do
40
+ @cloud.should_not be_nil
41
+ end
42
+ it "should set the minimum instances on the :app cloud" do
43
+ @cloud.minimum_instances.should == 1
44
+ end
45
+ it "should set the maximum instances on the :app cloud" do
46
+ @cloud.maximum_instances.should == 1
47
+ end
48
+ it "should set the keypair name on the :app cloud too" do
49
+ @cloud.keypair.should == "name"
50
+ end
51
+ end
52
+
53
+ after do
54
+ Script.inflate @basic
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,115 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ include PoolParty::Resources
4
+
5
+ describe "Custom Resource" do
6
+ before(:each) do
7
+ @cloud = cloud :name do; end
8
+ end
9
+ it "should provide custom_resource as a method" do
10
+ self.respond_to?(:define_resource).should == true
11
+ end
12
+ describe "defining" do
13
+ it "should not raise ResourceException if custom_function and custom_usage are defined" do
14
+ lambda {
15
+ define_resource(:rockstar) do
16
+ def has_a_line_in_file(line="line_in_file", file="file")
17
+ call_function "line(#{file}, #{line})"
18
+ end
19
+ custom_function <<-EOF
20
+ define line($file, $line, $ensure = 'present') {
21
+ case...
22
+ }
23
+ EOF
24
+ end
25
+ }.should_not raise_error
26
+ end
27
+ describe "define_resource" do
28
+ before(:each) do
29
+ define_resource(:rockstar) do
30
+ def has_a_line_in_file(line="line_in_file", file="file")
31
+ call_function "line(#{file}, #{line})"
32
+ end
33
+ custom_function <<-EOF
34
+ define line($file, $line, $ensure = 'present') {
35
+ case...
36
+ }
37
+ EOF
38
+ end
39
+ end
40
+ it "should create a custom resource available as a class" do
41
+ lambda {RockstarClass.new }.should_not raise_error
42
+ end
43
+ it "should add the method has_a_line_in_file to Resources" do
44
+ PoolParty::Resources.methods.include?("has_a_line_in_file").should == true
45
+ end
46
+ end
47
+ describe "printing" do
48
+ before do
49
+ reset_resources!
50
+ define_resource(:rockstar) do
51
+ def has_a_line_in_file(line="line_in_file", file="file")
52
+ call_function "line(#{file}, #{line})"
53
+ end
54
+ custom_function <<-EOF
55
+ define line($file, $line, $ensure = 'present') {
56
+ case...
57
+ }
58
+ EOF
59
+ end
60
+ @resource = RockstarClass.new
61
+ end
62
+ it "should not be nil after it is defined" do
63
+ @resource.should_not be_nil
64
+ end
65
+ it "should store the custom_function in the class" do
66
+ RockstarClass.custom_functions.select {|a| a if a =~ /define line/}.should_not be_empty
67
+ end
68
+ it "should allow for the has_a_line_in_file to be called from within a plugin" do
69
+ @resource.instance_eval do
70
+ has_a_line_in_file("hi", "filename")
71
+ end
72
+ @resource.resource(:call_function).to_string.should == "line(filename, hi)"
73
+ end
74
+ it "should be stored in an array" do
75
+ resource(:rockstar).class.should == Array
76
+ end
77
+ describe "call function" do
78
+ it "should have the class CallFunction available" do
79
+ lambda {PoolParty::Resources::CallFunction}.should_not raise_error
80
+ end
81
+ it "should create a new CallFunction instance when calling call_function with a string" do
82
+ PoolParty::Resources::CallFunction.should_receive(:new).and_return "bunk"
83
+ add_resource(:call_function, "line")
84
+ end
85
+ it "should create a call function in the function call array" do
86
+ add_resource(:call_function, @cloud, "heyyohey")
87
+ resource(:call_function).size.should == 1
88
+ end
89
+ describe "defining" do
90
+ it "should add the methods to the class through module_eval" do
91
+ PoolParty::Resources.should_receive(:module_eval).at_least(1)
92
+ define_resource :imarockstar2YEAH do
93
+ end
94
+ end
95
+ end
96
+
97
+ describe "within context" do
98
+ before(:each) do
99
+ cloud :apple do
100
+ has_line_in_file("hello", "messages")
101
+ brain_child("meee")
102
+ end
103
+ @cloud = cloud(:apple)
104
+ end
105
+ it "should have 1 resource (the line resource)" do
106
+ @cloud.resources.should_not be_empty
107
+ end
108
+ it "should have one call_function resource" do
109
+ @cloud.resource(:call_function).first.to_string.should =~ /line \{/
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end