auser-poolparty 0.2.16 → 0.2.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/Manifest.txt +72 -7
  2. data/PostInstall.txt +1 -1
  3. data/Rakefile +11 -0
  4. data/bin/cloud-provision +6 -10
  5. data/bin/server-build-messenger +20 -0
  6. data/bin/server-fire-cmd +0 -2
  7. data/bin/server-list-responding +24 -0
  8. data/bin/server-start-master +4 -9
  9. data/bin/server-start-node +7 -6
  10. data/lib/erlang/messenger/Emakefile +1 -0
  11. data/lib/erlang/messenger/Rakefile +29 -20
  12. data/lib/erlang/messenger/ebin/master_app.beam +0 -0
  13. data/lib/erlang/messenger/ebin/node_app.beam +0 -0
  14. data/lib/erlang/messenger/ebin/packager.app +19 -0
  15. data/lib/erlang/messenger/ebin/pm_client.beam +0 -0
  16. data/lib/erlang/messenger/ebin/pm_cluster.beam +0 -0
  17. data/lib/erlang/messenger/ebin/pm_event_handler.beam +0 -0
  18. data/lib/erlang/messenger/ebin/pm_master.beam +0 -0
  19. data/lib/erlang/messenger/ebin/pm_master_rel-0.1.rel +1 -7
  20. data/lib/erlang/messenger/ebin/pm_master_supervisor.beam +0 -0
  21. data/lib/erlang/messenger/ebin/pm_node.beam +0 -0
  22. data/lib/erlang/messenger/ebin/pm_node_rel-0.1.rel +1 -7
  23. data/lib/erlang/messenger/ebin/pm_node_supervisor.beam +0 -0
  24. data/lib/erlang/messenger/ebin/pm_packager.beam +0 -0
  25. data/lib/erlang/messenger/ebin/utils.beam +0 -0
  26. data/lib/erlang/messenger/lib/eunit/AUTHORS +2 -0
  27. data/lib/erlang/messenger/lib/eunit/CHANGELOG +14 -0
  28. data/lib/erlang/messenger/lib/eunit/COPYING +504 -0
  29. data/lib/erlang/messenger/lib/eunit/Makefile +28 -0
  30. data/lib/erlang/messenger/lib/eunit/NOTES +276 -0
  31. data/lib/erlang/messenger/lib/eunit/README +3 -0
  32. data/lib/erlang/messenger/lib/eunit/doc/edoc-info +3 -0
  33. data/lib/erlang/messenger/lib/eunit/doc/erlang.png +0 -0
  34. data/lib/erlang/messenger/lib/eunit/doc/eunit.html +172 -0
  35. data/lib/erlang/messenger/lib/eunit/doc/index.html +17 -0
  36. data/lib/erlang/messenger/lib/eunit/doc/modules-frame.html +12 -0
  37. data/lib/erlang/messenger/lib/eunit/doc/overview-summary.html +984 -0
  38. data/lib/erlang/messenger/lib/eunit/doc/overview.edoc +980 -0
  39. data/lib/erlang/messenger/lib/eunit/doc/packages-frame.html +11 -0
  40. data/lib/erlang/messenger/lib/eunit/doc/stylesheet.css +55 -0
  41. data/lib/erlang/messenger/lib/eunit/ebin/autoload.beam +0 -0
  42. data/lib/erlang/messenger/lib/eunit/ebin/code_monitor.beam +0 -0
  43. data/lib/erlang/messenger/lib/eunit/ebin/eunit.app +21 -0
  44. data/lib/erlang/messenger/lib/eunit/ebin/eunit.appup +1 -0
  45. data/lib/erlang/messenger/lib/eunit/ebin/eunit.beam +0 -0
  46. data/lib/erlang/messenger/lib/eunit/ebin/eunit_autoexport.beam +0 -0
  47. data/lib/erlang/messenger/lib/eunit/ebin/eunit_data.beam +0 -0
  48. data/lib/erlang/messenger/lib/eunit/ebin/eunit_lib.beam +0 -0
  49. data/lib/erlang/messenger/lib/eunit/ebin/eunit_proc.beam +0 -0
  50. data/lib/erlang/messenger/lib/eunit/ebin/eunit_serial.beam +0 -0
  51. data/lib/erlang/messenger/lib/eunit/ebin/eunit_server.beam +0 -0
  52. data/lib/erlang/messenger/lib/eunit/ebin/eunit_striptests.beam +0 -0
  53. data/lib/erlang/messenger/lib/eunit/ebin/eunit_test.beam +0 -0
  54. data/lib/erlang/messenger/lib/eunit/ebin/eunit_tests.beam +0 -0
  55. data/lib/erlang/messenger/lib/eunit/ebin/eunit_tty.beam +0 -0
  56. data/lib/erlang/messenger/lib/eunit/ebin/file_monitor.beam +0 -0
  57. data/lib/erlang/messenger/lib/eunit/examples/eunit_examples.erl +339 -0
  58. data/lib/erlang/messenger/lib/eunit/examples/fib.erl +19 -0
  59. data/lib/erlang/messenger/lib/eunit/examples/tests.txt +1 -0
  60. data/lib/erlang/messenger/lib/eunit/include/eunit.hrl +313 -0
  61. data/lib/erlang/messenger/lib/eunit/src/Makefile +46 -0
  62. data/lib/erlang/messenger/lib/eunit/src/autoload.erl +388 -0
  63. data/lib/erlang/messenger/lib/eunit/src/code_monitor.erl +243 -0
  64. data/lib/erlang/messenger/lib/eunit/src/eunit.app.src +21 -0
  65. data/lib/erlang/messenger/lib/eunit/src/eunit.appup.src +1 -0
  66. data/lib/erlang/messenger/lib/eunit/src/eunit.erl +196 -0
  67. data/lib/erlang/messenger/lib/eunit/src/eunit_autoexport.erl +102 -0
  68. data/lib/erlang/messenger/lib/eunit/src/eunit_data.erl +798 -0
  69. data/lib/erlang/messenger/lib/eunit/src/eunit_internal.hrl +48 -0
  70. data/lib/erlang/messenger/lib/eunit/src/eunit_lib.erl +682 -0
  71. data/lib/erlang/messenger/lib/eunit/src/eunit_proc.erl +552 -0
  72. data/lib/erlang/messenger/lib/eunit/src/eunit_serial.erl +157 -0
  73. data/lib/erlang/messenger/lib/eunit/src/eunit_server.erl +340 -0
  74. data/lib/erlang/messenger/lib/eunit/src/eunit_striptests.erl +64 -0
  75. data/lib/erlang/messenger/lib/eunit/src/eunit_test.erl +334 -0
  76. data/lib/erlang/messenger/lib/eunit/src/eunit_tests.erl +45 -0
  77. data/lib/erlang/messenger/lib/eunit/src/eunit_tty.erl +272 -0
  78. data/lib/erlang/messenger/lib/eunit/src/file_monitor.erl +409 -0
  79. data/lib/erlang/messenger/lib/eunit/sys.config +9 -0
  80. data/lib/erlang/messenger/lib/eunit/vsn.mk +1 -0
  81. data/lib/erlang/messenger/pm_master_rel-0.1.boot +0 -0
  82. data/lib/erlang/messenger/pm_master_rel-0.1.script +75 -2
  83. data/lib/erlang/messenger/pm_node_rel-0.1.boot +0 -0
  84. data/lib/erlang/messenger/pm_node_rel-0.1.script +75 -2
  85. data/lib/erlang/messenger/src/pm_client.erl +8 -3
  86. data/lib/erlang/messenger/src/pm_cluster.erl +32 -9
  87. data/lib/erlang/messenger/src/pm_master.erl +10 -11
  88. data/lib/erlang/messenger/src/pm_node.erl +2 -3
  89. data/lib/erlang/messenger/src/pm_packager.erl +73 -0
  90. data/lib/erlang/messenger/src/utils.erl +3 -10
  91. data/lib/poolparty/base_packages/heartbeat.rb +9 -9
  92. data/lib/poolparty/base_packages/poolparty.rb +16 -10
  93. data/lib/poolparty/config/allowed_commands.yml +1 -0
  94. data/lib/poolparty/core/object.rb +8 -0
  95. data/lib/poolparty/exceptions/UnacceptableCommand.rb +5 -0
  96. data/lib/poolparty/helpers/messenger.rb +29 -0
  97. data/lib/poolparty/helpers/provisioner_base.rb +7 -7
  98. data/lib/poolparty/helpers/provisioners/master.rb +3 -7
  99. data/lib/poolparty/helpers/provisioners/slave.rb +1 -0
  100. data/lib/poolparty/modules/cloud_resourcer.rb +7 -5
  101. data/lib/poolparty/modules/configurable.rb +1 -1
  102. data/lib/poolparty/modules/method_missing_sugar.rb +6 -1
  103. data/lib/poolparty/modules/pretty_printer.rb +1 -0
  104. data/lib/poolparty/modules/resourcing_dsl.rb +2 -1
  105. data/lib/poolparty/monitors/monitors/cpu_monitor.rb +1 -1
  106. data/lib/poolparty/net/remoter.rb +3 -1
  107. data/lib/poolparty/plugins/git.rb +3 -3
  108. data/lib/poolparty/pool/base.rb +7 -2
  109. data/lib/poolparty/pool/cloud.rb +3 -3
  110. data/lib/poolparty/pool/resource.rb +38 -24
  111. data/lib/poolparty/pool/resources/class_package.rb +2 -2
  112. data/lib/poolparty/pool/resources/conditional.rb +8 -4
  113. data/lib/poolparty/pool/resources/{gem.rb → gem_package.rb} +0 -0
  114. data/lib/poolparty/pool/resources/package.rb +8 -1
  115. data/lib/poolparty/version.rb +1 -1
  116. data/lib/poolparty.rb +1 -1
  117. data/poolparty.gemspec +476 -61
  118. data/spec/poolparty/core/object_spec.rb +20 -0
  119. data/spec/poolparty/helpers/messenger_spec.rb +14 -0
  120. data/spec/poolparty/helpers/provisioners/master_spec.rb +2 -2
  121. data/spec/poolparty/net/remoter_spec.rb +1 -1
  122. data/spec/poolparty/plugins/git_spec.rb +26 -19
  123. data/spec/poolparty/pool/base_spec.rb +20 -2
  124. data/spec/poolparty/pool/cloud_spec.rb +256 -249
  125. data/spec/poolparty/pool/custom_resource_spec.rb +6 -1
  126. data/spec/poolparty/pool/plugin_spec.rb +71 -65
  127. data/spec/poolparty/pool/resource_spec.rb +314 -237
  128. data/spec/poolparty/pool/resources/class_package_spec.rb +71 -66
  129. data/spec/poolparty/pool/resources/conditional_spec.rb +30 -26
  130. data/spec/poolparty/pool/resources/gem_spec.rb +18 -14
  131. data/spec/poolparty/pool/resources/variable_spec.rb +1 -1
  132. data/spec/poolparty/pool/script_spec.rb +46 -37
  133. data/spec/poolparty/spec_helper.rb +4 -0
  134. data/tasks/cloud.rake +0 -54
  135. data/tasks/development.rake +11 -14
  136. data/tasks/ec2.rake +10 -17
  137. data/tasks/instance.rake +0 -61
  138. data/website/index.html +1 -1
  139. metadata +83 -10
