auser-poolparty 0.2.16 → 0.2.20
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +72 -7
- data/PostInstall.txt +1 -1
- data/Rakefile +11 -0
- data/bin/cloud-provision +6 -10
- data/bin/server-build-messenger +20 -0
- data/bin/server-fire-cmd +0 -2
- data/bin/server-list-responding +24 -0
- data/bin/server-start-master +4 -9
- data/bin/server-start-node +7 -6
- data/lib/erlang/messenger/Emakefile +1 -0
- data/lib/erlang/messenger/Rakefile +29 -20
- data/lib/erlang/messenger/ebin/master_app.beam +0 -0
- data/lib/erlang/messenger/ebin/node_app.beam +0 -0
- data/lib/erlang/messenger/ebin/packager.app +19 -0
- data/lib/erlang/messenger/ebin/pm_client.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_cluster.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_event_handler.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_master.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_master_rel-0.1.rel +1 -7
- data/lib/erlang/messenger/ebin/pm_master_supervisor.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_node.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_node_rel-0.1.rel +1 -7
- data/lib/erlang/messenger/ebin/pm_node_supervisor.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_packager.beam +0 -0
- data/lib/erlang/messenger/ebin/utils.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/AUTHORS +2 -0
- data/lib/erlang/messenger/lib/eunit/CHANGELOG +14 -0
- data/lib/erlang/messenger/lib/eunit/COPYING +504 -0
- data/lib/erlang/messenger/lib/eunit/Makefile +28 -0
- data/lib/erlang/messenger/lib/eunit/NOTES +276 -0
- data/lib/erlang/messenger/lib/eunit/README +3 -0
- data/lib/erlang/messenger/lib/eunit/doc/edoc-info +3 -0
- data/lib/erlang/messenger/lib/eunit/doc/erlang.png +0 -0
- data/lib/erlang/messenger/lib/eunit/doc/eunit.html +172 -0
- data/lib/erlang/messenger/lib/eunit/doc/index.html +17 -0
- data/lib/erlang/messenger/lib/eunit/doc/modules-frame.html +12 -0
- data/lib/erlang/messenger/lib/eunit/doc/overview-summary.html +984 -0
- data/lib/erlang/messenger/lib/eunit/doc/overview.edoc +980 -0
- data/lib/erlang/messenger/lib/eunit/doc/packages-frame.html +11 -0
- data/lib/erlang/messenger/lib/eunit/doc/stylesheet.css +55 -0
- data/lib/erlang/messenger/lib/eunit/ebin/autoload.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/code_monitor.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit.app +21 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit.appup +1 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_autoexport.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_data.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_lib.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_proc.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_serial.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_server.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_striptests.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_test.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_tests.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_tty.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/file_monitor.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/examples/eunit_examples.erl +339 -0
- data/lib/erlang/messenger/lib/eunit/examples/fib.erl +19 -0
- data/lib/erlang/messenger/lib/eunit/examples/tests.txt +1 -0
- data/lib/erlang/messenger/lib/eunit/include/eunit.hrl +313 -0
- data/lib/erlang/messenger/lib/eunit/src/Makefile +46 -0
- data/lib/erlang/messenger/lib/eunit/src/autoload.erl +388 -0
- data/lib/erlang/messenger/lib/eunit/src/code_monitor.erl +243 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit.app.src +21 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit.appup.src +1 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit.erl +196 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_autoexport.erl +102 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_data.erl +798 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_internal.hrl +48 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_lib.erl +682 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_proc.erl +552 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_serial.erl +157 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_server.erl +340 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_striptests.erl +64 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_test.erl +334 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_tests.erl +45 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_tty.erl +272 -0
- data/lib/erlang/messenger/lib/eunit/src/file_monitor.erl +409 -0
- data/lib/erlang/messenger/lib/eunit/sys.config +9 -0
- data/lib/erlang/messenger/lib/eunit/vsn.mk +1 -0
- data/lib/erlang/messenger/pm_master_rel-0.1.boot +0 -0
- data/lib/erlang/messenger/pm_master_rel-0.1.script +75 -2
- data/lib/erlang/messenger/pm_node_rel-0.1.boot +0 -0
- data/lib/erlang/messenger/pm_node_rel-0.1.script +75 -2
- data/lib/erlang/messenger/src/pm_client.erl +8 -3
- data/lib/erlang/messenger/src/pm_cluster.erl +32 -9
- data/lib/erlang/messenger/src/pm_master.erl +10 -11
- data/lib/erlang/messenger/src/pm_node.erl +2 -3
- data/lib/erlang/messenger/src/pm_packager.erl +73 -0
- data/lib/erlang/messenger/src/utils.erl +3 -10
- data/lib/poolparty/base_packages/heartbeat.rb +9 -9
- data/lib/poolparty/base_packages/poolparty.rb +16 -10
- data/lib/poolparty/config/allowed_commands.yml +1 -0
- data/lib/poolparty/core/object.rb +8 -0
- data/lib/poolparty/exceptions/UnacceptableCommand.rb +5 -0
- data/lib/poolparty/helpers/messenger.rb +29 -0
- data/lib/poolparty/helpers/provisioner_base.rb +7 -7
- data/lib/poolparty/helpers/provisioners/master.rb +3 -7
- data/lib/poolparty/helpers/provisioners/slave.rb +1 -0
- data/lib/poolparty/modules/cloud_resourcer.rb +7 -5
- data/lib/poolparty/modules/configurable.rb +1 -1
- data/lib/poolparty/modules/method_missing_sugar.rb +6 -1
- data/lib/poolparty/modules/pretty_printer.rb +1 -0
- data/lib/poolparty/modules/resourcing_dsl.rb +2 -1
- data/lib/poolparty/monitors/monitors/cpu_monitor.rb +1 -1
- data/lib/poolparty/net/remoter.rb +3 -1
- data/lib/poolparty/plugins/git.rb +3 -3
- data/lib/poolparty/pool/base.rb +7 -2
- data/lib/poolparty/pool/cloud.rb +3 -3
- data/lib/poolparty/pool/resource.rb +38 -24
- data/lib/poolparty/pool/resources/class_package.rb +2 -2
- data/lib/poolparty/pool/resources/conditional.rb +8 -4
- data/lib/poolparty/pool/resources/{gem.rb → gem_package.rb} +0 -0
- data/lib/poolparty/pool/resources/package.rb +8 -1
- data/lib/poolparty/version.rb +1 -1
- data/lib/poolparty.rb +1 -1
- data/poolparty.gemspec +476 -61
- data/spec/poolparty/core/object_spec.rb +20 -0
- data/spec/poolparty/helpers/messenger_spec.rb +14 -0
- data/spec/poolparty/helpers/provisioners/master_spec.rb +2 -2
- data/spec/poolparty/net/remoter_spec.rb +1 -1
- data/spec/poolparty/plugins/git_spec.rb +26 -19
- data/spec/poolparty/pool/base_spec.rb +20 -2
- data/spec/poolparty/pool/cloud_spec.rb +256 -249
- data/spec/poolparty/pool/custom_resource_spec.rb +6 -1
- data/spec/poolparty/pool/plugin_spec.rb +71 -65
- data/spec/poolparty/pool/resource_spec.rb +314 -237
- data/spec/poolparty/pool/resources/class_package_spec.rb +71 -66
- data/spec/poolparty/pool/resources/conditional_spec.rb +30 -26
- data/spec/poolparty/pool/resources/gem_spec.rb +18 -14
- data/spec/poolparty/pool/resources/variable_spec.rb +1 -1
- data/spec/poolparty/pool/script_spec.rb +46 -37
- data/spec/poolparty/spec_helper.rb +4 -0
- data/tasks/cloud.rake +0 -54
- data/tasks/development.rake +11 -14
- data/tasks/ec2.rake +10 -17
- data/tasks/instance.rake +0 -61
- data/website/index.html +1 -1
- metadata +83 -10
@@ -1,6 +1,8 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
require File.dirname(__FILE__) + '/test_plugins/webserver'
|
3
3
|
|
4
|
+
include PoolParty::Resources
|
5
|
+
|
4
6
|
class MyResource < PoolParty::Resources::Resource
|
5
7
|
# Just to give some options for the test class
|
6
8
|
def options(h={})
|
@@ -8,283 +10,358 @@ class MyResource < PoolParty::Resources::Resource
|
|
8
10
|
end
|
9
11
|
end
|
10
12
|
describe "Resource" do
|
11
|
-
|
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
|
13
|
+
describe "wrapped" do
|
60
14
|
before(:each) do
|
61
|
-
@resource = MyResource.new
|
62
|
-
|
63
|
-
|
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
|
15
|
+
@resource = MyResource.new({:a => 10}) do
|
16
|
+
b "90"
|
17
|
+
end
|
83
18
|
end
|
84
|
-
it "should
|
85
|
-
@resource.
|
86
|
-
@resource.is_present
|
87
|
-
@resource.options[:ensure].should == "present"
|
19
|
+
it "should set a from the hash" do
|
20
|
+
@resource.a.should == 10
|
88
21
|
end
|
89
|
-
it "should
|
90
|
-
@resource.
|
91
|
-
@resource.is_absent
|
92
|
-
@resource.options[:ensure].should == "absent"
|
22
|
+
it "should set b from within the block" do
|
23
|
+
@resource.b.should == "90"
|
93
24
|
end
|
94
|
-
it "should
|
95
|
-
@resource.
|
96
|
-
@resource.ifnot "str"
|
97
|
-
@resource.options[:unless].should == "str"
|
25
|
+
it "should not wipe out the rest of the default options" do
|
26
|
+
@resource.c.should == 3
|
98
27
|
end
|
99
|
-
describe "
|
100
|
-
|
101
|
-
|
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
|
28
|
+
describe "to_s" do
|
29
|
+
it "should be able to coalesce the instances" do
|
30
|
+
@resource.to_string.should =~ /resource \{\n/
|
115
31
|
end
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
it "should call add_resource when creating using the command: file" do
|
137
|
-
@cloud.should_receive(:add_resource).with(:file, {:name => "frank"}, @cloud)
|
138
|
-
@cloud.instance_eval do
|
139
|
-
file(:name => "frank")
|
32
|
+
describe "with resources" do
|
33
|
+
before(:each) do
|
34
|
+
self.stub!(:options).and_return(:name => "cook")
|
35
|
+
|
36
|
+
@obj = PoolParty::Resources::Resource.new
|
37
|
+
@obj.stub!(:name).and_return "cook"
|
38
|
+
|
39
|
+
@resource2 = MyResource.new do
|
40
|
+
file(:name => "shulie")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
it "should call classpackage_with_self when it has resources" do
|
44
|
+
@resource2.should_receive(:classpackage_with_self).and_return @obj
|
45
|
+
@resource2.to_string
|
46
|
+
end
|
47
|
+
it "should call to_string on the class package" do
|
48
|
+
@obj.should_receive(:to_string).and_return "wee"
|
49
|
+
@resource2.should_receive(:classpackage_with_self).and_return @obj
|
50
|
+
@resource2.to_string
|
51
|
+
end
|
140
52
|
end
|
141
53
|
end
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
it "should receive << when adding a new one" do
|
146
|
-
resource(:file).should_receive(:<<).once
|
147
|
-
file({:name => "pop"})
|
148
|
-
end
|
149
|
-
it "should contain 3 instances after calling resource 3 times" do
|
150
|
-
file({:name => "red"})
|
151
|
-
file({:name => "hot"})
|
152
|
-
file({:name => "summer"})
|
153
|
-
resource(:file).size.should == 3
|
154
|
-
end
|
155
|
-
describe "adding" do
|
156
|
-
before(:each) do
|
157
|
-
@a = file({:name => "red"})
|
158
|
-
@b = file({:name => "hot"})
|
159
|
-
@c = file({:name => "summer"})
|
54
|
+
describe "class methods" do
|
55
|
+
it "should have an array of available resources" do
|
56
|
+
PoolParty::Resources::Resource.available_resources.class.should == Array
|
160
57
|
end
|
161
|
-
it "should
|
162
|
-
|
58
|
+
it "should not be empty" do
|
59
|
+
PoolParty::Resources::Resource.available_resources.should_not be_empty
|
163
60
|
end
|
164
61
|
end
|
165
|
-
describe "
|
62
|
+
describe "instance methods" do
|
166
63
|
before(:each) do
|
167
|
-
|
168
|
-
file({:name => "hot"})
|
169
|
-
file({:name => "summer"})
|
170
|
-
end
|
171
|
-
it "should be able to pick out methods with the phrase has_" do
|
172
|
-
lambda {
|
173
|
-
has_file
|
174
|
-
}.should_not raise_error
|
64
|
+
@resource = MyResource.new
|
175
65
|
end
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
66
|
+
%w(requires ensures is_present is_absent ifnot).each do |method|
|
67
|
+
eval <<-EOE
|
68
|
+
it "should have the method #{method} available" do; @resource.respond_to?(:#{method}).should == true; end
|
69
|
+
EOE
|
180
70
|
end
|
181
|
-
it "should
|
182
|
-
|
183
|
-
does_not_have_file({:name => "red"})
|
184
|
-
}.should_not raise_error
|
71
|
+
it "should be able to take requires method" do
|
72
|
+
@resource.respond_to?(:requires).should == true
|
185
73
|
end
|
186
|
-
it "should
|
187
|
-
|
188
|
-
resource
|
74
|
+
it "should push require onto the options" do
|
75
|
+
@resource.options.has_key?(:require).should == false
|
76
|
+
@resource.requires("nibbles")
|
77
|
+
@resource.options.has_key?(:require).should == true
|
189
78
|
end
|
190
|
-
it "should
|
191
|
-
|
192
|
-
resource(:file).get_named("net").first.options[:ensure].should == "absent"
|
79
|
+
it "should be able to call ensures method on the resource" do
|
80
|
+
@resource.respond_to?(:ensures).should == true
|
193
81
|
end
|
194
|
-
it "should
|
195
|
-
|
196
|
-
resource
|
197
|
-
|
198
|
-
end
|
199
|
-
describe "get_resource" do
|
200
|
-
before(:each) do
|
201
|
-
@red = file(:name => "red")
|
202
|
-
@hot = file(:name => "hot")
|
203
|
-
@tamales = file(:name => "tamales")
|
82
|
+
it "should push the option ensure onto the options" do
|
83
|
+
@resource.options.has_key?(:ensure).should == false
|
84
|
+
@resource.ensures("nibbles")
|
85
|
+
@resource.options.has_key?(:ensure).should == true
|
204
86
|
end
|
205
|
-
it "should
|
206
|
-
|
87
|
+
it "should write the option ensures as present with is_present" do
|
88
|
+
@resource.options.has_key?(:ensure).should == false
|
89
|
+
@resource.is_present
|
90
|
+
@resource.options[:ensure].should == "present"
|
207
91
|
end
|
208
|
-
it "should
|
209
|
-
|
92
|
+
it "should write the option ensures as absent with is_absent" do
|
93
|
+
@resource.options.has_key?(:ensure).should == false
|
94
|
+
@resource.is_absent
|
95
|
+
@resource.options[:ensure].should == "absent"
|
210
96
|
end
|
211
|
-
it "should
|
212
|
-
|
97
|
+
it "should write the option unless for ifnot" do
|
98
|
+
@resource.options.has_key?(:unless).should == false
|
99
|
+
@resource.ifnot "str"
|
100
|
+
@resource.options[:unless].should == "str"
|
213
101
|
end
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
@cloud = cloud :app do
|
218
|
-
tangerine "orange"
|
219
|
-
file(:name => "file.txt")
|
102
|
+
describe "templating" do
|
103
|
+
before(:each) do
|
104
|
+
FileUtils.stub!(:cp).and_return true
|
220
105
|
end
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
106
|
+
it "should have the method template" do
|
107
|
+
@resource.respond_to?(:template).should == true
|
108
|
+
end
|
109
|
+
it "should raise an exception if no file is given" do
|
110
|
+
lambda {
|
111
|
+
@resource.template
|
112
|
+
}.should raise_error
|
113
|
+
end
|
114
|
+
it "should raise an excepton if the file cannot be found" do
|
115
|
+
lambda {
|
116
|
+
@resource.template("radar")
|
117
|
+
}.should raise_error
|
118
|
+
end
|
119
|
+
it "should not raise an exception if there is a file passed and the file is found" do
|
120
|
+
File.should_receive(:file?).with("radar").and_return true
|
121
|
+
lambda {
|
122
|
+
@resource.template("radar")
|
123
|
+
}.should_not raise_error
|
124
|
+
end
|
125
|
+
# it "should push the template option on to the options" do
|
126
|
+
# File.stub!(:file?).with("radar").and_return true
|
127
|
+
# @resource.options.has_key?(:template).should == false
|
128
|
+
# @resource.template("radar")
|
129
|
+
# @resource.options.has_key?(:template).should == true
|
130
|
+
# end
|
228
131
|
end
|
229
132
|
end
|
230
|
-
describe "
|
133
|
+
describe "command" do
|
134
|
+
include PoolParty::Resources
|
231
135
|
before(:each) do
|
232
|
-
@
|
233
|
-
directory(:name => "/var/www") do
|
234
|
-
file(:name => "/var/www/file.html")
|
235
|
-
end
|
236
|
-
end
|
237
|
-
@dir = @cloud1.get_resource(:directory, "/var/www")
|
238
|
-
@file = @dir.get_resource(:file, "/var/www/file.html")
|
136
|
+
@cloud = cloud :command_cloud do; end
|
239
137
|
end
|
240
|
-
it "should
|
241
|
-
@
|
242
|
-
|
243
|
-
|
244
|
-
|
138
|
+
it "should call add_resource when creating using the command: file" do
|
139
|
+
@cloud.should_receive(:add_resource).with(:file, {:name => "frank"}, @cloud)
|
140
|
+
@cloud.instance_eval do
|
141
|
+
file(:name => "frank")
|
142
|
+
end
|
245
143
|
end
|
246
|
-
it "should
|
247
|
-
|
144
|
+
it "should create the new 'resource' as a resource" do
|
145
|
+
resource(:file).class.should == Array
|
248
146
|
end
|
249
|
-
it "should
|
250
|
-
|
147
|
+
it "should receive << when adding a new one" do
|
148
|
+
resource(:file).should_receive(:<<).once
|
149
|
+
has_file({:name => "pop"})
|
251
150
|
end
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
151
|
+
it "should contain 3 instances after calling resource 3 times" do
|
152
|
+
file({:name => "red"})
|
153
|
+
file({:name => "hot"})
|
154
|
+
file({:name => "summer"})
|
155
|
+
resource(:file).size.should == 3
|
256
156
|
end
|
257
|
-
|
258
|
-
|
259
|
-
|
157
|
+
describe "adding" do
|
158
|
+
before(:each) do
|
159
|
+
@a = file({:name => "red"})
|
160
|
+
@b = file({:name => "hot"})
|
161
|
+
@c = file({:name => "summer"})
|
162
|
+
end
|
163
|
+
it "should contain file named with 'red'" do
|
164
|
+
get_resource(:file, "red").nil?.should == false
|
165
|
+
end
|
260
166
|
end
|
261
|
-
|
262
|
-
|
167
|
+
describe "method_missing" do
|
168
|
+
before(:each) do
|
169
|
+
file({:name => "red"})
|
170
|
+
file({:name => "hot"})
|
171
|
+
file({:name => "summer"})
|
172
|
+
end
|
173
|
+
it "should be able to pick out methods with the phrase has_" do
|
174
|
+
lambda {
|
175
|
+
has_file
|
176
|
+
}.should_not raise_error
|
177
|
+
end
|
178
|
+
it "should not have a method prepended with crabs_" do
|
179
|
+
lambda {
|
180
|
+
crabs_file
|
181
|
+
}.should raise_error
|
182
|
+
end
|
183
|
+
it "should pick out methods with the phrase does_not_" do
|
184
|
+
lambda {
|
185
|
+
does_not_have_file({:name => "red"})
|
186
|
+
}.should_not raise_error
|
187
|
+
end
|
188
|
+
it "should set the has_file to present ensure" do
|
189
|
+
has_file({:name => "redface"})
|
190
|
+
resource(:file).get_named("redface").first.options[:ensure].should == "present"
|
191
|
+
end
|
192
|
+
it "should set the does_not_have_file to absent ensure" do
|
193
|
+
does_not_have_file({:name => "net"})
|
194
|
+
resource(:file).get_named("net").first.options[:ensure].should == "absent"
|
195
|
+
end
|
196
|
+
it "should be able to have_service as well" do
|
197
|
+
has_service({:name => "apache"})
|
198
|
+
resource(:service).get_named("apache").first.options[:ensure].should == "running"
|
199
|
+
end
|
263
200
|
end
|
264
|
-
|
265
|
-
|
266
|
-
|
201
|
+
describe "get_resource" do
|
202
|
+
before(:each) do
|
203
|
+
reset_resources!
|
204
|
+
@cloud_get_resource = cloud :get_resource do
|
205
|
+
file(:name => "red")
|
206
|
+
file(:name => "hot")
|
207
|
+
file(:name => "tamales")
|
208
|
+
end
|
209
|
+
end
|
210
|
+
it "should return a type of resource when looking for a resource that exists" do
|
211
|
+
@cloud_get_resource.get_resource(:file, "hot").class.should == PoolParty::Resources::File
|
212
|
+
end
|
213
|
+
it "should return the resource of the name requested" do
|
214
|
+
@cloud_get_resource.get_resource(:file, "hot").name.should == "hot"
|
215
|
+
end
|
216
|
+
it "should return nil if the resource requested is not there" do
|
217
|
+
@cloud_get_resource.get_resource(:file, "smarties").should be_nil
|
218
|
+
end
|
219
|
+
it "should not have created any more resources" do
|
220
|
+
@cloud_get_resource.resource(:file).size.should == 3
|
221
|
+
end
|
267
222
|
end
|
268
|
-
|
269
|
-
|
223
|
+
describe "parent" do
|
224
|
+
before(:each) do
|
225
|
+
@cloud = cloud :app do
|
226
|
+
tangerine "orange"
|
227
|
+
file(:name => "file.txt")
|
228
|
+
end
|
229
|
+
@file = @cloud.resources[:file].first
|
230
|
+
end
|
231
|
+
it "should take the options of the parent" do
|
232
|
+
@file.parent.tangerine.should_not == nil
|
233
|
+
end
|
234
|
+
it "should set the option as the same from the parent" do
|
235
|
+
@file.parent.tangerine.should == "orange"
|
236
|
+
end
|
270
237
|
end
|
271
|
-
describe "
|
272
|
-
|
273
|
-
@
|
238
|
+
describe "appending to resource" do
|
239
|
+
before(:each) do
|
240
|
+
@cloud1 = cloud :apples do
|
241
|
+
directory(:name => "/var/www") do
|
242
|
+
file(:name => "/var/www/file.html")
|
243
|
+
end
|
244
|
+
end
|
245
|
+
@dir = @cloud1.get_resource(:directory, "/var/www")
|
246
|
+
@file = @dir.get_resource(:file, "/var/www/file.html")
|
247
|
+
end
|
248
|
+
it "should say there is 1 resource because the lower-level resources should be contained on the parenting resource" do
|
249
|
+
@cloud1.resources.size.should == 1
|
250
|
+
end
|
251
|
+
it "should say there is one resource on the outer resource" do
|
252
|
+
@dir.resources.size.should == 1
|
253
|
+
end
|
254
|
+
it "should contain the file as a resource" do
|
255
|
+
@dir.resource(:file)[0].to_s.should == @file.to_s
|
274
256
|
end
|
275
|
-
it "should
|
276
|
-
@file.
|
277
|
-
@file.cancelled?.should == true
|
257
|
+
it "should set the parent as the parenting resource" do
|
258
|
+
@file.parent.to_s.should == @dir.to_s
|
278
259
|
end
|
279
260
|
end
|
280
|
-
describe "
|
261
|
+
describe "fetching" do
|
281
262
|
before(:each) do
|
282
|
-
@
|
263
|
+
@file = file(:name => "pancakes")
|
283
264
|
end
|
284
|
-
it "should
|
285
|
-
|
265
|
+
it "should not create a new resource if the same resource exists" do
|
266
|
+
PoolParty::Resources::File.should_not_receive(:new)
|
267
|
+
file(:name => "pancakes")
|
268
|
+
end
|
269
|
+
it "should return the file preiously created" do
|
270
|
+
get_resource(:file, "pancakes").should == @file
|
271
|
+
end
|
272
|
+
it "should be able to use the helper to grab the file" do
|
273
|
+
PoolParty::Resources::File.should_not_receive(:new)
|
274
|
+
file(:name => "pancakes").should == @file
|
275
|
+
end
|
276
|
+
it "should turn the resource into a string" do
|
277
|
+
@file.to_s.should == "File['pancakes']"
|
278
|
+
end
|
279
|
+
describe "cancelled" do
|
280
|
+
it "should make a resource not cancelled by default" do
|
281
|
+
@file.cancelled?.should == false
|
282
|
+
end
|
283
|
+
it "should say cancelled? is true if it has been cancelled" do
|
284
|
+
@file.cancel
|
285
|
+
@file.cancelled?.should == true
|
286
|
+
end
|
287
|
+
it "should be able to get the file from the helper" do
|
288
|
+
get_file("pancakes").should == @file
|
289
|
+
end
|
290
|
+
end
|
291
|
+
describe "virtual_resources" do
|
292
|
+
before(:each) do
|
293
|
+
@virtual_resource = git(:name => "tank", :source => "git://github.com/auser/testgit.git")
|
294
|
+
end
|
295
|
+
it "should fetch a virtual resource the same" do
|
296
|
+
git(:name => "tank", :source => "git://github.com/auser/testgit.git").to_s.should == @virtual_resource.to_s
|
297
|
+
end
|
286
298
|
end
|
287
299
|
end
|
288
|
-
|
300
|
+
describe "global resources" do
|
301
|
+
describe "setting" do
|
302
|
+
before(:each) do
|
303
|
+
@cloud2 = cloud :applepie do
|
304
|
+
directory(:name => "/var/www") do
|
305
|
+
file(:name => "/var/www/file.html")
|
306
|
+
end
|
307
|
+
end
|
308
|
+
@cloud2 = cloud(:applepie)
|
309
|
+
end
|
310
|
+
it "should have a global_resources_store available as an Array" do
|
311
|
+
@cloud2.global_resources_store.class.should == Array
|
312
|
+
end
|
313
|
+
it "should have stored the two resources from the cloud into the global_resources_store" do
|
314
|
+
@cloud2.global_resources_store.size.should >= 2
|
315
|
+
end
|
316
|
+
it "should be an array of resources" do
|
317
|
+
@cloud2.global_resources_store.first.is_a?(PoolParty::Resources::Resource).should == true
|
318
|
+
end
|
319
|
+
it "should say that the type directory of name /var/www is in the global_resources_store" do
|
320
|
+
@cloud2.in_global_resource_store?(:directory, "/var/www").should == true
|
321
|
+
end
|
322
|
+
it "should say that the type file of the name /var/www/file.html is in the global_resources_store" do
|
323
|
+
@cloud2.in_global_resource_store?(:file, "/var/www/file.html").should == true
|
324
|
+
end
|
325
|
+
it "should say tht the type exec of the name echo 'hello' is not in the global_resources_store" do
|
326
|
+
@cloud2.in_global_resource_store?(:exec, "echo 'hello'").should == false
|
327
|
+
end
|
328
|
+
it "should say that the resource is in the global_resources_store when put in the global_resources_store" do
|
329
|
+
@file1 = PoolParty::Resources::File.new(:name => "/var/tmp.txt")
|
330
|
+
@cloud2.store_into_global_resource_store(@file1)
|
331
|
+
@cloud2.in_global_resource_store?(:file, "/var/tmp.txt")
|
332
|
+
end
|
333
|
+
it "should put the resource into the global_resources_store when calling store_into_global_resource_store" do
|
334
|
+
@file2 = PoolParty::Resources::File.new({:name => "/var/bunk.txt"})
|
335
|
+
@cloud2.global_resources_store.should_receive(:<<).with(@file2)
|
336
|
+
@cloud2.store_into_global_resource_store(@file2)
|
337
|
+
end
|
338
|
+
it "should not put a resource into the global_resources_store if it's already there" do
|
339
|
+
@file3 = PoolParty::Resources::File.new({:name => "/var/www/file.html"})
|
340
|
+
@cloud2.global_resources_store.should_not_receive(:<<).with(@file3)
|
341
|
+
@cloud2.store_into_global_resource_store(@file3)
|
342
|
+
end
|
343
|
+
it "should be able to get the resource from the global_resources_store by the name and type" do
|
344
|
+
@cloud2.get_from_global_resource_store(:directory, "/var/www").key.should == "/var/www"
|
345
|
+
end
|
346
|
+
describe "grabbing after already instantiated" do
|
347
|
+
before(:each) do
|
348
|
+
@cloud2.instance_eval do
|
349
|
+
has_package(:name => "apache2") do
|
350
|
+
has_exec(:name => "Add apache2 module") do
|
351
|
+
command "a2enmod mpm_worker"
|
352
|
+
end
|
353
|
+
end
|
354
|
+
has_package(:name => "boxers") do
|
355
|
+
has_file(:name => "/var/list_of_boxers.txt", :requires => (get_package("apache2")) )
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
it "should grab the resource when called in in a block" do
|
360
|
+
@cloud2.resources_string_from_resources(@cloud2.resources).should =~ /\[ Package\['boxers'\], Package\['apache2'\] \]/
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
289
366
|
end
|
290
367
|
end
|