puppet 2.6.4 → 2.6.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (221) hide show
  1. data/CHANGELOG +147 -0
  2. data/LICENSE +2 -2
  3. data/Rakefile +3 -4
  4. data/lib/puppet.rb +1 -1
  5. data/lib/puppet/application.rb +22 -5
  6. data/lib/puppet/application/apply.rb +2 -18
  7. data/lib/puppet/application/doc.rb +1 -4
  8. data/lib/puppet/application/inspect.rb +178 -0
  9. data/lib/puppet/configurer.rb +9 -11
  10. data/lib/puppet/configurer/plugin_handler.rb +0 -2
  11. data/lib/puppet/defaults.rb +12 -3
  12. data/lib/puppet/external/pson/pure/generator.rb +1 -22
  13. data/lib/puppet/file_bucket/dipper.rb +9 -3
  14. data/lib/puppet/file_bucket/file.rb +14 -94
  15. data/lib/puppet/indirector.rb +4 -0
  16. data/lib/puppet/indirector/catalog/active_record.rb +1 -1
  17. data/lib/puppet/indirector/file_bucket_file/file.rb +64 -75
  18. data/lib/puppet/indirector/indirection.rb +18 -8
  19. data/lib/puppet/indirector/resource/ral.rb +7 -2
  20. data/lib/puppet/indirector/rest.rb +19 -2
  21. data/lib/puppet/network/http/api/v1.rb +3 -0
  22. data/lib/puppet/network/http/handler.rb +16 -1
  23. data/lib/puppet/network/http/rack/rest.rb +1 -3
  24. data/lib/puppet/network/rest_authconfig.rb +4 -12
  25. data/lib/puppet/network/rights.rb +28 -14
  26. data/lib/puppet/parser/ast.rb +4 -0
  27. data/lib/puppet/parser/compiler.rb +18 -3
  28. data/lib/puppet/parser/functions/defined.rb +28 -6
  29. data/lib/puppet/parser/functions/fqdn_rand.rb +6 -3
  30. data/lib/puppet/parser/templatewrapper.rb +1 -0
  31. data/lib/puppet/property.rb +16 -1
  32. data/lib/puppet/property/keyvalue.rb +0 -2
  33. data/lib/puppet/property/list.rb +0 -2
  34. data/lib/puppet/provider/file/posix.rb +1 -3
  35. data/lib/puppet/provider/file/win32.rb +1 -3
  36. data/lib/puppet/provider/maillist/mailman.rb +3 -5
  37. data/lib/puppet/provider/mount.rb +2 -0
  38. data/lib/puppet/provider/nameservice/directoryservice.rb +2 -2
  39. data/lib/puppet/provider/package/freebsd.rb +2 -2
  40. data/lib/puppet/provider/zone/solaris.rb +1 -1
  41. data/lib/puppet/reference/configuration.rb +2 -2
  42. data/lib/puppet/reference/function.rb +4 -0
  43. data/lib/puppet/relationship.rb +4 -0
  44. data/lib/puppet/reports/store.rb +1 -19
  45. data/lib/puppet/resource.rb +11 -2
  46. data/lib/puppet/resource/status.rb +24 -3
  47. data/lib/puppet/resource/type.rb +24 -16
  48. data/lib/puppet/resource/type_collection.rb +4 -1
  49. data/lib/puppet/simple_graph.rb +4 -0
  50. data/lib/puppet/transaction.rb +1 -28
  51. data/lib/puppet/transaction/event.rb +9 -4
  52. data/lib/puppet/transaction/report.rb +42 -22
  53. data/lib/puppet/transaction/resource_harness.rb +99 -71
  54. data/lib/puppet/type.rb +22 -9
  55. data/lib/puppet/type/cron.rb +1 -5
  56. data/lib/puppet/type/exec.rb +4 -34
  57. data/lib/puppet/type/file.rb +19 -26
  58. data/lib/puppet/type/file/checksum.rb +1 -1
  59. data/lib/puppet/type/file/content.rb +2 -1
  60. data/lib/puppet/type/file/ctime.rb +18 -0
  61. data/lib/puppet/type/file/ensure.rb +1 -1
  62. data/lib/puppet/type/file/mode.rb +10 -44
  63. data/lib/puppet/type/file/mtime.rb +17 -0
  64. data/lib/puppet/type/file/owner.rb +1 -1
  65. data/lib/puppet/type/file/source.rb +0 -1
  66. data/lib/puppet/type/file/target.rb +1 -1
  67. data/lib/puppet/type/file/type.rb +5 -12
  68. data/lib/puppet/type/host.rb +1 -1
  69. data/lib/puppet/type/mount.rb +2 -2
  70. data/lib/puppet/type/package.rb +0 -2
  71. data/lib/puppet/type/service.rb +11 -5
  72. data/lib/puppet/type/user.rb +7 -9
  73. data/lib/puppet/type/yumrepo.rb +2 -2
  74. data/lib/puppet/type/zpool.rb +0 -4
  75. data/lib/puppet/util/checksums.rb +24 -1
  76. data/lib/puppet/util/command_line.rb +6 -2
  77. data/lib/puppet/util/command_line/puppet +5 -1
  78. data/lib/puppet/util/command_line/puppetca +2 -2
  79. data/lib/puppet/util/command_line/puppetd +11 -9
  80. data/lib/puppet/util/command_line/puppetdoc +2 -2
  81. data/lib/puppet/util/command_line/puppetmasterd +5 -0
  82. data/lib/puppet/util/log.rb +15 -8
  83. data/lib/puppet/util/log/destinations.rb +2 -0
  84. data/lib/puppet/util/log_paths.rb +1 -1
  85. data/lib/puppet/util/logging.rb +1 -1
  86. data/lib/puppet/util/metric.rb +1 -0
  87. data/lib/puppet/util/reference.rb +1 -10
  88. data/lib/puppet/util/settings.rb +1 -1
  89. data/lib/puppet/util/zaml.rb +30 -31
  90. data/spec/fixtures/unit/provider/mount/mount-output.aix.txt +7 -0
  91. data/spec/integration/application/apply_spec.rb +1 -2
  92. data/spec/integration/defaults_spec.rb +1 -0
  93. data/spec/integration/indirector/catalog/queue_spec.rb +1 -4
  94. data/spec/integration/indirector/report/rest_spec.rb +13 -17
  95. data/spec/integration/network/formats_spec.rb +2 -5
  96. data/spec/integration/network/server/mongrel_spec.rb +1 -2
  97. data/spec/integration/provider/mailalias/aliases_spec.rb +0 -1
  98. data/spec/integration/provider/package_spec.rb +1 -3
  99. data/spec/integration/provider/service/init_spec.rb +3 -9
  100. data/spec/integration/reference/providers_spec.rb +2 -2
  101. data/spec/integration/resource/catalog_spec.rb +1 -2
  102. data/spec/integration/transaction/report_spec.rb +1 -1
  103. data/spec/monkey_patches/alias_should_to_must.rb +2 -0
  104. data/spec/shared_behaviours/file_server_terminus.rb +1 -1
  105. data/spec/shared_behaviours/file_serving.rb +1 -1
  106. data/spec/shared_behaviours/memory_terminus.rb +1 -1
  107. data/spec/spec_helper.rb +8 -6
  108. data/spec/unit/application/agent_spec.rb +1 -0
  109. data/spec/unit/application/apply_spec.rb +7 -7
  110. data/spec/unit/application/doc_spec.rb +2 -2
  111. data/spec/unit/application/filebucket_spec.rb +1 -0
  112. data/spec/unit/application/inspect_spec.rb +278 -0
  113. data/spec/unit/application/kick_spec.rb +1 -3
  114. data/spec/unit/application/master_spec.rb +1 -3
  115. data/spec/unit/application/queue_spec.rb +1 -0
  116. data/spec/unit/application_spec.rb +63 -5
  117. data/spec/unit/configurer/plugin_handler_spec.rb +5 -1
  118. data/spec/unit/configurer_spec.rb +33 -49
  119. data/spec/unit/file_bucket/dipper_spec.rb +69 -77
  120. data/spec/unit/file_bucket/file_spec.rb +12 -127
  121. data/spec/unit/file_serving/fileset_spec.rb +1 -0
  122. data/spec/unit/file_serving/metadata_spec.rb +4 -4
  123. data/spec/unit/indirector/active_record_spec.rb +1 -0
  124. data/spec/unit/indirector/catalog/active_record_spec.rb +29 -13
  125. data/spec/unit/indirector/facts/active_record_spec.rb +2 -3
  126. data/spec/unit/indirector/facts/couch_spec.rb +1 -2
  127. data/spec/unit/indirector/file_bucket_file/file_spec.rb +202 -218
  128. data/spec/unit/indirector/file_server_spec.rb +6 -7
  129. data/spec/unit/indirector/indirection_spec.rb +71 -2
  130. data/spec/unit/indirector/ldap_spec.rb +2 -6
  131. data/spec/unit/indirector/node/active_record_spec.rb +1 -3
  132. data/spec/unit/indirector/queue_spec.rb +1 -3
  133. data/spec/unit/indirector/rest_spec.rb +37 -1
  134. data/spec/unit/indirector/ssl_file_spec.rb +5 -5
  135. data/spec/unit/indirector_spec.rb +6 -1
  136. data/spec/unit/module_spec.rb +1 -3
  137. data/spec/unit/network/formats_spec.rb +2 -5
  138. data/spec/unit/network/http/api/v1_spec.rb +4 -0
  139. data/spec/unit/network/http/compression_spec.rb +1 -3
  140. data/spec/unit/network/http/handler_spec.rb +39 -0
  141. data/spec/unit/network/http/mongrel/rest_spec.rb +1 -2
  142. data/spec/unit/network/http/mongrel_spec.rb +3 -9
  143. data/spec/unit/network/http/rack/rest_spec.rb +1 -3
  144. data/spec/unit/network/http/rack/xmlrpc_spec.rb +2 -3
  145. data/spec/unit/network/http/rack_spec.rb +2 -3
  146. data/spec/unit/network/http/webrick_spec.rb +1 -0
  147. data/spec/unit/network/rest_authconfig_spec.rb +1 -1
  148. data/spec/unit/network/rights_spec.rb +43 -23
  149. data/spec/unit/network/xmlrpc/client_spec.rb +1 -0
  150. data/spec/unit/parameter_spec.rb +1 -2
  151. data/spec/unit/parser/collector_spec.rb +3 -6
  152. data/spec/unit/parser/compiler_spec.rb +90 -5
  153. data/spec/unit/parser/lexer_spec.rb +3 -2
  154. data/spec/unit/parser/templatewrapper_spec.rb +1 -0
  155. data/spec/unit/property/keyvalue_spec.rb +5 -5
  156. data/spec/unit/property/list_spec.rb +7 -7
  157. data/spec/unit/provider/mount/parsed_spec.rb +1 -2
  158. data/spec/unit/provider/mount_spec.rb +8 -0
  159. data/spec/unit/provider/nameservice/directoryservice_spec.rb +38 -0
  160. data/spec/unit/provider/package/freebsd_spec.rb +55 -0
  161. data/spec/unit/provider/service/init_spec.rb +2 -0
  162. data/spec/unit/rails/host_spec.rb +1 -3
  163. data/spec/unit/rails/param_value_spec.rb +2 -3
  164. data/spec/unit/rails/resource_spec.rb +2 -3
  165. data/spec/unit/rails_spec.rb +5 -15
  166. data/spec/unit/relationship_spec.rb +2 -6
  167. data/spec/unit/reports/http_spec.rb +1 -1
  168. data/spec/unit/reports/store_spec.rb +31 -0
  169. data/spec/unit/reports/tagmail_spec.rb +1 -1
  170. data/spec/unit/resource/catalog_spec.rb +2 -6
  171. data/spec/unit/resource/status_spec.rb +53 -3
  172. data/spec/unit/resource/type_collection_spec.rb +0 -8
  173. data/spec/unit/resource/type_spec.rb +50 -4
  174. data/spec/unit/resource_spec.rb +10 -6
  175. data/spec/unit/ssl/certificate_authority/interface_spec.rb +1 -1
  176. data/spec/unit/transaction/event_spec.rb +21 -2
  177. data/spec/unit/transaction/report_spec.rb +91 -35
  178. data/spec/unit/transaction/resource_harness_spec.rb +289 -208
  179. data/spec/unit/transaction_spec.rb +1 -6
  180. data/spec/unit/type/augeas_spec.rb +1 -3
  181. data/spec/unit/type/file/content_spec.rb +63 -10
  182. data/spec/unit/type/file/ctime.rb +35 -0
  183. data/spec/unit/type/file/ensure_spec.rb +8 -7
  184. data/spec/unit/type/file/group_spec.rb +5 -5
  185. data/spec/unit/type/file/mtime.rb +35 -0
  186. data/spec/unit/type/file/owner_spec.rb +7 -7
  187. data/spec/unit/type/file/selinux_spec.rb +2 -2
  188. data/spec/unit/type/file/source_spec.rb +3 -3
  189. data/spec/unit/type/file/type.rb +20 -0
  190. data/spec/unit/type/file_spec.rb +131 -8
  191. data/spec/unit/type/mount_spec.rb +4 -4
  192. data/spec/unit/type/package_spec.rb +3 -3
  193. data/spec/unit/type/ssh_authorized_key_spec.rb +1 -1
  194. data/spec/unit/type/user_spec.rb +31 -3
  195. data/spec/unit/type/zpool_spec.rb +12 -12
  196. data/spec/unit/type_spec.rb +2 -2
  197. data/spec/unit/util/checksums_spec.rb +9 -1
  198. data/spec/unit/util/command_line_spec.rb +29 -0
  199. data/spec/unit/util/log/destinations_spec.rb +13 -0
  200. data/spec/unit/util/log_spec.rb +24 -12
  201. data/spec/unit/util/logging_spec.rb +1 -1
  202. data/spec/unit/util/metric_spec.rb +7 -7
  203. data/spec/unit/util/pson_spec.rb +15 -0
  204. data/spec/unit/util/queue/stomp_spec.rb +2 -6
  205. data/spec/unit/util/settings/file_setting_spec.rb +1 -3
  206. data/spec/unit/util/zaml_spec.rb +51 -0
  207. data/test/language/snippets.rb +3 -0
  208. data/test/lib/puppettest/fileparsing.rb +2 -0
  209. data/test/lib/puppettest/reporttesting.rb +1 -1
  210. data/test/lib/puppettest/support/utils.rb +1 -1
  211. data/test/network/server/mongrel_test.rb +0 -6
  212. data/test/other/report.rb +1 -1
  213. data/test/ral/providers/cron/crontab.rb +4 -1
  214. data/test/ral/type/file.rb +1 -1
  215. data/test/ral/type/filesources.rb +1 -4
  216. metadata +1119 -1113
  217. data/lib/puppet/transaction/change.rb +0 -87
  218. data/spec/Rakefile +0 -91
  219. data/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +0 -46
  220. data/spec/spec_specs/runnable_spec.rb +0 -95
  221. data/spec/unit/transaction/change_spec.rb +0 -193
