auser-poolparty 0.2.2 → 0.2.3
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/Manifest.txt +201 -0
- data/PostInstall.txt +17 -0
- data/Rakefile +22 -1
- data/bin/cloud-add-keypair +0 -0
- data/bin/cloud-osxcopy +22 -0
- data/bin/cloud-provision +1 -0
- data/bin/cloud-start +17 -15
- data/bin/cloud-terminate +23 -0
- data/bin/pool-start +14 -14
- data/bin/pool-start-monitor +1 -0
- data/config/hoe.rb +114 -0
- data/config/requirements.rb +15 -0
- data/lib/poolparty.rb +1 -0
- data/lib/poolparty/base_packages/haproxy.rb +32 -31
- data/lib/poolparty/base_packages/heartbeat.rb +2 -2
- data/lib/poolparty/base_packages/poolparty.rb +9 -3
- data/lib/poolparty/base_packages/ruby.rb +10 -0
- data/lib/poolparty/core/proc.rb +5 -0
- data/lib/poolparty/core/string.rb +1 -1
- data/lib/poolparty/helpers/binary.rb +6 -5
- data/lib/poolparty/helpers/display.rb +11 -2
- data/lib/poolparty/helpers/optioner.rb +6 -3
- data/lib/poolparty/helpers/provisioner_base.rb +9 -7
- data/lib/poolparty/helpers/provisioners/master.rb +38 -4
- data/lib/poolparty/helpers/provisioners/slave.rb +2 -2
- data/lib/poolparty/modules/cloud_resourcer.rb +20 -3
- data/lib/poolparty/modules/definable_resource.rb +1 -1
- data/lib/poolparty/modules/method_missing_sugar.rb +12 -4
- data/lib/poolparty/modules/pretty_printer.rb +2 -1
- data/lib/poolparty/net/remote.rb +1 -1
- data/lib/poolparty/net/remote_bases/ec2.rb +13 -10
- data/lib/poolparty/net/remote_instance.rb +3 -2
- data/lib/poolparty/net/remoter.rb +33 -18
- data/lib/poolparty/net/remoter_base.rb +3 -3
- data/lib/poolparty/plugins/gem_package.rb +6 -29
- data/lib/poolparty/plugins/git.rb +22 -0
- data/lib/poolparty/pool/base.rb +7 -6
- data/lib/poolparty/pool/cloud.rb +34 -5
- data/lib/poolparty/pool/custom_resource.rb +4 -4
- data/lib/poolparty/pool/plugin.rb +13 -14
- data/lib/poolparty/pool/resource.rb +19 -10
- data/lib/poolparty/pool/resources/class_package.rb +10 -6
- data/lib/poolparty/pool/resources/conditional.rb +41 -0
- data/lib/poolparty/pool/resources/gem.rb +2 -2
- data/lib/poolparty/pool/script.rb +25 -2
- data/lib/poolparty/templates/haproxy.conf +1 -1
- data/lib/poolparty/templates/puppet.conf +4 -2
- data/lib/poolparty/version.rb +1 -1
- data/poolparty.gemspec +60 -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/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 +19 -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/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/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/website/index.html +81 -0
- data/website/index.txt +72 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +178 -60
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
pool :poolpartyrb do
|
|
2
|
+
plugin_directory "docs_plugins"
|
|
3
|
+
|
|
4
|
+
cloud :app do
|
|
5
|
+
|
|
6
|
+
# Configuration
|
|
7
|
+
configure({ :maximum_instances => 1,:keypair => "name" })
|
|
8
|
+
minimum_instances 1
|
|
9
|
+
|
|
10
|
+
apache do
|
|
11
|
+
enable_php
|
|
12
|
+
site("poolpartyrb.com")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/../test_plugins/webserver'
|
|
3
|
+
|
|
4
|
+
describe "Configurer" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
reset!
|
|
7
|
+
@basic = read_file(File.join(File.dirname(__FILE__), "files", "ruby_basic.rb"))
|
|
8
|
+
Script.inflate @basic
|
|
9
|
+
@conf = Object.new
|
|
10
|
+
end
|
|
11
|
+
it "should not be nil" do
|
|
12
|
+
@conf.should_not be_nil
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "with a spec file" do
|
|
16
|
+
before(:each) do
|
|
17
|
+
@s = Script.new
|
|
18
|
+
Script.stub!(:new).and_return(@s)
|
|
19
|
+
@basic = read_file(File.join(File.dirname(__FILE__), "files", "ruby_basic.rb"))
|
|
20
|
+
end
|
|
21
|
+
it "should load the basic example configure" do
|
|
22
|
+
@s.should_receive(:inflate).and_return true
|
|
23
|
+
end
|
|
24
|
+
it "should call inflate on the pools" do
|
|
25
|
+
@s.pools.each {|a,b| b.should_receive(:inflate).and_return true }
|
|
26
|
+
end
|
|
27
|
+
describe "pool" do
|
|
28
|
+
before(:each) do
|
|
29
|
+
Script.inflate @basic
|
|
30
|
+
@pool = pool(:poolpartyrb)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
describe "clouds" do
|
|
34
|
+
before(:each) do
|
|
35
|
+
reset!
|
|
36
|
+
Script.inflate @basic
|
|
37
|
+
@cloud = pool(:poolpartyrb).cloud(:app)
|
|
38
|
+
end
|
|
39
|
+
it "should contain a list of the clouds within the pool (:app)" do
|
|
40
|
+
@cloud.should_not be_nil
|
|
41
|
+
end
|
|
42
|
+
it "should set the minimum instances on the :app cloud" do
|
|
43
|
+
@cloud.minimum_instances.should == 1
|
|
44
|
+
end
|
|
45
|
+
it "should set the maximum instances on the :app cloud" do
|
|
46
|
+
@cloud.maximum_instances.should == 1
|
|
47
|
+
end
|
|
48
|
+
it "should set the keypair name on the :app cloud too" do
|
|
49
|
+
@cloud.keypair.should == "name"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
after do
|
|
54
|
+
Script.inflate @basic
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
include PoolParty::Resources
|
|
4
|
+
|
|
5
|
+
describe "Custom Resource" do
|
|
6
|
+
before(:each) do
|
|
7
|
+
@cloud = cloud :name do; end
|
|
8
|
+
end
|
|
9
|
+
it "should provide custom_resource as a method" do
|
|
10
|
+
self.respond_to?(:define_resource).should == true
|
|
11
|
+
end
|
|
12
|
+
describe "defining" do
|
|
13
|
+
it "should not raise ResourceException if custom_function and custom_usage are defined" do
|
|
14
|
+
lambda {
|
|
15
|
+
define_resource(:rockstar) do
|
|
16
|
+
def has_a_line_in_file(line="line_in_file", file="file")
|
|
17
|
+
call_function "line(#{file}, #{line})"
|
|
18
|
+
end
|
|
19
|
+
custom_function <<-EOF
|
|
20
|
+
define line($file, $line, $ensure = 'present') {
|
|
21
|
+
case...
|
|
22
|
+
}
|
|
23
|
+
EOF
|
|
24
|
+
end
|
|
25
|
+
}.should_not raise_error
|
|
26
|
+
end
|
|
27
|
+
describe "define_resource" do
|
|
28
|
+
before(:each) do
|
|
29
|
+
define_resource(:rockstar) do
|
|
30
|
+
def has_a_line_in_file(line="line_in_file", file="file")
|
|
31
|
+
call_function "line(#{file}, #{line})"
|
|
32
|
+
end
|
|
33
|
+
custom_function <<-EOF
|
|
34
|
+
define line($file, $line, $ensure = 'present') {
|
|
35
|
+
case...
|
|
36
|
+
}
|
|
37
|
+
EOF
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
it "should create a custom resource available as a class" do
|
|
41
|
+
lambda {RockstarClass.new }.should_not raise_error
|
|
42
|
+
end
|
|
43
|
+
it "should add the method has_a_line_in_file to Resources" do
|
|
44
|
+
PoolParty::Resources.methods.include?("has_a_line_in_file").should == true
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
describe "printing" do
|
|
48
|
+
before do
|
|
49
|
+
reset_resources!
|
|
50
|
+
define_resource(:rockstar) do
|
|
51
|
+
def has_a_line_in_file(line="line_in_file", file="file")
|
|
52
|
+
call_function "line(#{file}, #{line})"
|
|
53
|
+
end
|
|
54
|
+
custom_function <<-EOF
|
|
55
|
+
define line($file, $line, $ensure = 'present') {
|
|
56
|
+
case...
|
|
57
|
+
}
|
|
58
|
+
EOF
|
|
59
|
+
end
|
|
60
|
+
@resource = RockstarClass.new
|
|
61
|
+
end
|
|
62
|
+
it "should not be nil after it is defined" do
|
|
63
|
+
@resource.should_not be_nil
|
|
64
|
+
end
|
|
65
|
+
it "should store the custom_function in the class" do
|
|
66
|
+
RockstarClass.custom_functions.select {|a| a if a =~ /define line/}.should_not be_empty
|
|
67
|
+
end
|
|
68
|
+
it "should allow for the has_a_line_in_file to be called from within a plugin" do
|
|
69
|
+
@resource.instance_eval do
|
|
70
|
+
has_a_line_in_file("hi", "filename")
|
|
71
|
+
end
|
|
72
|
+
@resource.resource(:call_function).to_string.should == "line(filename, hi)"
|
|
73
|
+
end
|
|
74
|
+
it "should be stored in an array" do
|
|
75
|
+
resource(:rockstar).class.should == Array
|
|
76
|
+
end
|
|
77
|
+
describe "call function" do
|
|
78
|
+
it "should have the class CallFunction available" do
|
|
79
|
+
lambda {PoolParty::Resources::CallFunction}.should_not raise_error
|
|
80
|
+
end
|
|
81
|
+
it "should create a new CallFunction instance when calling call_function with a string" do
|
|
82
|
+
PoolParty::Resources::CallFunction.should_receive(:new).and_return "bunk"
|
|
83
|
+
add_resource(:call_function, "line")
|
|
84
|
+
end
|
|
85
|
+
it "should create a call function in the function call array" do
|
|
86
|
+
add_resource(:call_function, @cloud, "heyyohey")
|
|
87
|
+
resource(:call_function).size.should == 1
|
|
88
|
+
end
|
|
89
|
+
describe "defining" do
|
|
90
|
+
it "should add the methods to the class through module_eval" do
|
|
91
|
+
PoolParty::Resources.should_receive(:module_eval).at_least(1)
|
|
92
|
+
define_resource :imarockstar2YEAH do
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe "within context" do
|
|
98
|
+
before(:each) do
|
|
99
|
+
cloud :apple do
|
|
100
|
+
has_line_in_file("hello", "messages")
|
|
101
|
+
brain_child("meee")
|
|
102
|
+
end
|
|
103
|
+
@cloud = cloud(:apple)
|
|
104
|
+
end
|
|
105
|
+
it "should have 1 resource (the line resource)" do
|
|
106
|
+
@cloud.resources.should_not be_empty
|
|
107
|
+
end
|
|
108
|
+
it "should have one call_function resource" do
|
|
109
|
+
@cloud.resource(:call_function).first.to_string.should =~ /line \{/
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
require "open-uri"
|
|
3
|
+
|
|
4
|
+
describe "basic" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
@example_dir = ::File.join(::File.dirname(__FILE__), "..", "..", "..", "examples")
|
|
7
|
+
reset!
|
|
8
|
+
PoolParty::Script.inflate open(@example_dir + "/basic.rb").read
|
|
9
|
+
end
|
|
10
|
+
it "should have one pool called :app" do
|
|
11
|
+
pool(:app).should_not be_nil
|
|
12
|
+
end
|
|
13
|
+
it "should have a cloud called :app" do
|
|
14
|
+
pool(:app).cloud(:app).should_not be_nil
|
|
15
|
+
end
|
|
16
|
+
it "should have a cloud called :db" do
|
|
17
|
+
pool(:app).cloud(:db).should_not be_nil
|
|
18
|
+
end
|
|
19
|
+
it "should set the minimum_instances on the cloud to 2 (overriding the pool options)" do
|
|
20
|
+
pool(:app).cloud(:app).minimum_instances.should == 2
|
|
21
|
+
end
|
|
22
|
+
it "should set the maximum_instances on the cloud to 5" do
|
|
23
|
+
pool(:app).cloud(:app).maximum_instances.should == 5
|
|
24
|
+
end
|
|
25
|
+
it "should set the minimum_instances on the db cloud to 3" do
|
|
26
|
+
pool(:app).cloud(:db).minimum_instances.should == 3
|
|
27
|
+
end
|
|
28
|
+
describe "with_apache_plugin" do
|
|
29
|
+
before(:each) do
|
|
30
|
+
reset!
|
|
31
|
+
PoolParty::Script.inflate(open(@example_dir + "/with_apache_plugin.rb").read, File.dirname(__FILE__))
|
|
32
|
+
end
|
|
33
|
+
it "should have one pool called :app" do
|
|
34
|
+
pool(:app).should_not be_nil
|
|
35
|
+
end
|
|
36
|
+
it "should have a cloud called :app" do
|
|
37
|
+
pool(:app).cloud(:app).should_not be_nil
|
|
38
|
+
end
|
|
39
|
+
it "should have a cloud called :db" do
|
|
40
|
+
pool(:app).cloud(:db).should_not be_nil
|
|
41
|
+
end
|
|
42
|
+
it "should set the minimum_instances on the cloud to 2 (overriding the pool options)" do
|
|
43
|
+
pool(:app).cloud(:app).minimum_instances.should == 2
|
|
44
|
+
end
|
|
45
|
+
it "should set the maximum_instances on the cloud to 10" do
|
|
46
|
+
pool(:app).cloud(:app).maximum_instances.should == 10
|
|
47
|
+
end
|
|
48
|
+
it "should set the minimum_instances on the db cloud to 2" do
|
|
49
|
+
pool(:app).cloud(:db).minimum_instances.should == 2
|
|
50
|
+
end
|
|
51
|
+
it "should have included the apache plugin and given the class a method by the name of the plugin" do
|
|
52
|
+
pool(:app).cloud(:app).methods.include?("apache").should == true
|
|
53
|
+
end
|
|
54
|
+
describe "apache plugin" do
|
|
55
|
+
before(:each) do
|
|
56
|
+
@c = pool(:app).cloud(:app)
|
|
57
|
+
end
|
|
58
|
+
it "should have apache as the ApacheClass" do
|
|
59
|
+
@c.apache.class.should == PoolPartyApacheClass
|
|
60
|
+
end
|
|
61
|
+
it "should set php == true on the apache plugin" do
|
|
62
|
+
@c.apache.php.should == true
|
|
63
|
+
end
|
|
64
|
+
it "should store the method in options if it's not defined on the plugin" do
|
|
65
|
+
@c.enable_asp true
|
|
66
|
+
@c.options[:enable_asp].should == true
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
describe "plugin_without_plugin_directory" do
|
|
71
|
+
before(:each) do
|
|
72
|
+
reset!
|
|
73
|
+
PoolParty::Script.inflate(open(@example_dir + "/plugin_without_plugin_directory.rb").read, File.dirname(__FILE__))
|
|
74
|
+
end
|
|
75
|
+
it "should have one pool called :app" do
|
|
76
|
+
pool(:app).should_not be_nil
|
|
77
|
+
end
|
|
78
|
+
it "should have a cloud called :app" do
|
|
79
|
+
pool(:app).cloud(:app).should_not be_nil
|
|
80
|
+
end
|
|
81
|
+
it "should have a cloud called :db" do
|
|
82
|
+
pool(:app).cloud(:db).should_not be_nil
|
|
83
|
+
end
|
|
84
|
+
it "should set the minimum_instances on the cloud to 2 (overriding the pool options)" do
|
|
85
|
+
pool(:app).cloud(:app).minimum_instances.should == 2
|
|
86
|
+
end
|
|
87
|
+
it "should set the maximum_instances on the cloud to 10" do
|
|
88
|
+
pool(:app).cloud(:app).maximum_instances.should == 10
|
|
89
|
+
end
|
|
90
|
+
it "should set the minimum_instances on the db cloud to 2" do
|
|
91
|
+
pool(:app).cloud(:db).minimum_instances.should == 2
|
|
92
|
+
end
|
|
93
|
+
it "should have included the apache plugin and given the class a method by the name of the plugin" do
|
|
94
|
+
pool(:app).cloud(:app).methods.include?("apache").should == true
|
|
95
|
+
end
|
|
96
|
+
describe "apache plugin" do
|
|
97
|
+
before(:each) do
|
|
98
|
+
@c = pool(:app).cloud(:app)
|
|
99
|
+
end
|
|
100
|
+
it "should have apache as the ApacheClass" do
|
|
101
|
+
@c.apache.class.should == PoolPartyApacheClass
|
|
102
|
+
end
|
|
103
|
+
it "should set php == true on the apache plugin" do
|
|
104
|
+
@c.apache.php.should == true
|
|
105
|
+
end
|
|
106
|
+
it "should store the method in options if it's not defined on the plugin" do
|
|
107
|
+
@c.enable_asp true
|
|
108
|
+
@c.options[:enable_asp].should == true
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/test_plugins/webserver'
|
|
3
|
+
|
|
4
|
+
describe "Plugin" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
@p = pool :poolpartyrb do
|
|
7
|
+
cloud :app do
|
|
8
|
+
apache do
|
|
9
|
+
enable_php
|
|
10
|
+
site("heady", {
|
|
11
|
+
:document_root => "/root"
|
|
12
|
+
})
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
@c = @p.cloud(:app)
|
|
17
|
+
end
|
|
18
|
+
describe "methods should include" do
|
|
19
|
+
it "register_plugin(plugin)" do;WebServers.respond_to?(:register_plugin).should == true;end
|
|
20
|
+
end
|
|
21
|
+
describe "registered" do
|
|
22
|
+
before(:each) do
|
|
23
|
+
@plugin = "apache".class_constant.new(@c)
|
|
24
|
+
end
|
|
25
|
+
describe "storage" do
|
|
26
|
+
it "should store the plugin in a Hash on the pool" do
|
|
27
|
+
@c.plugins.class.should == Hash
|
|
28
|
+
end
|
|
29
|
+
it "should be able to retrieve the plugin as a name" do
|
|
30
|
+
@c.plugin("apache").should_not be_nil
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
it "should store the regsitered plugins in an array" do
|
|
34
|
+
@plugin.should_not be_nil
|
|
35
|
+
end
|
|
36
|
+
it "should set the pool on the plugin" do
|
|
37
|
+
@plugin.parent.should == @c
|
|
38
|
+
end
|
|
39
|
+
it "should have the plugin name as a method on the cloud " do
|
|
40
|
+
@c.respond_to?(:apache).should == true
|
|
41
|
+
end
|
|
42
|
+
describe "methods" do
|
|
43
|
+
before(:each) do
|
|
44
|
+
reset!
|
|
45
|
+
end
|
|
46
|
+
it "should call the enable_php method when in the defininition of the cloud" do
|
|
47
|
+
@plugin.respond_to?(:enable_php).should == true
|
|
48
|
+
end
|
|
49
|
+
it "should call php = true in the enable_php" do
|
|
50
|
+
@plugin.php.should_not == true
|
|
51
|
+
@plugin.enable_php
|
|
52
|
+
@plugin.php.should == true
|
|
53
|
+
end
|
|
54
|
+
it "should call the site method when in the defininition of the cloud" do
|
|
55
|
+
@plugin.respond_to?(:site).should == true
|
|
56
|
+
end
|
|
57
|
+
it "should be able to call the plugin method site" do
|
|
58
|
+
@plugin.should_receive(:virtual_host).once
|
|
59
|
+
@plugin.site("hi", {:document_root => "/root"})
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/test_plugins/webserver'
|
|
3
|
+
|
|
4
|
+
describe "Plugin" do
|
|
5
|
+
|
|
6
|
+
before(:each) do
|
|
7
|
+
reset!
|
|
8
|
+
pool :poolpartyrb do
|
|
9
|
+
cloud :app do
|
|
10
|
+
apache do
|
|
11
|
+
enable_php
|
|
12
|
+
site("heady", {
|
|
13
|
+
:document_root => "/root"
|
|
14
|
+
})
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
@p = pool :poolpartyrb
|
|
19
|
+
@c = @p.cloud(:app)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should allow access to the pool on the cloud" do
|
|
23
|
+
@c.parent.should == @p
|
|
24
|
+
end
|
|
25
|
+
describe "instance" do
|
|
26
|
+
before(:each) do
|
|
27
|
+
@plugin = "apache".class_constant.new(@c)
|
|
28
|
+
end
|
|
29
|
+
it "should not be empty" do
|
|
30
|
+
@plugin.class.should == PoolPartyApacheClass
|
|
31
|
+
end
|
|
32
|
+
it "should have access to the cloud's container" do
|
|
33
|
+
@plugin.parent.should == @c
|
|
34
|
+
end
|
|
35
|
+
it "should have enable_php as a method" do
|
|
36
|
+
@plugin.respond_to?(:enable_php).should == true
|
|
37
|
+
end
|
|
38
|
+
describe "after eval'ing" do
|
|
39
|
+
before(:each) do
|
|
40
|
+
@plugin.instance_eval do
|
|
41
|
+
enable_php
|
|
42
|
+
has_gem(:name => "aska")
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
it "should call enable_php on the class" do
|
|
46
|
+
@plugin.php.should == true
|
|
47
|
+
end
|
|
48
|
+
it "should have resources attached to it" do
|
|
49
|
+
@plugin.resources.class.should == Hash
|
|
50
|
+
end
|
|
51
|
+
it "should have an array of gem resources" do
|
|
52
|
+
@plugin.resource(:package).class.should == Array
|
|
53
|
+
end
|
|
54
|
+
it "should have 1 gem in the resources defined" do
|
|
55
|
+
@plugin.resource(:package).size.should == 1
|
|
56
|
+
end
|
|
57
|
+
it "should have the gem named aska in the gem resource" do
|
|
58
|
+
@plugin.resource(:package).first.name.should == "aska"
|
|
59
|
+
end
|
|
60
|
+
it "should have its resources visible to its parent" do
|
|
61
|
+
@plugin.parent = @c
|
|
62
|
+
@c.resources
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
describe "before eval'ing" do
|
|
66
|
+
before(:each) do
|
|
67
|
+
reset!
|
|
68
|
+
@plugin = "apache".class_constant.new(@c)
|
|
69
|
+
end
|
|
70
|
+
it "should call has_line_in_file" do
|
|
71
|
+
@plugin.should_receive(:php).and_return true
|
|
72
|
+
end
|
|
73
|
+
it "should call site" do
|
|
74
|
+
@plugin.should_receive(:site).with("frank").and_return true
|
|
75
|
+
end
|
|
76
|
+
after do
|
|
77
|
+
@plugin.instance_eval do
|
|
78
|
+
enable_php
|
|
79
|
+
site("frank")
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|