auser-poolparty 0.2.16 → 0.2.20

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.
Files changed (139) hide show
  1. data/Manifest.txt +72 -7
  2. data/PostInstall.txt +1 -1
  3. data/Rakefile +11 -0
  4. data/bin/cloud-provision +6 -10
  5. data/bin/server-build-messenger +20 -0
  6. data/bin/server-fire-cmd +0 -2
  7. data/bin/server-list-responding +24 -0
  8. data/bin/server-start-master +4 -9
  9. data/bin/server-start-node +7 -6
  10. data/lib/erlang/messenger/Emakefile +1 -0
  11. data/lib/erlang/messenger/Rakefile +29 -20
  12. data/lib/erlang/messenger/ebin/master_app.beam +0 -0
  13. data/lib/erlang/messenger/ebin/node_app.beam +0 -0
  14. data/lib/erlang/messenger/ebin/packager.app +19 -0
  15. data/lib/erlang/messenger/ebin/pm_client.beam +0 -0
  16. data/lib/erlang/messenger/ebin/pm_cluster.beam +0 -0
  17. data/lib/erlang/messenger/ebin/pm_event_handler.beam +0 -0
  18. data/lib/erlang/messenger/ebin/pm_master.beam +0 -0
  19. data/lib/erlang/messenger/ebin/pm_master_rel-0.1.rel +1 -7
  20. data/lib/erlang/messenger/ebin/pm_master_supervisor.beam +0 -0
  21. data/lib/erlang/messenger/ebin/pm_node.beam +0 -0
  22. data/lib/erlang/messenger/ebin/pm_node_rel-0.1.rel +1 -7
  23. data/lib/erlang/messenger/ebin/pm_node_supervisor.beam +0 -0
  24. data/lib/erlang/messenger/ebin/pm_packager.beam +0 -0
  25. data/lib/erlang/messenger/ebin/utils.beam +0 -0
  26. data/lib/erlang/messenger/lib/eunit/AUTHORS +2 -0
  27. data/lib/erlang/messenger/lib/eunit/CHANGELOG +14 -0
  28. data/lib/erlang/messenger/lib/eunit/COPYING +504 -0
  29. data/lib/erlang/messenger/lib/eunit/Makefile +28 -0
  30. data/lib/erlang/messenger/lib/eunit/NOTES +276 -0
  31. data/lib/erlang/messenger/lib/eunit/README +3 -0
  32. data/lib/erlang/messenger/lib/eunit/doc/edoc-info +3 -0
  33. data/lib/erlang/messenger/lib/eunit/doc/erlang.png +0 -0
  34. data/lib/erlang/messenger/lib/eunit/doc/eunit.html +172 -0
  35. data/lib/erlang/messenger/lib/eunit/doc/index.html +17 -0
  36. data/lib/erlang/messenger/lib/eunit/doc/modules-frame.html +12 -0
  37. data/lib/erlang/messenger/lib/eunit/doc/overview-summary.html +984 -0
  38. data/lib/erlang/messenger/lib/eunit/doc/overview.edoc +980 -0
  39. data/lib/erlang/messenger/lib/eunit/doc/packages-frame.html +11 -0
  40. data/lib/erlang/messenger/lib/eunit/doc/stylesheet.css +55 -0
  41. data/lib/erlang/messenger/lib/eunit/ebin/autoload.beam +0 -0
  42. data/lib/erlang/messenger/lib/eunit/ebin/code_monitor.beam +0 -0
  43. data/lib/erlang/messenger/lib/eunit/ebin/eunit.app +21 -0
  44. data/lib/erlang/messenger/lib/eunit/ebin/eunit.appup +1 -0
  45. data/lib/erlang/messenger/lib/eunit/ebin/eunit.beam +0 -0
  46. data/lib/erlang/messenger/lib/eunit/ebin/eunit_autoexport.beam +0 -0
  47. data/lib/erlang/messenger/lib/eunit/ebin/eunit_data.beam +0 -0
  48. data/lib/erlang/messenger/lib/eunit/ebin/eunit_lib.beam +0 -0
  49. data/lib/erlang/messenger/lib/eunit/ebin/eunit_proc.beam +0 -0
  50. data/lib/erlang/messenger/lib/eunit/ebin/eunit_serial.beam +0 -0
  51. data/lib/erlang/messenger/lib/eunit/ebin/eunit_server.beam +0 -0
  52. data/lib/erlang/messenger/lib/eunit/ebin/eunit_striptests.beam +0 -0
  53. data/lib/erlang/messenger/lib/eunit/ebin/eunit_test.beam +0 -0
  54. data/lib/erlang/messenger/lib/eunit/ebin/eunit_tests.beam +0 -0
  55. data/lib/erlang/messenger/lib/eunit/ebin/eunit_tty.beam +0 -0
  56. data/lib/erlang/messenger/lib/eunit/ebin/file_monitor.beam +0 -0
  57. data/lib/erlang/messenger/lib/eunit/examples/eunit_examples.erl +339 -0
  58. data/lib/erlang/messenger/lib/eunit/examples/fib.erl +19 -0
  59. data/lib/erlang/messenger/lib/eunit/examples/tests.txt +1 -0
  60. data/lib/erlang/messenger/lib/eunit/include/eunit.hrl +313 -0
  61. data/lib/erlang/messenger/lib/eunit/src/Makefile +46 -0
  62. data/lib/erlang/messenger/lib/eunit/src/autoload.erl +388 -0
  63. data/lib/erlang/messenger/lib/eunit/src/code_monitor.erl +243 -0
  64. data/lib/erlang/messenger/lib/eunit/src/eunit.app.src +21 -0
  65. data/lib/erlang/messenger/lib/eunit/src/eunit.appup.src +1 -0
  66. data/lib/erlang/messenger/lib/eunit/src/eunit.erl +196 -0
  67. data/lib/erlang/messenger/lib/eunit/src/eunit_autoexport.erl +102 -0
  68. data/lib/erlang/messenger/lib/eunit/src/eunit_data.erl +798 -0
  69. data/lib/erlang/messenger/lib/eunit/src/eunit_internal.hrl +48 -0
  70. data/lib/erlang/messenger/lib/eunit/src/eunit_lib.erl +682 -0
  71. data/lib/erlang/messenger/lib/eunit/src/eunit_proc.erl +552 -0
  72. data/lib/erlang/messenger/lib/eunit/src/eunit_serial.erl +157 -0
  73. data/lib/erlang/messenger/lib/eunit/src/eunit_server.erl +340 -0
  74. data/lib/erlang/messenger/lib/eunit/src/eunit_striptests.erl +64 -0
  75. data/lib/erlang/messenger/lib/eunit/src/eunit_test.erl +334 -0
  76. data/lib/erlang/messenger/lib/eunit/src/eunit_tests.erl +45 -0
  77. data/lib/erlang/messenger/lib/eunit/src/eunit_tty.erl +272 -0
  78. data/lib/erlang/messenger/lib/eunit/src/file_monitor.erl +409 -0
  79. data/lib/erlang/messenger/lib/eunit/sys.config +9 -0
  80. data/lib/erlang/messenger/lib/eunit/vsn.mk +1 -0
  81. data/lib/erlang/messenger/pm_master_rel-0.1.boot +0 -0
  82. data/lib/erlang/messenger/pm_master_rel-0.1.script +75 -2
  83. data/lib/erlang/messenger/pm_node_rel-0.1.boot +0 -0
  84. data/lib/erlang/messenger/pm_node_rel-0.1.script +75 -2
  85. data/lib/erlang/messenger/src/pm_client.erl +8 -3
  86. data/lib/erlang/messenger/src/pm_cluster.erl +32 -9
  87. data/lib/erlang/messenger/src/pm_master.erl +10 -11
  88. data/lib/erlang/messenger/src/pm_node.erl +2 -3
  89. data/lib/erlang/messenger/src/pm_packager.erl +73 -0
  90. data/lib/erlang/messenger/src/utils.erl +3 -10
  91. data/lib/poolparty/base_packages/heartbeat.rb +9 -9
  92. data/lib/poolparty/base_packages/poolparty.rb +16 -10
  93. data/lib/poolparty/config/allowed_commands.yml +1 -0
  94. data/lib/poolparty/core/object.rb +8 -0
  95. data/lib/poolparty/exceptions/UnacceptableCommand.rb +5 -0
  96. data/lib/poolparty/helpers/messenger.rb +29 -0
  97. data/lib/poolparty/helpers/provisioner_base.rb +7 -7
  98. data/lib/poolparty/helpers/provisioners/master.rb +3 -7
  99. data/lib/poolparty/helpers/provisioners/slave.rb +1 -0
  100. data/lib/poolparty/modules/cloud_resourcer.rb +7 -5
  101. data/lib/poolparty/modules/configurable.rb +1 -1
  102. data/lib/poolparty/modules/method_missing_sugar.rb +6 -1
  103. data/lib/poolparty/modules/pretty_printer.rb +1 -0
  104. data/lib/poolparty/modules/resourcing_dsl.rb +2 -1
  105. data/lib/poolparty/monitors/monitors/cpu_monitor.rb +1 -1
  106. data/lib/poolparty/net/remoter.rb +3 -1
  107. data/lib/poolparty/plugins/git.rb +3 -3
  108. data/lib/poolparty/pool/base.rb +7 -2
  109. data/lib/poolparty/pool/cloud.rb +3 -3
  110. data/lib/poolparty/pool/resource.rb +38 -24
  111. data/lib/poolparty/pool/resources/class_package.rb +2 -2
  112. data/lib/poolparty/pool/resources/conditional.rb +8 -4
  113. data/lib/poolparty/pool/resources/{gem.rb → gem_package.rb} +0 -0
  114. data/lib/poolparty/pool/resources/package.rb +8 -1
  115. data/lib/poolparty/version.rb +1 -1
  116. data/lib/poolparty.rb +1 -1
  117. data/poolparty.gemspec +476 -61
  118. data/spec/poolparty/core/object_spec.rb +20 -0
  119. data/spec/poolparty/helpers/messenger_spec.rb +14 -0
  120. data/spec/poolparty/helpers/provisioners/master_spec.rb +2 -2
  121. data/spec/poolparty/net/remoter_spec.rb +1 -1
  122. data/spec/poolparty/plugins/git_spec.rb +26 -19
  123. data/spec/poolparty/pool/base_spec.rb +20 -2
  124. data/spec/poolparty/pool/cloud_spec.rb +256 -249
  125. data/spec/poolparty/pool/custom_resource_spec.rb +6 -1
  126. data/spec/poolparty/pool/plugin_spec.rb +71 -65
  127. data/spec/poolparty/pool/resource_spec.rb +314 -237
  128. data/spec/poolparty/pool/resources/class_package_spec.rb +71 -66
  129. data/spec/poolparty/pool/resources/conditional_spec.rb +30 -26
  130. data/spec/poolparty/pool/resources/gem_spec.rb +18 -14
  131. data/spec/poolparty/pool/resources/variable_spec.rb +1 -1
  132. data/spec/poolparty/pool/script_spec.rb +46 -37
  133. data/spec/poolparty/spec_helper.rb +4 -0
  134. data/tasks/cloud.rake +0 -54
  135. data/tasks/development.rake +11 -14
  136. data/tasks/ec2.rake +10 -17
  137. data/tasks/instance.rake +0 -61
  138. data/website/index.html +1 -1
  139. 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