@@ -118,39 +118,39 @@ describe list_class do
118
118
  end
119
119
  end
120
120
 
121
- describe "when calling insync?" do
121
+ describe "when calling safe_insync?" do
122
122
  it "should return true unless @should is defined and not nil" do
123
- @property.must be_insync("foo")
123
+ @property.must be_safe_insync("foo")
124
124
  end
125
125
 
126
126
  it "should return true unless the passed in values is not nil" do
127
127
  @property.should = "foo"
128
- @property.must be_insync(nil)
128
+ @property.must be_safe_insync(nil)
129
129
  end
130
130
 
131
131
  it "should call prepare_is_for_comparison with value passed in and should" do
132
132
  @property.should = "foo"
133
133
  @property.expects(:prepare_is_for_comparison).with("bar")
134
134
  @property.expects(:should)
135
- @property.insync?("bar")
135
+ @property.safe_insync?("bar")
136
136
  end
137
137
 
138
138
  it "should return true if 'is' value is array of comma delimited should values" do
139
139
  @property.should = "bar,foo"
140
140
  @property.expects(:inclusive?).returns(true)
141
- @property.must be_insync(["bar","foo"])
141
+ @property.must be_safe_insync(["bar","foo"])
142
142
  end
143
143
 
144
144
  it "should return true if 'is' value is :absent and should value is empty string" do