@@ -1,6 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  include PoolParty::Cloud
4
+ include PoolParty::Resources
5
+
4
6
  class TestServiceClass
5
7
  plugin :test_service do
6
8
  def enable
@@ -11,317 +13,322 @@ end
11
13
 
12
14
  describe "Cloud" do
13
15
  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
16
+ reset_resources!
19
17
  end
20
- describe "global" do
18
+ describe "wrapped" do
21
19
  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
20
+ @obj = Object.new
21
+ @pool = pool :just_pool do; end
29
22
  end
30
- it "should have set the using base on intantiation to ec2" do
31
- @cloud1.using_remoter?.should_not == nil
23
+ it "should respond to the pool method outside the block" do
24
+ @obj.respond_to?(:cloud).should == true
32
25
  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
26
+ describe "global" do
27
+ before(:each) do
28
+ @cloud1 = cloud :pop do;end
50
29
  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"
30
+ it "should store the cloud in the global list of clouds" do
31
+ @obj.clouds.has_key?(:pop).should == true
32
+ end
33
+ it "should store the cloud" do
34
+ @obj.cloud(:pop).should == @cloud1
35
+ end
36
+ it "should have set the using base on intantiation to ec2" do
37
+ @cloud1.using_remoter?.should_not == nil
38
+ end
39
+ it "should say the remoter_base is ec2 (by default)" do
40
+ @cloud1.remote_base.should == PoolParty::Ec2
69
41
  end