- 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
13
+ describe "wrapped" do
60
14
  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
15
+ @resource = MyResource.new({:a => 10}) do
16
+ b "90"
17
+ end
83
18
  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"
19
+ it "should set a from the hash" do
20
+ @resource.a.should == 10
88
21
  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"
22
+ it "should set b from within the block" do
23
+ @resource.b.should == "90"
93
24
  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"
25
+ it "should not wipe out the rest of the default options" do
26
+ @resource.c.should == 3
98
27
  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
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
- 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
- @cloud = cloud :command_cloud do; end
135
- end
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
- it "should create the new 'resource' as a resource" do
143
- resource(:file).class.should == Array
144
- end
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 contain file named with 'red'" do
162
- resource(:file).include?(@a).should == true
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 "method_missing" do
62
+ describe "instance methods" do
166
63
  before(:each) do
167
- file({:name => "red"})
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
- it "should not have a method prepended with crabs_" do
177
- lambda {
178
- crabs_file
179
- }.should raise_error
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 pick out methods with the phrase does_not_" do
182
- lambda {
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 set the has_file to present ensure" do
187
- has_file({:name => "redface"})
188
- resource(:file).get_named("redface").first.options[:ensure].should == "present"
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 set the does_not_have_file to absent ensure" do
191
- does_not_have_file({:name => "net"})
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 be able to have_service as well" do
195
- has_service({:name => "apache"})
196
- resource(:service).get_named("apache").first.options[:ensure].should == "running"
197
- end
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 return a type of resource when looking for a resource that exists" do
206
- get_resource(:file, "hot").class.should == PoolParty::Resources::File
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 return the resource of the name requested" do
209
- get_resource(:file, "hot").should == @hot
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 return nil if the resource requested is not there" do
212
- get_resource(:file, "smarties").should be_nil
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
- end
215
- describe "parent" do
216
- before(:each) do
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
- @file = @cloud.resources[:file].first
222
- end
223
- it "should take the options of the parent" do
224
- @file.parent.tangerine.should_not == nil
225
- end
226
- it "should set the option as the same from the parent" do
227
- @file.parent.tangerine.should == "orange"
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 "appending to resource" do
133
+ describe "command" do
134
+ include PoolParty::Resources
231
135
  before(:each) do
232
- @cloud1 = cloud :apples do
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 say there is 1 resource because the lower-level resources should be contained on the parenting resource" do
241
- @cloud1.resources.size.should == 1
242
- end
243
- it "should say there is one resource on the outer resource" do
244
- @dir.resources.size.should == 1
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 contain the file as a resource" do
247
- @dir.resource(:file)[0].to_s.should == @file.to_s
144
+ it "should create the new 'resource' as a resource" do
145
+ resource(:file).class.should == Array
248
146
  end
249
- it "should set the parent as the parenting resource" do
250
- @file.parent.to_s.should == @dir.to_s
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
- end
253
- describe "fetching" do
254
- before(:each) do
255
- @file = file(:name => "pancakes")
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
- it "should not create a new resource if the same resource exists" do
258
- PoolParty::Resources::File.should_not_receive(:new)
259
- file(:name => "pancakes")
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
- it "should return the file preiously created" do
262
- get_resource(:file, "pancakes").should == @file
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
- it "should be able to use the helper to grab the file" do
265
- PoolParty::Resources::File.should_not_receive(:new)
266
- file(:name => "pancakes").should == @file
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
- it "should turn the resource into a string" do
269
- @file.to_s.should == "File['pancakes']"
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 "cancelled" do
272
- it "should make a resource not cancelled by default" do
273
- @file.cancelled?.should == false
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 say cancelled? is true if it has been cancelled" do
276
- @file.cancel
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 "virtual_resources" do
261
+ describe "fetching" do
281
262
  before(:each) do
282
- @virtual_resource = git(:name => "tank", :source => "git://github.com/auser/testgit.git")
263
+ @file = file(:name => "pancakes")
283
264
  end
284
- it "should fetch a virtual resource the same" do
285
- git(:name => "tank", :source => "git://github.com/auser/testgit.git").to_s.should == @virtual_resource.to_s
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
- end
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