poolparty 0.0.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +25 -0
- data/License.txt +20 -0
- data/Manifest.txt +203 -0
- data/PostInstall.txt +18 -0
- data/README.txt +21 -82
- data/Rakefile +25 -18
- data/bin/cloud +31 -0
- data/bin/cloud-add-keypair +23 -0
- data/bin/cloud-configure +31 -0
- data/bin/cloud-contract +27 -0
- data/bin/cloud-expand +27 -0
- data/bin/cloud-list +32 -0
- data/bin/cloud-maintain +36 -0
- data/bin/cloud-osxcopy +22 -0
- data/bin/cloud-provision +31 -0
- data/bin/cloud-refresh +26 -0
- data/bin/cloud-ssh +18 -0
- data/bin/cloud-start +32 -0
- data/bin/cloud-terminate +23 -0
- data/bin/pool +25 -27
- data/bin/pool-console +12 -0
- data/bin/pool-describe +9 -0
- data/bin/pool-list +28 -0
- data/bin/pool-provision +34 -0
- data/bin/pool-spec +17 -0
- data/bin/pool-start +32 -0
- data/bin/pool-start-monitor +1 -0
- data/config/hoe.rb +115 -0
- data/config/requirements.rb +15 -0
- data/examples/basic.rb +20 -0
- data/examples/plugin_without_plugin_directory.rb +13 -0
- data/examples/poolparty.rb +12 -0
- data/examples/with_apache_plugin.rb +22 -0
- data/generators/poolspec/USAGE +5 -0
- data/generators/poolspec/poolspec_generator.rb +65 -0
- data/generators/poolspec/templates/pool_spec_template.erb +9 -0
- data/lib/erlang/eb_server.erl +27 -0
- data/lib/poolparty.rb +56 -0
- data/lib/poolparty/base_packages/haproxy.rb +42 -0
- data/lib/poolparty/base_packages/heartbeat.rb +45 -0
- data/lib/poolparty/base_packages/poolparty.rb +36 -0
- data/lib/poolparty/base_packages/ruby.rb +43 -0
- data/lib/poolparty/core/array.rb +24 -0
- data/lib/{core → poolparty/core}/exception.rb +0 -0
- data/lib/poolparty/core/float.rb +13 -0
- data/lib/poolparty/core/hash.rb +29 -0
- data/lib/poolparty/core/kernel.rb +37 -0
- data/lib/{core → poolparty/core}/module.rb +18 -0
- data/lib/poolparty/core/my_open_struct.rb +18 -0
- data/lib/poolparty/core/object.rb +54 -0
- data/lib/poolparty/core/proc.rb +7 -0
- data/lib/poolparty/core/string.rb +72 -0
- data/lib/poolparty/core/symbol.rb +8 -0
- data/lib/{core → poolparty/core}/time.rb +15 -0
- data/lib/poolparty/exceptions/RemoteException.rb +12 -0
- data/lib/poolparty/exceptions/ResourceException.rb +7 -0
- data/lib/poolparty/exceptions/RuntimeException.rb +7 -0
- data/lib/poolparty/exceptions/SpecException.rb +7 -0
- data/lib/poolparty/exceptions/TemplateNotFound.rb +7 -0
- data/lib/poolparty/helpers/binary.rb +31 -0
- data/lib/poolparty/helpers/console.rb +30 -0
- data/lib/poolparty/helpers/display.rb +34 -0
- data/lib/poolparty/helpers/optioner.rb +64 -0
- data/lib/poolparty/helpers/provisioner_base.rb +250 -0
- data/lib/poolparty/helpers/provisioners/master.rb +136 -0
- data/lib/poolparty/helpers/provisioners/slave.rb +44 -0
- data/lib/poolparty/modules/cloud_resourcer.rb +89 -0
- data/lib/poolparty/modules/configurable.rb +34 -0
- data/lib/poolparty/modules/definable_resource.rb +59 -0
- data/lib/poolparty/modules/file_writer.rb +55 -0
- data/lib/poolparty/modules/method_missing_sugar.rb +53 -0
- data/lib/poolparty/modules/output.rb +13 -0
- data/lib/poolparty/modules/pretty_printer.rb +39 -0
- data/lib/{core/string.rb → poolparty/modules/s3_string.rb} +5 -22
- data/lib/{modules → poolparty/modules}/safe_instance.rb +0 -0
- data/lib/poolparty/monitors/base_monitor.rb +16 -0
- data/lib/poolparty/net/remote.rb +35 -0
- data/lib/poolparty/net/remote_bases/ec2.rb +148 -0
- data/lib/poolparty/net/remote_instance.rb +69 -0
- data/lib/poolparty/net/remoter.rb +224 -0
- data/lib/poolparty/net/remoter_base.rb +117 -0
- data/lib/poolparty/plugins/gem_package.rb +17 -0
- data/lib/poolparty/plugins/git.rb +41 -0
- data/lib/poolparty/plugins/line.rb +76 -0
- data/lib/poolparty/plugins/svn.rb +48 -0
- data/lib/poolparty/pool/base.rb +75 -0
- data/lib/poolparty/pool/cloud.rb +164 -0
- data/lib/poolparty/pool/custom_resource.rb +61 -0
- data/lib/poolparty/pool/loggable.rb +29 -0
- data/lib/poolparty/pool/plugin.rb +41 -0
- data/lib/poolparty/pool/plugin_model.rb +48 -0
- data/lib/poolparty/pool/pool.rb +55 -0
- data/lib/poolparty/pool/resource.rb +248 -0
- data/lib/poolparty/pool/resources/class_package.rb +64 -0
- data/lib/poolparty/pool/resources/conditional.rb +41 -0
- data/lib/poolparty/pool/resources/cron.rb +14 -0
- data/lib/poolparty/pool/resources/directory.rb +23 -0
- data/lib/poolparty/pool/resources/exec.rb +26 -0
- data/lib/poolparty/pool/resources/file.rb +23 -0
- data/lib/poolparty/pool/resources/gem.rb +14 -0
- data/lib/poolparty/pool/resources/host.rb +14 -0
- data/lib/poolparty/pool/resources/package.rb +14 -0
- data/lib/poolparty/pool/resources/remote_file.rb +22 -0
- data/lib/poolparty/pool/resources/service.rb +21 -0
- data/lib/poolparty/pool/resources/sshkey.rb +19 -0
- data/lib/poolparty/pool/resources/variable.rb +27 -0
- data/lib/poolparty/pool/script.rb +44 -0
- data/lib/poolparty/templates/authkeys +2 -0
- data/{config/monit/nginx.monit.conf → lib/poolparty/templates/cib.xml} +0 -0
- data/lib/poolparty/templates/fileserver.conf +4 -0
- data/lib/poolparty/templates/gem +25 -0
- data/{config/heartbeat.conf → lib/poolparty/templates/ha.cf} +3 -2
- data/{config → lib/poolparty/templates}/haproxy.conf +13 -6
- data/lib/poolparty/templates/namespaceauth.conf +19 -0
- data/lib/poolparty/templates/puppet.conf +17 -0
- data/lib/poolparty/version.rb +9 -0
- data/lib/poolpartycl.rb +3 -0
- data/poolparty.gemspec +56 -47
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/spec/poolparty/base_packages/haproxy_spec.rb +13 -0
- data/spec/poolparty/base_packages/heartbeat_spec.rb +30 -0
- data/spec/poolparty/bin/console_spec.rb +80 -0
- data/spec/poolparty/core/array_spec.rb +26 -0
- data/spec/poolparty/core/float.rb +13 -0
- data/spec/poolparty/core/hash_spec.rb +63 -0
- data/spec/poolparty/core/kernel_spec.rb +24 -0
- data/spec/poolparty/core/module_spec.rb +15 -0
- data/spec/poolparty/core/object_spec.rb +40 -0
- data/spec/poolparty/core/string_spec.rb +152 -0
- data/spec/poolparty/core/time_spec.rb +52 -0
- data/spec/poolparty/helpers/binary_spec.rb +26 -0
- data/spec/poolparty/helpers/display_spec.rb +13 -0
- data/spec/poolparty/helpers/optioner_spec.rb +39 -0
- data/spec/poolparty/helpers/provisioner_base_spec.rb +121 -0
- data/spec/poolparty/helpers/provisioners/master_spec.rb +54 -0
- data/spec/poolparty/helpers/provisioners/slave_spec.rb +28 -0
- data/spec/poolparty/modules/cloud_resourcer_spec.rb +135 -0
- data/spec/poolparty/modules/configurable_spec.rb +26 -0
- data/spec/poolparty/modules/definable_resource.rb +9 -0
- data/spec/poolparty/modules/file_writer_spec.rb +49 -0
- data/spec/poolparty/modules/s3_string_spec.rb +15 -0
- data/spec/poolparty/modules/tmp/willy/nilly.rb +1 -0
- data/spec/poolparty/net/remote_bases/ec2_spec.rb +92 -0
- data/spec/poolparty/net/remote_instance_spec.rb +70 -0
- data/spec/poolparty/net/remote_spec.rb +286 -0
- data/spec/poolparty/net/remoter_base_spec.rb +80 -0
- data/spec/poolparty/net/remoter_spec.rb +191 -0
- data/spec/poolparty/plugins/git_spec.rb +33 -0
- data/spec/poolparty/plugins/line_spec.rb +16 -0
- data/spec/poolparty/plugins/svn_spec.rb +16 -0
- data/spec/poolparty/pool/base_spec.rb +108 -0
- data/spec/poolparty/pool/cloud_spec.rb +299 -0
- data/spec/poolparty/pool/configurers/files/ruby_basic.rb +17 -0
- data/spec/poolparty/pool/configurers/files/ruby_plugins.rb +16 -0
- data/spec/poolparty/pool/configurers/ruby_spec.rb +58 -0
- data/spec/poolparty/pool/custom_resource_spec.rb +115 -0
- data/spec/poolparty/pool/example_spec.rb +112 -0
- data/spec/poolparty/pool/plugin_model_spec.rb +63 -0
- data/spec/poolparty/pool/plugin_spec.rb +85 -0
- data/spec/poolparty/pool/pool_spec.rb +83 -0
- data/spec/poolparty/pool/resource_spec.rb +224 -0
- data/spec/poolparty/pool/resources/class_package_spec.rb +84 -0
- data/spec/poolparty/pool/resources/conditional_spec.rb +38 -0
- data/spec/poolparty/pool/resources/cron_spec.rb +49 -0
- data/spec/poolparty/pool/resources/directory_spec.rb +40 -0
- data/spec/poolparty/pool/resources/exec_spec.rb +37 -0
- data/spec/poolparty/pool/resources/file_spec.rb +40 -0
- data/spec/poolparty/pool/resources/gem_spec.rb +16 -0
- data/spec/poolparty/pool/resources/host_spec.rb +28 -0
- data/spec/poolparty/pool/resources/package_spec.rb +44 -0
- data/spec/poolparty/pool/resources/remote_file_spec.rb +40 -0
- data/spec/poolparty/pool/resources/service_spec.rb +45 -0
- data/spec/poolparty/pool/resources/sshkey_spec.rb +48 -0
- data/spec/poolparty/pool/resources/variable_spec.rb +20 -0
- data/spec/poolparty/pool/script_spec.rb +51 -0
- data/spec/poolparty/pool/test_plugins/sshkey_test +2 -0
- data/{test/test_pool_party.rb → spec/poolparty/pool/test_plugins/virtual_host_template.erb} +0 -0
- data/spec/poolparty/pool/test_plugins/webserver.rb +46 -0
- data/spec/poolparty/poolparty_spec.rb +33 -0
- data/spec/poolparty/spec_helper.rb +120 -0
- data/tasks/cloud.rake +57 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/development.rake +78 -0
- data/tasks/ec2.rake +20 -0
- data/tasks/environment.rake +7 -0
- data/tasks/instance.rake +63 -0
- data/tasks/server.rake +42 -0
- data/tasks/spec.rake +17 -0
- data/tasks/website.rake +17 -0
- data/test/test_generator_helper.rb +29 -0
- data/test/test_helper.rb +2 -0
- data/test/test_pool_spec_generator.rb +47 -0
- data/test/test_poolparty.rb +11 -0
- data/test_manifest.pp +538 -0
- data/website/index.html +107 -0
- data/website/index.txt +95 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/code.css +29 -0
- data/website/stylesheets/screen.css +147 -0
- data/website/template.html.erb +49 -0
- metadata +282 -101
- data/CHANGELOG +0 -4
- data/Manifest +0 -55
- data/bin/instance +0 -54
- data/config/config.yml +0 -23
- data/config/create_proxy_ami.sh +0 -582
- data/config/heartbeat_authkeys.conf +0 -2
- data/config/monit.conf +0 -8
- data/config/monit/haproxy.monit.conf +0 -7
- data/config/nginx.conf +0 -24
- data/lib/core/array.rb +0 -10
- data/lib/core/kernel.rb +0 -9
- data/lib/core/object.rb +0 -14
- data/lib/modules/callback.rb +0 -55
- data/lib/modules/ec2_wrapper.rb +0 -74
- data/lib/pool_party.rb +0 -69
- data/lib/pool_party/application.rb +0 -133
- data/lib/pool_party/init.rb +0 -4
- data/lib/pool_party/master.rb +0 -189
- data/lib/pool_party/monitors.rb +0 -13
- data/lib/pool_party/monitors/cpu.rb +0 -18
- data/lib/pool_party/monitors/memory.rb +0 -21
- data/lib/pool_party/monitors/web.rb +0 -18
- data/lib/pool_party/optioner.rb +0 -16
- data/lib/pool_party/os.rb +0 -11
- data/lib/pool_party/os/ubuntu.rb +0 -78
- data/lib/pool_party/remote_instance.rb +0 -180
- data/lib/pool_party/remoting.rb +0 -112
- data/lib/pool_party/scheduler.rb +0 -93
- data/lib/pool_party/tasks.rb +0 -220
- data/lib/s3/s3_object_store_folders.rb +0 -44
- data/spec/application_spec.rb +0 -32
- data/spec/callback_spec.rb +0 -65
- data/spec/helpers/ec2_mock.rb +0 -56
- data/spec/helpers/remote_instance_mock.rb +0 -11
- data/spec/kernel_spec.rb +0 -11
- data/spec/master_spec.rb +0 -147
- data/spec/monitor_spec.rb +0 -16
- data/spec/optioner_spec.rb +0 -22
- data/spec/poolparty_spec.rb +0 -8
- data/spec/remote_instance_spec.rb +0 -29
- data/spec/remoting_spec.rb +0 -75
- data/spec/spec_helper.rb +0 -38
- data/spec/string_spec.rb +0 -28
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
include Remote
|
|
4
|
+
|
|
5
|
+
class TestRemoter
|
|
6
|
+
include RemoterBase
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "RemoterBase" do
|
|
10
|
+
describe "methods" do
|
|
11
|
+
before(:each) do
|
|
12
|
+
@tr = TestRemoter.new
|
|
13
|
+
end
|
|
14
|
+
%w(launch_new_instance! terminate_instance describe_instance instances_list).each do |method|
|
|
15
|
+
eval <<-EOE
|
|
16
|
+
it "should raise an exception if #{method} is not defined as a method" do
|
|
17
|
+
lambda { @tr.#{method} }.should raise_error
|
|
18
|
+
end
|
|
19
|
+
it "should not raise an exception if #{method} is defined as a method" do
|
|
20
|
+
lambda {
|
|
21
|
+
@tr.instance_eval do
|
|
22
|
+
def #{method}
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
@tr.#{method}
|
|
26
|
+
}.should_not raise_error
|
|
27
|
+
end
|
|
28
|
+
EOE
|
|
29
|
+
end
|
|
30
|
+
describe "lists" do
|
|
31
|
+
before(:each) do
|
|
32
|
+
stub_list_of_instances_for(@tr)
|
|
33
|
+
end
|
|
34
|
+
it "should gather a list of the running instances" do
|
|
35
|
+
@tr.list_of_running_instances.map {|a| a.name }.should == ["master", "node1"]
|
|
36
|
+
end
|
|
37
|
+
it "should be able to gather a list of the pending instances" do
|
|
38
|
+
@tr.list_of_pending_instances.map {|a| a.name }.should == ["node3"]
|
|
39
|
+
end
|
|
40
|
+
it "should be able to gather a list of the terminating instances" do
|
|
41
|
+
@tr.list_of_terminating_instances.map {|a| a.name }.should == []
|
|
42
|
+
end
|
|
43
|
+
it "should be able to gather a list of the non-terminated instances" do
|
|
44
|
+
@tr.list_of_nonterminated_instances.map {|a| a.name }.should == ["master", "node1", "node3"]
|
|
45
|
+
end
|
|
46
|
+
it "should return a list of remote instances" do
|
|
47
|
+
@tr.remote_instances_list.first.class.should == RemoteInstance
|
|
48
|
+
end
|
|
49
|
+
describe "by keypairs" do
|
|
50
|
+
it "should be able to grab all the alist keypairs" do
|
|
51
|
+
@tr.list_of_instances("fake_keypair").map {|a| a[:name] }.should == ["master", "node1", "node2", "node3"]
|
|
52
|
+
end
|
|
53
|
+
it "should be able to grab all the blist keypairs" do
|
|
54
|
+
@tr.list_of_instances("blist").map {|a| a[:name] }.should == ["node4"]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
describe "get by name" do
|
|
58
|
+
it "should fetch the instance by number " do
|
|
59
|
+
@tr.get_instance_by_number(1).name.should == "node1"
|
|
60
|
+
end
|
|
61
|
+
it "should fetch the master by number 0" do
|
|
62
|
+
@tr.get_instance_by_number(0).name.should == "master"
|
|
63
|
+
end
|
|
64
|
+
it "should not throw a fit if the node doesn't exist" do
|
|
65
|
+
lambda {@tr.get_instance_by_number(1000)}.should_not raise_error
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "adding custom install tasks (like set_hostname, for example)" do
|
|
71
|
+
before(:each) do
|
|
72
|
+
@master = Object.new
|
|
73
|
+
@master.stub!(:ip).and_return "192.68.0.1"
|
|
74
|
+
@tr.stub!(:master).and_return @master
|
|
75
|
+
end
|
|
76
|
+
it "should have the method custom_install_tasks" do;@tr.respond_to?(:custom_install_tasks_for).should == true;end
|
|
77
|
+
it "should have the method custom_configure_tasks" do;@tr.respond_to?(:custom_configure_tasks_for).should == true;end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
include PoolParty::Remote
|
|
4
|
+
|
|
5
|
+
class TestClass
|
|
6
|
+
include CloudResourcer
|
|
7
|
+
include Remote
|
|
8
|
+
using :ec2
|
|
9
|
+
attr_accessor :parent
|
|
10
|
+
|
|
11
|
+
def keypair
|
|
12
|
+
"fake_keypair"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
describe "Remoter" do
|
|
16
|
+
before(:each) do
|
|
17
|
+
@cloud = cloud :app do;end
|
|
18
|
+
@tc = TestClass.new
|
|
19
|
+
@tc.parent = @cloud
|
|
20
|
+
::File.stub!(:exists?).with("#{File.expand_path(Base.base_keypair_path)}/id_rsa-fake_keypair").and_return true
|
|
21
|
+
@sample_instances_list = [{:ip => "192.168.0.1", :name => "master"}, {:ip => "192.168.0.2", :name => "node1"}]
|
|
22
|
+
end
|
|
23
|
+
describe "ssh_string" do
|
|
24
|
+
it "should have the ssh command" do
|
|
25
|
+
@tc.ssh_string.should =~ /ssh -o StrictHostKeyChecking=no -l '#{Base.user}' -i/
|
|
26
|
+
end
|
|
27
|
+
it "should have the keypair in the ssh_string" do
|
|
28
|
+
@tc.ssh_string.should =~ /#{@tc.keypair}/
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
describe "ssh_array" do
|
|
32
|
+
it "should have StrictHostKeyChecking set to no" do
|
|
33
|
+
@tc.ssh_array.include?("-o StrictHostKeyChecking=no").should == true
|
|
34
|
+
end
|
|
35
|
+
it "should have the user set to the base user class" do
|
|
36
|
+
@tc.ssh_array.include?("-l '#{Base.user}'").should == true
|
|
37
|
+
end
|
|
38
|
+
it "should have the keypair path in the ssh_array" do
|
|
39
|
+
@tc.ssh_array.include?('-i "'+@tc.full_keypair_path+'"').should == true
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
describe "rsync_command" do
|
|
43
|
+
before(:each) do
|
|
44
|
+
@ri = Class.new
|
|
45
|
+
@ri.stub!(:ip).and_return "192.168.0.22"
|
|
46
|
+
end
|
|
47
|
+
it "should have rsync in the rsync_command" do
|
|
48
|
+
@tc.rsync_command.should == "rsync --delete -azP --exclude cache -e '#{@tc.ssh_string}'"
|
|
49
|
+
end
|
|
50
|
+
it "should be able to rsync storage commands" do
|
|
51
|
+
@tc.rsync_storage_files_to_command(@ri).should == "#{@tc.rsync_command} #{Dir.pwd}/tmp 192.168.0.22:/var/poolparty"
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
describe "launch_and_configure_master!" do
|
|
55
|
+
before(:each) do
|
|
56
|
+
@tc.stub!(:wait).and_return true
|
|
57
|
+
stub_list_from_remote_for(@tc)
|
|
58
|
+
@tc.stub!(:maximum_instances).and_return 5
|
|
59
|
+
@tc.stub!(:list_of_pending_instances).and_return []
|
|
60
|
+
@tc.stub!(:list_of_running_instances).and_return []
|
|
61
|
+
@tc.stub!(:master).and_return ris.first
|
|
62
|
+
Provisioner.stub!(:provision_master).and_return true
|
|
63
|
+
end
|
|
64
|
+
it "should have the method launch_master!" do
|
|
65
|
+
@tc.respond_to?(:launch_and_configure_master!).should == true
|
|
66
|
+
end
|
|
67
|
+
it "should test if it can start a new instance" do
|
|
68
|
+
@tc.should_receive(:can_start_a_new_instance?).once.and_return false
|
|
69
|
+
end
|
|
70
|
+
it "should test if the master is running" do
|
|
71
|
+
@tc.should_receive(:is_master_running?).and_return false
|
|
72
|
+
end
|
|
73
|
+
it "should ask to request_launch_new_instances when the master is not running and we can start a new instance" do
|
|
74
|
+
@tc.should_receive(:request_launch_new_instances).with(1)
|
|
75
|
+
@tc.stub!(:can_start_a_new_instance?).and_return true
|
|
76
|
+
@tc.stub!(:is_master_running?).and_return false
|
|
77
|
+
end
|
|
78
|
+
it "should tell the provisioner to provision_master" do
|
|
79
|
+
Provisioner.should_receive(:provision_master).once.and_return true
|
|
80
|
+
end
|
|
81
|
+
after(:each) do
|
|
82
|
+
@tc.launch_and_configure_master!
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
describe "listing" do
|
|
86
|
+
before(:each) do
|
|
87
|
+
@loc = Base.storage_directory + "/tc-instances.list"
|
|
88
|
+
@locations = [@loc]
|
|
89
|
+
@tc.stub!(:local_instances_list_file_locations).and_return @locations
|
|
90
|
+
end
|
|
91
|
+
it "should have the method list_from_local available" do
|
|
92
|
+
TestClass.respond_to?(:list_from_local).should == true
|
|
93
|
+
end
|
|
94
|
+
it "should have the method list_from_remote available" do
|
|
95
|
+
TestClass.respond_to?(:list_from_remote).should == true
|
|
96
|
+
end
|
|
97
|
+
describe "remote" do
|
|
98
|
+
before(:each) do
|
|
99
|
+
@tc.stub!(:list_of_instances).and_return @sample_instances_list
|
|
100
|
+
@tc.stub!(:local_instances_list_file_locations).and_return [
|
|
101
|
+
"#{Base.storage_directory}/tc-instances.list"
|
|
102
|
+
]
|
|
103
|
+
end
|
|
104
|
+
it "should call list_of_instances when trying to list from remote" do
|
|
105
|
+
TestClass.should_receive(:list_of_instances).once.and_return @sample_instances_list
|
|
106
|
+
TestClass.list_from_remote
|
|
107
|
+
end
|
|
108
|
+
it "should create a new RemoteInstance for each hashed instance" do
|
|
109
|
+
PoolParty::Remote::RemoteInstance.should_receive(:new).exactly(2).and_return @ri
|
|
110
|
+
@tc.list_from_remote
|
|
111
|
+
end
|
|
112
|
+
it "should return a string" do
|
|
113
|
+
@tc.list_from_remote.class.should == Array
|
|
114
|
+
end
|
|
115
|
+
it "should contain the master in the listing" do
|
|
116
|
+
@tc.list_from_remote.first.name.should == "master"
|
|
117
|
+
@tc.list_from_remote.first.master?.should == true
|
|
118
|
+
end
|
|
119
|
+
it "should write to the first (preferred) local instances list file location for next time" do
|
|
120
|
+
@tc.list_from_remote(:cache => true)
|
|
121
|
+
::File.file?(@tc.local_instances_list_file_locations.first).should == true
|
|
122
|
+
end
|
|
123
|
+
after(:all) do
|
|
124
|
+
# Cleanup after ourselves
|
|
125
|
+
# FileUtils.rm @loc if ::File.file?(@loc)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
describe "local" do
|
|
129
|
+
describe "listing" do
|
|
130
|
+
before(:each) do
|
|
131
|
+
stub_list_from_remote_for(@tc)
|
|
132
|
+
@tc.stub!(:list_of_instances).and_return([@ri])
|
|
133
|
+
end
|
|
134
|
+
it "should call local_instances_list_file_locations" do
|
|
135
|
+
@tc.should_receive(:local_instances_list_file_locations).at_least(1).and_return [@loc]
|
|
136
|
+
end
|
|
137
|
+
it "should call File.file? on the local_instances_list_file_locations locations" do
|
|
138
|
+
File.should_receive(:file?).with(@loc).at_least(1).and_return false
|
|
139
|
+
end
|
|
140
|
+
it "should call get_working_listing_file to get the working local instance file" do
|
|
141
|
+
@tc.should_receive(:get_working_listing_file).at_least(1).and_return nil
|
|
142
|
+
end
|
|
143
|
+
after(:each) do
|
|
144
|
+
@tc.list_from_local
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
describe "with listing" do
|
|
148
|
+
before(:each) do
|
|
149
|
+
str = "master 192.168.0.1
|
|
150
|
+
node1 192.168.0.2"
|
|
151
|
+
@loc.stub!(:read).and_return str
|
|
152
|
+
TestClass.stub!(:open).and_return @loc
|
|
153
|
+
TestClass.stub!(:get_working_listing_file).and_return @loc
|
|
154
|
+
@ri = PoolParty::Remote::RemoteInstance.new({:ip => "192.168.0.1", :name => "master"})
|
|
155
|
+
PoolParty::Remote::RemoteInstance.stub!(:new).and_return @ri
|
|
156
|
+
stub_list_from_remote_for(@tc)
|
|
157
|
+
end
|
|
158
|
+
it "should call open on the get_working_listing_file" do
|
|
159
|
+
@tc.should_receive(:open).with(@loc).at_least(1).and_return @loc
|
|
160
|
+
@tc.list_from_local
|
|
161
|
+
end
|
|
162
|
+
it "should create a new RemoteInstance for each line in the file" do
|
|
163
|
+
PoolParty::Remote::RemoteInstance.should_receive(:new).at_least(2)
|
|
164
|
+
@tc.list_from_local
|
|
165
|
+
end
|
|
166
|
+
it "should return a string" do
|
|
167
|
+
@tc.list_from_local.class.should == Array
|
|
168
|
+
end
|
|
169
|
+
it "should have the name of the master and the ip in the list_from_local" do
|
|
170
|
+
@tc.list_from_local[0].name.should == "master"
|
|
171
|
+
end
|
|
172
|
+
it "should have name in the listing" do
|
|
173
|
+
@ri.should_receive(:name).at_least(1).and_return "node0"
|
|
174
|
+
@ri.to_s
|
|
175
|
+
end
|
|
176
|
+
it "should have the ip in the listing" do
|
|
177
|
+
@ri.should_receive(:ip).at_least(1).and_return "127.0.0.1"
|
|
178
|
+
@ri.to_s
|
|
179
|
+
end
|
|
180
|
+
it "should call to_s on the RemoteInstance instances" do
|
|
181
|
+
PoolParty::Remote::RemoteInstance.should_receive(:new).at_least(2).and_return @ri
|
|
182
|
+
@ri.should_receive(:to_s).at_least(1)
|
|
183
|
+
@ri.to_s
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
after(:each) do
|
|
187
|
+
@tc.list_from_local
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
class TestClass
|
|
4
|
+
include PoolParty::Resources
|
|
5
|
+
end
|
|
6
|
+
describe "Remote Instance" do
|
|
7
|
+
before(:each) do
|
|
8
|
+
@tc = TestClass.new
|
|
9
|
+
end
|
|
10
|
+
it "should be a string" do
|
|
11
|
+
@tc.has_git(:name => "gitrepos.git", :source => "git://source.git").to_string.should =~ /file \{/
|
|
12
|
+
end
|
|
13
|
+
it "should included the flushed out options" do
|
|
14
|
+
@tc.has_git({:name => "git.git", :source => "git://source.git", :user => "finger"}).to_string.should =~ /finger@git:/
|
|
15
|
+
end
|
|
16
|
+
it "should not include the user if none is given" do
|
|
17
|
+
@tc.has_git({:name => "git.git", :source => "git://source.git"}).to_string.should =~ /git clone git:/
|
|
18
|
+
end
|
|
19
|
+
describe "in resource" do
|
|
20
|
+
before(:each) do
|
|
21
|
+
@tc.instance_eval do
|
|
22
|
+
git(:name => "gittr") do
|
|
23
|
+
source "git://source.git"
|
|
24
|
+
path "/var/www/xnot.org"
|
|
25
|
+
symlink "/var/www/xnot.org/public"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
it "should have the path set within the resource" do
|
|
30
|
+
@tc.resource(:git).first.to_string.should =~ /file \{/
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
class TestClass
|
|
4
|
+
include PoolParty::Resources
|
|
5
|
+
end
|
|
6
|
+
describe "Remote Instance" do
|
|
7
|
+
before(:each) do
|
|
8
|
+
@tc = TestClass.new
|
|
9
|
+
end
|
|
10
|
+
it "should be a string" do
|
|
11
|
+
@tc.has_line_in_file("hi", "ho").to_string.should =~ /line \{/
|
|
12
|
+
end
|
|
13
|
+
it "should included the flushed out options" do
|
|
14
|
+
@tc.has_line_in_file("hi", "who", {:name => "finger"}).to_string.should =~ /name => 'finger'/
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
class TestClass
|
|
4
|
+
include PoolParty::Resources
|
|
5
|
+
end
|
|
6
|
+
describe "Remote Instance" do
|
|
7
|
+
before(:each) do
|
|
8
|
+
@tc = TestClass.new
|
|
9
|
+
end
|
|
10
|
+
it "should be a string" do
|
|
11
|
+
@tc.has_svnpath({:name => "name", :source => "svn://"}).to_string.should =~ /svnserve \{/
|
|
12
|
+
end
|
|
13
|
+
it "should included the flushed out options" do
|
|
14
|
+
@tc.has_svnpath({:user => "finger"}).to_string.should =~ /user => \"finger\"/
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Base" do
|
|
4
|
+
before(:each) do
|
|
5
|
+
ENV.stub!(:[]).with("AWS_ACCESS_KEY_ID").and_return "KEY"
|
|
6
|
+
ENV.stub!(:[]).with("AWS_SECRET_ACCESS_ID").and_return "SECRET"
|
|
7
|
+
end
|
|
8
|
+
it "should set the environment, if not set to production" do
|
|
9
|
+
Base.environment.should == "production"
|
|
10
|
+
end
|
|
11
|
+
it "should set the user to root" do
|
|
12
|
+
Base.user.should == "root"
|
|
13
|
+
end
|
|
14
|
+
it "should set the base keypair path to ~/.ec2" do
|
|
15
|
+
Base.base_keypair_path.should == "~/.ec2"
|
|
16
|
+
end
|
|
17
|
+
it "should set the storage_directory to the tmp directory of the current working directory" do
|
|
18
|
+
Base.storage_directory.should == "#{Dir.pwd}/tmp"
|
|
19
|
+
end
|
|
20
|
+
it "should set the tmp path to tmp" do
|
|
21
|
+
Base.tmp_path.should == "tmp"
|
|
22
|
+
end
|
|
23
|
+
it "should set the remote storage path to /var/poolparty" do
|
|
24
|
+
Base.remote_storage_path.should == "/var/poolparty"
|
|
25
|
+
end
|
|
26
|
+
it "should set the fileserver_base to puppet://" do
|
|
27
|
+
Base.fileserver_base.should =~ /puppet:\/\//
|
|
28
|
+
end
|
|
29
|
+
it "should have an access key" do
|
|
30
|
+
Base.access_key.should == "KEY"
|
|
31
|
+
end
|
|
32
|
+
it "should have a secret access key" do
|
|
33
|
+
Base.secret_access_key.should == "SECRET"
|
|
34
|
+
end
|
|
35
|
+
describe "keys" do
|
|
36
|
+
it "should have an array of key_file_locations" do
|
|
37
|
+
Base.key_file_locations.class.should == Array
|
|
38
|
+
end
|
|
39
|
+
it "should test if the files exist when looking for the file" do
|
|
40
|
+
::File.stub!(:file?).and_return false
|
|
41
|
+
::File.stub!(:file?).with("ppkeys").and_return true
|
|
42
|
+
Base.get_working_key_file_locations.should == "ppkeys"
|
|
43
|
+
end
|
|
44
|
+
describe "with keyfile" do
|
|
45
|
+
before(:each) do
|
|
46
|
+
@keyfile = "ppkeys"
|
|
47
|
+
@str = "---
|
|
48
|
+
:access_key: KEY
|
|
49
|
+
:secret_access_key: SECRET"
|
|
50
|
+
@keyfile.stub!(:read).and_return @str
|
|
51
|
+
Base.stub!(:get_working_key_file_locations).and_return @keyfile
|
|
52
|
+
Base.stub!(:open).with(@keyfile).and_return @keyfile
|
|
53
|
+
end
|
|
54
|
+
it "should call YAML::load on the working key file" do
|
|
55
|
+
YAML.should_receive(:load).with(@str)
|
|
56
|
+
Base.load_keys_from_file
|
|
57
|
+
end
|
|
58
|
+
it "should return a hash" do
|
|
59
|
+
Base.load_keys_from_file.class.should == Hash
|
|
60
|
+
end
|
|
61
|
+
it "should be able to fetch the access key from the loaded keys" do
|
|
62
|
+
Base.load_keys_from_file[:access_key].should == "KEY"
|
|
63
|
+
end
|
|
64
|
+
it "should be able to fetch the secret_access_key from the loaded key file" do
|
|
65
|
+
Base.load_keys_from_file[:secret_access_key].should == "SECRET"
|
|
66
|
+
end
|
|
67
|
+
describe "without keyfile" do
|
|
68
|
+
before(:each) do
|
|
69
|
+
Base.stub!(:get_working_key_file_locations).and_return nil
|
|
70
|
+
ENV.stub!(:[]).with("AWS_ACCESS_KEY_ID").and_return nil
|
|
71
|
+
ENV.stub!(:[]).with("AWS_SECRET_ACCESS_ID").and_return nil
|
|
72
|
+
Base.reset!
|
|
73
|
+
end
|
|
74
|
+
it "should render the access_key nil" do
|
|
75
|
+
Base.access_key.should == nil
|
|
76
|
+
end
|
|
77
|
+
it "should render the secret_access_key as nil" do
|
|
78
|
+
Base.secret_access_key.should == nil
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
describe "storing keyfile" do
|
|
83
|
+
before(:each) do
|
|
84
|
+
@ak = "KEY"
|
|
85
|
+
@pk = "SECRET"
|
|
86
|
+
@str = "weee"
|
|
87
|
+
@hash = {:access_key => @ak, :secret_access_key => @pk}
|
|
88
|
+
Base.stub!(:access_key).and_return @ak
|
|
89
|
+
Base.stub!(:secret_access_key).and_return @pk
|
|
90
|
+
Base.stub!(:write_to_file).and_return true
|
|
91
|
+
Base.stub!(:key_file_locations).and_return ["ppkey"]
|
|
92
|
+
end
|
|
93
|
+
it "should call access_key.nil?" do
|
|
94
|
+
@ak.should_receive(:nil?).and_return false
|
|
95
|
+
@pk.should_receive(:nil?).and_return true
|
|
96
|
+
end
|
|
97
|
+
it "should call YAML::dump" do
|
|
98
|
+
YAML.should_receive(:dump).and_return @str
|
|
99
|
+
end
|
|
100
|
+
it "should call write_to_file with the key file location" do
|
|
101
|
+
Base.should_receive(:write_to_file).with("ppkey", YAML::dump(@hash)).and_return true
|
|
102
|
+
end
|
|
103
|
+
after(:each) do
|
|
104
|
+
Base.store_keys_in_file
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|