70
42
  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
43
+ it "should return the cloud if the cloud key is already in the clouds list" do
44
+ @cld = cloud :pop do;end
45
+ @pool.cloud(:pop).should == @cld
83
46
  end
84
- describe "configuration" do
47
+ describe "options" do
85
48
  before(:each) do
86
49
  reset!
87
- @cloud2 = Cloud.new(:test, @pool) do
88
- minimum_instances 1
89
- maximum_instances 2
50
+ @p = pool :options do
51
+ minimum_instances 100
52
+ access_key "access_key"
53
+ cloud :apple do
54
+ access_key "cloud_access_key"
55
+ end
90
56
  end
57
+ @c = @p.cloud(:apple)
91
58
  end
92
- it "should be able to se the minimum_instances without the var" do
93
- @cloud2.minimum_instances.should == 1
59
+ it "should be able to grab the cloud from the pool" do
60
+ @c.should == @p.cloud(:apple)
94
61
  end
95
- it "should be able to se the maximum_instances with the =" do
96
- @cloud2.maximum_instances.should == 2
62
+ it "should take the options set on the pool" do
63
+ @p.minimum_instances.should == 100
64
+ end
65
+ it "should take the access_key option set from the cloud" do
66
+ @c.access_key.should == "cloud_access_key"
97
67
  end
