poolparty 0.0.4 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- 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,52 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "Time" do
|
4
|
+
describe "parsing" do
|
5
|
+
it "should be able to parse seconds" do
|
6
|
+
10.seconds.should == 10
|
7
|
+
end
|
8
|
+
it "should be able to parse minutes" do
|
9
|
+
80.minutes.should == 4800
|
10
|
+
end
|
11
|
+
it "should be able to parse hours" do
|
12
|
+
2.hours.should == 7200
|
13
|
+
end
|
14
|
+
it "should be able to parse days" do
|
15
|
+
1.days.should == 86400
|
16
|
+
end
|
17
|
+
it "should be able to parse weeks" do
|
18
|
+
2.weeks.should == 1209600
|
19
|
+
end
|
20
|
+
it "should be able to parse months" do
|
21
|
+
1.month.should == 2678400
|
22
|
+
end
|
23
|
+
end
|
24
|
+
describe "from" do
|
25
|
+
it "should be able to find minutes ago" do
|
26
|
+
10.minutes.ago.to_s.should == (Time.new - 10.minutes).to_s
|
27
|
+
end
|
28
|
+
it "should be able to find from now" do
|
29
|
+
10.minutes.from_now.to_s.should == (Time.now + 10.minutes).to_s
|
30
|
+
end
|
31
|
+
end
|
32
|
+
describe "time_ago string" do
|
33
|
+
it "should be able to turn 10.minutes.ago into a string" do
|
34
|
+
10.minutes.time_ago.should == "10 minutes ago"
|
35
|
+
end
|
36
|
+
it "should be able to turn 30.seconds into Less than a minute ago" do
|
37
|
+
30.seconds.time_ago.should == "Less than a minute ago"
|
38
|
+
end
|
39
|
+
it "should turn 1.year.ago into 1 year ago" do
|
40
|
+
2.years.time_ago.should == "2 years ago"
|
41
|
+
end
|
42
|
+
it "should turn 35.days into 35 days ago" do
|
43
|
+
29.days.time_ago.should == "4 weeks ago"
|
44
|
+
end
|
45
|
+
it "should turn 45.days into 1 month ago" do
|
46
|
+
45.days.time_ago.should == "1 month ago"
|
47
|
+
end
|
48
|
+
it "should turn 70.days into 2 months ago" do
|
49
|
+
70.days.time_ago.should == "2 months ago"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../../lib/poolparty/helpers/binary'
|
3
|
+
|
4
|
+
describe "Binary" do
|
5
|
+
before(:each) do
|
6
|
+
Dir.stub!(:[]).and_return %w(init console)
|
7
|
+
end
|
8
|
+
it "should have the binary location set on Binary" do
|
9
|
+
Binary.binary_directory.should =~ /lib\/poolparty\/helpers\/\.\.\/\.\.\/\.\.\/bin/
|
10
|
+
end
|
11
|
+
it "should be able to list the binaries in the bin directory" do
|
12
|
+
Binary.available_binaries_for("pool").should == %w(console init)
|
13
|
+
end
|
14
|
+
it "should be able to say the binary is in the binary_directory" do
|
15
|
+
Binary.available_binaries_for("pool").include?("console")
|
16
|
+
end
|
17
|
+
describe "get_existing_spec_location" do
|
18
|
+
before(:each) do
|
19
|
+
::File.stub!(:file?).and_return false
|
20
|
+
::File.stub!(:file?).with("#{Base.storage_directory}/pool.spec").and_return true
|
21
|
+
end
|
22
|
+
it "should be a String" do
|
23
|
+
Binary.get_existing_spec_location.class.should == String
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../../lib/poolparty/helpers/display'
|
3
|
+
|
4
|
+
include Display
|
5
|
+
|
6
|
+
describe "Display" do
|
7
|
+
it "should respond to pool_describe" do
|
8
|
+
self.respond_to?(:pool_describe).should == true
|
9
|
+
end
|
10
|
+
it "should be able to get the list of remote bases" do
|
11
|
+
self.respond_to?(:available_bases).should == true
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../../lib/poolparty/helpers/optioner'
|
3
|
+
|
4
|
+
describe "Option Parser" do
|
5
|
+
describe "options" do
|
6
|
+
before(:each) do
|
7
|
+
@op = PoolParty::Optioner.new
|
8
|
+
@op.parse_options
|
9
|
+
end
|
10
|
+
it "should set the options as an Hash" do
|
11
|
+
@op.options.class.should == Hash
|
12
|
+
end
|
13
|
+
it "should have the verbose option set to false by default" do
|
14
|
+
@op.verbose.should == false
|
15
|
+
end
|
16
|
+
it "should call a method called on it that is not defined on the options if they exist" do
|
17
|
+
@op.options.should_receive(:[]).with(:verbose).once.and_return true
|
18
|
+
@op.verbose
|
19
|
+
end
|
20
|
+
it "should be able to display the version" do
|
21
|
+
@op.version.should == PoolParty::VERSION::STRING
|
22
|
+
end
|
23
|
+
it "should exit after displaying the help message" do
|
24
|
+
hide_output do
|
25
|
+
lambda {
|
26
|
+
@o = PoolParty::Optioner.new(["-h"], {:parse_options => false})
|
27
|
+
@o.should_receive(:process_options).once
|
28
|
+
@o.parse_options
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
it "should be able to take a block and set some options on the block" do
|
34
|
+
o = PoolParty::Optioner.new(["-w"], {}) do |opts, optioner|
|
35
|
+
opts.on('-w', '--wee') { optioner.wee "wee" }
|
36
|
+
end
|
37
|
+
o.wee.should == "wee"
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../../lib/poolparty/helpers/provisioner_base'
|
3
|
+
|
4
|
+
include Provisioner
|
5
|
+
|
6
|
+
describe "ProvisionerBase" do
|
7
|
+
before(:each) do
|
8
|
+
@cloud = cloud :app do;end
|
9
|
+
@remote_instance = PoolParty::Remote::RemoteInstance.new({:ip => "192.168.0.1", :status => "running", :name => "master"}, @cloud)
|
10
|
+
@cloud.stub!(:custom_install_tasks_for).with(@remote_instance).and_return []
|
11
|
+
stub_list_from_remote_for(@remote_instance)
|
12
|
+
stub_list_from_remote_for(@cloud)
|
13
|
+
end
|
14
|
+
describe "class methods" do
|
15
|
+
it "should have install" do
|
16
|
+
ProvisionerBase.respond_to?(:install).should == true
|
17
|
+
end
|
18
|
+
it "should have configure" do
|
19
|
+
ProvisionerBase.respond_to?(:configure).should == true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
describe "tasks" do
|
23
|
+
before(:each) do
|
24
|
+
class Provisioner::TestProvisioner < Provisioner::ProvisionerBase
|
25
|
+
def tasks
|
26
|
+
[
|
27
|
+
"hello",
|
28
|
+
" ",
|
29
|
+
"world"
|
30
|
+
]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
@tp = TestProvisioner.new(@remote_instance,@cloud)
|
34
|
+
end
|
35
|
+
it "should have tasks on the provisioner" do
|
36
|
+
ProvisionerBase.new(@remote_instance,@cloud).install_tasks.class.should == Array
|
37
|
+
end
|
38
|
+
it "should have empty tasks on the provisioner" do
|
39
|
+
ProvisionerBase.new(@remote_instance,@cloud).install_tasks.should be_empty
|
40
|
+
end
|
41
|
+
it "should allow a new class to write tasks that aren't empty upon instantiation" do
|
42
|
+
@tp.tasks.should_not be_empty
|
43
|
+
end
|
44
|
+
it "should have described 3 tasks in the task_list" do
|
45
|
+
@tp.tasks.size.should == 3
|
46
|
+
end
|
47
|
+
end
|
48
|
+
it "should return a hash when asking for the installers" do
|
49
|
+
ProvisionerBase.installers.class.should == Hash
|
50
|
+
end
|
51
|
+
it "should not return an empty string when asking for the Ubuntu installer" do
|
52
|
+
ProvisionerBase.installers[:ubuntu].should_not be_nil
|
53
|
+
end
|
54
|
+
it "should be able to fetch the ubuntu installer with the helper method installer" do
|
55
|
+
ProvisionerBase.new(@remote_instance,@cloud, "ubuntu").installer_for.should == "apt-get install -y "
|
56
|
+
end
|
57
|
+
it "should be able to fetch the fedora installer with the helper method installer" do
|
58
|
+
ProvisionerBase.new(@remote_instance,@cloud, "fedora").installer_for.should == "yum install "
|
59
|
+
end
|
60
|
+
describe "install_string" do
|
61
|
+
before(:each) do
|
62
|
+
class Provisioner::BTestProvisioner < Provisioner::ProvisionerBase
|
63
|
+
def install_tasks
|
64
|
+
[
|
65
|
+
"hello",
|
66
|
+
insert_space,
|
67
|
+
add_world
|
68
|
+
]
|
69
|
+
end
|
70
|
+
def insert_space
|
71
|
+
" "
|
72
|
+
end
|
73
|
+
def add_world
|
74
|
+
"cruel world"
|
75
|
+
end
|
76
|
+
def default_install_tasks
|
77
|
+
[] << install_tasks
|
78
|
+
end
|
79
|
+
end
|
80
|
+
@provisioner = BTestProvisioner.new(@remote_instance, @cloud)
|
81
|
+
end
|
82
|
+
it "should not run \"hello\"" do
|
83
|
+
@provisioner.should_not_receive(:hello)
|
84
|
+
end
|
85
|
+
it "should run insert_space" do
|
86
|
+
@provisioner.should_receive(:insert_space).once.and_return " "
|
87
|
+
end
|
88
|
+
it "should run add_world" do
|
89
|
+
@provisioner.should_receive(:insert_space).once.and_return "world"
|
90
|
+
end
|
91
|
+
it "should compound the string to be hello \n \n cruel world" do
|
92
|
+
@provisioner.install_string.should == "hello \n \n cruel world"
|
93
|
+
end
|
94
|
+
after do
|
95
|
+
@provisioner.install_string
|
96
|
+
end
|
97
|
+
describe "processing" do
|
98
|
+
before(:each) do
|
99
|
+
@provisioner = ProvisionerBase.new(@remote_instance, @cloud)
|
100
|
+
stub_list_from_remote_for(@cloud)
|
101
|
+
@cloud.stub!(:keypair).and_return "fake_keypair"
|
102
|
+
@cloud.stub!(:keypair_path).and_return "~/.ec2/fake_keypair"
|
103
|
+
Provisioner::Master.stub!(:new).and_return @provisioner
|
104
|
+
@cloud.stub!(:copy_file_to_storage_directory).and_return true
|
105
|
+
end
|
106
|
+
describe "provision_master" do
|
107
|
+
it "should call write_install_file" do
|
108
|
+
@provisioner.should_receive(:write_install_file).and_return(true)
|
109
|
+
end
|
110
|
+
it "should call process_install!" do
|
111
|
+
@provisioner.should_receive(:process_install!).and_return(true)
|
112
|
+
end
|
113
|
+
after(:each) do
|
114
|
+
hide_output {
|
115
|
+
Provisioner.provision_master(@cloud, true)
|
116
|
+
}
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../../../lib/poolparty/helpers/provisioner_base'
|
3
|
+
|
4
|
+
include Provisioner
|
5
|
+
|
6
|
+
describe "Master provisioner" do
|
7
|
+
before(:each) do
|
8
|
+
@cloud = cloud :app do; end
|
9
|
+
stub_list_from_remote_for(@cloud)
|
10
|
+
@remote_instance = PoolParty::Remote::RemoteInstance.new({:ip => "192.168.0.1", :status => "running", :name => "master"}, @cloud)
|
11
|
+
|
12
|
+
@cloud.stub!(:master).and_return @ris.first
|
13
|
+
@master = Master.new(@cloud, :ubuntu)
|
14
|
+
end
|
15
|
+
describe "install_tasks" do
|
16
|
+
before(:each) do
|
17
|
+
@cloud.stub!(:master).and_return @ris.first
|
18
|
+
@master.stub!(:cloud).and_return @cloud
|
19
|
+
end
|
20
|
+
it "should call install_puppet_master" do
|
21
|
+
@master.should_receive(:install_puppet_master)
|
22
|
+
end
|
23
|
+
it "should call create_local_hosts_entry" do
|
24
|
+
@master.should_receive(:create_local_hosts_entry)
|
25
|
+
end
|
26
|
+
it "should call setup_fileserver" do
|
27
|
+
@master.should_receive(:setup_fileserver)
|
28
|
+
end
|
29
|
+
it "should call create_local_node" do
|
30
|
+
@master.should_receive(:create_local_node)
|
31
|
+
end
|
32
|
+
it "should call the custom_install_tasks" do
|
33
|
+
@master.should_receive(:custom_install_tasks)
|
34
|
+
end
|
35
|
+
after do
|
36
|
+
@master.install
|
37
|
+
end
|
38
|
+
end
|
39
|
+
it "should return install_puppet_master as apt-get install puppet factor" do
|
40
|
+
@master.install_puppet_master.should =~ /apt-get install -y puppet puppetmaster/
|
41
|
+
end
|
42
|
+
it "should return setup basic structure" do
|
43
|
+
@master.setup_basic_structure.should =~ /puppetmasterd --mkusers/
|
44
|
+
end
|
45
|
+
it "should return setup_fileserver with the setup" do
|
46
|
+
@master.setup_fileserver.should =~ /\[files\]/
|
47
|
+
end
|
48
|
+
it "should be able to create_local_node" do
|
49
|
+
@master.create_local_node.should =~ /ode \"master\"/
|
50
|
+
end
|
51
|
+
it "should create a node1 node as well" do
|
52
|
+
@master.create_local_node.should =~ /ode \"node1\"/
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../../../lib/poolparty/helpers/provisioner_base'
|
3
|
+
|
4
|
+
include Provisioner
|
5
|
+
|
6
|
+
describe "Slave provisioner" do
|
7
|
+
before(:each) do
|
8
|
+
|
9
|
+
@cloud = cloud :app do; end
|
10
|
+
@remote_instance = PoolParty::Remote::RemoteInstance.new({:ip => "192.168.0.1", :status => "running", :name => "master"}, @cloud)
|
11
|
+
stub_list_from_remote_for(@cloud)
|
12
|
+
|
13
|
+
@cloud.stub!(:master).and_return @ris.first
|
14
|
+
|
15
|
+
@slave = Slave.new(@remote_instance, @cloud, :ubuntu)
|
16
|
+
end
|
17
|
+
describe "install_tasks" do
|
18
|
+
it "should call install_puppet_slave" do
|
19
|
+
@slave.should_receive(:install_puppet_master)
|
20
|
+
end
|
21
|
+
after do
|
22
|
+
@slave.install
|
23
|
+
end
|
24
|
+
end
|
25
|
+
it "should return install_puppet as apt-get install puppet factor" do
|
26
|
+
@slave.setup_puppet.should =~ /puppetd/
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
class ResourcerTestClass
|
4
|
+
include CloudResourcer
|
5
|
+
include Configurable
|
6
|
+
|
7
|
+
def initialize(&block)
|
8
|
+
store_block(&block) if block
|
9
|
+
end
|
10
|
+
|
11
|
+
# Stub keypair
|
12
|
+
def keypair
|
13
|
+
"rangerbob"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
class TestParentClass
|
17
|
+
def options
|
18
|
+
{}
|
19
|
+
end
|
20
|
+
def services
|
21
|
+
@services ||= []
|
22
|
+
end
|
23
|
+
def add_service(s)
|
24
|
+
services << s
|
25
|
+
end
|
26
|
+
end
|
27
|
+
describe "CloudResourcer" do
|
28
|
+
before(:each) do
|
29
|
+
@tc = ResourcerTestClass.new
|
30
|
+
end
|
31
|
+
it "should have the method instances" do
|
32
|
+
@tc.respond_to?(:instances).should == true
|
33
|
+
end
|
34
|
+
it "should be able to accept a range and set the first to the minimum instances" do
|
35
|
+
@tc.instances 4..10
|
36
|
+
@tc.minimum_instances.should == 4
|
37
|
+
end
|
38
|
+
it "should set the max to the maximum instances to the last" do
|
39
|
+
@tc.instances 4..10
|
40
|
+
@tc.maximum_instances.should == 10
|
41
|
+
end
|
42
|
+
describe "keypair_path" do
|
43
|
+
before(:each) do
|
44
|
+
end
|
45
|
+
it "should look for the file in the known directories it should reside in" do
|
46
|
+
@tc.should_receive(:keypair_paths).once.and_return []
|
47
|
+
@tc.keypair_path
|
48
|
+
end
|
49
|
+
it "should see if the file exists" do
|
50
|
+
@t = "#{File.expand_path(Base.base_keypair_path)}"
|
51
|
+
::File.should_receive(:exists?).with(@t+"/id_rsa-rangerbob").and_return false
|
52
|
+
::File.stub!(:exists?).with(@t+"/rangerbob").and_return false
|
53
|
+
@tc.should_receive(:keypair_paths).once.and_return [@t]
|
54
|
+
@tc.keypair_path
|
55
|
+
end
|
56
|
+
it "should fallback to the second one if the first doesn't exist" do
|
57
|
+
@t = "#{File.expand_path(Base.base_keypair_path)}"
|
58
|
+
@q = "#{File.expand_path(Base.base_config_directory)}"
|
59
|
+
::File.stub!(:exists?).with(@t+"/id_rsa-rangerbob").and_return false
|
60
|
+
::File.stub!(:exists?).with(@t+"/rangerbob").and_return false
|
61
|
+
::File.stub!(:exists?).with(@q+"/id_rsa-rangerbob").and_return false
|
62
|
+
::File.should_receive(:exists?).with(@q+"/rangerbob").and_return true
|
63
|
+
@tc.should_receive(:keypair_paths).once.and_return [@t, @q]
|
64
|
+
@tc.keypair_path.should == "/etc/poolparty/rangerbob"
|
65
|
+
end
|
66
|
+
describe "exists" do
|
67
|
+
before(:each) do
|
68
|
+
@t = "#{File.expand_path(Base.base_keypair_path)}"
|
69
|
+
::File.stub!(:exists?).with(@t+"/id_rsa-rangerbob").and_return false
|
70
|
+
::File.stub!(:exists?).with(@t+"/rangerbob").and_return true
|
71
|
+
end
|
72
|
+
it "should have the keypair_path" do
|
73
|
+
@tc.respond_to?(:keypair_path).should == true
|
74
|
+
end
|
75
|
+
it "should set the keypair to the Base.keypair_path" do
|
76
|
+
@tc.keypair_path.should =~ /#{File.expand_path(Base.base_keypair_path)}/
|
77
|
+
end
|
78
|
+
it "should set the keypair to have the keypair set" do
|
79
|
+
@tc.keypair.should =~ /rangerbob/
|
80
|
+
end
|
81
|
+
it "should set it to the Base keypair_path and the keypair" do
|
82
|
+
@tc.keypair_path.should == "#{File.expand_path(Base.base_keypair_path)}/#{@tc.keypair}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
it "should provide set_parent" do
|
87
|
+
@tc.respond_to?(:set_parent).should == true
|
88
|
+
end
|
89
|
+
describe "parents" do
|
90
|
+
before(:each) do
|
91
|
+
@testparent = TestParentClass.new
|
92
|
+
end
|
93
|
+
describe "setting" do
|
94
|
+
it "should add the child to its services" do
|
95
|
+
@testparent.should_receive(:add_service)
|
96
|
+
end
|
97
|
+
it "should call configure with options" do
|
98
|
+
@tc.should_receive(:configure).with(@testparent.options)
|
99
|
+
end
|
100
|
+
after do
|
101
|
+
@tc.set_parent(@testparent)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
describe "parent's services" do
|
105
|
+
before(:each) do
|
106
|
+
@tc.set_parent(@testparent)
|
107
|
+
end
|
108
|
+
it "should set the parent" do
|
109
|
+
@tc.parent.should == @testparent
|
110
|
+
end
|
111
|
+
it "should have one service set" do
|
112
|
+
@testparent.services.size.should == 1
|
113
|
+
end
|
114
|
+
it "should have the child in the parent's services" do
|
115
|
+
@testparent.services.first.should == @tc
|
116
|
+
end
|
117
|
+
end
|
118
|
+
describe "storing block" do
|
119
|
+
before(:each) do
|
120
|
+
@new_tc = ResourcerTestClass.new do
|
121
|
+
"hi"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
it "should store the block when creating a new one" do
|
125
|
+
@new_tc.store_block.should_not == nil
|
126
|
+
end
|
127
|
+
it "should have a reference to the stored block" do
|
128
|
+
@new_tc.store_block.class.should == Proc
|
129
|
+
end
|
130
|
+
it "should store the containing block" do
|
131
|
+
@new_tc.store_block.call.should == "hi"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|