puppet 0.24.1 → 0.24.2
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 +94 -0
- data/Rakefile +0 -4
- data/bin/puppet +18 -10
- data/bin/puppetd +1 -1
- data/bin/puppetdoc +14 -4
- data/bin/puppetmasterd +1 -1
- data/bin/puppetrun +3 -8
- data/bin/ralsh +12 -11
- data/conf/freebsd/puppetd +1 -1
- data/conf/freebsd/puppetmasterd +1 -1
- data/conf/gentoo/puppet/puppet.conf +29 -0
- data/conf/namespaceauth.conf +20 -0
- data/conf/redhat/puppet.spec +4 -1
- data/conf/solaris/smf/puppetd.xml +1 -1
- data/conf/solaris/smf/puppetmasterd.xml +1 -1
- data/conf/suse/puppet.spec +10 -8
- data/examples/root/etc/puppet/{puppetmasterd.conf → puppet.conf} +6 -3
- data/ext/logcheck/puppet +7 -0
- data/ext/puppet-test +28 -5
- data/lib/puppet.rb +2 -1
- data/lib/puppet/defaults.rb +12 -5
- data/lib/puppet/dsl.rb +43 -45
- data/lib/puppet/external/{gratr/rdot.rb → dot.rb} +0 -0
- data/lib/puppet/external/nagios.rb +50 -0
- data/lib/puppet/external/nagios/base.rb +421 -0
- data/lib/puppet/external/nagios/parser.rb +816 -0
- data/lib/puppet/file_serving/file_base.rb +16 -3
- data/lib/puppet/file_serving/metadata.rb +29 -11
- data/lib/puppet/indirector/terminus.rb +1 -0
- data/lib/puppet/metatype/closure.rb +4 -0
- data/lib/puppet/metatype/evaluation.rb +2 -17
- data/lib/puppet/metatype/metaparams.rb +1 -1
- data/lib/puppet/network.rb +3 -0
- data/lib/puppet/network/client.rb +4 -5
- data/lib/puppet/network/client/master.rb +10 -7
- data/lib/puppet/network/handler/fileserver.rb +22 -45
- data/lib/puppet/network/http_pool.rb +3 -0
- data/lib/puppet/network/http_server/mongrel.rb +7 -1
- data/lib/puppet/network/http_server/webrick.rb +4 -3
- data/lib/puppet/network/xmlrpc/client.rb +12 -1
- data/lib/puppet/node/catalog.rb +51 -40
- data/lib/puppet/parser/ast.rb +27 -49
- data/lib/puppet/parser/ast/astarray.rb +5 -24
- data/lib/puppet/parser/ast/caseopt.rb +4 -4
- data/lib/puppet/parser/ast/casestatement.rb +4 -5
- data/lib/puppet/parser/ast/collection.rb +3 -5
- data/lib/puppet/parser/ast/collexpr.rb +3 -5
- data/lib/puppet/parser/ast/definition.rb +148 -159
- data/lib/puppet/parser/ast/else.rb +2 -3
- data/lib/puppet/parser/ast/function.rb +3 -10
- data/lib/puppet/parser/ast/hostclass.rb +66 -59
- data/lib/puppet/parser/ast/ifstatement.rb +4 -5
- data/lib/puppet/parser/ast/leaf.rb +6 -6
- data/lib/puppet/parser/ast/node.rb +26 -58
- data/lib/puppet/parser/ast/resource.rb +5 -7
- data/lib/puppet/parser/ast/resource_defaults.rb +2 -4
- data/lib/puppet/parser/ast/resource_override.rb +4 -6
- data/lib/puppet/parser/ast/resource_reference.rb +2 -4
- data/lib/puppet/parser/ast/resourceparam.rb +2 -4
- data/lib/puppet/parser/ast/selector.rb +5 -6
- data/lib/puppet/parser/ast/tag.rb +2 -4
- data/lib/puppet/parser/ast/vardef.rb +3 -4
- data/lib/puppet/parser/collector.rb +5 -5
- data/lib/puppet/parser/{compile.rb → compiler.rb} +69 -107
- data/lib/puppet/parser/functions.rb +3 -3
- data/lib/puppet/parser/interpreter.rb +32 -23
- data/lib/puppet/parser/lexer.rb +391 -282
- data/lib/puppet/parser/parser.rb +5 -4
- data/lib/puppet/parser/parser_support.rb +3 -6
- data/lib/puppet/parser/resource.rb +24 -36
- data/lib/puppet/parser/resource/param.rb +1 -1
- data/lib/puppet/parser/resource/reference.rb +7 -3
- data/lib/puppet/parser/scope.rb +12 -7
- data/lib/puppet/parser/templatewrapper.rb +1 -1
- data/lib/puppet/pgraph.rb +9 -98
- data/lib/puppet/provider/interface/redhat.rb +65 -65
- data/lib/puppet/provider/mount/parsed.rb +1 -1
- data/lib/puppet/provider/naginator.rb +55 -0
- data/lib/puppet/provider/nameservice/directoryservice.rb +6 -7
- data/lib/puppet/provider/package/fink.rb +0 -2
- data/lib/puppet/provider/package/gem.rb +9 -5
- data/lib/puppet/provider/package/openbsd.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +3 -8
- data/lib/puppet/provider/package/portage.rb +4 -4
- data/lib/puppet/provider/package/yumhelper.py +8 -6
- data/lib/puppet/provider/parsedfile.rb +7 -1
- data/lib/puppet/provider/service/debian.rb +2 -0
- data/lib/puppet/provider/service/gentoo.rb +4 -0
- data/lib/puppet/provider/service/init.rb +1 -1
- data/lib/puppet/provider/sshkey/parsed.rb +2 -0
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/rails.rb +4 -0
- data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +17 -0
- data/lib/puppet/rails/fact_value.rb +4 -0
- data/lib/puppet/rails/host.rb +1 -2
- data/lib/puppet/rails/param_value.rb +4 -0
- data/lib/puppet/rails/resource_tag.rb +4 -0
- data/lib/puppet/rails/source_file.rb +4 -1
- data/lib/puppet/relationship.rb +5 -1
- data/lib/puppet/reports/tagmail.rb +12 -1
- data/lib/puppet/resource_reference.rb +1 -1
- data/lib/puppet/simple_graph.rb +78 -11
- data/lib/puppet/sslcertificates.rb +1 -1
- data/lib/puppet/sslcertificates/ca.rb +3 -3
- data/lib/puppet/transaction.rb +7 -4
- data/lib/puppet/transportable.rb +1 -1
- data/lib/puppet/type.rb +3 -10
- data/lib/puppet/type/cron.rb +18 -0
- data/lib/puppet/type/exec.rb +18 -12
- data/lib/puppet/type/{pfile.rb → file.rb} +66 -84
- data/lib/puppet/type/file/checksum.rb +271 -0
- data/lib/puppet/type/{pfile → file}/content.rb +10 -15
- data/lib/puppet/type/{pfile → file}/ensure.rb +15 -8
- data/lib/puppet/type/{pfile → file}/group.rb +0 -0
- data/lib/puppet/type/{pfile → file}/mode.rb +0 -0
- data/lib/puppet/type/{pfile → file}/owner.rb +0 -0
- data/lib/puppet/type/{pfile → file}/source.rb +34 -48
- data/lib/puppet/type/{pfile → file}/target.rb +0 -0
- data/lib/puppet/type/{pfile → file}/type.rb +0 -0
- data/lib/puppet/type/{pfilebucket.rb → filebucket.rb} +0 -0
- data/lib/puppet/type/host.rb +13 -0
- data/lib/puppet/type/mailalias.rb +1 -1
- data/lib/puppet/type/nagios_command.rb +3 -0
- data/lib/puppet/type/nagios_contact.rb +3 -0
- data/lib/puppet/type/nagios_contactgroup.rb +3 -0
- data/lib/puppet/type/nagios_host.rb +3 -0
- data/lib/puppet/type/nagios_hostextinfo.rb +3 -0
- data/lib/puppet/type/nagios_hostgroup.rb +3 -0
- data/lib/puppet/type/nagios_hostgroupescalation.rb +3 -0
- data/lib/puppet/type/nagios_service.rb +3 -0
- data/lib/puppet/type/nagios_servicedependency.rb +3 -0
- data/lib/puppet/type/nagios_serviceescalation.rb +3 -0
- data/lib/puppet/type/nagios_serviceextinfo.rb +3 -0
- data/lib/puppet/type/nagios_timeperiod.rb +3 -0
- data/lib/puppet/type/package.rb +4 -12
- data/lib/puppet/type/service.rb +9 -0
- data/lib/puppet/type/sshkey.rb +3 -3
- data/lib/puppet/util/autoload.rb +5 -5
- data/lib/puppet/util/checksums.rb +51 -13
- data/lib/puppet/util/constant_inflector.rb +14 -0
- data/lib/puppet/util/filetype.rb +1 -1
- data/lib/puppet/util/graph.rb +3 -9
- data/lib/puppet/util/nagios_maker.rb +57 -0
- data/lib/puppet/util/settings.rb +19 -16
- data/lib/puppet/util/tagging.rb +39 -0
- data/test/executables/puppetbin.rb +17 -0
- data/test/language/ast.rb +8 -58
- data/test/language/ast/casestatement.rb +3 -3
- data/test/language/ast/resource.rb +6 -7
- data/test/language/ast/resource_reference.rb +12 -12
- data/test/language/ast/selector.rb +2 -2
- data/test/language/ast/variable.rb +2 -2
- data/test/language/functions.rb +24 -24
- data/test/language/parser.rb +20 -8
- data/test/language/resource.rb +5 -42
- data/test/language/scope.rb +21 -37
- data/test/language/snippets.rb +7 -0
- data/test/lib/puppettest.rb +28 -14
- data/test/lib/puppettest/parsertesting.rb +10 -10
- data/test/lib/puppettest/support/resources.rb +1 -1
- data/test/network/client/master.rb +10 -0
- data/test/network/handler/fileserver.rb +51 -49
- data/test/network/server/webrick.rb +1 -1
- data/test/other/dsl.rb +3 -4
- data/test/other/transactions.rb +6 -4
- data/test/rails/ast.rb +2 -2
- data/test/rails/configuration.rb +1 -1
- data/test/rails/railsparameter.rb +2 -0
- data/test/rails/railsresource.rb +1 -0
- data/test/ral/manager/type.rb +4 -4
- data/test/ral/providers/cron/crontab.rb +3 -1
- data/test/ral/providers/package.rb +1 -1
- data/test/ral/{types → type}/basic.rb +2 -2
- data/test/ral/{types → type}/cron.rb +0 -0
- data/test/ral/{types → type}/exec.rb +42 -2
- data/test/ral/{types → type}/file.rb +34 -79
- data/test/ral/{types → type}/file/target.rb +0 -0
- data/test/ral/{types → type}/filebucket.rb +0 -0
- data/test/ral/{types → type}/fileignoresource.rb +0 -0
- data/test/ral/{types → type}/filesources.rb +8 -27
- data/test/ral/{types → type}/group.rb +0 -0
- data/test/ral/{types → type}/host.rb +16 -0
- data/test/ral/{types → type}/mailalias.rb +0 -0
- data/test/ral/{types → type}/parameter.rb +0 -0
- data/test/ral/{types → type}/port.rb +0 -0
- data/test/ral/{types → type}/property.rb +0 -0
- data/test/ral/{types → type}/resources.rb +0 -0
- data/test/ral/{types → type}/service.rb +0 -0
- data/test/ral/{types → type}/sshkey.rb +0 -0
- data/test/ral/{types → type}/tidy.rb +1 -0
- data/test/ral/{types → type}/user.rb +0 -0
- data/test/ral/{types → type}/yumrepo.rb +0 -0
- data/test/ral/{types → type}/zone.rb +0 -0
- data/test/util/autoload.rb +24 -5
- metadata +60 -107
- data/conf/gentoo/puppet/puppetca.conf +0 -29
- data/conf/gentoo/puppet/puppetd.conf +0 -29
- data/conf/gentoo/puppet/puppetmasterd.conf +0 -29
- data/examples/root/etc/puppet/puppetd.conf +0 -4
- data/lib/puppet/external/gratr.rb +0 -33
- data/lib/puppet/external/gratr/adjacency_graph.rb +0 -257
- data/lib/puppet/external/gratr/base.rb +0 -34
- data/lib/puppet/external/gratr/biconnected.rb +0 -116
- data/lib/puppet/external/gratr/chinese_postman.rb +0 -123
- data/lib/puppet/external/gratr/common.rb +0 -73
- data/lib/puppet/external/gratr/comparability.rb +0 -92
- data/lib/puppet/external/gratr/digraph.rb +0 -116
- data/lib/puppet/external/gratr/digraph_distance.rb +0 -185
- data/lib/puppet/external/gratr/dot.rb +0 -90
- data/lib/puppet/external/gratr/edge.rb +0 -145
- data/lib/puppet/external/gratr/graph.rb +0 -303
- data/lib/puppet/external/gratr/graph_api.rb +0 -83
- data/lib/puppet/external/gratr/import.rb +0 -44
- data/lib/puppet/external/gratr/labels.rb +0 -90
- data/lib/puppet/external/gratr/maximum_flow.rb +0 -64
- data/lib/puppet/external/gratr/search.rb +0 -409
- data/lib/puppet/external/gratr/strong_components.rb +0 -127
- data/lib/puppet/external/gratr/undirected_graph.rb +0 -153
- data/lib/puppet/rails/external/tagging/acts_as_taggable.rb +0 -62
- data/lib/puppet/rails/external/tagging/init.rb +0 -5
- data/lib/puppet/rails/external/tagging/tag.rb +0 -50
- data/lib/puppet/rails/external/tagging/tagging.rb +0 -12
- data/lib/puppet/rails/puppet_class.rb +0 -6
- data/lib/puppet/reference/node_source.rb +0 -9
- data/lib/puppet/reference/report.rb +0 -21
- data/lib/puppet/type/pfile/checksum.rb +0 -326
- data/test/language/ast/definition.rb +0 -166
- data/test/language/ast/hostclass.rb +0 -184
- data/test/language/compile.rb +0 -569
- data/test/language/lexer.rb +0 -276
- data/test/lib/mocha.rb +0 -19
- data/test/lib/mocha/any_instance_method.rb +0 -35
- data/test/lib/mocha/auto_verify.rb +0 -113
- data/test/lib/mocha/central.rb +0 -35
- data/test/lib/mocha/class_method.rb +0 -62
- data/test/lib/mocha/deprecation.rb +0 -22
- data/test/lib/mocha/exception_raiser.rb +0 -17
- data/test/lib/mocha/expectation.rb +0 -378
- data/test/lib/mocha/expectation_error.rb +0 -6
- data/test/lib/mocha/infinite_range.rb +0 -25
- data/test/lib/mocha/inspect.rb +0 -39
- data/test/lib/mocha/instance_method.rb +0 -8
- data/test/lib/mocha/is_a.rb +0 -9
- data/test/lib/mocha/metaclass.rb +0 -7
- data/test/lib/mocha/missing_expectation.rb +0 -27
- data/test/lib/mocha/mock.rb +0 -207
- data/test/lib/mocha/multiple_yields.rb +0 -20
- data/test/lib/mocha/no_yields.rb +0 -11
- data/test/lib/mocha/object.rb +0 -110
- data/test/lib/mocha/parameter_matchers.rb +0 -9
- data/test/lib/mocha/parameter_matchers/all_of.rb +0 -39
- data/test/lib/mocha/parameter_matchers/any_of.rb +0 -44
- data/test/lib/mocha/parameter_matchers/anything.rb +0 -30
- data/test/lib/mocha/parameter_matchers/has_entry.rb +0 -39
- data/test/lib/mocha/parameter_matchers/has_key.rb +0 -39
- data/test/lib/mocha/parameter_matchers/has_value.rb +0 -39
- data/test/lib/mocha/parameter_matchers/includes.rb +0 -37
- data/test/lib/mocha/pretty_parameters.rb +0 -28
- data/test/lib/mocha/return_values.rb +0 -31
- data/test/lib/mocha/setup_and_teardown.rb +0 -23
- data/test/lib/mocha/single_return_value.rb +0 -24
- data/test/lib/mocha/single_yield.rb +0 -18
- data/test/lib/mocha/standalone.rb +0 -32
- data/test/lib/mocha/stub.rb +0 -18
- data/test/lib/mocha/test_case_adapter.rb +0 -49
- data/test/lib/mocha/yield_parameters.rb +0 -31
@@ -45,7 +45,7 @@ class TestCaseStatement < Test::Unit::TestCase
|
|
45
45
|
|
46
46
|
result = nil
|
47
47
|
assert_nothing_raised do
|
48
|
-
result = ast.evaluate
|
48
|
+
result = ast.evaluate scope
|
49
49
|
end
|
50
50
|
assert(result, "did not get valid result")
|
51
51
|
assert_equal(["upper"], $evaluated, "Did not match case-sensitively")
|
@@ -56,7 +56,7 @@ class TestCaseStatement < Test::Unit::TestCase
|
|
56
56
|
$evaluated.clear
|
57
57
|
hash["MyParam"].reset
|
58
58
|
assert_nothing_raised do
|
59
|
-
result = ast.evaluate
|
59
|
+
result = ast.evaluate scope
|
60
60
|
end
|
61
61
|
assert(result, "did not get valid result")
|
62
62
|
assert_equal(["lower"], result, "Did not match case-insensitively")
|
@@ -92,7 +92,7 @@ class TestCaseStatement < Test::Unit::TestCase
|
|
92
92
|
scope = mkscope
|
93
93
|
scope.setvar("testparam", value)
|
94
94
|
assert_nothing_raised do
|
95
|
-
result = ast.evaluate(
|
95
|
+
result = ast.evaluate(scope)
|
96
96
|
end
|
97
97
|
|
98
98
|
assert_equal(should, result, "Got incorrect result for %s" % value)
|
@@ -16,8 +16,7 @@ class TestASTResource< Test::Unit::TestCase
|
|
16
16
|
def setup
|
17
17
|
super
|
18
18
|
@scope = mkscope
|
19
|
-
@parser = @scope.
|
20
|
-
@scope.compile.send(:evaluate_main)
|
19
|
+
@parser = @scope.compiler.parser
|
21
20
|
end
|
22
21
|
|
23
22
|
def newdef(type, title, params = nil)
|
@@ -36,24 +35,24 @@ class TestASTResource< Test::Unit::TestCase
|
|
36
35
|
title = "title"
|
37
36
|
|
38
37
|
# First try a qualified type
|
39
|
-
assert_equal("One::Two", newdef("two", title).evaluate(
|
38
|
+
assert_equal("One::Two", newdef("two", title).evaluate(twoscope)[0].type,
|
40
39
|
"Defined type was not made fully qualified")
|
41
40
|
|
42
41
|
# Then try a type that does not need to be qualified
|
43
|
-
assert_equal("One", newdef("one", title).evaluate(
|
42
|
+
assert_equal("One", newdef("one", title).evaluate(twoscope)[0].type,
|
44
43
|
"Unqualified defined type was not handled correctly")
|
45
44
|
|
46
45
|
# Then an unqualified type from within the one namespace
|
47
|
-
assert_equal("Three", newdef("three", title).evaluate(
|
46
|
+
assert_equal("Three", newdef("three", title).evaluate(twoscope)[0].type,
|
48
47
|
"Defined type was not made fully qualified")
|
49
48
|
|
50
49
|
# Then a builtin type
|
51
|
-
assert_equal("File", newdef("file", title).evaluate(
|
50
|
+
assert_equal("File", newdef("file", title).evaluate(twoscope)[0].type,
|
52
51
|
"Builtin type was not handled correctly")
|
53
52
|
|
54
53
|
# Now try a type that does not exist, which should throw an error.
|
55
54
|
assert_raise(Puppet::ParseError, "Did not fail on a missing type in a resource reference") do
|
56
|
-
newdef("nosuchtype", title).evaluate(
|
55
|
+
newdef("nosuchtype", title).evaluate(twoscope)
|
57
56
|
end
|
58
57
|
end
|
59
58
|
end
|
@@ -20,7 +20,7 @@ class TestASTResourceReference < Test::Unit::TestCase
|
|
20
20
|
def setup
|
21
21
|
super
|
22
22
|
@scope = mkscope
|
23
|
-
@parser = @scope.
|
23
|
+
@parser = @scope.compiler.parser
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_evaluate
|
@@ -31,7 +31,7 @@ class TestASTResourceReference < Test::Unit::TestCase
|
|
31
31
|
|
32
32
|
evaled = nil
|
33
33
|
assert_nothing_raised("Could not evaluate resource ref") do
|
34
|
-
evaled = ref.evaluate(
|
34
|
+
evaled = ref.evaluate(@scope)
|
35
35
|
end
|
36
36
|
|
37
37
|
assert_equal(type, evaled.type, "Type did not translate correctly")
|
@@ -44,7 +44,7 @@ class TestASTResourceReference < Test::Unit::TestCase
|
|
44
44
|
ref = newref("Class", "one")
|
45
45
|
evaled = nil
|
46
46
|
assert_nothing_raised("Could not evaluate resource ref") do
|
47
|
-
evaled = ref.evaluate(
|
47
|
+
evaled = ref.evaluate(@scope)
|
48
48
|
end
|
49
49
|
|
50
50
|
assert_equal("Class", evaled.type, "Did not set type to 'class'")
|
@@ -61,24 +61,24 @@ class TestASTResourceReference < Test::Unit::TestCase
|
|
61
61
|
title = "title"
|
62
62
|
|
63
63
|
# First try a qualified type
|
64
|
-
assert_equal("One::Two", newref("two", title).evaluate(
|
64
|
+
assert_equal("One::Two", newref("two", title).evaluate(twoscope).type,
|
65
65
|
"Defined type was not made fully qualified")
|
66
66
|
|
67
67
|
# Then try a type that does not need to be qualified
|
68
|
-
assert_equal("One", newref("one", title).evaluate(
|
68
|
+
assert_equal("One", newref("one", title).evaluate(twoscope).type,
|
69
69
|
"Unqualified defined type was not handled correctly")
|
70
70
|
|
71
71
|
# Then an unqualified type from within the one namespace
|
72
|
-
assert_equal("Three", newref("three", title).evaluate(
|
72
|
+
assert_equal("Three", newref("three", title).evaluate(twoscope).type,
|
73
73
|
"Defined type was not made fully qualified")
|
74
74
|
|
75
75
|
# Then a builtin type
|
76
|
-
assert_equal("File", newref("file", title).evaluate(
|
76
|
+
assert_equal("File", newref("file", title).evaluate(twoscope).type,
|
77
77
|
"Builtin type was not handled correctly")
|
78
78
|
|
79
79
|
# Now try a type that does not exist, which should throw an error.
|
80
80
|
assert_raise(Puppet::ParseError, "Did not fail on a missing type in a resource reference") do
|
81
|
-
newref("nosuchtype", title).evaluate(
|
81
|
+
newref("nosuchtype", title).evaluate(twoscope)
|
82
82
|
end
|
83
83
|
|
84
84
|
# Now run the same tests, but with the classes
|
@@ -86,20 +86,20 @@ class TestASTResourceReference < Test::Unit::TestCase
|
|
86
86
|
@parser.newclass "one::five"
|
87
87
|
|
88
88
|
# First try an unqualified type
|
89
|
-
assert_equal("four", newref("class", "four").evaluate(
|
89
|
+
assert_equal("four", newref("class", "four").evaluate(twoscope).title,
|
90
90
|
"Unqualified class was not found")
|
91
91
|
|
92
92
|
# Then a qualified class
|
93
|
-
assert_equal("one::five", newref("class", "five").evaluate(
|
93
|
+
assert_equal("one::five", newref("class", "five").evaluate(twoscope).title,
|
94
94
|
"Class was not made fully qualified")
|
95
95
|
|
96
96
|
# Then try a type that does not need to be qualified
|
97
|
-
assert_equal("four", newref("class", "four").evaluate(
|
97
|
+
assert_equal("four", newref("class", "four").evaluate(twoscope).title,
|
98
98
|
"Unqualified class was not handled correctly")
|
99
99
|
|
100
100
|
# Now try a type that does not exist, which should throw an error.
|
101
101
|
assert_raise(Puppet::ParseError, "Did not fail on a missing type in a resource reference") do
|
102
|
-
newref("class", "nosuchclass").evaluate(
|
102
|
+
newref("class", "nosuchclass").evaluate(twoscope)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
@@ -37,7 +37,7 @@ class TestSelector < Test::Unit::TestCase
|
|
37
37
|
params = maker.call()
|
38
38
|
sel = AST::Selector.new(:param => param, :values => params.values)
|
39
39
|
result = nil
|
40
|
-
assert_nothing_raised { result = sel.evaluate(
|
40
|
+
assert_nothing_raised { result = sel.evaluate(scope) }
|
41
41
|
assert_equal(should[str], result, "did not case-sensitively match %s" % str)
|
42
42
|
end
|
43
43
|
|
@@ -53,7 +53,7 @@ class TestSelector < Test::Unit::TestCase
|
|
53
53
|
params.delete(:upper)
|
54
54
|
sel = AST::Selector.new(:param => param, :values => params.values)
|
55
55
|
result = nil
|
56
|
-
assert_nothing_raised { result = sel.evaluate(
|
56
|
+
assert_nothing_raised { result = sel.evaluate(scope) }
|
57
57
|
assert_equal("lower", result, "did not case-insensitively match %s" % str)
|
58
58
|
end
|
59
59
|
end
|
@@ -22,9 +22,9 @@ class TestVariable < Test::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_evaluate
|
25
|
-
assert_equal("", @var.evaluate(
|
25
|
+
assert_equal("", @var.evaluate(@scope), "did not return empty string on unset var")
|
26
26
|
@scope.setvar(@name, "something")
|
27
|
-
assert_equal("something", @var.evaluate(
|
27
|
+
assert_equal("something", @var.evaluate(@scope), "incorrect variable value")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
data/test/language/functions.rb
CHANGED
@@ -41,7 +41,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
41
41
|
scope = mkscope
|
42
42
|
val = nil
|
43
43
|
assert_nothing_raised do
|
44
|
-
val = func.evaluate(
|
44
|
+
val = func.evaluate(scope)
|
45
45
|
end
|
46
46
|
|
47
47
|
assert_equal("output avalue", val)
|
@@ -57,7 +57,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
57
57
|
|
58
58
|
val = nil
|
59
59
|
assert_nothing_raised do
|
60
|
-
val = func.evaluate(
|
60
|
+
val = func.evaluate(scope)
|
61
61
|
end
|
62
62
|
|
63
63
|
assert_equal(retval, val, "'tagged' returned %s for %s" % [val, tag])
|
@@ -66,7 +66,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
66
66
|
# Now make sure we correctly get tags.
|
67
67
|
scope.resource.tag("resourcetag")
|
68
68
|
assert(scope.function_tagged("resourcetag"), "tagged function did not catch resource tags")
|
69
|
-
scope.
|
69
|
+
scope.compiler.catalog.tag("configtag")
|
70
70
|
assert(scope.function_tagged("configtag"), "tagged function did not catch catalog tags")
|
71
71
|
end
|
72
72
|
|
@@ -86,7 +86,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
86
86
|
scope = mkscope
|
87
87
|
val = nil
|
88
88
|
assert_raise(Puppet::ParseError) do
|
89
|
-
val = func.evaluate(
|
89
|
+
val = func.evaluate(scope)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -117,16 +117,16 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
117
117
|
|
118
118
|
scope = mkscope
|
119
119
|
assert_raise(Puppet::ParseError) do
|
120
|
-
ast.evaluate(
|
120
|
+
ast.evaluate(scope)
|
121
121
|
end
|
122
122
|
|
123
123
|
scope.setvar("one", "One")
|
124
124
|
assert_raise(Puppet::ParseError) do
|
125
|
-
ast.evaluate(
|
125
|
+
ast.evaluate(scope)
|
126
126
|
end
|
127
127
|
scope.setvar("two", "Two")
|
128
128
|
assert_nothing_raised do
|
129
|
-
ast.evaluate(
|
129
|
+
ast.evaluate(scope)
|
130
130
|
end
|
131
131
|
|
132
132
|
assert_equal("template One\ntemplate Two\n", scope.lookupvar("output"),
|
@@ -155,13 +155,13 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
155
155
|
|
156
156
|
scope = mkscope
|
157
157
|
assert_raise(Puppet::ParseError) do
|
158
|
-
ast.evaluate(
|
158
|
+
ast.evaluate(scope)
|
159
159
|
end
|
160
160
|
|
161
161
|
scope.setvar("yayness", "this is yayness")
|
162
162
|
|
163
163
|
assert_nothing_raised do
|
164
|
-
ast.evaluate(
|
164
|
+
ast.evaluate(scope)
|
165
165
|
end
|
166
166
|
|
167
167
|
assert_equal("template this is yayness\n", scope.lookupvar("output"),
|
@@ -191,7 +191,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
191
191
|
scope = mkscope
|
192
192
|
scope.setvar("myvar", "this is yayness")
|
193
193
|
assert_raise(Puppet::ParseError) do
|
194
|
-
ast.evaluate(
|
194
|
+
ast.evaluate(scope)
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
@@ -264,14 +264,14 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
264
264
|
}.each do |string, value|
|
265
265
|
scope = mkscope
|
266
266
|
assert_raise(Puppet::ParseError) do
|
267
|
-
ast.evaluate(
|
267
|
+
ast.evaluate(scope)
|
268
268
|
end
|
269
269
|
|
270
270
|
scope.setvar("yayness", string)
|
271
271
|
assert_equal(string, scope.lookupvar("yayness", false))
|
272
272
|
|
273
273
|
assert_nothing_raised("An empty string was not a valid variable value") do
|
274
|
-
ast.evaluate(
|
274
|
+
ast.evaluate(scope)
|
275
275
|
end
|
276
276
|
|
277
277
|
assert_equal("template #{value}\n", scope.lookupvar("output"),
|
@@ -308,7 +308,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
308
308
|
|
309
309
|
def test_realize
|
310
310
|
scope = mkscope
|
311
|
-
parser = scope.
|
311
|
+
parser = scope.compiler.parser
|
312
312
|
|
313
313
|
# Make a definition
|
314
314
|
parser.newdefine("mytype")
|
@@ -318,7 +318,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
318
318
|
virtual = mkresource(:type => type, :title => title,
|
319
319
|
:virtual => true, :params => {}, :scope => scope)
|
320
320
|
|
321
|
-
scope.
|
321
|
+
scope.compiler.add_resource(scope, virtual)
|
322
322
|
|
323
323
|
ref = Puppet::Parser::Resource::Reference.new(
|
324
324
|
:type => type, :title => title,
|
@@ -330,13 +330,13 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
330
330
|
end
|
331
331
|
|
332
332
|
# Make sure it created a collection
|
333
|
-
assert_equal(1, scope.
|
333
|
+
assert_equal(1, scope.compiler.collections.length,
|
334
334
|
"Did not set collection")
|
335
335
|
|
336
336
|
assert_nothing_raised do
|
337
|
-
scope.
|
337
|
+
scope.compiler.collections.each do |coll| coll.evaluate end
|
338
338
|
end
|
339
|
-
scope.
|
339
|
+
scope.compiler.collections.clear
|
340
340
|
|
341
341
|
# Now make sure the virtual resource is no longer virtual
|
342
342
|
assert(! virtual.virtual?, "Did not make virtual resource real")
|
@@ -354,17 +354,17 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
354
354
|
end
|
355
355
|
|
356
356
|
# Make sure it created a collection
|
357
|
-
assert_equal(1, scope.
|
357
|
+
assert_equal(1, scope.compiler.collections.length,
|
358
358
|
"Did not set collection")
|
359
359
|
|
360
360
|
# And the collection has our resource in it
|
361
|
-
assert_equal([none.to_s], scope.
|
361
|
+
assert_equal([none.to_s], scope.compiler.collections[0].resources,
|
362
362
|
"Did not set resources in collection")
|
363
363
|
end
|
364
364
|
|
365
365
|
def test_defined
|
366
366
|
scope = mkscope
|
367
|
-
parser = scope.
|
367
|
+
parser = scope.compiler.parser
|
368
368
|
|
369
369
|
parser.newclass("yayness")
|
370
370
|
parser.newdefine("rahness")
|
@@ -385,7 +385,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
385
385
|
"Multiple falses were somehow true")
|
386
386
|
|
387
387
|
# Now make sure we can test resources
|
388
|
-
scope.
|
388
|
+
scope.compiler.add_resource(scope, mkresource(:type => "file", :title => "/tmp/rahness",
|
389
389
|
:scope => scope, :source => scope.source,
|
390
390
|
:params => {:owner => "root"}))
|
391
391
|
|
@@ -420,7 +420,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
420
420
|
|
421
421
|
def test_include
|
422
422
|
scope = mkscope
|
423
|
-
parser = scope.
|
423
|
+
parser = scope.compiler.parser
|
424
424
|
|
425
425
|
assert_raise(Puppet::ParseError, "did not throw error on missing class") do
|
426
426
|
scope.function_include("nosuchclass")
|
@@ -428,7 +428,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
428
428
|
|
429
429
|
parser.newclass("myclass")
|
430
430
|
|
431
|
-
scope.
|
431
|
+
scope.compiler.expects(:evaluate_classes).with(%w{myclass otherclass}, scope, false).returns(%w{myclass otherclass})
|
432
432
|
|
433
433
|
assert_nothing_raised do
|
434
434
|
scope.function_include(["myclass", "otherclass"])
|
@@ -480,7 +480,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
480
480
|
assert_equal("yay-foo\n", %x{#{command} foo}, "command did not work")
|
481
481
|
|
482
482
|
scope = mkscope
|
483
|
-
parser = scope.
|
483
|
+
parser = scope.compiler.parser
|
484
484
|
|
485
485
|
val = nil
|
486
486
|
assert_nothing_raised("Could not call generator with no args") do
|
data/test/language/parser.rb
CHANGED
@@ -45,9 +45,9 @@ class TestParser < Test::Unit::TestCase
|
|
45
45
|
assert_raise(Puppet::ParseError, "Did not fail while parsing %s" % file) {
|
46
46
|
parser.file = file
|
47
47
|
ast = parser.parse
|
48
|
-
config =
|
48
|
+
config = mkcompiler(parser)
|
49
49
|
config.compile
|
50
|
-
#ast.classes[""].evaluate
|
50
|
+
#ast.classes[""].evaluate config.topscope
|
51
51
|
}
|
52
52
|
Puppet::Type.allclear
|
53
53
|
}
|
@@ -868,7 +868,7 @@ file { "/tmp/yayness":
|
|
868
868
|
|
869
869
|
def test_newclass
|
870
870
|
scope = mkscope
|
871
|
-
parser = scope.
|
871
|
+
parser = scope.compiler.parser
|
872
872
|
|
873
873
|
mkcode = proc do |ary|
|
874
874
|
classes = ary.collect do |string|
|
@@ -891,7 +891,7 @@ file { "/tmp/yayness":
|
|
891
891
|
assert(parser.classes["myclass"], "Could not find definition")
|
892
892
|
assert_equal("myclass", parser.classes["myclass"].classname)
|
893
893
|
assert_equal(%w{original code},
|
894
|
-
parser.classes["myclass"].code.evaluate(
|
894
|
+
parser.classes["myclass"].code.evaluate(scope))
|
895
895
|
|
896
896
|
# Newclass behaves differently than the others -- it just appends
|
897
897
|
# the code to the existing class.
|
@@ -901,7 +901,7 @@ file { "/tmp/yayness":
|
|
901
901
|
end
|
902
902
|
assert(klass, "Did not return class when appending")
|
903
903
|
assert_equal(%w{original code something new},
|
904
|
-
parser.classes["myclass"].code.evaluate(
|
904
|
+
parser.classes["myclass"].code.evaluate(scope))
|
905
905
|
|
906
906
|
# Now create the same class name in a different scope
|
907
907
|
assert_nothing_raised {
|
@@ -914,7 +914,7 @@ file { "/tmp/yayness":
|
|
914
914
|
assert_equal("other::myclass", other.classname)
|
915
915
|
assert_equal("other::myclass", other.namespace)
|
916
916
|
assert_equal(%w{something diff},
|
917
|
-
other.code.evaluate(
|
917
|
+
other.code.evaluate(scope))
|
918
918
|
|
919
919
|
# Make sure newclass deals correctly with nodes with no code
|
920
920
|
klass = parser.newclass("nocode")
|
@@ -925,7 +925,7 @@ file { "/tmp/yayness":
|
|
925
925
|
end
|
926
926
|
assert(klass, "Did not return class with no code")
|
927
927
|
assert_equal(%w{yay test},
|
928
|
-
parser.classes["nocode"].code.evaluate(
|
928
|
+
parser.classes["nocode"].code.evaluate(scope))
|
929
929
|
|
930
930
|
# Then try merging something into nothing
|
931
931
|
parser.newclass("nocode2", :code => mkcode.call(%w{foo test}))
|
@@ -936,7 +936,7 @@ file { "/tmp/yayness":
|
|
936
936
|
end
|
937
937
|
assert(klass, "Did not return class with no code")
|
938
938
|
assert_equal(%w{foo test},
|
939
|
-
parser.classes["nocode2"].code.evaluate(
|
939
|
+
parser.classes["nocode2"].code.evaluate(scope))
|
940
940
|
|
941
941
|
# And lastly, nothing and nothing
|
942
942
|
klass = parser.newclass("nocode3")
|
@@ -1188,5 +1188,17 @@ file { "/tmp/yayness":
|
|
1188
1188
|
assert_equal(result, parser.finddefine("", "fUntEst"),
|
1189
1189
|
"%s was not matched" % "fUntEst")
|
1190
1190
|
end
|
1191
|
+
|
1192
|
+
def test_manifests_with_multiple_environments
|
1193
|
+
parser = mkparser :environment => "something"
|
1194
|
+
|
1195
|
+
# We use an exception to cut short the processing to simplify our stubbing
|
1196
|
+
#Puppet::Module.expects(:find_manifests).with("test", {:cwd => ".", :environment => "something"}).raises(Puppet::ParseError)
|
1197
|
+
Puppet::Module.expects(:find_manifests).with("test", {:cwd => ".", :environment => "something"}).returns([])
|
1198
|
+
|
1199
|
+
assert_raise(Puppet::ImportError) do
|
1200
|
+
parser.import("test")
|
1201
|
+
end
|
1202
|
+
end
|
1191
1203
|
end
|
1192
1204
|
|
data/test/language/resource.rb
CHANGED
@@ -106,7 +106,6 @@ class TestResource < PuppetTest::TestCase
|
|
106
106
|
|
107
107
|
def test_finish
|
108
108
|
res = mkresource
|
109
|
-
res.expects(:add_overrides)
|
110
109
|
res.expects(:add_defaults)
|
111
110
|
res.expects(:add_metaparams)
|
112
111
|
res.expects(:validate)
|
@@ -266,48 +265,12 @@ class TestResource < PuppetTest::TestCase
|
|
266
265
|
ref.expects(:definedtype).returns(type)
|
267
266
|
res.expects(:finish)
|
268
267
|
res.scope = mock("scope")
|
269
|
-
config = mock("config")
|
270
|
-
res.scope.expects(:compile).returns(config)
|
271
|
-
config.expects(:delete_resource).with(res)
|
272
268
|
|
273
|
-
|
274
|
-
type.expects(:evaluate).with(args)
|
269
|
+
type.expects(:evaluate_code).with(res)
|
275
270
|
|
276
271
|
res.evaluate
|
277
272
|
end
|
278
273
|
|
279
|
-
def test_add_overrides
|
280
|
-
# Try it with nil
|
281
|
-
res = mkresource
|
282
|
-
res.scope = mock('scope')
|
283
|
-
config = mock("config")
|
284
|
-
res.scope.expects(:compile).returns(config)
|
285
|
-
config.expects(:resource_overrides).with(res).returns(nil)
|
286
|
-
res.expects(:merge).never
|
287
|
-
res.send(:add_overrides)
|
288
|
-
|
289
|
-
# And an empty array
|
290
|
-
res = mkresource
|
291
|
-
res.scope = mock('scope')
|
292
|
-
config = mock("config")
|
293
|
-
res.scope.expects(:compile).returns(config)
|
294
|
-
config.expects(:resource_overrides).with(res).returns([])
|
295
|
-
res.expects(:merge).never
|
296
|
-
res.send(:add_overrides)
|
297
|
-
|
298
|
-
# And with some overrides
|
299
|
-
res = mkresource
|
300
|
-
res.scope = mock('scope')
|
301
|
-
config = mock("config")
|
302
|
-
res.scope.expects(:compile).returns(config)
|
303
|
-
returns = %w{a b}
|
304
|
-
config.expects(:resource_overrides).with(res).returns(returns)
|
305
|
-
res.expects(:merge).with("a")
|
306
|
-
res.expects(:merge).with("b")
|
307
|
-
res.send(:add_overrides)
|
308
|
-
assert(returns.empty?, "Did not clear overrides")
|
309
|
-
end
|
310
|
-
|
311
274
|
def test_proxymethods
|
312
275
|
res = Parser::Resource.new :type => "evaltest", :title => "yay",
|
313
276
|
:source => mock("source"), :scope => mkscope
|
@@ -378,7 +341,7 @@ class TestResource < PuppetTest::TestCase
|
|
378
341
|
{:name => "one", :title => "two"},
|
379
342
|
{:title => "three"},
|
380
343
|
].each do |hash|
|
381
|
-
config =
|
344
|
+
config = mkcompiler parser
|
382
345
|
args = {:type => "yayness", :title => hash[:title],
|
383
346
|
:source => klass, :scope => config.topscope}
|
384
347
|
if hash[:name]
|
@@ -425,7 +388,7 @@ class TestResource < PuppetTest::TestCase
|
|
425
388
|
:code => resourcedef("file", varref("name"),
|
426
389
|
"mode" => "644"))
|
427
390
|
|
428
|
-
config =
|
391
|
+
config = mkcompiler(parser)
|
429
392
|
|
430
393
|
res = mkresource :type => "yayness", :title => "foo", :params => {}, :scope => config.topscope
|
431
394
|
res.virtual = true
|
@@ -464,8 +427,8 @@ class TestResource < PuppetTest::TestCase
|
|
464
427
|
scope = stub 'scope', :resource => scope_resource
|
465
428
|
resource = Puppet::Parser::Resource.new(:type => "file", :title => "yay", :scope => scope, :source => mock('source'))
|
466
429
|
|
467
|
-
# Make sure we get the
|
468
|
-
%w{
|
430
|
+
# Make sure we get the type and title
|
431
|
+
%w{yay file}.each do |tag|
|
469
432
|
assert(resource.tags.include?(tag), "Did not tag resource with %s" % tag)
|
470
433
|
end
|
471
434
|
|