145
145
  @property.should = ""
146
146
  @property.expects(:inclusive?).returns(true)
147
- @property.must be_insync([])
147
+ @property.must be_safe_insync([])
148
148
  end
149
149
 
150
150
  it "should return false if prepared value != should value" do
151
151
  @property.should = "bar,baz,foo"
152
152
  @property.expects(:inclusive?).returns(true)
153
- @property.must_not be_insync(["bar","foo"])
153
+ @property.must_not be_safe_insync(["bar","foo"])
154
154
  end
155
155
  end
156
156
 
@@ -157,8 +157,7 @@ describe provider_class do
157
157
  end
158
158
  end
159
159
 
160
- describe provider_class, " when parsing information about the root filesystem" do
161
- confine "Mount type not tested on Darwin" => Facter["operatingsystem"].value != "Darwin"
160
+ describe provider_class, " when parsing information about the root filesystem", :if => Facter["operatingsystem"].value != "Darwin" do
162
161
  include ParsedMountTesting
163
162
 
164
163
  before do
@@ -120,6 +120,14 @@ describe Puppet::Provider::Mount do
120
120
  @mounter.should be_mounted
121
121
  end
122
122
 
123
+ it "should match mounted devices if the operating system is AIX" do
124
+ Facter.stubs(:value).with("operatingsystem").returns("AIX")
125
+ mount_data = File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'unit', 'provider', 'mount', 'mount-output.aix.txt'))
126
+ @mounter.expects(:mountcmd).returns(mount_data)
127
+
128
+ @mounter.should be_mounted
129
+ end
130
+
123
131
  it "should match ' on <name>' if the operating system is not Darwin, Solaris, or HP-UX" do