98
68
  end
99
- describe "options" do
100
- it "should set the minimum_instances to 2" do
101
- @cloud.minimum_instances.should == 2
69
+ describe "block" do
70
+ before(:each) do
71
+ reset!
72
+ @cloud = Cloud.new(:test, @pool) do
73
+ # Inside cloud block
74
+ keypair "fake_keypair"
75
+ end
102
76
  end
103
- it "should set the maximum_instances to 4" do
104
- @cloud.maximum_instances.should == 4
77
+
78
+ it "should be able to pull the pool from the cloud" do
79
+ @cloud.parent == @pool
80
+ end
81
+ it "should have services in an array" do
82
+ @cloud.services.class.should == Array
105
83
  end
106
- it "should be able to set the minimum instances" do
107
- @cloud.minimum_instances 3
108
- @cloud.minimum_instances.should == 3
84
+ it "should have no services in the array when there are no services defined" do
85
+ @cloud.services.size.should == 0
109
86
  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"
87
+ it "should respond to a configure method" do
88
+ @cloud.respond_to?(:configure).should == true
113
89
  end
114
- describe "minimum_instances/maximum_instances as a range" do
90
+ describe "configuration" do
115
91
  before(:each) do
116
92
  reset!
117
- @pool = pool :just_pool do
118
- cloud :app do
119
- instances 8..15
120
- end
93
+ @cloud2 = Cloud.new(:test, @pool) do
94
+ minimum_instances 1
95
+ maximum_instances 2
121
96
  end
122
- @cloud = @pool.cloud(:app)
123
97
  end
124
- it "should set the minimum based on the range" do
125
- @cloud.minimum_instances.should == 8
98
+ it "should be able to se the minimum_instances without the var" do
99
+ @cloud2.minimum_instances.should == 1
126
100
  end
127
- it "should set the maximum based on the range set by instances" do
128
- @cloud.maximum_instances.should == 15
101
+ it "should be able to se the maximum_instances with the =" do
102
+ @cloud2.maximum_instances.should == 2
129
103
  end
130
104
  end
131
- describe "keypair" do
132
- before(:each) do
133
- reset!
105
+ describe "options" do
106
+ it "should set the minimum_instances to 2" do
107
+ @cloud.minimum_instances.should == 2
134
108
  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"
109
+ it "should set the maximum_instances to 4" do
110
+ @cloud.maximum_instances.should == 4
140
111
  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
