auser-poolparty 0.1.2 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. data/History.txt +22 -0
  2. data/License.txt +20 -0
  3. data/README.txt +52 -0
  4. data/Rakefile +4 -109
  5. data/bin/cloud +31 -0
  6. data/bin/cloud-add-keypair +23 -0
  7. data/bin/cloud-configure +35 -0
  8. data/bin/cloud-contract +27 -0
  9. data/bin/cloud-expand +27 -0
  10. data/bin/cloud-list +32 -0
  11. data/bin/cloud-maintain +36 -0
  12. data/bin/cloud-provision +30 -0
  13. data/bin/cloud-reconfigure +24 -0
  14. data/bin/cloud-ssh +18 -0
  15. data/bin/cloud-start +29 -0
  16. data/bin/pool +23 -75
  17. data/bin/pool-console +12 -0
  18. data/bin/pool-describe +9 -0
  19. data/bin/pool-list +28 -0
  20. data/bin/pool-provision +34 -0
  21. data/bin/pool-spec +17 -0
  22. data/bin/pool-start +32 -0
  23. data/examples/basic.rb +20 -0
  24. data/examples/plugin_without_plugin_directory.rb +13 -0
  25. data/examples/poolparty.rb +12 -0
  26. data/examples/with_apache_plugin.rb +22 -0
  27. data/generators/poolspec/USAGE +5 -0
  28. data/generators/poolspec/poolspec_generator.rb +65 -0
  29. data/generators/poolspec/templates/pool_spec_template.erb +9 -0
  30. data/lib/erlang/eb_server.erl +27 -0
  31. data/lib/poolparty.rb +40 -116
  32. data/lib/poolparty/base_packages/haproxy.rb +41 -0
  33. data/lib/poolparty/base_packages/heartbeat.rb +43 -0
  34. data/lib/poolparty/base_packages/poolparty.rb +18 -0
  35. data/lib/poolparty/base_packages/ruby.rb +27 -0
  36. data/lib/poolparty/core/array.rb +24 -0
  37. data/lib/{core → poolparty/core}/exception.rb +0 -0
  38. data/lib/{core → poolparty/core}/float.rb +0 -0
  39. data/lib/poolparty/core/hash.rb +29 -0
  40. data/lib/poolparty/core/kernel.rb +34 -0
  41. data/lib/{core → poolparty/core}/module.rb +18 -0
  42. data/lib/poolparty/core/my_open_struct.rb +18 -0
  43. data/lib/poolparty/core/object.rb +54 -0
  44. data/lib/poolparty/core/proc.rb +2 -0
  45. data/lib/poolparty/core/string.rb +72 -0
  46. data/lib/poolparty/core/symbol.rb +8 -0
  47. data/lib/{core → poolparty/core}/time.rb +15 -0
  48. data/lib/poolparty/exceptions/RemoteException.rb +12 -0
  49. data/lib/poolparty/exceptions/ResourceException.rb +7 -0
  50. data/lib/poolparty/exceptions/RuntimeException.rb +7 -0
  51. data/lib/poolparty/exceptions/SpecException.rb +7 -0
  52. data/lib/poolparty/exceptions/TemplateNotFound.rb +7 -0
  53. data/lib/poolparty/helpers/binary.rb +30 -0
  54. data/lib/poolparty/helpers/console.rb +30 -0
  55. data/lib/poolparty/helpers/display.rb +25 -0
  56. data/lib/poolparty/helpers/optioner.rb +61 -0
  57. data/lib/poolparty/helpers/provisioner_base.rb +226 -0
  58. data/lib/poolparty/helpers/provisioners/master.rb +120 -0
  59. data/lib/poolparty/helpers/provisioners/slave.rb +52 -0
  60. data/lib/poolparty/modules/cloud_resourcer.rb +72 -0
  61. data/lib/poolparty/modules/configurable.rb +34 -0
  62. data/lib/poolparty/modules/definable_resource.rb +59 -0
  63. data/lib/poolparty/modules/file_writer.rb +55 -0
  64. data/lib/poolparty/modules/method_missing_sugar.rb +17 -0
  65. data/lib/poolparty/modules/output.rb +13 -0
  66. data/lib/poolparty/modules/pretty_printer.rb +38 -0
  67. data/lib/{core/string.rb → poolparty/modules/s3_string.rb} +5 -29
  68. data/lib/{modules → poolparty/modules}/safe_instance.rb +0 -0
  69. data/lib/poolparty/monitors/base_monitor.rb +16 -0
  70. data/lib/poolparty/net/remote.rb +35 -0
  71. data/lib/poolparty/net/remote_bases/ec2.rb +145 -0
  72. data/lib/poolparty/net/remote_instance.rb +68 -0
  73. data/lib/poolparty/net/remoter.rb +209 -0
  74. data/lib/poolparty/net/remoter_base.rb +117 -0
  75. data/lib/poolparty/plugins/gem_package.rb +39 -0
  76. data/lib/poolparty/plugins/line.rb +76 -0
  77. data/lib/poolparty/plugins/svn.rb +48 -0
  78. data/lib/poolparty/pool/base.rb +74 -0
  79. data/lib/poolparty/pool/cloud.rb +132 -0
  80. data/lib/poolparty/pool/custom_resource.rb +61 -0
  81. data/lib/poolparty/pool/loggable.rb +29 -0
  82. data/lib/poolparty/pool/plugin.rb +42 -0
  83. data/lib/poolparty/pool/plugin_model.rb +48 -0
  84. data/lib/poolparty/pool/pool.rb +55 -0
  85. data/lib/poolparty/pool/resource.rb +235 -0
  86. data/lib/poolparty/pool/resources/class_package.rb +60 -0
  87. data/lib/poolparty/pool/resources/cron.rb +14 -0
  88. data/lib/poolparty/pool/resources/directory.rb +23 -0
  89. data/lib/poolparty/pool/resources/exec.rb +26 -0
  90. data/lib/poolparty/pool/resources/file.rb +23 -0
  91. data/lib/poolparty/pool/resources/gem.rb +14 -0
  92. data/lib/poolparty/pool/resources/host.rb +14 -0
  93. data/lib/poolparty/pool/resources/package.rb +14 -0
  94. data/lib/poolparty/pool/resources/remote_file.rb +20 -0
  95. data/lib/poolparty/pool/resources/service.rb +21 -0
  96. data/lib/poolparty/pool/resources/sshkey.rb +19 -0
  97. data/lib/poolparty/pool/resources/variable.rb +27 -0
  98. data/lib/poolparty/pool/script.rb +21 -0
  99. data/{config/heartbeat_authkeys.conf → lib/poolparty/templates/authkeys} +0 -0
  100. data/lib/poolparty/templates/cib.xml +1 -0
  101. data/lib/poolparty/templates/fileserver.conf +4 -0
  102. data/{config/heartbeat.conf → lib/poolparty/templates/ha.cf} +3 -1
  103. data/{config → lib/poolparty/templates}/haproxy.conf +13 -6
  104. data/lib/poolparty/templates/namespaceauth.conf +19 -0
  105. data/lib/poolparty/templates/puppet.conf +13 -0
  106. data/lib/poolparty/version.rb +9 -0
  107. data/lib/poolpartycl.rb +3 -0
  108. data/script/destroy +14 -0
  109. data/script/generate +14 -0
  110. data/script/txt2html +82 -0
  111. data/{lib/poolparty/tasks → tasks}/cloud.rake +1 -1
  112. data/tasks/deployment.rake +34 -0
  113. data/tasks/development.rake +78 -0
  114. data/{lib/poolparty/tasks → tasks}/ec2.rake +1 -1
  115. data/tasks/environment.rake +7 -0
  116. data/{lib/poolparty/tasks → tasks}/instance.rake +0 -0
  117. data/{lib/poolparty/tasks → tasks}/server.rake +0 -0
  118. data/tasks/spec.rake +17 -0
  119. data/tasks/website.rake +17 -0
  120. metadata +154 -249
  121. data/CHANGELOG +0 -23
  122. data/LICENSE +0 -22
  123. data/README +0 -139
  124. data/assets/clouds.png +0 -0
  125. data/bin/instance +0 -68
  126. data/bin/poolnotify +0 -34
  127. data/config/cloud_master_takeover +0 -17
  128. data/config/create_proxy_ami.sh +0 -582
  129. data/config/installers/ubuntu_install.sh +0 -77
  130. data/config/monit.conf +0 -9
  131. data/config/monit/haproxy.monit.conf +0 -8
  132. data/config/monit/nginx.monit.conf +0 -0
  133. data/config/nginx.conf +0 -24
  134. data/config/reconfigure_instances_script.sh +0 -37
  135. data/config/sample-config.yml +0 -23
  136. data/config/scp_instances_script.sh +0 -12
  137. data/lib/core/array.rb +0 -16
  138. data/lib/core/hash.rb +0 -11
  139. data/lib/core/kernel.rb +0 -12
  140. data/lib/core/object.rb +0 -21
  141. data/lib/core/proc.rb +0 -15
  142. data/lib/helpers/plugin_spec_helper.rb +0 -58
  143. data/lib/modules/callback.rb +0 -133
  144. data/lib/modules/ec2_wrapper.rb +0 -108
  145. data/lib/modules/file_writer.rb +0 -38
  146. data/lib/modules/sprinkle_overrides.rb +0 -27
  147. data/lib/modules/vlad_override.rb +0 -83
  148. data/lib/poolparty/application.rb +0 -199
  149. data/lib/poolparty/init.rb +0 -6
  150. data/lib/poolparty/master.rb +0 -492
  151. data/lib/poolparty/monitors.rb +0 -11
  152. data/lib/poolparty/monitors/cpu.rb +0 -23
  153. data/lib/poolparty/monitors/memory.rb +0 -33
  154. data/lib/poolparty/monitors/web.rb +0 -29
  155. data/lib/poolparty/optioner.rb +0 -20
  156. data/lib/poolparty/plugin.rb +0 -78
  157. data/lib/poolparty/provider.rb +0 -104
  158. data/lib/poolparty/provider/essential.rb +0 -6
  159. data/lib/poolparty/provider/git.rb +0 -8
  160. data/lib/poolparty/provider/haproxy.rb +0 -9
  161. data/lib/poolparty/provider/heartbeat.rb +0 -6
  162. data/lib/poolparty/provider/rsync.rb +0 -8
  163. data/lib/poolparty/provider/ruby.rb +0 -65
  164. data/lib/poolparty/provider/s3fuse.rb +0 -22
  165. data/lib/poolparty/remote_instance.rb +0 -250
  166. data/lib/poolparty/remoter.rb +0 -171
  167. data/lib/poolparty/remoting.rb +0 -137
  168. data/lib/poolparty/scheduler.rb +0 -93
  169. data/lib/poolparty/tasks.rb +0 -47
  170. data/lib/poolparty/tasks/development.rake +0 -78
  171. data/lib/poolparty/tasks/plugins.rake +0 -30
  172. data/lib/poolparty/thread_pool.rb +0 -94
  173. data/lib/s3/s3_object_store_folders.rb +0 -44
  174. data/poolparty.gemspec +0 -71
  175. data/spec/files/describe_response +0 -37
  176. data/spec/files/multi_describe_response +0 -69
  177. data/spec/files/remote_desc_response +0 -37
  178. data/spec/helpers/ec2_mock.rb +0 -57
  179. data/spec/lib/core/core_spec.rb +0 -26
  180. data/spec/lib/core/kernel_spec.rb +0 -24
  181. data/spec/lib/core/string_spec.rb +0 -28
  182. data/spec/lib/modules/callback_spec.rb +0 -213
  183. data/spec/lib/modules/file_writer_spec.rb +0 -74
  184. data/spec/lib/poolparty/application_spec.rb +0 -135
  185. data/spec/lib/poolparty/ec2_wrapper_spec.rb +0 -110
  186. data/spec/lib/poolparty/master_spec.rb +0 -479
  187. data/spec/lib/poolparty/optioner_spec.rb +0 -34
  188. data/spec/lib/poolparty/plugin_spec.rb +0 -115
  189. data/spec/lib/poolparty/poolparty_spec.rb +0 -60
  190. data/spec/lib/poolparty/provider_spec.rb +0 -74
  191. data/spec/lib/poolparty/remote_instance_spec.rb +0 -178
  192. data/spec/lib/poolparty/remoter_spec.rb +0 -72
  193. data/spec/lib/poolparty/remoting_spec.rb +0 -148
  194. data/spec/lib/poolparty/scheduler_spec.rb +0 -70
  195. data/spec/monitors/cpu_monitor_spec.rb +0 -39
  196. data/spec/monitors/memory_spec.rb +0 -51
  197. data/spec/monitors/misc_monitor_spec.rb +0 -51
  198. data/spec/monitors/web_spec.rb +0 -40
  199. data/spec/spec_helper.rb +0 -53