124
132
  Facter.stubs(:value).with("operatingsystem").returns("Debian")
125
133
  @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on / and stuff\n/dev/other/disk on /var and stuff")
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/../../../spec_helper'
4
+
5
+ # We use this as a reasonable way to obtain all the support infrastructure.
6
+ [:user, :group].each do |type_for_this_round|
7
+ provider_class = Puppet::Type.type(type_for_this_round).provider(:directoryservice)
8
+
9
+ describe provider_class do
10
+ before do
11
+ @resource = stub("resource")
12
+ @provider = provider_class.new(@resource)
13
+ end
14
+
15
+ it "[#6009] should handle nested arrays of members" do
16
+ current = ["foo", "bar", "baz"]
17
+ desired = ["foo", ["quux"], "qorp"]
18
+ group = 'example'
19
+
20
+ @resource.stubs(:[]).with(:name).returns(group)
21
+ @resource.stubs(:[]).with(:auth_membership).returns(true)
22
+ @provider.instance_variable_set(:@property_value_cache_hash,
23
+ { :members => current })
24
+
25
+ %w{bar baz}.each do |del|
26
+ @provider.expects(:execute).once.
27
+ with([:dseditgroup, '-o', 'edit', '-n', '.', '-d', del, group])
28
+ end
29
+
30
+ %w{quux qorp}.each do |add|
31
+ @provider.expects(:execute).once.
32
+ with([:dseditgroup, '-o', 'edit', '-n', '.', '-a', add, group])
33
+ end
34
+
35
+ expect { @provider.set(:members, desired) }.should_not raise_error
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/../../../spec_helper'
4
+
5
+ provider_class = Puppet::Type.type(:package).provider(:freebsd)
6
+
7
+ describe provider_class do
8
+ before :each do
9
+ # Create a mock resource
10
+ @resource = stub 'resource'
11
+
12
+ # A catch all; no parameters set
13
+ @resource.stubs(:[]).returns(nil)
14
+
15
+ # But set name and source
16
+ @resource.stubs(:[]).with(:name).returns "mypackage"
17
+ @resource.stubs(:[]).with(:ensure).returns :installed
18
+
19
+ @provider = provider_class.new
20
+ @provider.resource = @resource
21
+ end
22
+
23
+ it "should have an install method" do
24
+ @provider = provider_class.new
25
+ @provider.should respond_to(:install)
26
+ end
27
+
28
+ describe "when installing" do
29
+ before :each do
30
+ @resource.stubs(:should).with(:ensure).returns(:installed)
31
+ end
32
+
33
+ it "should install a package from a path to a directory" do
34
+ # For better or worse, trailing '/' is needed. --daniel 2011-01-26
35
+ path = '/path/to/directory/'
36
+ @resource.stubs(:[]).with(:source).returns(path)
37
+ Puppet::Util::Execution.expects(:withenv).once.with({:PKG_PATH => path}).yields
38
+ @provider.expects(:pkgadd).once.with("mypackage")
39
+
40
+ expect { @provider.install }.should_not raise_error
41
+ end
42
+
43
+ %w{http https ftp}.each do |protocol|
44
+ it "should install a package via #{protocol}" do
45
+ # For better or worse, trailing '/' is needed. --daniel 2011-01-26
46
+ path = "#{protocol}://localhost/"
47
+ @resource.stubs(:[]).with(:source).returns(path)
48
+ Puppet::Util::Execution.expects(:withenv).once.with({:PACKAGESITE => path}).yields
49
+ @provider.expects(:pkgadd).once.with('-r', "mypackage")
50
+
51
+ expect { @provider.install }.should_not raise_error
52
+ end
53
+ end
54
+ end
55
+ end
@@ -84,10 +84,12 @@ describe provider_class do
84
84
  end
