auser-poolparty 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -0
- data/README.txt +5 -7
- data/Rakefile +27 -12
- data/bin/instance +2 -2
- data/bin/pool +8 -6
- data/config/reconfigure_instances_script.sh +3 -3
- data/config/sample-config.yml +1 -1
- data/lib/core/array.rb +5 -2
- data/lib/core/hash.rb +1 -1
- data/lib/core/string.rb +6 -2
- data/lib/helpers/plugin_spec_helper.rb +4 -5
- data/lib/modules/sprinkle_overrides.rb +24 -29
- data/lib/poolparty/application.rb +37 -27
- data/lib/poolparty/master.rb +35 -14
- data/lib/poolparty/plugin.rb +11 -6
- data/lib/poolparty/plugin_manager.rb +2 -2
- data/lib/poolparty/provider/{packages/essential.rb → essential.rb} +0 -0
- data/lib/poolparty/provider/{packages/git.rb → git.rb} +0 -0
- data/lib/poolparty/provider/{packages/haproxy.rb → haproxy.rb} +1 -1
- data/lib/poolparty/provider/{packages/heartbeat.rb → heartbeat.rb} +0 -0
- data/lib/poolparty/provider/{packages/rsync.rb → rsync.rb} +0 -0
- data/lib/poolparty/provider/{packages/ruby.rb → ruby.rb} +1 -1
- data/lib/poolparty/provider/{packages/s3fuse.rb → s3fuse.rb} +0 -0
- data/lib/poolparty/provider.rb +86 -2
- data/lib/poolparty/remote_instance.rb +35 -21
- data/lib/poolparty/remoter.rb +4 -1
- data/lib/poolparty/remoting.rb +2 -1
- data/lib/poolparty/tasks/cloud.rake +1 -1
- data/lib/poolparty/tasks/development.rake +48 -13
- data/lib/poolparty/tasks.rb +24 -6
- data/lib/poolparty.rb +8 -4
- data/poolparty.gemspec +10 -7
- data/spec/helpers/ec2_mock.rb +5 -2
- data/spec/{application_spec.rb → lib/application_spec.rb} +42 -9
- data/spec/{callback_spec.rb → lib/callback_spec.rb} +1 -1
- data/spec/{core_spec.rb → lib/core_spec.rb} +6 -4
- data/spec/{ec2_wrapper_spec.rb → lib/ec2_wrapper_spec.rb} +3 -3
- data/spec/{file_writer_spec.rb → lib/file_writer_spec.rb} +2 -2
- data/spec/{kernel_spec.rb → lib/kernel_spec.rb} +1 -1
- data/spec/{master_spec.rb → lib/master_spec.rb} +38 -16
- data/spec/{optioner_spec.rb → lib/optioner_spec.rb} +1 -1
- data/spec/{plugin_manager_spec.rb → lib/plugin_manager_spec.rb} +3 -3
- data/spec/{plugin_spec.rb → lib/plugin_spec.rb} +12 -1
- data/spec/{pool_binary_spec.rb → lib/pool_binary_spec.rb} +1 -1
- data/spec/{poolparty_spec.rb → lib/poolparty_spec.rb} +5 -5
- data/spec/lib/provider_spec.rb +72 -0
- data/spec/{remote_instance_spec.rb → lib/remote_instance_spec.rb} +51 -9
- data/spec/{remoter_spec.rb → lib/remoter_spec.rb} +7 -2
- data/spec/{remoting_spec.rb → lib/remoting_spec.rb} +60 -4
- data/spec/{scheduler_spec.rb → lib/scheduler_spec.rb} +1 -1
- data/spec/{string_spec.rb → lib/string_spec.rb} +1 -1
- data/spec/monitors/cpu_monitor_spec.rb +2 -2
- data/spec/monitors/memory_spec.rb +3 -3
- data/spec/monitors/misc_monitor_spec.rb +1 -1
- data/spec/monitors/web_spec.rb +3 -3
- metadata +46 -41
- data/lib/poolparty/provider/packages/monit.rb +0 -6
- data/lib/poolparty/provider/provider.rb +0 -100
- data/spec/provider_spec.rb +0 -18
@@ -1,11 +1,11 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
class TestClass
|
4
4
|
include FileWriter
|
5
5
|
end
|
6
6
|
describe "FileWriter" do
|
7
7
|
before(:each) do
|
8
|
-
Application.reset!
|
8
|
+
# Application.reset!
|
9
9
|
@instance = RemoteInstance.new
|
10
10
|
@instance.stub!(:name).and_return "node0"
|
11
11
|
@instance.stub!(:ip).and_return "127.0.0.1"
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
2
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../helpers/ec2_mock'
|
3
3
|
|
4
4
|
describe "Master" do
|
5
5
|
before(:each) do
|
@@ -8,8 +8,10 @@ describe "Master" do
|
|
8
8
|
Kernel.stub!(:exec).and_return true
|
9
9
|
Kernel.stub!(:sleep).and_return true # WHy wait?, just do it
|
10
10
|
|
11
|
+
Application.options
|
12
|
+
|
11
13
|
Application.options.stub!(:contract_when).and_return("web > 30.0\n cpu < 0.10")
|
12
|
-
Application.options.stub!(:expand_when).and_return("web < 3.0\n cpu > 0.80")
|
14
|
+
Application.options.stub!(:expand_when).and_return("web < 3.0\n cpu > 0.80")
|
13
15
|
@master = Master.new
|
14
16
|
end
|
15
17
|
after(:all) do
|
@@ -111,10 +113,10 @@ describe "Master" do
|
|
111
113
|
it "should be able to return the size of the cloud" do
|
112
114
|
@master.nodes.size.should == 3
|
113
115
|
end
|
114
|
-
it "should be able to restart the running instances' services" do
|
115
|
-
|
116
|
-
|
117
|
-
end
|
116
|
+
# it "should be able to restart the running instances' services" do
|
117
|
+
# @master.nodes.each {|a| a.should_receive(:restart_with_monit).and_return true }
|
118
|
+
# @master.restart_running_instances_services
|
119
|
+
# end
|
118
120
|
it "should be able to build a heartbeat auth file" do
|
119
121
|
open(@master.build_and_copy_heartbeat_authkeys_file.path).read.should =~ /1 md5/
|
120
122
|
end
|
@@ -157,7 +159,7 @@ describe "Master" do
|
|
157
159
|
end
|
158
160
|
describe "rsync'ing the files to the instances" do
|
159
161
|
it "should cleanup the tmp directory before sending configuration to the nodes" do
|
160
|
-
@master.should_receive(:cleanup_tmp_directory).
|
162
|
+
@master.should_receive(:cleanup_tmp_directory).at_least(1)
|
161
163
|
@master.build_and_send_config_files_in_temp_directory
|
162
164
|
end
|
163
165
|
it "should receive send_config_files_to_nodes after it builds the config files in the temp directory" do
|
@@ -199,13 +201,16 @@ describe "Master" do
|
|
199
201
|
before(:each) do
|
200
202
|
Application.stub!(:install_on_load?).and_return true
|
201
203
|
Sprinkle::Script.stub!(:sprinkle).and_return true
|
204
|
+
Provider.stub!(:install_poolparty).and_return true
|
202
205
|
@master.stub!(:ssh).and_return true
|
203
206
|
@master.nodes.each do |node|
|
204
207
|
node.stub!(:run_now).and_return true
|
205
208
|
end
|
206
209
|
end
|
207
|
-
|
208
|
-
|
210
|
+
after(:all) do
|
211
|
+
Kernel.system("ssh-add -d #{Application.keypair_path} >/dev/null 2>/dev/null")
|
212
|
+
end
|
213
|
+
it "should install on the instances if the application says it should" do
|
209
214
|
Provider.should_receive(:install_poolparty)
|
210
215
|
@master.install_cloud
|
211
216
|
end
|
@@ -213,18 +218,24 @@ describe "Master" do
|
|
213
218
|
@master.should_receive(:ssh).and_return true
|
214
219
|
@master.install_cloud
|
215
220
|
end
|
221
|
+
it "should store the ssh keypair before install" do
|
222
|
+
Kernel.should_receive(:system).with("ssh-add #{Application.keypair_path} >/dev/null 2>/dev/null").at_least(1).and_return true
|
223
|
+
@master.install_cloud
|
224
|
+
end
|
225
|
+
it "should delete the ssh keypair after configure_cloud" do
|
226
|
+
Kernel.should_receive_at_least_once(:system).with("ssh-add -d #{Application.keypair_name} >/dev/null 2>/dev/null").and_return true
|
227
|
+
@master.configure_cloud
|
228
|
+
end
|
216
229
|
describe "stubbing installation" do
|
217
230
|
before(:each) do
|
218
231
|
@master.stub!(:execute_tasks).and_return true
|
219
232
|
end
|
220
233
|
it "should install poolparty" do
|
221
234
|
Provider.should_receive(:install_poolparty).and_return true
|
222
|
-
Provider.should_receive(:install_userpackages).and_return true
|
223
235
|
@master.install_cloud
|
224
236
|
end
|
225
237
|
it "should install the user packages" do
|
226
238
|
Provider.should_receive(:install_poolparty).and_return true
|
227
|
-
Provider.should_receive(:install_userpackages).and_return true
|
228
239
|
@master.install_cloud
|
229
240
|
end
|
230
241
|
end
|
@@ -333,8 +344,7 @@ describe "Master" do
|
|
333
344
|
File.directory?(@master.base_tmp_dir).should == true
|
334
345
|
end
|
335
346
|
it "should copy the cloud_master_takeover script to the tmp directory" do
|
336
|
-
@master.
|
337
|
-
File.should_receive(:copy).exactly(3).and_return true
|
347
|
+
@master.should_not_receive(:get_config_file_for)
|
338
348
|
@master.build_and_send_config_files_in_temp_directory
|
339
349
|
end
|
340
350
|
it "should tar the plugin_dir into the tmp directory" do
|
@@ -343,6 +353,18 @@ describe "Master" do
|
|
343
353
|
Kernel.should_receive(:system).with("tar -czf #{@master.base_tmp_dir}/plugins.tar.gz #{File.basename(Application.plugin_dir)}").and_return true
|
344
354
|
@master.build_and_send_config_files_in_temp_directory
|
345
355
|
end
|
356
|
+
it "should try to copy the pem files" do
|
357
|
+
@master.should_receive(:copy_pem_files_to_tmp_dir).and_return true
|
358
|
+
@master.build_and_send_config_files_in_temp_directory
|
359
|
+
end
|
360
|
+
it "should try to copy the cert file" do
|
361
|
+
File.should_receive(:copy).with("/Users/auser/.ec2/current/cert-56EMRIBSJ56JJ5P6QEGXICFOO6DDVVDD.pem", "/Users/auser/Sites/work/citrusbyte/internal/gems/pool-party/pool/tmp/cert-56EMRIBSJ56JJ5P6QEGXICFOO6DDVVDD.pem")
|
362
|
+
@master.copy_pem_files_to_tmp_dir
|
363
|
+
end
|
364
|
+
it "should try the copy the pk file" do
|
365
|
+
File.should_receive(:copy).with("/Users/auser/.ec2/current/pk-56EMRIBSJ56JJ5P6QEGXICFOO6DDVVDD.pem", "/Users/auser/Sites/work/citrusbyte/internal/gems/pool-party/pool/tmp/pk-56EMRIBSJ56JJ5P6QEGXICFOO6DDVVDD.pem")
|
366
|
+
@master.copy_pem_files_to_tmp_dir
|
367
|
+
end
|
346
368
|
describe "get configs" do
|
347
369
|
before(:each) do
|
348
370
|
@master.stub!(:user_dir).and_return("user")
|
@@ -360,7 +382,7 @@ describe "Master" do
|
|
360
382
|
it "should copy the config file if it exists" do
|
361
383
|
Application.stub!(:config_file).and_return "config.yml"
|
362
384
|
File.stub!(:exists?).and_return true
|
363
|
-
File.should_receive(:copy).
|
385
|
+
File.should_receive(:copy).at_least(2).times.and_return true
|
364
386
|
@master.build_and_send_config_files_in_temp_directory
|
365
387
|
end
|
366
388
|
describe "with copy_config_files_in_directory_to_tmp_dir method" do
|
@@ -387,7 +409,7 @@ describe "Master" do
|
|
387
409
|
end
|
388
410
|
it "should copy all the resource.d files from the monit directory to the tmp directory" do
|
389
411
|
@master.stub!(:copy_config_files_in_directory_to_tmp_dir).with("config/resource.d").and_return true
|
390
|
-
@master.should_receive(:copy_config_files_in_directory_to_tmp_dir).at_least(1).with("config/monit.d").and_return true
|
412
|
+
# @master.should_receive(:copy_config_files_in_directory_to_tmp_dir).at_least(1).with("config/monit.d").and_return true
|
391
413
|
@master.build_and_send_config_files_in_temp_directory
|
392
414
|
end
|
393
415
|
it "should build the authkeys file for haproxy" do
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe "Plugin manager" do
|
4
4
|
before(:each) do
|
5
5
|
FileUtils.stub!(:mkdir_p).and_return true
|
6
|
-
Dir["./spec/../lib/../
|
6
|
+
Dir["./spec/../lib/../plugin/*"].each {|a| FileUtils.rm_rf a}
|
7
7
|
Git.stub!(:clone).and_return true
|
8
8
|
PluginManager.stub!(:extract_git_repos_from_plugin_dirs).and_return %w(git@github.com:auser/poolparty-plugins.git)
|
9
9
|
end
|
10
10
|
it "should git clone the directory when it is installing a plugin" do
|
11
11
|
File.stub!(:directory?).and_return false
|
12
|
-
Git.should_receive(:clone).with("git@github.com:auser/poolparty.git", "/Users/auser/Sites/work/citrusbyte/internal/gems/pool-party/pool/
|
12
|
+
Git.should_receive(:clone).with("git@github.com:auser/poolparty.git", "/Users/auser/Sites/work/citrusbyte/internal/gems/pool-party/pool/plugin/poolparty").and_return true
|
13
13
|
PluginManager.install_plugin "git@github.com:auser/poolparty.git"
|
14
14
|
end
|
15
15
|
it "should keep a list of the installed plugin locations" do
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + "/../helpers/ec2_mock"
|
2
3
|
|
3
4
|
class TestPlugin < PoolParty::Plugin
|
4
5
|
after_define_tasks :takss
|
@@ -73,6 +74,16 @@ describe "Plugin" do
|
|
73
74
|
@test.should_not_receive(:email_updates)
|
74
75
|
@master.configure_cloud
|
75
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
|
76
87
|
describe "instance methods" do
|
77
88
|
before(:each) do
|
78
89
|
@str = "filename"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
module TestMonitor
|
4
4
|
module Master
|
@@ -12,7 +12,7 @@ describe "Application options" do
|
|
12
12
|
stub_option_load
|
13
13
|
end
|
14
14
|
it "should be able to say that the plugin directory is the current directory" do
|
15
|
-
File.basename(PoolParty.plugin_dir).should == "
|
15
|
+
File.basename(PoolParty.plugin_dir).should == "plugins"
|
16
16
|
end
|
17
17
|
it "should not load plugins if the directory doesn't exist" do
|
18
18
|
File.stub!(:directory?).with(plugin_dir).and_return false
|
@@ -44,17 +44,17 @@ describe "Application options" do
|
|
44
44
|
it "should try to load from the user directory before the root lib directory" do
|
45
45
|
File.should_receive_at_least_once(:directory?).with("#{user_dir}/monitors").and_return true
|
46
46
|
Dir.should_receive(:[]).with("#{user_dir}/monitors/*").and_return([])
|
47
|
-
PoolParty.
|
47
|
+
PoolParty.load_app
|
48
48
|
end
|
49
49
|
it "should try to load from the root directory if the user directory monitors don't exist" do
|
50
50
|
File.should_receive_at_least_once(:directory?).with("#{user_dir}/monitors").and_return false
|
51
51
|
Dir.should_receive(:[]).with("#{Application.root_dir}/lib/poolparty/monitors/*").and_return([])
|
52
|
-
PoolParty.
|
52
|
+
PoolParty.load_app
|
53
53
|
end
|
54
54
|
it "should load the monitors and the plugins" do
|
55
55
|
PoolParty.should_receive(:load_plugins)
|
56
56
|
PoolParty.should_receive(:load_monitors)
|
57
|
-
PoolParty.
|
57
|
+
PoolParty.load_app
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -0,0 +1,72 @@
|
|
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
|
+
end
|
35
|
+
describe "user packages" do
|
36
|
+
describe "defining" do
|
37
|
+
before(:each) do
|
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 strings" do
|
49
|
+
Provider.user_packages.first.class.should == Proc
|
50
|
+
end
|
51
|
+
end
|
52
|
+
describe "defining custom packages" do
|
53
|
+
before(:each) do
|
54
|
+
Provider.reset!
|
55
|
+
Provider.define_custom_package(:custom) do
|
56
|
+
<<-EOE
|
57
|
+
package :custom do
|
58
|
+
description 'custom packages'
|
59
|
+
end
|
60
|
+
EOE
|
61
|
+
end
|
62
|
+
end
|
63
|
+
it "should be able to define a custom package with a name" do
|
64
|
+
Provider.user_packages.size.should > 1
|
65
|
+
end
|
66
|
+
it "should have the name of the custom package built in" do
|
67
|
+
Provider.user_install_packages.sort {|a,b| a.to_s <=> b.to_s }.should == [:custom, :sprinkle]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + "/../helpers/ec2_mock"
|
2
3
|
|
3
4
|
class RemoteInstance
|
4
5
|
def scp(src="", dest="", opts={})
|
@@ -19,12 +20,7 @@ describe "remote instance" do
|
|
19
20
|
|
20
21
|
@master = Master.new
|
21
22
|
end
|
22
|
-
|
23
|
-
describe "scping" do
|
24
|
-
end
|
25
|
-
describe "ssh'ing" do
|
26
|
-
end
|
27
|
-
|
23
|
+
|
28
24
|
describe "in general" do
|
29
25
|
it "should set the ip upon creation" do
|
30
26
|
@instance.ip.should == "127.0.0.1"
|
@@ -61,6 +57,52 @@ describe "remote instance" do
|
|
61
57
|
Kernel.stub!(:system).and_return true
|
62
58
|
stub_option_load
|
63
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
|
64
106
|
describe "with a public ip" do
|
65
107
|
before(:each) do
|
66
108
|
Application.stub!(:public_ip).and_return "127.0.0.1"
|
@@ -82,7 +124,7 @@ describe "remote instance" do
|
|
82
124
|
end
|
83
125
|
it "should untar and move plugin directories around" do
|
84
126
|
dir = File.basename Application.plugin_dir
|
85
|
-
@instance.update_plugin_string.should == "mkdir -p
|
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"
|
86
128
|
end
|
87
129
|
end
|
88
130
|
end
|
@@ -121,7 +163,7 @@ describe "remote instance" do
|
|
121
163
|
|
122
164
|
describe "when installing the poolparty software" do
|
123
165
|
before(:each) do
|
124
|
-
@instance.stub!(:
|
166
|
+
@instance.stub!(:run).and_return false
|
125
167
|
end
|
126
168
|
it "should be able to detect if the stack_installed? == false" do
|
127
169
|
@instance.stack_installed?.should == false
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + "/../helpers/ec2_mock"
|
2
3
|
|
3
4
|
class TestRemote
|
4
5
|
include Remoter
|
@@ -20,9 +21,13 @@ describe "Remoter" do
|
|
20
21
|
Application.stub!(:ec2_dir).and_return "/Users"
|
21
22
|
Application.stub!(:keypair).and_return "app"
|
22
23
|
Application.stub!(:username).and_return "root"
|
24
|
+
Application.stub!(:keypair_path).and_return "/Users/id_rsa-app"
|
23
25
|
end
|
24
26
|
it "should have an ssh method that corresponds to ssm with the keypair" do
|
25
|
-
RemoteInstance.ssh_string.should
|
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'"]
|
26
31
|
end
|
27
32
|
it "should have a list of ssh_tasks" do
|
28
33
|
@remoter.ssh_tasks.should == []
|
@@ -1,9 +1,10 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
2
|
-
require File.dirname(__FILE__) + "
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + "/../helpers/ec2_mock"
|
3
3
|
|
4
4
|
describe "Master remoting: " do
|
5
5
|
before(:each) do
|
6
6
|
stub_option_load
|
7
|
+
|
7
8
|
Kernel.stub!(:system).and_return true
|
8
9
|
Application.stub!(:environment).and_return("test") # So it doesn't daemonize
|
9
10
|
Application.stub!(:minimum_instances).and_return(2)
|
@@ -12,11 +13,63 @@ describe "Master remoting: " do
|
|
12
13
|
Application.stub!(:verbose).and_return(false) # Turn off messaging
|
13
14
|
|
14
15
|
@master = Master.new
|
15
|
-
@master.launch_new_instance!
|
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
|
16
58
|
end
|
17
59
|
describe "starting" do
|
18
60
|
before(:each) do
|
19
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"
|
20
73
|
end
|
21
74
|
it "should start the cloud with instances" do
|
22
75
|
@master.list_of_instances.should_not be_empty
|
@@ -30,6 +83,9 @@ describe "Master remoting: " do
|
|
30
83
|
end
|
31
84
|
end
|
32
85
|
describe "maintaining" do
|
86
|
+
before(:each) do
|
87
|
+
Application.stub!(:keypair).and_return "alist"
|
88
|
+
end
|
33
89
|
it "should maintain the minimum_instances if one goes down" do
|
34
90
|
@master.start_cloud!
|
35
91
|
wait 0.2 # Give the two instances time to boot up
|
@@ -46,7 +102,7 @@ describe "Master remoting: " do
|
|
46
102
|
it "should launch a new instance when the load gets too heavy set in the configs" do
|
47
103
|
@master.stub!(:expand?).and_return true
|
48
104
|
@master.start_cloud!
|
49
|
-
wait 0.
|
105
|
+
wait 0.5 # Give the two instances time to boot up
|
50
106
|
(Application.minimum_instances - @master.number_of_pending_and_running_instances).should == 0
|
51
107
|
@master.scale_cloud!
|
52
108
|
@master.nodes.size.should == Application.minimum_instances + 1
|
@@ -27,11 +27,11 @@ describe "monitors" do
|
|
27
27
|
end
|
28
28
|
describe "remote instance" do
|
29
29
|
it "should try to ssh into the remote instance" do
|
30
|
-
@instance.should_receive(:
|
30
|
+
@instance.should_receive(:run).once.with("uptime")
|
31
31
|
@instance.cpu
|
32
32
|
end
|
33
33
|
it "should be able to find the exact amount of time the processor has been up" do
|
34
|
-
@instance.stub!(:
|
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
35
|
@instance.cpu.should == 0.32
|
36
36
|
end
|
37
37
|
end
|
@@ -26,12 +26,12 @@ describe "monitors" do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
describe "remote instance" do
|
29
|
-
it "should try to
|
30
|
-
@instance.should_receive(:
|
29
|
+
it "should try to run into the remote instance" do
|
30
|
+
@instance.should_receive(:run).once.with("free -m | grep -i mem")
|
31
31
|
@instance.memory
|
32
32
|
end
|
33
33
|
it "should be able to find the exact amount of time the processor has been up" do
|
34
|
-
@instance.stub!(:
|
34
|
+
@instance.stub!(:run).once.with("free -m | grep -i mem").and_return("Mem: 1700 546 1644 0 2 18")
|
35
35
|
@instance.memory.round_to(2).should == 0.32
|
36
36
|
end
|
37
37
|
end
|
@@ -40,7 +40,7 @@ describe "monitors (random, to spec the inclusion)" do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
describe "remote instance" do
|
43
|
-
it "should try to
|
43
|
+
it "should try to run into the remote instance" do
|
44
44
|
@instance.db.should == 5.0
|
45
45
|
end
|
46
46
|
it "should be able to find the exact amount of time the processor has been up" do
|
data/spec/monitors/web_spec.rb
CHANGED
@@ -27,12 +27,12 @@ describe "monitors" do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
describe "remote instance" do
|
30
|
-
it "should try to
|
31
|
-
@instance.should_receive(:
|
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
32
|
@instance.web
|
33
33
|
end
|
34
34
|
it "should be able to find the exact amount of time the processor has been up" do
|
35
|
-
@instance.stub!(:
|
35
|
+
@instance.stub!(:run).once.and_return("Request rate: 1.5 req/s (649.9 ms/req)")
|
36
36
|
@instance.web.round_to(2).should == 1.5
|
37
37
|
end
|
38
38
|
end
|