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,34 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
-
3
- describe "Optioner with options" do
4
- it "should be able to pull out the lonely arguments without any switches" do
5
- Optioner.parse("hello".split(" ")).should == ["hello"]
6
- end
7
- it "should be able to pull out the lonely arguments with switches" do
8
- Optioner.parse("-s 30.seconds -m hello world".split(" ")).should == ["world"]
9
- end
10
- it "should be able to pull out start from the the string" do
11
- Optioner.parse("-c 'config/config.yml' -A 'Who' -S 'DarkwingDuck' list".split(" ")).should == ["list"]
12
- end
13
- it "should be able to pull out the lonely arguments with optional argument switches" do
14
- Optioner.parse("-s 30 -q -n start".split(" "), %w(-q -n)).should == ["start"]
15
- end
16
- it "should be able to pull out the lonely arguments with optional argument switches in any order" do
17
- Optioner.parse("start -s 30 -q -n".split(" "), %w(-q -n)).should == ["start"]
18
- end
19
- it "should be able to pull out the lonely, default arguments with optional argument switches" do
20
- Optioner.parse("-s 30 -q -n start -i -v".split(" "), %w(-q -n)).should == ["start"]
21
- end
22
- it "should pull out the lonely arguments if none are there" do
23
- Optioner.parse("-s 30 -q".split(" ")).should == []
24
- end
25
- it "should pull out empty array if there are no lonely arguments" do
26
- Optioner.parse("-s 30".split(" ")).should == []
27
- end
28
- it "should pull out quoted arguments" do
29
- Optioner.parse("-s 30 'ls'".split(" ")).should == ["'ls'"]
30
- end
31
- it "should be able to pull out a quoted argument in a sea of nonquotes" do
32
- Optioner.parse("-v -k auser scp 'pkg/poolparty-0.0.9.gem'".split(" ")).should == ["scp", "'pkg/poolparty-0.0.9.gem'"]
33
- end
34
- end
@@ -1,115 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
- require File.dirname(__FILE__) + '/../../helpers/ec2_mock'
3
-
4
- class TestPlugin < PoolParty::Plugin
5
- after_define_tasks :takss
6
- after_install :email_updates, :echo_hosts
7
- before_configure_cloud :echo_hosts
8
- after_start :echo_start
9
-
10
- def echo_start(master)
11
- "start"
12
- end
13
- def echo_hosts(caller)
14
- write_out "hosts"
15
- end
16
- def email_updates(caller)
17
- write_out "email_updates"
18
- end
19
- def takss(tasks)
20
- "tasks"
21
- end
22
- def write_out(msg="")
23
- end
24
- end
25
-
26
- describe "Plugin" do
27
- it "should define run_before method" do
28
- TestPlugin.methods.include?("before_install").should == true
29
- end
30
- it "should define run_after method" do
31
- TestPlugin.methods.include?("after_install").should == true
32
- end
33
- it "should define a singleton method on the plugin'ed class" do
34
- Master.new.methods.include?("testplugin").should == true
35
- end
36
- describe "usage" do
37
- before(:each) do
38
- stub_option_load
39
- @num = 2
40
- @test, @master, @instances = PoolParty::PluginSpecHelper.define_stubs(TestPlugin, @num)
41
- @instance = @instances.first
42
- end
43
- it "should should call echo_hosts after calling configure" do
44
- @test.should_receive_at_least_once(:write_out).with("email_updates")
45
- @instance.install
46
- end
47
- describe "installation" do
48
- before(:each) do
49
- Application.stub!(:install_on_load?).and_return true
50
- end
51
- it "should call install on each of the instances after calling install_cloud" do
52
- @test.should_receive(:email_updates).exactly(@num)
53
- @test.should_receive(:echo_hosts).exactly(@num)
54
- @master.install_cloud
55
- end
56
- it "should call email_updates after calling install" do
57
- @test.should_receive(:email_updates).twice
58
- @master.install_cloud
59
- end
60
- it "should call echo_hosts before it calls configure" do
61
- @test.should_receive(:echo_hosts).at_least(1).and_return "hi"
62
- @master.install_cloud
63
- end
64
- end
65
- it "should say that it started on the master" do
66
- @master.stub!(:launch_minimum_instances)
67
- @master.stub!(:wait_for_all_instances_to_boot)
68
- @master.stub!(:setup_cloud)
69
- @test.should_receive(:echo_start).at_least(1).and_return "hi"
70
- @master.start
71
- end
72
- it "should not call echo_hosts after if configures" do
73
- @test.stub!(:echo_hosts).and_return true
74
- @test.should_not_receive(:email_updates)
75
- @master.configure_cloud
76
- end
77
- describe "user-data" do
78
- it "should be able to add to the user-data with a string" do
79
- @test.add_user_data("hollow")
80
- Application.launching_user_data.should =~ /:user_data: hollow/
81
- end
82
- it "should be able to add a hash to the user-data with a hash" do
83
- @test.add_user_data(:box => "box")
84
- Application.launching_user_data.should =~ /:box: box/
85
- end
86
- end
87
- describe "instance methods" do
88
- before(:each) do
89
- @str = "filename"
90
- @str.stub!(:read).and_return "filename"
91
- @test.stub!(:open).and_return @str
92
- end
93
- it "should try to open the file with the given filename" do
94
- @test.should_receive(:open).with("filename").and_return @str
95
- @test.read_config_file("filename")
96
- end
97
- it "should open a yaml file" do
98
- YAML.should_receive(:load).with("filename").and_return ""
99
- @test.read_config_file("filename")
100
- end
101
- describe "when reading the yaml file" do
102
- before(:each) do
103
- @str.stub!(:read).and_return ":username: eddie\n:password: eddie"
104
- end
105
- it "should parse the yaml file to a Hash" do
106
- @str.should_receive(:read).and_return ":username: eddie\n:password: eddie"
107
- @test.read_config_file("filename").class.should == Hash
108
- end
109
- it "should parse the yaml file into the proper hash" do
110
- @test.read_config_file("filename").should == {:username => "eddie", :password => "eddie"}
111
- end
112
- end
113
- end
114
- end
115
- end
@@ -1,60 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
-
3
- module TestMonitor
4
- module Master
5
- end
6
- module Remote
7
- end
8
- end
9
-
10
- describe "Application options" do
11
- before(:each) do
12
- stub_option_load
13
- end
14
- it "should be able to say that the plugin directory is the current directory" do
15
- File.basename(PoolParty.plugin_dir).should == "plugins"
16
- end
17
- it "should not load plugins if the directory doesn't exist" do
18
- File.stub!(:directory?).with(plugin_dir).and_return false
19
- Dir.should_not_receive(:[])
20
- PoolParty.load_plugins
21
- end
22
- it "should load the plugins if the directory exists" do
23
- File.stub!(:directory?).with(plugin_dir).and_return true
24
- Dir.should_receive(:[]).and_return %w()
25
- PoolParty.load_plugins
26
- end
27
- describe "monitors" do
28
- before(:each) do
29
- PoolParty.reset!
30
- end
31
- it "should load a monitor and store it into the registered monitor's array" do
32
- PoolParty.register_monitor TestMonitor
33
- PoolParty.registered_monitors.include?(TestMonitor).should == true
34
- end
35
- it "should be able to ask if the monitor is a registered monitor" do
36
- PoolParty.register_monitor TestMonitor
37
- PoolParty.registered_monitor?(TestMonitor).should == true
38
- end
39
- it "should not register a monitor more than once" do
40
- PoolParty::Monitors.should_receive(:extend).once
41
- PoolParty.register_monitor TestMonitor
42
- PoolParty.register_monitor TestMonitor
43
- end
44
- it "should try to load from the user directory before the root lib directory" do
45
- File.should_receive_at_least_once(:directory?).with("#{user_dir}/monitors").and_return true
46
- Dir.should_receive(:[]).with("#{user_dir}/monitors/*").and_return([])
47
- PoolParty.load_app
48
- end
49
- it "should try to load from the root directory if the user directory monitors don't exist" do
50
- File.should_receive_at_least_once(:directory?).with("#{user_dir}/monitors").and_return false
51
- Dir.should_receive(:[]).with("#{Application.root_dir}/lib/poolparty/monitors/*").and_return([])
52
- PoolParty.load_app
53
- end
54
- it "should load the monitors and the plugins" do
55
- PoolParty.should_receive(:load_plugins)
56
- PoolParty.should_receive(:load_monitors)
57
- PoolParty.load_app
58
- end
59
- end
60
- end
@@ -1,74 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
- require File.dirname(__FILE__) + '/../../helpers/ec2_mock'
3
-
4
- describe "Provider" do
5
- before(:each) do
6
- stub_option_load
7
- Sprinkle::Script.stub!(:sprinkle).and_return true
8
- @ips = ["127.0.0.1"]
9
- Master.stub!(:cloud_ips).and_return @ips
10
- end
11
- it "should load the packages in the package directory" do
12
- Dir.should_receive(:[]).and_return []
13
- Provider.new.load_packages
14
- end
15
- it "should load the packages defined in the user directory"
16
- describe "running" do
17
- describe "server packages" do
18
- before(:each) do
19
- @provider = Provider.new
20
- @str = "new"
21
- @str.stub!(:process).and_return true
22
- @provider.stub!(:set_start_with_sprinkle).and_return @str
23
- Provider.stub!(:new).and_return @provider
24
- Master.stub!(:cloud_ips).and_return ["127.0.0.1"]
25
- end
26
- it "should use the loaded packages to install" do
27
- @provider.should_receive(:load_packages).and_return []
28
- @provider.install_poolparty
29
- end
30
- it "should load the install script when installing" do
31
- @provider.should_receive(:set_start_with_sprinkle).and_return true
32
- @provider.install_poolparty
33
- end
34
- describe "user packages" do
35
- describe "defining" do
36
- before(:each) do
37
- @stdout = nil
38
- Provider.define_custom_package(:sprinkle) do
39
- package :sprinkle, :provides => :package do
40
- description 'Sprinkle'
41
- apt %w( sprinkle )
42
- end
43
- end
44
- end
45
- it "should be able to define user packages with blocks and pass those into the user_packages" do
46
- Provider.user_packages.size.should == 1
47
- end
48
- it "should define the user packages as Sprinkle::Package::Package" do
49
- Provider.user_packages.first.class.should == Sprinkle::Package::Package
50
- end
51
- end
52
- describe "defining custom packages" do
53
- before(:each) do
54
- Provider.reset!
55
- @provider.stub!(:set_start_with_sprinkle).and_return true
56
- @provider.stub!(:process).and_return true
57
- @proc = lambda {package :custom do;description 'custom packages';end}
58
- Provider.define_custom_package(:custom)
59
- end
60
- it "should be able to define a custom package with a name" do
61
- Provider.user_packages.size.should > 1
62
- end
63
- it "should have the name of the custom package built in" do
64
- Provider.user_install_packages.sort {|a,b| a.to_s <=> b.to_s }.should == [:custom, :sprinkle]
65
- end
66
- end
67
- it "should not run the installer if we are in testing mode" do
68
- @provider.should_not_receive(:process)
69
- hide_output { Provider.install_poolparty(true) }
70
- end
71
- end
72
- end
73
- end
74
- end
@@ -1,178 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
- require File.dirname(__FILE__) + '/../../helpers/ec2_mock'
3
-
4
- class RemoteInstance
5
- def scp(src="", dest="", opts={})
6
- "true"
7
- end
8
- # Ssh into the instance or run a command, if the cmd is set
9
- def ssh(cmd="")
10
- "true"
11
- end
12
- end
13
- describe "remote instance" do
14
- before(:each) do
15
- stub_option_load
16
- @instance = RemoteInstance.new({:ip => "127.0.0.1", :instance_id => "i-abcdef1"})
17
- @instance.stub!(:ssh).and_return true
18
- @instance.stub!(:scp).and_return true
19
- Kernel.stub!(:system).and_return true
20
-
21
- @master = Master.new
22
- end
23
-
24
- describe "in general" do
25
- it "should set the ip upon creation" do
26
- @instance.ip.should == "127.0.0.1"
27
- end
28
- it "should be able to tell if it is the master" do
29
- @instance.master?.should == true
30
- end
31
- it "should be able to say that it isn't secondary?" do
32
- @instance.secondary?.should_not be_true
33
- end
34
- it "should be able to build itself a haproxy_resources_entry" do
35
- @instance.haproxy_resources_entry.should =~ /node0/
36
- end
37
- it "should be able to build a list of the heartbeat nodes" do
38
- @instance.node_entry.should =~ /node0/
39
- end
40
- it "should be able to build a hosts_entry for self" do
41
- @instance.hosts_entry.should =~ /node0/
42
- end
43
- it "should be able to have local_hosts_entry with 127.0.0.01" do
44
- @instance.local_hosts_entry.should =~ /127\.0\.0\.1/
45
- end
46
- it "should have a heartbeat_entry" do
47
- @instance.heartbeat_entry.should =~ /127\.0\.0\.1/
48
- @instance.heartbeat_entry.should =~ /#{Application.managed_services}/
49
- end
50
- it "should be able to build a haproxy_entry" do
51
- @instance.haproxy_entry.should =~ /server/
52
- end
53
- end
54
- describe "new configuration style (build scripts)" do
55
- before(:each) do
56
- @tempfile = Tempfile.new("/tmp")
57
- Kernel.stub!(:system).and_return true
58
- stub_option_load
59
- end
60
- describe "configure tasks" do
61
- it "should move_hostfile" do
62
- @instance.should_receive(:change_hostname).once.and_return ""
63
- @instance.configure_tasks
64
- end
65
- it "should configure_master" do
66
- @instance.should_receive(:configure_master).once.and_return ""
67
- @instance.configure_tasks
68
- end
69
- it "should move_config_file" do
70
- @instance.should_receive(:move_config_file).once.and_return ""
71
- @instance.configure_tasks
72
- end
73
- it "should mount_s3_drive" do
74
- @instance.should_receive(:mount_s3_drive).once.and_return ""
75
- @instance.configure_tasks
76
- end
77
- it "should update_plugin_string" do
78
- @instance.should_receive(:update_plugin_string).once.and_return ""
79
- @instance.configure_tasks
80
- end
81
- it "should setup_pems" do
82
- @instance.should_receive(:setup_pems).once.and_return ""
83
- @instance.configure_tasks
84
- end
85
- it "should configure_authkeys" do
86
- @instance.should_receive(:configure_authkeys).once.and_return ""
87
- @instance.configure_tasks
88
- end
89
- it "should configure_resource_d" do
90
- @instance.should_receive(:configure_resource_d).once.and_return ""
91
- @instance.configure_tasks
92
- end
93
- it "should setup_haproxy" do
94
- @instance.should_receive(:setup_haproxy).once.and_return ""
95
- @instance.configure_tasks
96
- end
97
- it "should configure_heartbeat" do
98
- @instance.should_receive(:configure_heartbeat).once.and_return ""
99
- @instance.configure_tasks
100
- end
101
- it "should run user_tasks" do
102
- @instance.should_receive(:user_tasks).once.and_return ""
103
- @instance.configure_tasks
104
- end
105
- end
106
- describe "with a public ip" do
107
- before(:each) do
108
- Application.stub!(:public_ip).and_return "127.0.0.1"
109
- Master.stub!(:new).and_return @master
110
- @master.stub!(:nodes).and_return [@instance]
111
- end
112
- it "should call configure on the instances after configure_cloud" do
113
- @instance.should_receive(:configure).and_return true
114
- @master.configure_cloud
115
- end
116
- it "should run associate_address if there is a public_ip set in the Application.options" do
117
- @instance.should_receive(:associate_address_with).with(Application.public_ip, @instance.instance_id).at_least(1).and_return true
118
- @master.configure_cloud
119
- end
120
- it "should not run associate_address_with if the public_ip is empty" do
121
- Application.stub!(:public_ip).and_return ""
122
- @instance.should_not_receive(:associate_address_with)
123
- @master.configure_cloud
124
- end
125
- it "should untar and move plugin directories around" do
126
- dir = File.basename Application.plugin_dir
127
- @instance.update_plugin_string.should == "if [ -f ~/tmp/plugins.tar.gz ]; then mkdir -p plugins && tar -zxf ~/tmp/plugins.tar.gz -C plugins; fi"
128
- end
129
- end
130
- end
131
- describe "in failover" do
132
- before(:each) do
133
- Master.stub!(:new).and_return @master
134
- end
135
- it "should be able to become master " do
136
- @instance.stub!(:configure).and_return true
137
- @instance.number = 1
138
- @instance.become_master
139
- @instance.number.should == 0
140
- end
141
- it "should reconfigure after becoming master" do
142
- @master.should_receive(:configure_cloud).and_return true
143
- @instance.should_receive(:configure).and_return true
144
- @instance.become_master
145
- end
146
- it "should say that it is the master after becoming master" do
147
- @instance.stub!(:configure).and_return true
148
- @instance.become_master
149
- @instance.master?.should == true
150
- end
151
- it "should be able to detect is_not_master_and_master_is_not_running? and return false when the server is the master" do
152
- @instance.is_not_master_and_master_is_not_running?.should == false
153
- end
154
- it "should be able to detect is_not_master_and_master_is_not_running? and return false when the master server is responding" do
155
- Master.stub!(:is_master_responding?).and_return true
156
- @instance.is_not_master_and_master_is_not_running?.should == false
157
- end
158
- it "should be able to detect is_not_master_and_master_is_not_running? and return false when the master server is responding" do
159
- @instance.stub!(:master?).and_return false
160
- Master.stub!(:is_master_responding?).and_return false
161
- @instance.is_not_master_and_master_is_not_running?.should == true
162
- end
163
-
164
- describe "when installing the poolparty software" do
165
- before(:each) do
166
- @instance.stub!(:run).and_return false
167
- end
168
- it "should be able to detect if the stack_installed? == false" do
169
- @instance.stack_installed?.should == false
170
- end
171
- it "should set the stack_installed? once installed" do
172
- @instance.install
173
- @instance.stack_installed?.should == true
174
- end
175
- end
176
-
177
- end
178
- end