85
85
 
86
86
  it "should be able to find the init script in the service path" do
87
+ File.stubs(:stat).raises(Errno::ENOENT.new('No such file or directory'))
87
88
  File.expects(:stat).with("/service/path/myservice").returns true
88
89
  @provider.initscript.should == "/service/path/myservice"
89
90
  end
90
91
  it "should be able to find the init script in the service path" do
92
+ File.stubs(:stat).raises(Errno::ENOENT.new('No such file or directory'))
91
93
  File.expects(:stat).with("/alt/service/path/myservice").returns true
92
94
  @provider.initscript.should == "/alt/service/path/myservice"
93
95
  end
@@ -2,9 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/../../spec_helper'
4
4
 
5
- describe "Puppet::Rails::Host" do
6
- confine "Cannot test without ActiveRecord" => Puppet.features.rails?
7
-
5
+ describe "Puppet::Rails::Host", :if => Puppet.features.rails? do
8
6
  def column(name, type)
9
7
  ActiveRecord::ConnectionAdapters::Column.new(name, nil, type, false)
10
8
  end
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.dirname(__FILE__) + '/../../spec_helper'
4
+ require 'puppet/rails'
4
5
 
5
- describe "Puppet::Rails::ParamValue" do
6
- confine "Cannot test without ActiveRecord" => Puppet.features.rails?
7
-
6
+ describe "Puppet::Rails::ParamValue", :if => Puppet.features.rails? do
8
7
  def column(name, type)