112
+ it "should be able to set the minimum instances" do
113
+ @cloud.minimum_instances 3
114
+ @cloud.minimum_instances.should == 3
115
+ end
116
+ it "should be able to take a hash from configure and convert it to the options" do
117
+ @cloud.configure( {:minimum_instances => 1, :maximum_instances => 10, :keypair => "friend"} )
118
+ @cloud.keypair.should == "friend"
119
+ end
120
+ describe "minimum_instances/maximum_instances as a range" do
121
+ before(:each) do
122
+ reset!
123
+ @pool = pool :just_pool do
124
+ cloud :app do
125
+ instances 8..15
126
+ end
147
127
  end
128
+ @cloud = @pool.cloud(:app)
129
+ end
130
+ it "should set the minimum based on the range" do
131
+ @cloud.minimum_instances.should == 8
132
+ end
133
+ it "should set the maximum based on the range set by instances" do
134
+ @cloud.maximum_instances.should == 15
148
135
  end
149
- pool(:pool).cloud(:app).keypair.should == "ney"
150
- pool(:pool).cloud(:group).keypair.should == "ney"
151
136
  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
137
+ describe "keypair" do
138
+ before(:each) do
139
+ reset!
140
+ end
141
+ it "should be able to define a keypair in the cloud" do
142
+ @c = cloud :app do
143
+ keypair "hotdog"
155
144
  end
156
- cloud :nickes do
145
+ @c.keypair.should == "hotdog"
146
+ end
147
+ it "should take the pool parent's keypair if it's defined on the pool" do
148
+ pool :pool do
149
+ keypair "ney"
150
+ cloud :app do
151
+ end
152
+ cloud :group do
153
+ end
157
154
  end
155
+ pool(:pool).cloud(:app).keypair.should == "ney"
156
+ pool(:pool).cloud(:group).keypair.should == "ney"
158
157
  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
158
+ it "should generate a keypair based on the cloud name if none is defined" do
159
+ pool :pool do
160
+ cloud :app do
161
+ end
162
+ cloud :nickes do
163
+ end
172
164
  end
173
- has_gempackage(:name => "poolparty")
174
- has_package(:name => "dummy")
165
+ pool(:pool).cloud(:app).keypair.should == "pool_app"
166
+ pool(:pool).cloud(:nickes).keypair.should == "pool_nickes"
175
167
  end
176
168
  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
169
+ describe "Manifest" do
189
170
  before(:each) do
190
- reset!
171
+ reset!
172
+ stub_list_from_remote_for(@cloud)
191
173
  @cloud.instance_eval do
192
- @heartbeat = nil
174
+ has_file(:name => "/etc/httpd/http.conf") do
175
+ content <<-EOE
176
+ hello my lady
177
+ EOE
178
+ end
179
+ has_gempackage(:name => "poolparty")
180
+ has_package(:name => "dummy")
193
181
  end
194
- @hb = "heartbeat".class_constant.new(@cloud)
195
182
  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
183
+ it "should it should have the method build_manifest" do
184
+ @cloud.respond_to?(:build_manifest).should == true
199
185
  end
200
- it "should call heartbeat on the cloud" do
201
- @cloud.should_receive(:heartbeat).and_return true
186
+ it "should have 3 resources" do
202
187
  @cloud.add_poolparty_base_requirements
188
+ @cloud.number_of_resources.should > 2
203
189
  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
190
+ it "should receive add_poolparty_base_requirements before building the manifest" do
191
+ @cloud.should_receive(:add_poolparty_base_requirements).once
192
+ @cloud.build_manifest
214
193
  end
215
- describe "after adding" do
194
+ describe "add_poolparty_base_requirements" do
216
195
  before(:each) do
217
- stub_list_from_remote_for(@cloud)
218
- @cloud.add_poolparty_base_requirements
196
+ reset!
197
+ @cloud.instance_eval do
198
+ @heartbeat = nil
199
+ end
200
+ @hb = "heartbeat".class_constant.new(@cloud)
201
+ end
202
+ it "should call initialize on heartbeat (in add_poolparty_base_requirements)" do
203
+ @hb.class.should_receive(:new).and_return true
204
+ @cloud.add_poolparty_base_requirements
219
205
  end
