puppet 2.6.6 → 2.6.7
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.
- data/CHANGELOG +107 -1
- data/README.queueing +1 -1
- data/Rakefile +1 -1
- data/conf/solaris/smf/svc-puppetd +0 -2
- data/conf/solaris/smf/svc-puppetmasterd +0 -2
- data/examples/etc/init.d/sleeper +0 -2
- data/examples/modules/sample-module/README.txt +2 -2
- data/ext/puppetstoredconfigclean.rb +1 -1
- data/install.rb +20 -25
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/agent.rb +2 -2
- data/lib/puppet/application/apply.rb +2 -2
- data/lib/puppet/application/cert.rb +27 -11
- data/lib/puppet/application/filebucket.rb +1 -1
- data/lib/puppet/application/inspect.rb +1 -1
- data/lib/puppet/application/kick.rb +2 -2
- data/lib/puppet/application/master.rb +1 -1
- data/lib/puppet/application/queue.rb +2 -2
- data/lib/puppet/configurer/downloader.rb +1 -0
- data/lib/puppet/configurer/plugin_handler.rb +8 -1
- data/lib/puppet/daemon.rb +1 -1
- data/lib/puppet/defaults.rb +18 -2
- data/lib/puppet/external/nagios.rb +0 -2
- data/lib/puppet/external/nagios/base.rb +0 -2
- data/lib/puppet/indirector/facts/inventory_active_record.rb +97 -0
- data/lib/puppet/indirector/facts/rest.rb +2 -0
- data/lib/puppet/indirector/facts/yaml.rb +75 -0
- data/lib/puppet/indirector/indirection.rb +1 -0
- data/lib/puppet/module.rb +1 -1
- data/lib/puppet/network/http/api/v1.rb +3 -4
- data/lib/puppet/network/http/compression.rb +4 -1
- data/lib/puppet/network/http/handler.rb +1 -1
- data/lib/puppet/network/rest_authconfig.rb +1 -1
- data/lib/puppet/node/facts.rb +29 -0
- data/lib/puppet/parser/ast/collection.rb +5 -4
- data/lib/puppet/parser/ast/leaf.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +7 -14
- data/lib/puppet/parser/functions/split.rb +7 -7
- data/lib/puppet/parser/grammar.ra +2 -4
- data/lib/puppet/parser/lexer.rb +4 -1
- data/lib/puppet/parser/parser.rb +2062 -1976
- data/lib/puppet/parser/parser_support.rb +3 -3
- data/lib/puppet/provider/computer/computer.rb +1 -3
- data/lib/puppet/provider/mount.rb +12 -16
- data/lib/puppet/provider/mount/parsed.rb +67 -8
- data/lib/puppet/provider/parsedfile.rb +3 -1
- data/lib/puppet/provider/service/daemontools.rb +6 -6
- data/lib/puppet/provider/service/gentoo.rb +0 -2
- data/lib/puppet/provider/service/launchd.rb +11 -8
- data/lib/puppet/provider/service/runit.rb +4 -4
- data/lib/puppet/provider/user/useradd.rb +6 -1
- data/lib/puppet/rails/database/004_add_inventory_service_tables.rb +36 -0
- data/lib/puppet/rails/database/schema.rb +17 -0
- data/lib/puppet/rails/fact_name.rb +0 -2
- data/lib/puppet/rails/fact_value.rb +0 -2
- data/lib/puppet/rails/inventory_fact.rb +5 -0
- data/lib/puppet/rails/inventory_node.rb +25 -0
- data/lib/puppet/reference/configuration.rb +1 -1
- data/lib/puppet/reference/metaparameter.rb +1 -1
- data/lib/puppet/reports/store.rb +4 -1
- data/lib/puppet/resource.rb +39 -25
- data/lib/puppet/type.rb +5 -5
- data/lib/puppet/type/augeas.rb +4 -4
- data/lib/puppet/type/computer.rb +5 -1
- data/lib/puppet/type/exec.rb +3 -1
- data/lib/puppet/type/file.rb +3 -1
- data/lib/puppet/type/file/content.rb +13 -15
- data/lib/puppet/type/file/ensure.rb +11 -17
- data/lib/puppet/type/file/selcontext.rb +16 -0
- data/lib/puppet/type/file/target.rb +14 -1
- data/lib/puppet/type/k5login.rb +0 -2
- data/lib/puppet/type/macauthorization.rb +4 -1
- data/lib/puppet/type/mcx.rb +4 -1
- data/lib/puppet/type/mount.rb +37 -21
- data/lib/puppet/type/package.rb +5 -1
- data/lib/puppet/type/schedule.rb +20 -20
- data/lib/puppet/type/selmodule.rb +3 -1
- data/lib/puppet/type/ssh_authorized_key.rb +5 -1
- data/lib/puppet/type/user.rb +14 -1
- data/lib/puppet/type/zfs.rb +3 -1
- data/lib/puppet/type/zone.rb +3 -1
- data/lib/puppet/type/zpool.rb +7 -5
- data/lib/puppet/util.rb +5 -0
- data/lib/puppet/util/command_line.rb +1 -1
- data/lib/puppet/util/execution.rb +4 -5
- data/lib/puppet/util/execution_stub.rb +26 -0
- data/lib/puppet/util/monkey_patches.rb +21 -0
- data/lib/puppet/util/rdoc/code_objects.rb +39 -0
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +18 -0
- data/lib/puppet/util/rdoc/parser.rb +5 -3
- data/lib/puppet/util/settings.rb +1 -1
- data/spec/integration/parser/parser_spec.rb +7 -0
- data/spec/integration/provider/mount_spec.rb +151 -0
- data/spec/integration/type/file_spec.rb +32 -29
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/application/agent_spec.rb +3 -7
- data/spec/unit/application/apply_spec.rb +17 -2
- data/spec/unit/application/cert_spec.rb +54 -14
- data/spec/unit/application/filebucket_spec.rb +1 -1
- data/spec/unit/application/queue_spec.rb +1 -5
- data/spec/unit/configurer/downloader_spec.rb +22 -10
- data/spec/unit/daemon_spec.rb +1 -5
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +163 -0
- data/spec/unit/indirector/facts/yaml_spec.rb +216 -2
- data/spec/unit/indirector/queue_spec.rb +3 -0
- data/spec/unit/module_spec.rb +2 -2
- data/spec/unit/network/handler/fileserver_spec.rb +1 -1
- data/spec/unit/network/http/api/v1_spec.rb +28 -0
- data/spec/unit/network/http/compression_spec.rb +1 -1
- data/spec/unit/network/http/handler_spec.rb +7 -4
- data/spec/unit/node/facts_spec.rb +24 -0
- data/spec/unit/parser/ast/collection_spec.rb +16 -12
- data/spec/unit/parser/lexer_spec.rb +16 -0
- data/spec/unit/parser/parser_spec.rb +35 -2
- data/spec/unit/provider/mount/parsed_spec.rb +199 -114
- data/spec/unit/provider/mount_spec.rb +54 -53
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
- data/spec/unit/provider/user/user_role_add_spec.rb +1 -0
- data/spec/unit/provider/user/useradd_spec.rb +43 -3
- data/spec/unit/reports/store_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +39 -13
- data/spec/unit/type/file/content_spec.rb +38 -137
- data/spec/unit/type/file/selinux_spec.rb +5 -0
- data/spec/unit/type/mount_spec.rb +167 -122
- data/spec/unit/type/user_spec.rb +4 -0
- data/spec/unit/type_spec.rb +12 -1
- data/spec/unit/util/execution_spec.rb +49 -0
- data/spec/unit/util/execution_stub_spec.rb +35 -0
- data/spec/unit/util/rdoc/parser_spec.rb +15 -3
- data/spec/unit/util/settings_spec.rb +11 -2
- data/tasks/rake/git_workflow.rake +1 -1
- data/test/Rakefile +0 -2
- data/test/data/providers/mount/parsed/aix.mount +7 -0
- data/test/data/providers/mount/parsed/darwin.mount +6 -0
- data/test/data/providers/mount/parsed/hpux.mount +17 -0
- data/test/data/providers/mount/parsed/linux.mount +5 -0
- data/test/data/providers/mount/parsed/solaris.mount +6 -0
- data/test/data/types/mount/linux.fstab +1 -0
- data/test/data/types/mount/solaris.fstab +1 -0
- metadata +18 -4
@@ -10,9 +10,9 @@ describe Puppet::Node::Facts::Yaml do
|
|
10
10
|
Puppet::Node::Facts::Yaml.superclass.should equal(Puppet::Indirector::Yaml)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
13
|
it "should have documentation" do
|
15
14
|
Puppet::Node::Facts::Yaml.doc.should_not be_nil
|
15
|
+
Puppet::Node::Facts::Yaml.doc.should_not be_empty
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should be registered with the facts indirection" do
|
@@ -20,7 +20,221 @@ describe Puppet::Node::Facts::Yaml do
|
|
20
20
|
Puppet::Node::Facts::Yaml.indirection.should equal(indirection)
|
21
21
|
end
|
22
22
|
|
23
|
-
it "should have its name set to :
|
23
|
+
it "should have its name set to :yaml" do
|
24
24
|
Puppet::Node::Facts::Yaml.name.should == :yaml
|
25
25
|
end
|
26
|
+
|
27
|
+
describe "#search" do
|
28
|
+
def assert_search_matches(matching, nonmatching, query)
|
29
|
+
request = Puppet::Indirector::Request.new(:inventory, :search, nil, query)
|
30
|
+
|
31
|
+
Dir.stubs(:glob).returns(matching.keys + nonmatching.keys)
|
32
|
+
[matching, nonmatching].each do |examples|
|
33
|
+
examples.each do |key, value|
|
34
|
+
YAML.stubs(:load_file).with(key).returns value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
Puppet::Node::Facts::Yaml.new.search(request).should =~ matching.values.map {|facts| facts.name}
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return node names that match the search query options" do
|
41
|
+
assert_search_matches({
|
42
|
+
'/path/to/matching.yaml' => Puppet::Node::Facts.new("matchingnode", "architecture" => "i386", 'processor_count' => '4'),
|
43
|
+
'/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "i386", 'processor_count' => '4', 'randomfact' => 'foo')
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "powerpc", 'processor_count' => '4'),
|
47
|
+
"/path/to/nonmatching1.yaml" => Puppet::Node::Facts.new("nonmatchingnode1", "architecture" => "powerpc", 'processor_count' => '5'),
|
48
|
+
"/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '5'),
|
49
|
+
"/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3", 'processor_count' => '4'),
|
50
|
+
},
|
51
|
+
{'facts.architecture' => 'i386', 'facts.processor_count' => '4'}
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return empty array when no nodes match the search query options" do
|
56
|
+
assert_search_matches({}, {
|
57
|
+
"/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "powerpc", 'processor_count' => '10'),
|
58
|
+
"/path/to/nonmatching1.yaml" => Puppet::Node::Facts.new("nonmatchingnode1", "architecture" => "powerpc", 'processor_count' => '5'),
|
59
|
+
"/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '5'),
|
60
|
+
"/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3", 'processor_count' => '4'),
|
61
|
+
},
|
62
|
+
{'facts.processor_count.lt' => '4', 'facts.processor_count.gt' => '4'}
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
it "should return node names that match the search query options with the greater than operator" do
|
68
|
+
assert_search_matches({
|
69
|
+
'/path/to/matching.yaml' => Puppet::Node::Facts.new("matchingnode", "architecture" => "i386", 'processor_count' => '5'),
|
70
|
+
'/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '10', 'randomfact' => 'foo')
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "powerpc", 'processor_count' => '4'),
|
74
|
+
"/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '3'),
|
75
|
+
"/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3" ),
|
76
|
+
},
|
77
|
+
{'facts.processor_count.gt' => '4'}
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should return node names that match the search query options with the less than operator" do
|
82
|
+
assert_search_matches({
|
83
|
+
'/path/to/matching.yaml' => Puppet::Node::Facts.new("matchingnode", "architecture" => "i386", 'processor_count' => '5'),
|
84
|
+
'/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '30', 'randomfact' => 'foo')
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "powerpc", 'processor_count' => '50' ),
|
88
|
+
"/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '100'),
|
89
|
+
"/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3" ),
|
90
|
+
},
|
91
|
+
{'facts.processor_count.lt' => '50'}
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should return node names that match the search query options with the less than or equal to operator" do
|
96
|
+
assert_search_matches({
|
97
|
+
'/path/to/matching.yaml' => Puppet::Node::Facts.new("matchingnode", "architecture" => "i386", 'processor_count' => '5'),
|
98
|
+
'/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '50', 'randomfact' => 'foo')
|
99
|
+
},
|
100
|
+
{
|
101
|
+
"/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "powerpc", 'processor_count' => '100' ),
|
102
|
+
"/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '5000'),
|
103
|
+
"/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3" ),
|
104
|
+
},
|
105
|
+
{'facts.processor_count.le' => '50'}
|
106
|
+
)
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should return node names that match the search query options with the greater than or equal to operator" do
|
110
|
+
assert_search_matches({
|
111
|
+
'/path/to/matching.yaml' => Puppet::Node::Facts.new("matchingnode", "architecture" => "i386", 'processor_count' => '100'),
|
112
|
+
'/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '50', 'randomfact' => 'foo')
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "powerpc", 'processor_count' => '40'),
|
116
|
+
"/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '9' ),
|
117
|
+
"/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3" ),
|
118
|
+
},
|
119
|
+
{'facts.processor_count.ge' => '50'}
|
120
|
+
)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should return node names that match the search query options with the not equal operator" do
|
124
|
+
assert_search_matches({
|
125
|
+
'/path/to/matching.yaml' => Puppet::Node::Facts.new("matchingnode", "architecture" => 'arm' ),
|
126
|
+
'/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => 'powerpc', 'randomfact' => 'foo')
|
127
|
+
},
|
128
|
+
{
|
129
|
+
"/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "i386" ),
|
130
|
+
"/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '9' ),
|
131
|
+
"/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3" ),
|
132
|
+
},
|
133
|
+
{'facts.architecture.ne' => 'i386'}
|
134
|
+
)
|
135
|
+
end
|
136
|
+
|
137
|
+
def apply_timestamp(facts, timestamp)
|
138
|
+
facts.timestamp = timestamp
|
139
|
+
facts
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should be able to query based on meta.timestamp.gt" do
|
143
|
+
assert_search_matches({
|
144
|
+
'/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
|
145
|
+
'/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
|
146
|
+
},
|
147
|
+
{
|
148
|
+
'/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
|
149
|
+
'/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
|
150
|
+
'/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
|
151
|
+
},
|
152
|
+
{'meta.timestamp.gt' => '2010-10-15'}
|
153
|
+
)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should be able to query based on meta.timestamp.le" do
|
157
|
+
assert_search_matches({
|
158
|
+
'/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
|
159
|
+
'/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
|
160
|
+
'/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
|
161
|
+
},
|
162
|
+
{
|
163
|
+
'/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
|
164
|
+
'/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
|
165
|
+
},
|
166
|
+
{'meta.timestamp.le' => '2010-10-15'}
|
167
|
+
)
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should be able to query based on meta.timestamp.lt" do
|
171
|
+
assert_search_matches({
|
172
|
+
'/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
|
173
|
+
'/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
|
174
|
+
},
|
175
|
+
{
|
176
|
+
'/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
|
177
|
+
'/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
|
178
|
+
'/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
|
179
|
+
},
|
180
|
+
{'meta.timestamp.lt' => '2010-10-15'}
|
181
|
+
)
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should be able to query based on meta.timestamp.ge" do
|
185
|
+
assert_search_matches({
|
186
|
+
'/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
|
187
|
+
'/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
|
188
|
+
'/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
|
189
|
+
},
|
190
|
+
{
|
191
|
+
'/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
|
192
|
+
'/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
|
193
|
+
},
|
194
|
+
{'meta.timestamp.ge' => '2010-10-15'}
|
195
|
+
)
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should be able to query based on meta.timestamp.eq" do
|
199
|
+
assert_search_matches({
|
200
|
+
'/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
|
201
|
+
},
|
202
|
+
{
|
203
|
+
'/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
|
204
|
+
'/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
|
205
|
+
'/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
|
206
|
+
'/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
|
207
|
+
},
|
208
|
+
{'meta.timestamp.eq' => '2010-10-15'}
|
209
|
+
)
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should be able to query based on meta.timestamp" do
|
213
|
+
assert_search_matches({
|
214
|
+
'/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
|
215
|
+
},
|
216
|
+
{
|
217
|
+
'/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
|
218
|
+
'/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
|
219
|
+
'/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
|
220
|
+
'/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
|
221
|
+
},
|
222
|
+
{'meta.timestamp' => '2010-10-15'}
|
223
|
+
)
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should be able to query based on meta.timestamp.ne" do
|
227
|
+
assert_search_matches({
|
228
|
+
'/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
|
229
|
+
'/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
|
230
|
+
'/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
|
231
|
+
'/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
|
232
|
+
},
|
233
|
+
{
|
234
|
+
'/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
|
235
|
+
},
|
236
|
+
{'meta.timestamp.ne' => '2010-10-15'}
|
237
|
+
)
|
238
|
+
end
|
239
|
+
end
|
26
240
|
end
|
@@ -114,6 +114,9 @@ describe Puppet::Indirector::Queue, :if => Puppet.features.pson? do
|
|
114
114
|
@store_class.client.expects(:subscribe).yields("foo")
|
115
115
|
@store_class.expects(:intern).raises ArgumentError
|
116
116
|
Puppet.expects(:err)
|
117
|
+
|
118
|
+
@store_class.expects(:puts)
|
119
|
+
|
117
120
|
@store_class.subscribe {|o| o }
|
118
121
|
end
|
119
122
|
end
|
data/spec/unit/module_spec.rb
CHANGED
@@ -367,9 +367,9 @@ describe Puppet::Module do
|
|
367
367
|
mod.stubs(:path).returns "/a/foo"
|
368
368
|
FileTest.expects(:exist?).with("/a/foo/plugins").returns true
|
369
369
|
|
370
|
-
mod.expects(:warning)
|
371
|
-
|
372
370
|
mod.plugin_directory.should == "/a/foo/plugins"
|
371
|
+
@logs.first.message.should == "using the deprecated 'plugins' directory for ruby extensions; please move to 'lib'"
|
372
|
+
@logs.first.level.should == :warning
|
373
373
|
end
|
374
374
|
|
375
375
|
it "should default to 'lib' for the plugins directory" do
|
@@ -158,7 +158,7 @@ describe Puppet::Network::Handler::FileServer do
|
|
158
158
|
end
|
159
159
|
|
160
160
|
it "should not fail for inexistant plugins type" do
|
161
|
-
|
161
|
+
@mount.list("puppet/parser",true,false)
|
162
162
|
end
|
163
163
|
|
164
164
|
end
|
@@ -76,6 +76,34 @@ describe Puppet::Network::HTTP::API::V1 do
|
|
76
76
|
@tester.uri2indirection("GET", "/env/foos/bar", {}).method.should == :search
|
77
77
|
end
|
78
78
|
|
79
|
+
it "should choose 'find' as the indirection method if the http method is a GET and the indirection name is facts" do
|
80
|
+
@tester.uri2indirection("GET", "/env/facts/bar", {}).method.should == :find
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should choose 'save' as the indirection method if the http method is a PUT and the indirection name is facts" do
|
84
|
+
@tester.uri2indirection("PUT", "/env/facts/bar", {}).method.should == :save
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should choose 'search' as the indirection method if the http method is a GET and the indirection name is inventory" do
|
88
|
+
@tester.uri2indirection("GET", "/env/inventory/search", {}).method.should == :search
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should choose 'search' as the indirection method if the http method is a GET and the indirection name is facts_search" do
|
92
|
+
@tester.uri2indirection("GET", "/env/facts_search/bar", {}).method.should == :search
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should change indirection name to 'facts' if the http method is a GET and the indirection name is facts_search" do
|
96
|
+
@tester.uri2indirection("GET", "/env/facts_search/bar", {}).indirection_name.should == :facts
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should not change indirection name from 'facts' if the http method is a GET and the indirection name is facts" do
|
100
|
+
@tester.uri2indirection("GET", "/env/facts/bar", {}).indirection_name.should == :facts
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should change indirection name to 'status' if the http method is a GET and the indirection name is statuses" do
|
104
|
+
@tester.uri2indirection("GET", "/env/statuses/bar", {}).indirection_name.should == :status
|
105
|
+
end
|
106
|
+
|
79
107
|
it "should choose 'delete' as the indirection method if the http method is a DELETE and the indirection name is singular" do
|
80
108
|
@tester.uri2indirection("DELETE", "/env/foo/bar", {}).method.should == :destroy
|
81
109
|
end
|
@@ -178,7 +178,7 @@ describe "http compression" do
|
|
178
178
|
end
|
179
179
|
|
180
180
|
it "should raise the error the second time" do
|
181
|
-
@inflater.
|
181
|
+
@inflater.stubs(:inflate).raises(Zlib::DataError.new("not a zlib stream"))
|
182
182
|
Zlib::Inflate.expects(:new).with.returns(@inflater)
|
183
183
|
lambda { @adapter.uncompress("chunk") }.should raise_error
|
184
184
|
end
|
@@ -344,17 +344,20 @@ describe Puppet::Network::HTTP::Handler do
|
|
344
344
|
@handler.do_search(@irequest, @request, @response)
|
345
345
|
end
|
346
346
|
|
347
|
-
it "should return
|
348
|
-
@
|
349
|
-
@handler.expects(:set_response).with { |response, body, status| status == 404 }
|
347
|
+
it "should return [] when searching returns an empty array" do
|
348
|
+
@handler.expects(:accept_header).with(@request).returns "one,two"
|
350
349
|
@model_class.stubs(:search).returns([])
|
350
|
+
@model_class.expects(:render_multiple).with(@oneformat, []).returns "[]"
|
351
|
+
|
352
|
+
|
353
|
+
@handler.expects(:set_response).with { |response, data| data == "[]" }
|
351
354
|
@handler.do_search(@irequest, @request, @response)
|
352
355
|
end
|
353
356
|
|
354
357
|
it "should return a 404 when searching returns nil" do
|
355
358
|
@model_class.stubs(:name).returns "my name"
|
356
359
|
@handler.expects(:set_response).with { |response, body, status| status == 404 }
|
357
|
-
@model_class.stubs(:search).returns(
|
360
|
+
@model_class.stubs(:search).returns(nil)
|
358
361
|
@handler.do_search(@irequest, @request, @response)
|
359
362
|
end
|
360
363
|
end
|
@@ -109,5 +109,29 @@ describe Puppet::Node::Facts, "when indirecting" do
|
|
109
109
|
facts = Puppet::Node::Facts.new("me", "one" => "two", "three" => "four")
|
110
110
|
facts.values[:_timestamp].should be_instance_of(Time)
|
111
111
|
end
|
112
|
+
|
113
|
+
describe "using pson" do
|
114
|
+
before :each do
|
115
|
+
@timestamp = Time.parse("Thu Oct 28 11:16:31 -0700 2010")
|
116
|
+
@expiration = Time.parse("Thu Oct 28 11:21:31 -0700 2010")
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should accept properly formatted pson" do
|
120
|
+
pson = %Q({"name": "foo", "expiration": "#{@expiration}", "timestamp": "#{@timestamp}", "values": {"a": "1", "b": "2", "c": "3"}})
|
121
|
+
format = Puppet::Network::FormatHandler.format('pson')
|
122
|
+
facts = format.intern(Puppet::Node::Facts,pson)
|
123
|
+
facts.name.should == 'foo'
|
124
|
+
facts.expiration.should == @expiration
|
125
|
+
facts.values.should == {'a' => '1', 'b' => '2', 'c' => '3', :_timestamp => @timestamp}
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should generate properly formatted pson" do
|
129
|
+
Time.stubs(:now).returns(@timestamp)
|
130
|
+
facts = Puppet::Node::Facts.new("foo", {'a' => 1, 'b' => 2, 'c' => 3})
|
131
|
+
facts.expiration = @expiration
|
132
|
+
pson = PSON.parse(facts.to_pson)
|
133
|
+
pson.should == {"name"=>"foo", "timestamp"=>@timestamp.to_s, "expiration"=>@expiration.to_s, "values"=>{"a"=>1, "b"=>2, "c"=>3}}
|
134
|
+
end
|
135
|
+
end
|
112
136
|
end
|
113
137
|
end
|
@@ -4,20 +4,21 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
4
4
|
|
5
5
|
describe Puppet::Parser::AST::Collection do
|
6
6
|
before :each do
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
10
|
-
|
11
|
-
@
|
7
|
+
@mytype = Puppet::Resource::Type.new(:definition, "mytype")
|
8
|
+
@environment = Puppet::Node::Environment.new
|
9
|
+
@environment.known_resource_types.add @mytype
|
10
|
+
|
11
|
+
@compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foonode", :environment => @environment))
|
12
|
+
@scope = Puppet::Parser::Scope.new(:compiler => @compiler)
|
12
13
|
|
13
14
|
@overrides = stub_everything 'overrides'
|
14
15
|
@overrides.stubs(:is_a?).with(Puppet::Parser::AST).returns(true)
|
15
|
-
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should evaluate its query" do
|
19
19
|
query = mock 'query'
|
20
20
|
collection = Puppet::Parser::AST::Collection.new :query => query, :form => :virtual
|
21
|
+
collection.type = 'mytype'
|
21
22
|
|
22
23
|
query.expects(:safeevaluate).with(@scope)
|
23
24
|
|
@@ -26,8 +27,8 @@ describe Puppet::Parser::AST::Collection do
|
|
26
27
|
|
27
28
|
it "should instantiate a Collector for this type" do
|
28
29
|
collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test"
|
29
|
-
@test_type =
|
30
|
-
@
|
30
|
+
@test_type = Puppet::Resource::Type.new(:definition, "test")
|
31
|
+
@environment.known_resource_types.add @test_type
|
31
32
|
|
32
33
|
Puppet::Parser::Collector.expects(:new).with(@scope, "test", nil, nil, :virtual)
|
33
34
|
|
@@ -35,7 +36,7 @@ describe Puppet::Parser::AST::Collection do
|
|
35
36
|
end
|
36
37
|
|
37
38
|
it "should tell the compiler about this collector" do
|
38
|
-
collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "
|
39
|
+
collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "mytype"
|
39
40
|
Puppet::Parser::Collector.stubs(:new).returns("whatever")
|
40
41
|
|
41
42
|
@compiler.expects(:add_collection).with("whatever")
|
@@ -45,7 +46,7 @@ describe Puppet::Parser::AST::Collection do
|
|
45
46
|
|
46
47
|
it "should evaluate overriden paramaters" do
|
47
48
|
collector = stub_everything 'collector'
|
48
|
-
collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "
|
49
|
+
collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "mytype", :override => @overrides
|
49
50
|
Puppet::Parser::Collector.stubs(:new).returns(collector)
|
50
51
|
|
51
52
|
@overrides.expects(:safeevaluate).with(@scope)
|
@@ -55,7 +56,7 @@ describe Puppet::Parser::AST::Collection do
|
|
55
56
|
|
56
57
|
it "should tell the collector about overrides" do
|
57
58
|
collector = mock 'collector'
|
58
|
-
collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "
|
59
|
+
collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "mytype", :override => @overrides
|
59
60
|
Puppet::Parser::Collector.stubs(:new).returns(collector)
|
60
61
|
|
61
62
|
collector.expects(:add_override)
|
@@ -63,5 +64,8 @@ describe Puppet::Parser::AST::Collection do
|
|
63
64
|
collection.evaluate(@scope)
|
64
65
|
end
|
65
66
|
|
66
|
-
|
67
|
+
it "should fail when evaluating undefined resource types" do
|
68
|
+
collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "bogus"
|
69
|
+
lambda { collection.evaluate(@scope) }.should raise_error "Resource type bogus doesn't exist"
|
70
|
+
end
|
67
71
|
end
|
@@ -529,6 +529,22 @@ describe Puppet::Parser::Lexer, "when lexing comments" do
|
|
529
529
|
@lexer.fullscan
|
530
530
|
end
|
531
531
|
|
532
|
+
it "should add a new comment stack level on LPAREN" do
|
533
|
+
@lexer.string = "("
|
534
|
+
|
535
|
+
@lexer.expects(:commentpush)
|
536
|
+
|
537
|
+
@lexer.fullscan
|
538
|
+
end
|
539
|
+
|
540
|
+
it "should pop the current comment on RPAREN" do
|
541
|
+
@lexer.string = ")"
|
542
|
+
|
543
|
+
@lexer.expects(:commentpop)
|
544
|
+
|
545
|
+
@lexer.fullscan
|
546
|
+
end
|
547
|
+
|
532
548
|
it "should return the current comments on getcomment" do
|
533
549
|
@lexer.string = "# comment"
|
534
550
|
@lexer.fullscan
|