9
8
  ActiveRecord::ConnectionAdapters::Column.new(name, nil, type, false)
10
9
  end
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.dirname(__FILE__) + '/../../spec_helper'
4
+ require 'puppet/rails'
4
5
 
5
- describe "Puppet::Rails::Resource" do
6
- confine "Cannot test without ActiveRecord" => Puppet.features.rails?
7
-
6
+ describe "Puppet::Rails::Resource", :if => Puppet.features.rails? do
8
7
  def column(name, type)
9
8
  ActiveRecord::ConnectionAdapters::Column.new(name, nil, type, false)
10
9
  end
@@ -3,9 +3,7 @@
3
3
  require File.dirname(__FILE__) + '/../spec_helper'
4
4
  require 'puppet/rails'
5
5
 
6
- describe Puppet::Rails, "when initializing any connection" do
7
- confine "Cannot test without ActiveRecord" => Puppet.features.rails?
8
-
6
+ describe Puppet::Rails, "when initializing any connection", :if => Puppet.features.rails? do
9
7
  before do
10
8
  Puppet.settings.stubs(:use)
11
9
  @logger = mock 'logger'
@@ -77,9 +75,7 @@ describe Puppet::Rails, "when initializing any connection" do
77
75
  end
78
76
  end
79
77
 
80
- describe Puppet::Rails, "when initializing a sqlite3 connection" do
81
- confine "Cannot test without ActiveRecord" => Puppet.features.rails?
82
-
78
+ describe Puppet::Rails, "when initializing a sqlite3 connection", :if => Puppet.features.rails? do
83
79
  it "should provide the adapter, log_level, and database arguments" do
84
80
  Puppet.settings.expects(:value).with(:dbadapter).returns("sqlite3")
85
81
  Puppet.settings.expects(:value).with(:rails_loglevel).returns("testlevel")
@@ -93,9 +89,7 @@ describe Puppet::Rails, "when initializing a sqlite3 connection" do
93
89
  end
94
90
  end
95
91
 
96
- describe Puppet::Rails, "when initializing a mysql connection" do
97
- confine "Cannot test without ActiveRecord" => Puppet.features.rails?
98
-
92
+ describe Puppet::Rails, "when initializing a mysql connection", :if => Puppet.features.rails? do
99
93
  it "should provide the adapter, log_level, and host, port, username, password, database, and reconnect arguments" do
100
94
  Puppet.settings.stubs(:value).with(:dbadapter).returns("mysql")
101
95
  Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
@@ -190,9 +184,7 @@ describe Puppet::Rails, "when initializing a mysql connection" do
190
184
  end
191
185
  end
192
186
 