220
- it "should add resources onto the heartbeat class inside the cloud" do
221
- @cloud.services.size.should > 0
206
+ it "should call heartbeat on the cloud" do
207
+ @cloud.should_receive(:heartbeat).and_return true
208
+ @cloud.add_poolparty_base_requirements
222
209
  end
223
- it "should store the class heartbeat" do
224
- @cloud.services.map {|a| a.class}.include?("heartbeat".class_constant).should == true
210
+ it "should call Hearbeat.new" do
211
+ "heartbeat".class_constant.should_receive(:new).and_return @hb
212
+ @cloud.add_poolparty_base_requirements
225
213
  end
226
- it "should have an array of resources on the heartbeat" do
227
- @cloud.services.first.resources.class.should == Hash
214
+ it "should call enable on the plugin call" do
215
+ @hb = "heartbeat".class_constant
216
+ "heartbeat".class_constant.stub!(:new).and_return @hb
217
+
218
+ @cloud.add_poolparty_base_requirements
219
+ @cloud.heartbeat.should == @hb
228
220
  end
229
- describe "resources" do
221
+ describe "after adding" do
230
222
  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)
223
+ stub_list_from_remote_for(@cloud)
224
+ @cloud.add_poolparty_base_requirements
236
225
  end
237
- it "should have a file resource" do
238
- @files.first.nil?.should == false
226
+ it "should add resources onto the heartbeat class inside the cloud" do
227
+ @cloud.services.size.should > 0
239
228
  end
240
- it "should have an array of lines" do
241
- @files.class.should == Array
229
+ it "should store the class heartbeat" do
230
+ @cloud.services.map {|a| a.class}.include?("heartbeat".class_constant).should == true
242
231
  end
243
- it "should not be empty" do
244
- @files.should_not be_empty
232
+ it "should have an array of resources on the heartbeat" do
233
+ @cloud.services.first.resources.class.should == Hash
234
+ end
235
+ describe "resources" do
236
+ before(:each) do
237
+ @cloud8 = Cloud.new(:tester, @pool) do
238
+ test_service
239
+ end
240
+ @service = @cloud8.services.first
241
+ @files = @service.resource(:file)
242
+ end
243
+ it "should have a file resource" do
244
+ @files.first.nil?.should == false
245
+ end
246
+ it "should have an array of lines" do
247
+ @files.class.should == Array
248
+ end
249
+ it "should not be empty" do
250
+ @files.should_not be_empty
251
+ end
245
252
  end
246
253
  end
247
254
  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