@@ -1,72 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
- require File.dirname(__FILE__) + '/../../helpers/ec2_mock'
3
-
4
- class TestRemote
5
- include Remoter
6
- include Callbacks
7
- attr_accessor :ip
8
- end
9
- describe "Remoter" do
10
- before(:each) do
11
- stub_option_load
12
-
13
- @instance = RemoteInstance.new
14
- @master = Master.new
15
-
16
- @remoter = TestRemote.new
17
- @remoter.stub!(:put).and_return "true"
18
- # @tempfile = Tempfile.new("/tmp") do |f|
19
- # f << "hi"
20
- # end
21
- Application.stub!(:ec2_dir).and_return "/Users"
22
- Application.stub!(:keypair).and_return "app"
23
- Application.stub!(:username).and_return "root"
24
- Application.stub!(:keypair_path).and_return "/Users/id_rsa-app"
25
- end
26
- it "should have an ssh method that corresponds to ssm with the keypair" do
27
- RemoteInstance.ssh_string.should =~ /ssh -o StrictHostKeyChecking=no -l 'root' -i/
28
- end
29
- it "should an ssh array that just contains the ssh commands" do
30
- RemoteInstance.ssh_array.should == ["-o StrictHostKeyChecking=no","-l 'root'","-i '/Users/id_rsa-app'"]
31
- end
32
- it "should have a list of ssh_tasks" do
33
- @remoter.ssh_tasks.should == []
34
- end
35
- it "should have a list of scp_tasks" do
36
- @remoter.scp_tasks.should == []
37
- end
38
- it "should reset the values to nil when calling reset" do
39
- @remoter.target_hosts.should_not be_nil
40
- @remoter.reset!
41
- @hosts.should be_nil
42
- end
43
- describe "executing" do
44
- it "should call set_hosts before it executes the tasks" do
45
- @remoter.should_receive(:set_hosts).once
46
- @remoter.execute_tasks {}
47
- end
48
- it "should not call set_hosts before it executes the task if it explicitly doesn't want it to" do
49
- @remoter.should_not_receive(:set_hosts)
50
- @remoter.execute_tasks(:dont_set_hosts => true) {}
51
- end
52
-
53
- describe "ssh" do
54
- before(:each) do
55
- @arr = []
56
- @arr << @a = proc{puts "hello"}
57
- @arr << @b = proc{puts "world"}
58
- @instance.stub!(:ip).and_return("127.0.0.1")
59
- end
60
- it "should run the tasks in an array with run_thread_list" do
61
- @remoter.should_receive(:run_thread_list).once
62
- @remoter.run_array_of_tasks(@arr)
63
- end
64
-
65
- it "should be able to collect the list of the target hosts's ips" do
66
- Master.should_receive(:new).and_return(@master)
67
- @master.stub!(:nodes).and_return([@instance])
68
- @remoter.target_hosts.should == %w(127.0.0.1)
69
- end
70
- end
71
- end
72
- end
@@ -1,148 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
- require File.dirname(__FILE__) + '/../../helpers/ec2_mock'
3
-
4
- describe "Master remoting: " do
5
- before(:each) do
6
- stub_option_load
7
-
8
- Kernel.stub!(:system).and_return true
9
- Application.stub!(:environment).and_return("test") # So it doesn't daemonize
10
- Application.stub!(:minimum_instances).and_return(2)
11
- Application.stub!(:maximum_instances).and_return(10)
12
- Application.stub!(:polling_time).and_return(0.1)
13
- Application.stub!(:verbose).and_return(false) # Turn off messaging
14
-
15
- @master = Master.new
16
- @master.launch_new_instance!
17
- end
18
- describe "listing" do
19
- before(:each) do
20
- Application.stub!(:keypair).and_return("alist")
21
- @a1={:instance_id => "i-a1", :ip => "127.0.0.1", :status => "running", :launching_time => 10.minutes.ago, :keypair => "alist"}
22
- @a2={:instance_id => "i-a2", :ip => "127.0.0.3", :status => "running", :launching_time => 2.hours.ago, :keypair => "alist"}
23
- @a3={:instance_id => "i-a3", :ip => "127.0.0.3", :status => "terminated", :launching_time => 2.hours.ago, :keypair => "alist"}
24
- @a4={:instance_id => "i-a4", :ip => "127.0.0.4", :status => "pending", :launching_time => 2.hours.ago, :keypair => "alist"}
25
-
26
- @b1={:instance_id => "i-b1", :ip => "127.0.0.2", :status => "terminated", :launching_time => 55.minutes.ago, :keypair => "blist"}
27
- @c1={:instance_id => "i-c1", :ip => "127.0.0.4", :status => "pending", :launching_time => 2.days.ago, :keypair => "clist"}
28
- @master.stub!(:get_instances_description).and_return [@a1, @a2, @a3, @a4, @b1, @c1]
29
- end
30
- it "should pull out the list those instances with the keypair requested" do
31
- @master.list_of_instances.collect {|a| a[:instance_id]}.should == ["i-a1", "i-a2", "i-a3", "i-a4"]
32
- end
33
- it "should pull out the list with the blist keypair" do
34
- Application.stub!(:keypair).and_return("blist")
35
- @master.list_of_instances.collect {|a| a[:instance_id]}.should == ["i-b1"]
36
- end
37
- it "should be able to pull out the list_of_nonterminated_instances" do
38
- @master.list_of_nonterminated_instances.should == [@a1, @a2, @a4]
39
- end
40
- it "should be able to pull the list of list_of_pending_instances" do
41
- @master.list_of_pending_instances.should == [@a4]
42
- end
43
- it "should be able to pull the list of list_of_running_instances" do
44
- @master.list_of_running_instances.should == [@a1, @a2]
45
- end
46
- it "should be able to get the number_of_pending_instances" do
47
- @master.number_of_pending_instances.should == 1
48
- end
49
- it "should be able to grab the number_of_running_instances" do
50
- @master.number_of_running_instances.should == 2
51
- end
52
- it "should be able to grab the entire list of instances" do
53
- @master.list_of_all_instances.should == [@a1, @a2, @a3, @a4, @b1, @c1]
54
- end
55
- it "should be able to grab the entire list sorted by keypair" do
56
- @master.cloud_keypairs.should == ["alist", "blist", "clist"]
57
- end
58
- end
59
- describe "starting" do
60
- before(:each) do
61
- @master.start_cloud!
62
-
63
- @a1={:instance_id => "i-a1", :ip => "127.0.0.1", :status => "running", :launching_time => 10.minutes.ago, :keypair => "alist"}
64
- @a2={:instance_id => "i-a2", :ip => "127.0.0.3", :status => "running", :launching_time => 2.hours.ago, :keypair => "alist"}
65
- @a3={:instance_id => "i-a3", :ip => "127.0.0.3", :status => "terminated", :launching_time => 2.hours.ago, :keypair => "alist"}
66
- @a4={:instance_id => "i-a4", :ip => "127.0.0.4", :status => "pending", :launching_time => 2.hours.ago, :keypair => "alist"}
67
-
68
- @b1={:instance_id => "i-b1", :ip => "127.0.0.2", :status => "terminated", :launching_time => 55.minutes.ago, :keypair => "blist"}
69
- @c1={:instance_id => "i-c1", :ip => "127.0.0.4", :status => "pending", :launching_time => 2.days.ago, :keypair => "clist"}
70
- @master.stub!(:get_instances_description).and_return [@a1, @a2, @a3, @a4, @b1, @c1]
71
-
72
- Application.stub!(:keypair).and_return "alist"
73
- end
74
- it "should start the cloud with instances" do
75
- @master.list_of_instances.should_not be_empty
76
- end
77
- it "should start the cloud with running instances" do
78
- @master.list_of_running_instances.should_not be_empty
79
- end
80
- it "should start with the minimum_instances running" do
81
- wait 0.5 # Give the last one time to get to running
82
- @master.list_of_running_instances.size.should == Application.minimum_instances
83
- end
84
- end
85
- describe "maintaining" do
86
- before(:each) do
87
- Application.stub!(:keypair).and_return "alist"
88
- end
89
- it "should maintain the minimum_instances if one goes down" do
90
- @master.start_cloud!
91
- wait 0.2 # Give the two instances time to boot up
92
- (Application.minimum_instances - @master.number_of_pending_and_running_instances).should == 0
93
-
94
- # Kill one off to test how it handles the response
95
- @master.terminate_instance!(@master.list_of_running_instances[0][:instance_id])
96
- (Application.minimum_instances - @master.number_of_pending_and_running_instances).should == 1
97
- @master.launch_minimum_instances # Assume this runs in the bg process
98
-
99
- (Application.minimum_instances - @master.number_of_pending_and_running_instances).should == 0
100
- @master.number_of_pending_and_running_instances.should == Application.minimum_instances
101
- end
102
- it "should launch a new instance when the load gets too heavy set in the configs" do
103
- @master.stub!(:expand?).and_return true
104
- @master.start_cloud!
105
- wait 0.5 # Give the two instances time to boot up
106
- (Application.minimum_instances - @master.number_of_pending_and_running_instances).should == 0
107
- @master.scale_cloud!
108
- @master.nodes.size.should == Application.minimum_instances + 1
109
- end
110
- it "should terminate an instance when the load shows that it's too light" do
111
- @master.stub!(:contract?).and_return true
112
- @master.start_cloud!
113
- @master.request_launch_new_instance
114
- wait 0.5 # Give the two instances time to boot up
115
- @master.number_of_pending_and_running_instances.should == Application.minimum_instances + 1
116
- @master.scale_cloud!
117
- @master.number_of_pending_and_running_instances.should == Application.minimum_instances
118
- end
119
- end
120
- describe "configuring" do
121
- before(:each) do
122
- @instance = RemoteInstance.new
123
- @instance.stub!(:ip).and_return "127.0.0.1"
124
- @instance.stub!(:name).and_return "node0"
125
- Master.stub!(:new).and_return @master
126
- @master.stub!(:nodes).and_return [@instance]
127
- end
128
- it "should call configure on all of the nodes when calling reconfigure_running_instances" do
129
- @master.nodes.each {|a|
130
- a.stub!(:status).and_return("running")
131
- a.should_receive(:configure).and_return true
132
- }
133
- @master.configure_cloud
134
- end
135
- it "should call restart_with_monit on all of the nodes when calling restart_running_instances_services" do
136
- @master.nodes.each {|a| a.should_receive(:restart_with_monit).and_return true }
137
- @master.restart_running_instances_services
138
- end
139
- it "should be able to say there are no number_of_unconfigured_nodes left when all the nodes are configured" do
140
- @master.nodes.each {|a| a.should_receive(:stack_installed?).and_return true }
141
- @master.number_of_unconfigured_nodes.should == 0
142
- end
143
- it "should be able to say that there is an unconfigured node" do
144
- @master.nodes[-1].should_receive(:stack_installed?).and_return false
145
- @master.number_of_unconfigured_nodes.should_not == 0
146
- end
147
- end
148
- end
@@ -1,70 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
-
3
- class TestSched
4
- include Scheduler
5
- end
6
- describe "Scheduler" do
7
- before(:each) do
8
- @test = TestSched.new
9
- end
10
- it "should create a ScheduleTasks" do
11
- @test._tasker.class.should == ScheduleTasks
12
- end
13
- describe "run_thread_loop" do
14
- before(:each) do
15
- @klass = Class.new
16
- @klass.stub!(:pop).once.and_return true
17
- @block = Proc.new {@klass.pop}
18
- end
19
- it "should yield the block that it is given" do
20
- @test.run_thread_list &@block
21
- end
22
- it "should run run_threads" do
23
- @test.should_receive(:run_threads).and_return true
24
- @test.run_thread_list &@block
25
- end
26
- it "should call run on the _tasker" do
27
- @test._tasker.should_receive(:run).once.and_return true
28
- @test.run_thread_list &@block
29
- end
30
- describe "ScheduleTasks class" do
31
- before(:each) do
32
- @stasks = ScheduleTasks.new
33
- @test.stub!(:_tasker).and_return(@stasks)
34
- end
35
- it "should have its tasks listed as an empty array if there are no tasks added" do
36
- @stasks.tasks.should == []
37
- end
38
- it "should have one task listed if it is added" do
39
- @test.add_task {@klass.pop}
40
- @stasks.tasks.size.should == 1
41
- end
42
- end
43
- describe "when running" do
44
- before(:each) do
45
- @test.add_task {@klass.pop}
46
- end
47
- it "should not run the tasks after adding them" do
48
- @klass.should_not_receive(:pop)
49
- @test.add_task {@klass.pop}
50
- end
51
- it "should run the tasks when run_thread_list" do
52
- @klass.should_receive(:pop)
53
- @test.run_thread_list
54
- end
55
- it "should use the ThreadPool" do
56
- p = ThreadPool.new(10)
57
- ThreadPool.should_receive(:new).with(10).and_return p
58
- @test.run_thread_list
59
- end
60
- it "should process each of the tasks" do
61
- @klass.should_receive(:pop)
62
- @test.run_thread_list
63
- end
64
- it "should empty all the tasks after running them in the loop" do
65
- @test.run_thread_list
66
- @test._tasker.tasks.size.should == 0
67
- end
68
- end
69
- end
70
- end
@@ -1,39 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require "lib/poolparty/monitors/cpu"
3
-
4
- describe "monitors" do
5
- describe "when included" do
6
- before(:each) do
7
- stub_option_load
8
- @master = Master.new
9
- @instance = RemoteInstance.new
10
- end
11
- it "should include them in the Monitors module" do
12
- @master.methods.include?("cpu").should == true
13
- end
14
- it "should also include the new methods in the remote model" do
15
- RemoteInstance.new.methods.include?("cpu").should == true
16
- end
17
- describe "master" do
18
- before(:each) do
19
- @master.stub!(:list_of_nonterminated_instances).and_return(
20
- [{:instance_id => "i-abcdde1"}]
21
- )
22
- end
23
- it "should try to collect the cpu for the entire set of remote instances when calling cpu" do
24
- @master.nodes.should_receive(:inject).once.with(0).and_return 0.0
25
- @master.cpu
26
- end
27
- end
28
- describe "remote instance" do
29
- it "should try to ssh into the remote instance" do
30
- @instance.should_receive(:run).once.with("uptime")
31
- @instance.cpu
32
- end
33
- it "should be able to find the exact amount of time the processor has been up" do
34
- @instance.stub!(:run).once.with("uptime").and_return("18:55:31 up 5 min, 1 user, load average: 0.32, 0.03, 0.00")
35
- @instance.cpu.should == 0.32
36
- end
37
- end
38
- end
39
- end
@@ -1,51 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require "lib/poolparty/monitors/memory"
3
-
4
- describe "monitors" do
5
- describe "when included" do
6
- before(:each) do
7
- stub_option_load
8
- @master = Master.new
9
- @instance = RemoteInstance.new
10
- end
11
- it "should include them in the Monitors module" do
12
- @master.methods.include?("memory").should == true
13
- end
14
- it "should also include the new methods in the remote model" do
15
- @instance.methods.include?("memory").should == true
16
- end
17
- describe "master" do
18
- before(:each) do
19
- @master.stub!(:list_of_nonterminated_instances).and_return(
20
- [{:instance_id => "i-abcdde1"}]
21
- )
22
- end
23
- it "should try to collect the cpu for the entire set of remote instances when calling cpu" do
24
- @master.nodes.should_receive(:inject).once.and_return 0.0
25
- @master.memory
26
- end
27
- end
28
- describe "remote instance" do
29
- it "should try to run into the remote instance" do
30
- @instance.should_receive(:run).once.with("free -m | grep -i mem")
31
- @instance.memory
32
- end
33
- it "should be able to find the exact amount of time the processor has been up" do
34
- @instance.stub!(:run).once.with("free -m | grep -i mem").and_return("Mem: 1700 546 1644 0 2 18")
35
- @instance.memory.round_to(2).should == 0.32
36
- end
37
- end
38
- # it "should web monitor should be able to extract the amount of the requests it can handle" do
39
- # str = "Request rate: 1.5 req/s (649.9 ms/req)"
40
- # # Monitors::Web.monitor_from_string(str).should == 1.5
41
- # end
42
- # it "should be able to monitor the percentage of memory available on the server" do
43
- # str = "Mem: 1700 56 1644 0 2 18"
44
- # # Monitors::Memory.monitor_from_string(str).to_s.should =~ /0.032/
45
- # end
46
- # it "should be able to show the load on the cpu available on the server" do
47
- # str = "18:55:31 up 5 min, 1 user, load average: 0.32, 0.03, 0.00"
48
- # # Monitors::Cpu.monitor_from_string(str).should == 0.32
49
- # end
50
- end
51
- end
@@ -1,51 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- module Database
4
- module Master
5
- def db
6
- nodes.inject(0) {|i,inst| i * inst.db} / nodes.size
7
- end
8
- end
9
- module Remote
10
- def db
11
- 5.0
12
- end
13
- end
14
- end
15
-
16
- PoolParty.register_monitor Database
17
-
18
- describe "monitors (random, to spec the inclusion)" do
19
- describe "when included" do
20
- before(:each) do
21
- stub_option_load
22
- @master = Master.new
23
- @instance = RemoteInstance.new
24
- end
25
- it "should include them in the Monitors module" do
26
- @master.methods.include?("db").should == true
27
- end
28
- it "should also include the new methods in the remote model" do
29
- @instance.methods.include?("db").should == true
30
- end
31
- describe "master" do
32
- before(:each) do
33
- @master.stub!(:list_of_nonterminated_instances).and_return(
34
- [{:instance_id => "i-abcdde1"}]
35
- )
36
- end
37
- it "should try to collect the cpu for the entire set of remote instances when calling cpu" do
38
- @master.nodes.should_receive(:inject).once.and_return 5.0
39
- @master.db.should == 5.0
40
- end
41
- end
42
- describe "remote instance" do
43
- it "should try to run into the remote instance" do
44
- @instance.db.should == 5.0
45
- end
46
- it "should be able to find the exact amount of time the processor has been up" do
47
- @instance.db.round_to(2).should == 5.0
48
- end
49
- end
50
- end
51
- end
@@ -1,40 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require "lib/poolparty/monitors/web"
3
-
4
- describe "monitors" do
5
- describe "when included" do
6
- before(:each) do
7
- stub_option_load
8
- Application.stub!(:client_port).and_return 8001
9
- @master = Master.new
10
- @instance = RemoteInstance.new
11
- end
12
- it "should include them in the Monitors module" do
13
- @master.methods.include?("web").should == true
14
- end
15
- it "should also include the new methods in the remote model" do
16
- @instance.methods.include?("web").should == true
17
- end
18
- describe "master" do
19
- before(:each) do
20
- @master.stub!(:list_of_nonterminated_instances).and_return(
21
- [{:instance_id => "i-abcdde1"}]
22
- )
23
- end
24
- it "should try to collect the cpu for the entire set of remote instances when calling cpu" do
25
- @master.nodes.should_receive(:inject).once.and_return 0.0
26
- @master.web
27
- end
28
- end
29
- describe "remote instance" do
30
- it "should try to run into the remote instance" do
31
- @instance.should_receive(:run).once.with("httperf --server localhost --port #{Application.client_port} --num-conn 3 --timeout 5 | grep 'Request rate'")
32
- @instance.web
33
- end
34
- it "should be able to find the exact amount of time the processor has been up" do
35
- @instance.stub!(:run).once.and_return("Request rate: 1.5 req/s (649.9 ms/req)")
36
- @instance.web.round_to(2).should == 1.5
37
- end
38
- end
39
- end
40
- end