auser-poolparty 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- 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,83 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "Pool" do
|
4
|
+
before(:each) do
|
5
|
+
@obj = Object.new
|
6
|
+
end
|
7
|
+
it "should respond to the pool method" do
|
8
|
+
@obj.respond_to?(:pool).should == true
|
9
|
+
end
|
10
|
+
it "should store the pool in the global array" do
|
11
|
+
@p = pool :app do
|
12
|
+
end
|
13
|
+
@obj.pools[:app].should == @p
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "block" do
|
17
|
+
before(:each) do
|
18
|
+
@pool = Pool.new(:test) do
|
19
|
+
# Inside pool block
|
20
|
+
Proc.new {puts "hello world"}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be able to define a cloud within the pool block" do
|
25
|
+
@pool.respond_to?(:cloud).should == true
|
26
|
+
end
|
27
|
+
it "should evaluate the block when creating a new pool" do
|
28
|
+
Proc.should_receive(:new).once
|
29
|
+
Pool.new(:test) do
|
30
|
+
Proc.new {puts "hi"}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
describe "plugins" do
|
34
|
+
after(:each) do
|
35
|
+
@pool.instance_eval do
|
36
|
+
plugin_directory "yaway"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
it "should call Dir when the plugin directory is set" do
|
40
|
+
Dir.should_receive(:[]).with("yaway/*.rb").once.and_return []
|
41
|
+
end
|
42
|
+
end
|
43
|
+
describe "configuration" do
|
44
|
+
before(:each) do
|
45
|
+
reset!
|
46
|
+
@pool = Pool.new :test do
|
47
|
+
nick_nack "nails"
|
48
|
+
rocky_shores "ranger"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
it "should set the plugin_directory to nails" do
|
52
|
+
@pool.nick_nack.should == "nails"
|
53
|
+
end
|
54
|
+
it "should set the rocky_shores to ranger" do
|
55
|
+
@pool.rocky_shores.should == "ranger"
|
56
|
+
end
|
57
|
+
describe "range for min/max instances" do
|
58
|
+
it "should be able to respond to instances" do
|
59
|
+
@pool.respond_to?(:instances).should == true
|
60
|
+
end
|
61
|
+
it "should be able to pass instances a range" do
|
62
|
+
lambda {
|
63
|
+
@pool.instance_eval do
|
64
|
+
instances 2..5
|
65
|
+
end
|
66
|
+
}.should_not raise_error
|
67
|
+
end
|
68
|
+
it "should set the minimum as the minimum_instances from the range" do
|
69
|
+
@pool.instance_eval do
|
70
|
+
instances 2..5
|
71
|
+
end
|
72
|
+
@pool.minimum_instances.should == 2
|
73
|
+
end
|
74
|
+
it "should set the maximum as the maximum_instances from the range" do
|
75
|
+
@pool.instance_eval do
|
76
|
+
instances 2..5
|
77
|
+
end
|
78
|
+
@pool.maximum_instances.should == 5
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,224 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/test_plugins/webserver'
|
3
|
+
|
4
|
+
class MyResource < PoolParty::Resources::Resource
|
5
|
+
# Just to give some options for the test class
|
6
|
+
def options(h={})
|
7
|
+
@options ||= {:a => 1,:b => 2,:c => 3}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
describe "Resource" do
|
11
|
+
before(:each) do
|
12
|
+
@resource = MyResource.new({:a => 10}) do
|
13
|
+
b "90"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
it "should set a from the hash" do
|
17
|
+
@resource.a.should == 10
|
18
|
+
end
|
19
|
+
it "should set b from within the block" do
|
20
|
+
@resource.b.should == "90"
|
21
|
+
end
|
22
|
+
it "should not wipe out the rest of the default options" do
|
23
|
+
@resource.c.should == 3
|
24
|
+
end
|
25
|
+
describe "to_s" do
|
26
|
+
it "should be able to coalesce the instances" do
|
27
|
+
@resource.to_string.should =~ /resource \{\n/
|
28
|
+
end
|
29
|
+
describe "with resources" do
|
30
|
+
before(:each) do
|
31
|
+
self.stub!(:options).and_return(:name => "cook")
|
32
|
+
|
33
|
+
@obj = PoolParty::Resources::Resource.new
|
34
|
+
@obj.stub!(:name).and_return "cook"
|
35
|
+
|
36
|
+
@resource2 = MyResource.new do
|
37
|
+
file(:name => "shulie")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
it "should call classpackage_with_self when it has resources" do
|
41
|
+
@resource2.should_receive(:classpackage_with_self).and_return @obj
|
42
|
+
@resource2.to_string
|
43
|
+
end
|
44
|
+
it "should call to_string on the class package" do
|
45
|
+
@obj.should_receive(:to_string).and_return "wee"
|
46
|
+
@resource2.should_receive(:classpackage_with_self).and_return @obj
|
47
|
+
@resource2.to_string
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
describe "class methods" do
|
52
|
+
it "should have an array of available resources" do
|
53
|
+
PoolParty::Resources::Resource.available_resources.class.should == Array
|
54
|
+
end
|
55
|
+
it "should not be empty" do
|
56
|
+
PoolParty::Resources::Resource.available_resources.should_not be_empty
|
57
|
+
end
|
58
|
+
end
|
59
|
+
describe "instance methods" do
|
60
|
+
before(:each) do
|
61
|
+
@resource = MyResource.new
|
62
|
+
end
|
63
|
+
%w(requires ensures is_present is_absent ifnot).each do |method|
|
64
|
+
eval <<-EOE
|
65
|
+
it "should have the method #{method} available" do; @resource.respond_to?(:#{method}).should == true; end
|
66
|
+
EOE
|
67
|
+
end
|
68
|
+
it "should be able to take requires method" do
|
69
|
+
@resource.respond_to?(:requires).should == true
|
70
|
+
end
|
71
|
+
it "should push require onto the options" do
|
72
|
+
@resource.options.has_key?(:require).should == false
|
73
|
+
@resource.requires("nibbles")
|
74
|
+
@resource.options.has_key?(:require).should == true
|
75
|
+
end
|
76
|
+
it "should be able to call ensures method on the resource" do
|
77
|
+
@resource.respond_to?(:ensures).should == true
|
78
|
+
end
|
79
|
+
it "should push the option ensure onto the options" do
|
80
|
+
@resource.options.has_key?(:ensure).should == false
|
81
|
+
@resource.ensures("nibbles")
|
82
|
+
@resource.options.has_key?(:ensure).should == true
|
83
|
+
end
|
84
|
+
it "should write the option ensures as present with is_present" do
|
85
|
+
@resource.options.has_key?(:ensure).should == false
|
86
|
+
@resource.is_present
|
87
|
+
@resource.options[:ensure].should == "present"
|
88
|
+
end
|
89
|
+
it "should write the option ensures as absent with is_absent" do
|
90
|
+
@resource.options.has_key?(:ensure).should == false
|
91
|
+
@resource.is_absent
|
92
|
+
@resource.options[:ensure].should == "absent"
|
93
|
+
end
|
94
|
+
it "should write the option unless for ifnot" do
|
95
|
+
@resource.options.has_key?(:unless).should == false
|
96
|
+
@resource.ifnot "str"
|
97
|
+
@resource.options[:unless].should == "str"
|
98
|
+
end
|
99
|
+
describe "templating" do
|
100
|
+
before(:each) do
|
101
|
+
FileUtils.stub!(:cp).and_return true
|
102
|
+
end
|
103
|
+
it "should have the method template" do
|
104
|
+
@resource.respond_to?(:template).should == true
|
105
|
+
end
|
106
|
+
it "should raise an exception if no file is given" do
|
107
|
+
lambda {
|
108
|
+
@resource.template
|
109
|
+
}.should raise_error
|
110
|
+
end
|
111
|
+
it "should raise an excepton if the file cannot be found" do
|
112
|
+
lambda {
|
113
|
+
@resource.template("radar")
|
114
|
+
}.should raise_error
|
115
|
+
end
|
116
|
+
it "should not raise an exception if there is a file passed and the file is found" do
|
117
|
+
File.should_receive(:file?).with("radar").and_return true
|
118
|
+
lambda {
|
119
|
+
@resource.template("radar")
|
120
|
+
}.should_not raise_error
|
121
|
+
end
|
122
|
+
# it "should push the template option on to the options" do
|
123
|
+
# File.stub!(:file?).with("radar").and_return true
|
124
|
+
# @resource.options.has_key?(:template).should == false
|
125
|
+
# @resource.template("radar")
|
126
|
+
# @resource.options.has_key?(:template).should == true
|
127
|
+
# end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
describe "command" do
|
131
|
+
include PoolParty::Resources
|
132
|
+
before(:each) do
|
133
|
+
reset_resources!
|
134
|
+
end
|
135
|
+
it "should create the new 'resource' as a resource" do
|
136
|
+
resource(:file).class.should == Array
|
137
|
+
end
|
138
|
+
it "should receive << when adding a new one" do
|
139
|
+
resource(:file).should_receive(:<<).once
|
140
|
+
file({:name => "pop"})
|
141
|
+
end
|
142
|
+
it "should contain 3 instances after calling resource 3 times" do
|
143
|
+
file({:name => "red"})
|
144
|
+
file({:name => "hot"})
|
145
|
+
file({:name => "summer"})
|
146
|
+
resource(:file).size.should == 3
|
147
|
+
end
|
148
|
+
describe "adding" do
|
149
|
+
before(:each) do
|
150
|
+
@a = file({:name => "red"})
|
151
|
+
@b = file({:name => "hot"})
|
152
|
+
@c = file({:name => "summer"})
|
153
|
+
end
|
154
|
+
it "should contain file named with 'red'" do
|
155
|
+
resource(:file).include?(@a).should == true
|
156
|
+
end
|
157
|
+
end
|
158
|
+
describe "method_missing" do
|
159
|
+
before(:each) do
|
160
|
+
file({:name => "red"})
|
161
|
+
file({:name => "hot"})
|
162
|
+
file({:name => "summer"})
|
163
|
+
end
|
164
|
+
it "should be able to pick out methods with the phrase has_" do
|
165
|
+
lambda {
|
166
|
+
has_file
|
167
|
+
}.should_not raise_error
|
168
|
+
end
|
169
|
+
it "should not have a method prepended with crabs_" do
|
170
|
+
lambda {
|
171
|
+
crabs_file
|
172
|
+
}.should raise_error
|
173
|
+
end
|
174
|
+
it "should pick out methods with the phrase does_not_" do
|
175
|
+
lambda {
|
176
|
+
does_not_have_file({:name => "red"})
|
177
|
+
}.should_not raise_error
|
178
|
+
end
|
179
|
+
it "should set the has_file to present ensure" do
|
180
|
+
has_file({:name => "redface"})
|
181
|
+
resource(:file).get_named("redface").first.options[:ensure].should == "present"
|
182
|
+
end
|
183
|
+
it "should set the does_not_have_file to absent ensure" do
|
184
|
+
does_not_have_file({:name => "net"})
|
185
|
+
resource(:file).get_named("net").first.options[:ensure].should == "absent"
|
186
|
+
end
|
187
|
+
it "should be able to have_service as well" do
|
188
|
+
has_service({:name => "apache"})
|
189
|
+
resource(:service).get_named("apache").first.options[:ensure].should == "running"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
describe "get_resource" do
|
193
|
+
before(:each) do
|
194
|
+
@red = file(:name => "red")
|
195
|
+
@hot = file(:name => "hot")
|
196
|
+
@tamales = file(:name => "tamales")
|
197
|
+
end
|
198
|
+
it "should return a type of resource when looking for a resource that exists" do
|
199
|
+
get_resource(:file, "hot").class.should == PoolParty::Resources::File
|
200
|
+
end
|
201
|
+
it "should return the resource of the name requested" do
|
202
|
+
get_resource(:file, "hot").should == @hot
|
203
|
+
end
|
204
|
+
it "should return nil if the resource requested is not there" do
|
205
|
+
get_resource(:file, "smarties").should be_nil
|
206
|
+
end
|
207
|
+
end
|
208
|
+
describe "parent" do
|
209
|
+
before(:each) do
|
210
|
+
@cloud = cloud :app do
|
211
|
+
tangerine "orange"
|
212
|
+
file(:name => "file.txt")
|
213
|
+
end
|
214
|
+
@file = @cloud.resources[:file].first
|
215
|
+
end
|
216
|
+
it "should take the options of the parent" do
|
217
|
+
@file.parent.tangerine.should_not == nil
|
218
|
+
end
|
219
|
+
it "should set the option as the same from the parent" do
|
220
|
+
@file.parent.tangerine.should == "orange"
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
include PoolParty::Resources
|
4
|
+
|
5
|
+
describe "File" do
|
6
|
+
before(:each) do
|
7
|
+
reset!
|
8
|
+
@class = PoolParty::Resources::Classpackage.new({:name => "rockstar"})
|
9
|
+
end
|
10
|
+
it "should have a method resources" do
|
11
|
+
@class.respond_to?(:resources).should == true
|
12
|
+
end
|
13
|
+
it "should store the resources in an array" do
|
14
|
+
@class.resources.class.should == Hash
|
15
|
+
end
|
16
|
+
describe "with resources" do
|
17
|
+
before(:each) do
|
18
|
+
cloud :application_cloud do
|
19
|
+
classpackage do
|
20
|
+
file({:name => "red"})
|
21
|
+
end
|
22
|
+
end
|
23
|
+
@class = cloud(:application_cloud).resource(:classpackage).first
|
24
|
+
end
|
25
|
+
it "should store a resource in the resources array" do
|
26
|
+
@class.resources.size.should == 1
|
27
|
+
end
|
28
|
+
it "should have a file resource in the cloud" do
|
29
|
+
@class.resource(:file).should_not == nil
|
30
|
+
end
|
31
|
+
describe "to_s" do
|
32
|
+
before(:each) do
|
33
|
+
@class.instance_eval do
|
34
|
+
name "rockstar"
|
35
|
+
file({:name => "red"}) do; end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
it "should output the class with the name as class [name]" do
|
39
|
+
@class.to_string.should =~ /class rockstar/
|
40
|
+
end
|
41
|
+
after do
|
42
|
+
@class.to_string
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
describe "setting with a block" do
|
48
|
+
before(:each) do
|
49
|
+
@class1 = classpackage do
|
50
|
+
name "my_class"
|
51
|
+
file({:name => "frank"})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
it "should set the name when set" do
|
55
|
+
@class1.name.should == "my_class"
|
56
|
+
end
|
57
|
+
it "should have the file resource in the resources class" do
|
58
|
+
@class1.resources.size.should_not be_zero
|
59
|
+
end
|
60
|
+
it "should have the file resource in the resources array" do
|
61
|
+
@class1.resource(:file).class.should == Array
|
62
|
+
end
|
63
|
+
it "should store the file in the resources array" do
|
64
|
+
@class1.resource(:file).get_named("frank").first.name.should == "frank"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
describe "from a collection of resources to another" do
|
68
|
+
before(:each) do
|
69
|
+
self.stub!(:options).and_return({:name => "cook"})
|
70
|
+
file(:name => "franksfile")
|
71
|
+
exec(:name => "get file", :command => "kill frank for file")
|
72
|
+
end
|
73
|
+
it "should have the method classpackage_with_self" do
|
74
|
+
self.respond_to?(:classpackage_with_self).should == true
|
75
|
+
end
|
76
|
+
it "should transfer the resources to the class" do
|
77
|
+
@class2 = classpackage_with_self(self)
|
78
|
+
@class2.resources.should_not be_empty
|
79
|
+
end
|
80
|
+
it "should leave zero resources on the parent" do
|
81
|
+
@class2 = classpackage_with_self(self)
|
82
|
+
resources.should be_empty
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
include PoolParty::Resources
|
4
|
+
|
5
|
+
describe "Conditional" do
|
6
|
+
before(:each) do
|
7
|
+
@cloud = cloud :app do; end
|
8
|
+
@cloud.instance_eval do
|
9
|
+
execute_if("$hostname", "'master'", self) do
|
10
|
+
file({:name => "/etc/apache2/puppetmaster.conf"})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
@cond = @cloud.resource(:conditional).first
|
14
|
+
end
|
15
|
+
it "should add the block of resources on the parent" do
|
16
|
+
@cloud.resources.size.should == 1
|
17
|
+
end
|
18
|
+
it "should have a conditional in the resources" do
|
19
|
+
@cloud.resource(:conditional).first.name.should == "$hostname == 'master'"
|
20
|
+
end
|
21
|
+
it "should push the resources onto the conditional resource" do
|
22
|
+
@cond.resources.size.should == 1
|
23
|
+
end
|
24
|
+
it "should have a file resource on the conditional" do
|
25
|
+
@cond.resource(:file).first.name.should == "/etc/apache2/puppetmaster.conf"
|
26
|
+
end
|
27
|
+
it "should have the parent as the cloud" do
|
28
|
+
@cond.parent.should == @cloud
|
29
|
+
end
|
30
|
+
describe "to_string" do
|
31
|
+
before(:each) do
|
32
|
+
@string = @cond.to_string
|
33
|
+
end
|
34
|
+
it "should have a case statement for the hostname" do
|
35
|
+
@string.should =~ /case \$hostname/
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
include PoolParty::Resources
|
4
|
+
|
5
|
+
describe "Cron" do
|
6
|
+
describe "instances" do
|
7
|
+
before(:each) do
|
8
|
+
@cloud = cloud :cron_resources do
|
9
|
+
cron({:command => "/bin/logrotate"})
|
10
|
+
end
|
11
|
+
@cron = @cloud.resource(:cron).first
|
12
|
+
end
|
13
|
+
it "should turn the one hash instance into a string" do
|
14
|
+
@cron.to_string.should =~ /'\/bin\/logrotate'/
|
15
|
+
end
|
16
|
+
it "should turn the two hash instance into a string" do
|
17
|
+
@cron = cron({:name => "mail", :command => "/bin/mail -s \"letters\""})
|
18
|
+
@cron.to_string.should =~ /"mail":/
|
19
|
+
end
|
20
|
+
describe "as included" do
|
21
|
+
before(:each) do
|
22
|
+
@cron = cron({:rent => "low"}) do
|
23
|
+
name "/www/conf/httpd.conf"
|
24
|
+
hour 23
|
25
|
+
minute 5
|
26
|
+
weekday 1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
it "should use default values" do
|
30
|
+
@cron.name.should == "/www/conf/httpd.conf"
|
31
|
+
end
|
32
|
+
it "should keep the default values for the file" do
|
33
|
+
@cron.user.should == "root"
|
34
|
+
end
|
35
|
+
it "should also set options through a hash" do
|
36
|
+
@cron.rent.should == "low"
|
37
|
+
end
|
38
|
+
it "should set the hour to 23" do
|
39
|
+
@cron.hour.should == 23
|
40
|
+
end
|
41
|
+
it "should set the minute to 5" do
|
42
|
+
@cron.minute.should == 5
|
43
|
+
end
|
44
|
+
it "should set the weekday to 1" do
|
45
|
+
@cron.weekday.should == 1
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|