- describe "building with an existing manifest" do
283
- before(:each) do
284
- @file = "/etc/puppet/manifests/nodes/nodes.pp"
285
- @file.stub!(:read).and_return "nodes"
286
- ::FileTest.stub!(:file?).with("/etc/puppet/manifests/classes/poolparty.pp").and_return true
287
- @cloud.stub!(:open).with("/etc/puppet/manifests/classes/poolparty.pp").and_return @file
288
- end
289
- it "should not call resources_string_from_resources if the file /etc/puppet/manifests/nodes/nodes.pp exists" do
290
- @cloud.should_not_receive(:add_poolparty_base_requirements)
291
- @cloud.build_manifest
255
+ describe "building" do
256
+ before(:each) do
257
+ str = "master 192.168.0.1
258
+ node1 192.168.0.2"
259
+ @sample_instances_list = [{:ip => "192.168.0.1", :name => "master"}, {:ip => "192.168.0.2", :name => "node1"}]
260
+ @ris = @sample_instances_list.map {|h| PoolParty::Remote::RemoteInstance.new(h, @cloud) }
261
+
262
+ @manifest = @cloud.build_manifest
263
+ end
264
+ it "should return a string when calling build_manifest" do
265
+ @manifest.class.should == String
266
+ end
267
+ it "should have a comment of # file in the manifest as described by the has_file" do
268
+ @manifest.should =~ /file \{/
269
+ end
270
+ it "should have the comment of a package in the manifest" do
271
+ @manifest.should =~ /package \{/
272
+ end
273
+ it "should have the comment for heartbeat in the manifest" do
274
+ @manifest.should =~ /class heartbeat/
275
+ end
276
+ it "should include the poolparty gem" do
277
+ @manifest.should =~ /package \{/
278
+ end
279
+ it "should include custom functions" do
280
+ @manifest.should =~ /define line\(\$file/
281
+
282
+ File.open("test_manifest.pp", "w+") {|f| f << @manifest}
283
+ end
284
+ it "should include the hosts for all the listed local instances" do
285
+ @manifest.should =~ /host \{\n\t\t"master":/
286
+ end
292
287
  end
293
- it "should build from the existing file" do
294
- @cloud.build_manifest.should == "nodes"
288
+ describe "building with an existing manifest" do
289
+ before(:each) do
290
+ @file = "/etc/puppet/manifests/nodes/nodes.pp"
291
+ @file.stub!(:read).and_return "nodes"
292
+ ::FileTest.stub!(:file?).with("/etc/puppet/manifests/classes/poolparty.pp").and_return true
293
+ @cloud.stub!(:open).with("/etc/puppet/manifests/classes/poolparty.pp").and_return @file
294
+ end
295
+ it "should not call resources_string_from_resources if the file /etc/puppet/manifests/nodes/nodes.pp exists" do
296
+ @cloud.should_not_receive(:add_poolparty_base_requirements)
297
+ @cloud.build_manifest
298
+ end
299
+ it "should build from the existing file" do
300
+ @cloud.build_manifest.should == "nodes"
301
+ end
295
302
  end
296
303
  end
297
304
  end
298
- end
299
-
300
- describe "instances" do
301
- before(:each) do
302
- @cloud3 = cloud :pop do;keypair "fake_keypair";end
303
- stub_list_from_remote_for(@cloud3)
304
- end
305
- it "should respond to the method master" do
306
- @cloud3.respond_to?(:master).should == true
307
- end
308
- it "should return a master that is not nil" do
309
- @cloud3.master.should_not be_nil
310
- end
311
- end
312
-
313
- describe "provisioning" do
314
- it "should be able to tell that it is provisioning when setting the provisioning flag" do
315
- @cloud.provisioning?.should == false
316
- end
317
- it "should be able to set it as provisioning" do
318
- @cloud.provisioning_in_progress
319
- @cloud.provisioning?.should == true
305
+
306
+ describe "instances" do
307
+ before(:each) do
308
+ @cloud3 = cloud :pop do;keypair "fake_keypair";end
309
+ stub_list_from_remote_for(@cloud3)
310
+ end
311
+ it "should respond to the method master" do
312
+ @cloud3.respond_to?(:master).should == true
313
+ end
314
+ it "should return a master that is not nil" do
315
+ @cloud3.master.should_not be_nil
316
+ end
320
317
  end
321
- it "should be able to unset itself as provisioning" do
322
- @cloud.provisioning_in_progress
323
- @cloud.provisioning_complete
324
- @cloud.provisioning?.should == false
318
+
319
+ describe "provisioning" do
320
+ it "should be able to tell that it is provisioning when setting the provisioning flag" do
321
+ @cloud.provisioning?.should == false
322
+ end
323
+ it "should be able to set it as provisioning" do
324
+ @cloud.provisioning_in_progress
325
+ @cloud.provisioning?.should == true
326
+ end
327
+ it "should be able to unset itself as provisioning" do
328
+ @cloud.provisioning_in_progress
329
+ @cloud.provisioning_complete
330
+ @cloud.provisioning?.should == false
331
+ end
325
332
  end
326
333
  end
327
334
  end
@@ -75,11 +75,16 @@ describe "Custom Resource" do
75
75
  resource(:rockstar).class.should == Array
76
76
  end
77
77
  describe "call function" do
78
+ before(:each) do
79
+ @res = Class.new
80
+ @res.stub!(:class_name_sym).and_return :bunk
81
+ @res.stub!(:key).and_return "bunk"
82
+ end
78
83
  it "should have the class CallFunction available" do
79
84
  lambda {PoolParty::Resources::CallFunction}.should_not raise_error
80
85
  end
81
86
  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"
87
+ PoolParty::Resources::CallFunction.should_receive(:new).and_return @res
83
88
  add_resource(:call_function, :name => "line")
84
89
  end
85
90
  it "should create a call function in the function call array" do