193
- describe Puppet::Rails, "when initializing a postgresql connection" do
194
- confine "Cannot test without ActiveRecord" => Puppet.features.rails?
195
-
187
+ describe Puppet::Rails, "when initializing a postgresql connection", :if => Puppet.features.rails? do
196
188
  it "should provide the adapter, log_level, and host, port, username, password, connections, and database arguments" do
197
189
  Puppet.settings.stubs(:value).with(:dbadapter).returns("postgresql")
198
190
  Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
@@ -263,9 +255,7 @@ describe Puppet::Rails, "when initializing a postgresql connection" do
263
255
  end
264
256
  end
265
257
 
266
- describe Puppet::Rails, "when initializing an Oracle connection" do
267
- confine "Cannot test without ActiveRecord" => Puppet.features.rails?
268
-
258
+ describe Puppet::Rails, "when initializing an Oracle connection", :if => Puppet.features.rails? do
269
259
  it "should provide the adapter, log_level, and username, password, and database arguments" do
270
260
  Puppet.settings.stubs(:value).with(:dbadapter).returns("oracle_enhanced")
271
261
  Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
@@ -155,9 +155,7 @@ describe Puppet::Relationship, " when matching edges with a non-standard event"
155
155
  end
156
156
  end
157
157
 
158
- describe Puppet::Relationship, "when converting to pson" do
159
- confine "Missing 'pson' library" => Puppet.features.pson?
160
-
158
+ describe Puppet::Relationship, "when converting to pson", :if => Puppet.features.pson? do
161
159
  before do
162
160
  @edge = Puppet::Relationship.new(:a, :b, :event => :random, :callback => :whatever)
163
161
  end
@@ -190,9 +188,7 @@ describe Puppet::Relationship, "when converting to pson" do
190
188
  end
191
189
  end
192
190
 
193
- describe Puppet::Relationship, "when converting from pson" do
194
- confine "Missing 'pson' library" => Puppet.features.pson?
195
-
191
+ describe Puppet::Relationship, "when converting from pson", :if => Puppet.features.pson? do
196
192
  before do
197
193
  @event = "random"
198
194
  @callback = "whatever"
@@ -18,7 +18,7 @@ processor = Puppet::Reports.report(:http)
18
18
 
19
19
  describe processor do
20
20
  before { Net::HTTP.any_instance.stubs(:start).yields(FakeHTTP) }
21
- subject { Puppet::Transaction::Report.new.extend(processor) }
21
+ subject { Puppet::Transaction::Report.new("apply").extend(processor) }
22
22
 
23
23
  it { should respond_to(:process) }
24
24
 
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
4
+
5
+ require 'puppet/reports'
6
+ require 'time'
7
+
8
+ processor = Puppet::Reports.report(:store)
9
+
10
+ describe processor do
11
+ describe "#process" do
12
+ include PuppetSpec::Files
13
+ before :each do
14
+ Puppet[:reportdir] = tmpdir('reports')
15
+ @report = YAML.load_file(File.join(PuppetSpec::FIXTURE_DIR, 'yaml/report2.6.x.yaml')).extend processor
16
+ end
17
+
18
+ it "should create a report directory for the client if one doesn't exist" do
19
+ @report.process
20
+
21
+ File.should be_directory(File.join(Puppet[:reportdir], @report.host))
22
+ end
23
+
24
+ it "should write the report to the file in YAML" do
25
+ Time.stubs(:now).returns(Time.parse("2011-01-06 12:00:00 UTC"))
26
+ @report.process
27
+
28
+ File.read(File.join(Puppet[:reportdir], @report.host, "201101061200.yaml")).should == @report.to_yaml
29
+ end
30
+ end
31
+ end
@@ -11,7 +11,7 @@ describe tagmail do
11
11
  extend PuppetTest::Support::Utils
12
12
 
13
13
  before do
14
- @processor = Puppet::Transaction::Report.new
14
+ @processor = Puppet::Transaction::Report.new("apply")
15
15
  @processor.extend(Puppet::Reports.report(:tagmail))
16
16
  end
17
17
 
@@ -880,9 +880,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
880
880
  end
881
881
  end
882
882
 
883
- describe Puppet::Resource::Catalog, "when converting to pson" do
884
- confine "Missing 'pson' library" => Puppet.features.pson?
885
-
883
+ describe Puppet::Resource::Catalog, "when converting to pson", :if => Puppet.features.pson? do
886
884
  before do
887
885
  @catalog = Puppet::Resource::Catalog.new("myhost")
888
886
  end
@@ -940,9 +938,7 @@ describe Puppet::Resource::Catalog, "when converting to pson" do
940
938
  end
941
939
  end
942
940
 
943
- describe Puppet::Resource::Catalog, "when converting from pson" do
944
- confine "Missing 'pson' library" => Puppet.features.pson?
945
-
941
+ describe Puppet::Resource::Catalog, "when converting from pson", :if => Puppet.features.pson? do
946
942
  def pson_result_should
947
943
  Puppet::Resource::Catalog.expects(:new).with { |hash| yield hash }
948
944
  end
@@ -10,7 +10,12 @@ describe Puppet::Resource::Status do
10
10
  @status = Puppet::Resource::Status.new(@resource)
11
11
  end
12
12
 
13
- [:node, :version, :file, :line, :current_values, :skipped_reason, :status, :evaluation_time, :change_count].each do |attr|
13
+ it "should compute type and title correctly" do
14
+ @status.resource_type.should == "File"
15
+ @status.title.should == "/my/file"
16
+ end
17
+
18
+ [:node, :file, :line, :current_values, :status, :evaluation_time].each do |attr|
14
19
  it "should support #{attr}" do
15
20
  @status.send(attr.to_s + "=", "foo")
16
21
  @status.send(attr).should == "foo"
@@ -38,7 +43,7 @@ describe Puppet::Resource::Status do
38
43
  Puppet::Resource::Status.new(@resource).source_description.should == "/my/path"
39
44
  end
40
45
 
41
- [:file, :line, :version].each do |attr|
46
+ [:file, :line].each do |attr|
42
47
  it "should copy the resource's #{attr}" do
43
48
  @resource.expects(attr).returns "foo"
44
49
  Puppet::Resource::Status.new(@resource).send(attr).should == "foo"
@@ -74,7 +79,7 @@ describe Puppet::Resource::Status do
74
79
  @status.send_log :notice, "my message"
75
80
  end
76
81
 
77
- [:file, :line, :version].each do |attr|
82
+ [:file, :line].each do |attr|
78
83
  it "should pass the #{attr}" do
79
84
  Puppet::Util::Log.expects(:new).with { |args| args[attr] == "my val" }
80
85
  @status.send(attr.to_s + "=", "my val")
@@ -100,4 +105,49 @@ describe Puppet::Resource::Status do
100
105
  (@status << event).should equal(@status)
101
106
  @status.events.should == [event]
102
107
  end
108
+
109
+ it "should count the number of successful events and set changed" do
110
+ 3.times{ @status << Puppet::Transaction::Event.new(:status => 'success') }
111
+ @status.change_count.should == 3
112
+
113
+ @status.changed.should == true
114
+ @status.out_of_sync.should == true
115
+ end
116
+
117
+ it "should not start with any changes" do
118
+ @status.change_count.should == 0
119
+
120
+ @status.changed.should == false
121
+ @status.out_of_sync.should == false
122
+ end
123
+
124
+ it "should not treat failure, audit, or noop events as changed" do
125
+ ['failure', 'audit', 'noop'].each do |s| @status << Puppet::Transaction::Event.new(:status => s) end
126
+ @status.change_count.should == 0
127
+ @status.changed.should == false
128
+ end
129
+
130
+ it "should not treat audit events as out of sync" do
131
+ @status << Puppet::Transaction::Event.new(:status => 'audit')
132
+ @status.out_of_sync_count.should == 0
133
+ @status.out_of_sync.should == false
134
+ end
135
+
136
+ ['failure', 'noop', 'success'].each do |event_status|
137
+ it "should treat #{event_status} events as out of sync" do
138
+ 3.times do @status << Puppet::Transaction::Event.new(:status => event_status) end
139
+ @status.out_of_sync_count.should == 3
140
+ @status.out_of_sync.should == true
141
+ end
142
+ end
143
+
144
+ describe "When converting to YAML" do
145
+ it "should include only documented attributes" do
146
+ @status.file = "/foo.rb"
147
+ @status.line = 27
148
+ @status.evaluation_time = 2.7
149
+ @status.tags = %w{one two}
150
+ @status.to_yaml_properties.should == Puppet::Resource::Status::YAML_ATTRIBUTES.sort
151
+ end
152
+ end
103
153
  end