puppet 0.24.4 → 0.24.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.
- data/CHANGELOG +170 -0
- data/Rakefile +6 -4
- data/bin/filebucket +3 -2
- data/bin/puppet +7 -4
- data/bin/puppetca +32 -14
- data/bin/puppetd +12 -34
- data/bin/puppetmasterd +3 -2
- data/bin/puppetrun +5 -43
- data/bin/ralsh +2 -2
- data/conf/debian/README.source +2 -0
- data/conf/debian/TODO.Debian +1 -0
- data/conf/debian/changelog +257 -0
- data/conf/debian/compat +1 -0
- data/conf/debian/control +45 -0
- data/conf/debian/copyright +17 -0
- data/conf/debian/docs +1 -0
- data/conf/debian/fileserver.conf +12 -0
- data/conf/debian/puppet.NEWS +63 -0
- data/conf/debian/puppet.conf +8 -0
- data/conf/debian/puppet.dirs +7 -0
- data/conf/debian/puppet.files +6 -0
- data/conf/debian/puppet.init +64 -0
- data/conf/debian/puppet.logrotate +11 -0
- data/conf/debian/puppet.postinst +9 -0
- data/conf/debian/puppet.postrm +21 -0
- data/conf/debian/puppet.preinst +25 -0
- data/conf/debian/puppetmaster.files +4 -0
- data/conf/debian/puppetmaster.init +58 -0
- data/conf/debian/rules +115 -0
- data/conf/debian/watch +2 -0
- data/conf/gentoo/init.d/puppet +1 -1
- data/conf/gentoo/init.d/puppetmaster +32 -31
- data/conf/redhat/client.init +10 -2
- data/conf/redhat/puppet.spec +4 -1
- data/conf/redhat/server.init +9 -1
- data/examples/{code/allatonce → allatonce} +0 -0
- data/examples/{code/assignments → assignments} +0 -0
- data/examples/{code/components → components} +0 -0
- data/examples/{root/etc → etc}/init.d/sleeper +0 -0
- data/examples/{root/etc → etc}/otherfile +0 -0
- data/examples/{root/etc → etc}/puppet/fileserver.conf +0 -0
- data/examples/{root/etc → etc}/puppet/namespaceauth.conf +0 -0
- data/examples/{root/etc → etc}/puppet/puppet.conf +0 -0
- data/examples/{root/etc → etc}/puppet/tagmail.conf +0 -0
- data/examples/{code/execs → execs} +0 -0
- data/examples/{code/file.bl → file.bl} +0 -0
- data/examples/{code/filedefaults → filedefaults} +0 -0
- data/examples/{code/fileparsing → fileparsing} +0 -0
- data/examples/{code/filerecursion → filerecursion} +0 -0
- data/examples/{code/functions → functions} +0 -0
- data/examples/{code/groups → groups} +0 -0
- data/examples/{code/head → head} +0 -0
- data/examples/{code/importing → importing} +0 -0
- data/examples/{code/mac_automount.pp → mac_automount.pp} +0 -0
- data/examples/{code/mac_dscl.pp → mac_dscl.pp} +0 -0
- data/examples/{code/mac_dscl_revert.pp → mac_dscl_revert.pp} +0 -0
- data/examples/{code/mac_netinfo.pp → mac_netinfo.pp} +0 -0
- data/examples/{code/mac_pkgdmg.pp → mac_pkgdmg.pp} +0 -0
- data/examples/{code/modules → modules}/sample-module.pp +0 -0
- data/examples/{code/modules → modules}/sample-module/README.txt +0 -0
- data/examples/{code/modules → modules}/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +0 -0
- data/examples/{code/modules → modules}/sample-module/manifests/init.pp +0 -0
- data/examples/{code/modules → modules}/sample-module/templates/sample.erb +0 -0
- data/examples/{code/nodes → nodes} +0 -0
- data/examples/{code/one → one} +0 -0
- data/examples/{code/relationships → relationships} +0 -0
- data/examples/{code/selectors → selectors} +0 -0
- data/examples/{code/simpletests → simpletests} +0 -0
- data/examples/{code/svncommit → svncommit} +0 -0
- data/ext/autotest/Rakefile +8 -0
- data/ext/autotest/config +43 -0
- data/ext/autotest/readme.rst +16 -0
- data/{examples/root → ext}/bin/sleeper +1 -1
- data/ext/emacs/puppet-mode.el +246 -184
- data/ext/ldap/puppet.schema +7 -2
- data/ext/module_puppet +4 -3
- data/ext/nagios/check_puppet.rb +117 -0
- data/ext/puppetlast +40 -0
- data/install.rb +12 -3
- data/lib/puppet.rb +1 -44
- data/lib/puppet/defaults.rb +23 -10
- data/lib/puppet/dsl.rb +2 -2
- data/lib/puppet/executables/client/certhandler.rb +77 -0
- data/lib/puppet/external/nagios.rb +1 -1
- data/lib/puppet/external/nagios/base.rb +60 -46
- data/lib/puppet/file_serving/indirection_hooks.rb +4 -2
- data/lib/puppet/file_serving/metadata.rb +0 -9
- data/lib/puppet/file_serving/terminus_helper.rb +4 -4
- data/lib/puppet/indirector.rb +26 -28
- data/lib/puppet/indirector/catalog/compiler.rb +6 -28
- data/lib/puppet/indirector/checksum/file.rb +2 -2
- data/lib/puppet/indirector/direct_file_server.rb +7 -7
- data/lib/puppet/indirector/envelope.rb +13 -0
- data/lib/puppet/indirector/exec.rb +2 -2
- data/lib/puppet/indirector/facts/facter.rb +2 -2
- data/lib/puppet/indirector/file.rb +17 -14
- data/lib/puppet/indirector/file_metadata/file.rb +2 -2
- data/lib/puppet/indirector/file_server.rb +14 -14
- data/lib/puppet/indirector/indirection.rb +113 -48
- data/lib/puppet/indirector/ldap.rb +13 -25
- data/lib/puppet/indirector/memory.rb +7 -7
- data/lib/puppet/indirector/module_files.rb +14 -14
- data/lib/puppet/indirector/node/exec.rb +3 -10
- data/lib/puppet/indirector/node/ldap.rb +138 -41
- data/lib/puppet/indirector/node/plain.rb +1 -8
- data/lib/puppet/indirector/node/rest.rb +1 -1
- data/lib/puppet/indirector/plain.rb +2 -2
- data/lib/puppet/indirector/report/processor.rb +2 -2
- data/lib/puppet/indirector/request.rb +42 -0
- data/lib/puppet/indirector/rest.rb +51 -3
- data/lib/puppet/indirector/terminus.rb +0 -27
- data/lib/puppet/indirector/yaml.rb +12 -17
- data/lib/puppet/metatype/attributes.rb +3 -7
- data/lib/puppet/metatype/evaluation.rb +2 -2
- data/lib/puppet/module.rb +6 -2
- data/lib/puppet/network/client/master.rb +29 -81
- data/lib/puppet/network/handler/master.rb +12 -43
- data/lib/puppet/network/http.rb +8 -6
- data/lib/puppet/network/http/handler.rb +42 -32
- data/lib/puppet/network/http/mongrel.rb +8 -9
- data/lib/puppet/network/http/mongrel/rest.rb +42 -15
- data/lib/puppet/network/http/webrick.rb +27 -16
- data/lib/puppet/network/http/webrick/rest.rb +38 -14
- data/lib/puppet/network/http_pool.rb +3 -2
- data/lib/puppet/network/server.rb +24 -22
- data/lib/puppet/network/xmlrpc/client.rb +6 -1
- data/lib/puppet/node.rb +38 -79
- data/lib/puppet/node/catalog.rb +9 -0
- data/lib/puppet/node/facts.rb +9 -1
- data/lib/puppet/parser/ast/function.rb +1 -1
- data/lib/puppet/parser/collector.rb +6 -0
- data/lib/puppet/parser/compiler.rb +1 -1
- data/lib/puppet/parser/functions.rb +25 -1
- data/lib/puppet/parser/interpreter.rb +2 -17
- data/lib/puppet/parser/parser.rb +4 -4
- data/lib/puppet/parser/parser_support.rb +6 -2
- data/lib/puppet/parser/resource.rb +6 -0
- data/lib/puppet/parser/templatewrapper.rb +9 -0
- data/lib/puppet/pgraph.rb +1 -1
- data/lib/puppet/property.rb +0 -1
- data/lib/puppet/provider.rb +9 -95
- data/lib/puppet/provider/confine.rb +77 -0
- data/lib/puppet/provider/confine/exists.rb +22 -0
- data/lib/puppet/provider/confine/false.rb +19 -0
- data/lib/puppet/provider/confine/feature.rb +17 -0
- data/lib/puppet/provider/confine/true.rb +20 -0
- data/lib/puppet/provider/confine/variable.rb +42 -0
- data/lib/puppet/provider/confine_collection.rb +47 -0
- data/lib/puppet/provider/confiner.rb +20 -0
- data/lib/puppet/provider/cron/crontab.rb +6 -2
- data/lib/puppet/provider/group/groupadd.rb +1 -1
- data/lib/puppet/provider/group/ldap.rb +48 -0
- data/lib/puppet/provider/ldap.rb +137 -0
- data/lib/puppet/provider/nameservice.rb +1 -2
- data/lib/puppet/provider/nameservice/objectadd.rb +2 -5
- data/lib/puppet/provider/package/dpkg.rb +16 -1
- data/lib/puppet/provider/package/freebsd.rb +15 -4
- data/lib/puppet/provider/package/gem.rb +33 -12
- data/lib/puppet/provider/package/pkgdmg.rb +1 -60
- data/lib/puppet/provider/package/ports.rb +6 -1
- data/lib/puppet/provider/package/rpm.rb +14 -13
- data/lib/puppet/provider/package/urpmi.rb +3 -3
- data/lib/puppet/provider/service/base.rb +4 -4
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/init.rb +5 -3
- data/lib/puppet/provider/service/redhat.rb +35 -7
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +69 -0
- data/lib/puppet/provider/user/ldap.rb +133 -0
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +14 -14
- data/lib/puppet/rails/database/schema.rb +9 -0
- data/lib/puppet/rails/resource.rb +1 -0
- data/lib/puppet/reference/providers.rb +8 -2
- data/lib/puppet/reference/report.rb +23 -0
- data/lib/puppet/reports/rrdgraph.rb +4 -2
- data/lib/puppet/sslcertificates/ca.rb +9 -4
- data/lib/puppet/sslcertificates/support.rb +26 -2
- data/lib/puppet/transaction.rb +11 -16
- data/lib/puppet/transaction/change.rb +94 -0
- data/lib/puppet/transaction/event.rb +21 -0
- data/lib/puppet/transaction/report.rb +4 -0
- data/lib/puppet/type.rb +0 -2
- data/lib/puppet/type/file/ensure.rb +0 -5
- data/lib/puppet/type/file/group.rb +13 -7
- data/lib/puppet/type/file/source.rb +8 -15
- data/lib/puppet/type/file/target.rb +2 -0
- data/lib/puppet/type/group.rb +1 -1
- data/lib/puppet/type/mount.rb +4 -2
- data/lib/puppet/type/nagios_hostescalation.rb +3 -0
- data/lib/puppet/type/nagios_servicegroup.rb +3 -0
- data/lib/puppet/type/ssh_authorized_key.rb +56 -0
- data/lib/puppet/type/user.rb +3 -0
- data/lib/puppet/type/yumrepo.rb +0 -1
- data/lib/puppet/util.rb +1 -1
- data/lib/puppet/util/ldap.rb +5 -0
- data/lib/puppet/util/ldap/connection.rb +69 -0
- data/lib/puppet/util/ldap/generator.rb +45 -0
- data/lib/puppet/util/ldap/manager.rb +281 -0
- data/lib/puppet/util/posix.rb +2 -2
- data/lib/puppet/util/resource_template.rb +61 -0
- data/lib/puppet/util/settings.rb +63 -3
- data/lib/puppet/util/storage.rb +4 -0
- data/lib/puppet/util/warnings.rb +7 -0
- data/man/man8/filebucket.8 +116 -0
- data/man/man8/pi.8 +34 -0
- data/man/man8/puppet.8 +78 -0
- data/man/man8/puppet.conf.8 +1747 -0
- data/man/man8/puppetca.8 +118 -0
- data/man/man8/puppetd.8 +184 -0
- data/man/man8/puppetdoc.8 +62 -0
- data/man/man8/puppetmasterd.8 +87 -0
- data/man/man8/puppetrun.8 +151 -0
- data/man/man8/ralsh.8 +135 -0
- data/test/README +24 -0
- data/test/certmgr/support.rb +28 -1
- data/test/data/failers/badclassnoparam +10 -0
- data/test/data/failers/badclassparam +10 -0
- data/test/data/failers/badcompnoparam +9 -0
- data/test/data/failers/badcompparam +9 -0
- data/test/data/failers/badtypeparam +3 -0
- data/test/data/failers/noobjectrvalue +1 -0
- data/test/data/providers/cron/crontab.allthree +17 -0
- data/test/data/providers/cron/crontab.envNcomment +12 -0
- data/test/data/providers/cron/crontab.envNname +11 -0
- data/test/data/providers/cron/crontab.multirecords +12 -0
- data/test/data/providers/cron/crontab_collections.yaml +44 -0
- data/test/data/providers/cron/crontab_multiple_with_env.yaml +54 -0
- data/test/data/providers/cron/crontab_sample_records.yaml +272 -0
- data/test/data/providers/cron/examples/freebsd +2 -0
- data/test/data/providers/cron/examples/one +14 -0
- data/test/data/providers/cron/examples/openbsd +20 -0
- data/test/data/providers/package/testpackages.yaml +65 -0
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +5 -0
- data/test/data/reports/1.yaml +108 -0
- data/test/data/reports/2.yaml +108 -0
- data/test/data/reports/tagmail_failers.conf +3 -0
- data/test/data/reports/tagmail_passers.conf +30 -0
- data/test/data/snippets/aliastest.pp +16 -0
- data/test/data/snippets/argumentdefaults +14 -0
- data/test/data/snippets/casestatement.pp +58 -0
- data/test/data/snippets/classheirarchy.pp +15 -0
- data/test/data/snippets/classincludes.pp +17 -0
- data/test/data/snippets/classpathtest +11 -0
- data/test/data/snippets/collection.pp +10 -0
- data/test/data/snippets/collection_within_virtual_definitions.pp +20 -0
- data/test/data/snippets/componentmetaparams.pp +11 -0
- data/test/data/snippets/componentrequire.pp +8 -0
- data/test/data/snippets/deepclassheirarchy.pp +23 -0
- data/test/data/snippets/defineoverrides.pp +17 -0
- data/test/data/snippets/emptyclass.pp +9 -0
- data/test/data/snippets/emptyexec.pp +3 -0
- data/test/data/snippets/falsevalues.pp +3 -0
- data/test/data/snippets/filecreate +11 -0
- data/test/data/snippets/fqdefinition.pp +5 -0
- data/test/data/snippets/fqparents.pp +11 -0
- data/test/data/snippets/implicititeration +15 -0
- data/test/data/snippets/multipleinstances +7 -0
- data/test/data/snippets/multisubs.pp +13 -0
- data/test/data/snippets/namevartest +9 -0
- data/test/data/snippets/scopetest +13 -0
- data/test/data/snippets/selectorvalues.pp +42 -0
- data/test/data/snippets/simpledefaults +5 -0
- data/test/data/snippets/simpleselector +38 -0
- data/test/data/snippets/singleary.pp +19 -0
- data/test/data/snippets/singlequote.pp +11 -0
- data/test/data/snippets/singleselector.pp +22 -0
- data/test/data/snippets/subclass_name_duplication.pp +11 -0
- data/test/data/snippets/tag.pp +9 -0
- data/test/data/snippets/tagged.pp +35 -0
- data/test/data/snippets/virtualresources.pp +14 -0
- data/test/data/types/hosts/1 +3 -0
- data/test/data/types/hosts/2 +13 -0
- data/test/data/types/hosts/solaris +5 -0
- data/test/data/types/mailalias/file1 +183 -0
- data/test/data/types/mount/freebsd.fstab +7 -0
- data/test/data/types/mount/linux.fstab +11 -0
- data/test/data/types/mount/solaris.fstab +11 -0
- data/test/data/types/port/1 +533 -0
- data/test/data/types/port/darwin +11866 -0
- data/test/data/types/ssh_authorized_key/1 +2 -0
- data/test/data/types/sshkey/1 +21 -0
- data/test/data/types/yumrepos/fedora-devel.repo +26 -0
- data/test/data/types/yumrepos/fedora.repo +9 -0
- data/test/language/parser.rb +8 -1
- data/test/lib/puppettest/runnable_test.rb +3 -0
- data/test/lib/puppettest/support/utils.rb +1 -1
- data/test/lib/rake/puppet_testtask.rb +3 -0
- data/test/lib/stubba.rb +1 -1
- data/test/network/client/ca.rb +1 -0
- data/test/network/client/master.rb +13 -127
- data/test/network/handler/master.rb +61 -80
- data/test/other/provider.rb +0 -45
- data/test/other/transactions.rb +53 -15
- data/test/rails/host.rb +0 -37
- data/test/ral/providers/cron/crontab.rb +32 -3
- data/test/ral/providers/provider.rb +28 -7
- data/test/ral/type/filesources.rb +2 -18
- data/test/ral/type/sshkey.rb +0 -1
- data/test/ral/type/user.rb +6 -0
- data/test/test +241 -0
- metadata +289 -113
- data/examples/root/etc/configfile +0 -0
- data/examples/root/etc/debian-passwd +0 -29
- data/examples/root/etc/debian-syslog.conf +0 -71
- data/lib/puppet/event.rb +0 -28
- data/lib/puppet/network/handler/configuration.rb +0 -184
- data/lib/puppet/network/http/mongrel/xmlrpc.rb +0 -4
- data/lib/puppet/network/http/webrick/xmlrpc.rb +0 -4
- data/lib/puppet/propertychange.rb +0 -141
- data/lib/puppet/provider/interface/redhat.rb +0 -250
- data/lib/puppet/provider/interface/sunos.rb +0 -133
- data/lib/puppet/type/interface.rb +0 -60
- data/lib/puppet/util/variables.rb +0 -38
- data/test/network/handler/configuration.rb +0 -160
- data/test/other/propertychange.rb +0 -140
- data/test/util/loadedfile.rb +0 -121
@@ -1,160 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../../lib/puppettest'
|
4
|
-
|
5
|
-
require 'puppettest'
|
6
|
-
require 'puppet/network/handler/configuration'
|
7
|
-
|
8
|
-
class TestHandlerConfiguration < Test::Unit::TestCase
|
9
|
-
include PuppetTest
|
10
|
-
|
11
|
-
Config = Puppet::Network::Handler.handler(:configuration)
|
12
|
-
|
13
|
-
# Check all of the setup stuff.
|
14
|
-
def test_initialize
|
15
|
-
config = nil
|
16
|
-
assert_nothing_raised("Could not create local config") do
|
17
|
-
config = Config.new(:Local => true)
|
18
|
-
end
|
19
|
-
|
20
|
-
assert(config.local?, "Config is not considered local after being started that way")
|
21
|
-
end
|
22
|
-
|
23
|
-
# Test creation/returning of the interpreter
|
24
|
-
def test_interpreter
|
25
|
-
config = Config.new
|
26
|
-
|
27
|
-
# First test the defaults
|
28
|
-
config.expects(:create_interpreter).returns(:interp)
|
29
|
-
assert_equal(:interp, config.send(:interpreter), "Did not return the interpreter")
|
30
|
-
|
31
|
-
# Now run it again and make sure we get the same thing
|
32
|
-
assert_equal(:interp, config.send(:interpreter), "Did not cache the interpreter")
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_create_interpreter
|
36
|
-
config = Config.new(:Local => false)
|
37
|
-
args = {}
|
38
|
-
|
39
|
-
# Try it first with defaults.
|
40
|
-
Puppet::Parser::Interpreter.expects(:new).returns(:interp)
|
41
|
-
assert_equal(:interp, config.send(:create_interpreter), "Did not return the interpreter")
|
42
|
-
end
|
43
|
-
|
44
|
-
# Make sure node objects get appropriate data added to them.
|
45
|
-
def test_add_node_data
|
46
|
-
# First with no classes
|
47
|
-
config = Config.new
|
48
|
-
|
49
|
-
fakenode = Object.new
|
50
|
-
# Set the server facts to something
|
51
|
-
config.instance_variable_set("@server_facts", :facts)
|
52
|
-
fakenode.expects(:merge).with(:facts)
|
53
|
-
config.send(:add_node_data, fakenode)
|
54
|
-
|
55
|
-
# Now try it with classes.
|
56
|
-
config.classes = %w{a b}
|
57
|
-
list = []
|
58
|
-
fakenode = Object.new
|
59
|
-
fakenode.expects(:merge).with(:facts)
|
60
|
-
fakenode.expects(:classes).returns(list).times(2)
|
61
|
-
config.send(:add_node_data, fakenode)
|
62
|
-
assert_equal(%w{a b}, list, "Did not add classes to node")
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_compile
|
66
|
-
config = Config.new
|
67
|
-
|
68
|
-
# First do a local
|
69
|
-
node = mock 'node'
|
70
|
-
node.stubs(:name).returns(:mynode)
|
71
|
-
node.stubs(:environment).returns(:myenv)
|
72
|
-
|
73
|
-
interp = mock 'interpreter'
|
74
|
-
interp.stubs(:environment)
|
75
|
-
interp.expects(:compile).with(node).returns(:config)
|
76
|
-
config.expects(:interpreter).returns(interp)
|
77
|
-
|
78
|
-
Puppet.expects(:notice) # The log message from benchmarking
|
79
|
-
|
80
|
-
assert_equal(:config, config.send(:compile, node), "Did not return config")
|
81
|
-
|
82
|
-
# Now try it non-local
|
83
|
-
node = mock 'node'
|
84
|
-
node.stubs(:name).returns(:mynode)
|
85
|
-
node.stubs(:environment).returns(:myenv)
|
86
|
-
|
87
|
-
interp = mock 'interpreter'
|
88
|
-
interp.stubs(:environment)
|
89
|
-
interp.expects(:compile).with(node).returns(:config)
|
90
|
-
|
91
|
-
config = Config.new(:Local => true)
|
92
|
-
config.expects(:interpreter).returns(interp)
|
93
|
-
|
94
|
-
assert_equal(:config, config.send(:compile, node), "Did not return config")
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_set_server_facts
|
98
|
-
config = Config.new
|
99
|
-
assert_nothing_raised("Could not call :set_server_facts") do
|
100
|
-
config.send(:set_server_facts)
|
101
|
-
end
|
102
|
-
facts = config.instance_variable_get("@server_facts")
|
103
|
-
%w{servername serverversion serverip}.each do |fact|
|
104
|
-
assert(facts.include?(fact), "Config did not set %s fact" % fact)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_translate
|
109
|
-
# First do a local config
|
110
|
-
config = Config.new(:Local => true)
|
111
|
-
assert_equal(:plain, config.send(:translate, :plain), "Attempted to translate local config")
|
112
|
-
|
113
|
-
# Now a non-local
|
114
|
-
config = Config.new(:Local => false)
|
115
|
-
assert(! config.local?, "Config wrongly thinks it's local")
|
116
|
-
obj = mock 'dumpee'
|
117
|
-
yamld = mock 'yaml'
|
118
|
-
obj.expects(:to_yaml).with(:UseBlock => true).returns(yamld)
|
119
|
-
CGI.expects(:escape).with(yamld).returns(:translated)
|
120
|
-
assert_equal(:translated, config.send(:translate, obj), "Did not return translated config")
|
121
|
-
end
|
122
|
-
|
123
|
-
# Check that we're storing the node freshness into the rails db. Hackilicious.
|
124
|
-
def test_update_node_check
|
125
|
-
# This is stupid.
|
126
|
-
config = Config.new
|
127
|
-
node = Object.new
|
128
|
-
node.expects(:name).returns(:hostname)
|
129
|
-
now = Object.new
|
130
|
-
Time.expects(:now).returns(now)
|
131
|
-
host = Object.new
|
132
|
-
host.expects(:last_freshcheck=).with(now)
|
133
|
-
host.expects(:save)
|
134
|
-
|
135
|
-
# Only test the case where rails is there
|
136
|
-
Puppet[:storeconfigs] = true
|
137
|
-
Puppet.features.expects(:rails?).returns(true)
|
138
|
-
Puppet::Rails.expects(:connect)
|
139
|
-
Puppet::Rails::Host.expects(:find_or_create_by_name).with(:hostname).returns(host)
|
140
|
-
|
141
|
-
config.send(:update_node_check, node)
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_version
|
145
|
-
# First try the case where we can't look up the node
|
146
|
-
config = Config.new
|
147
|
-
node = Object.new
|
148
|
-
Puppet::Node.stubs(:find_by_any_name).with(:client).returns(false, node)
|
149
|
-
interp = Object.new
|
150
|
-
assert_instance_of(Bignum, config.version(:client), "Did not return configuration version")
|
151
|
-
|
152
|
-
# And then when we find the node.
|
153
|
-
config = Config.new
|
154
|
-
config.expects(:update_node_check).with(node)
|
155
|
-
interp = Object.new
|
156
|
-
interp.expects(:configuration_version).returns(:version)
|
157
|
-
config.expects(:interpreter).returns(interp)
|
158
|
-
assert_equal(:version, config.version(:client), "Did not return configuration version")
|
159
|
-
end
|
160
|
-
end
|
@@ -1,140 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Created by Luke A. Kanies on 2006-12-21.
|
4
|
-
# Copyright (c) 2006. All rights reserved.
|
5
|
-
|
6
|
-
require File.dirname(__FILE__) + '/../lib/puppettest'
|
7
|
-
|
8
|
-
require 'puppettest'
|
9
|
-
|
10
|
-
class TestPropertyChange < Test::Unit::TestCase
|
11
|
-
include PuppetTest
|
12
|
-
class FakeProperty < Puppet::Property
|
13
|
-
attr_accessor :is, :should, :resource
|
14
|
-
attr_reader :noop
|
15
|
-
def change_to_s(currentvalue, newvalue)
|
16
|
-
"fake change"
|
17
|
-
end
|
18
|
-
def insync?(is)
|
19
|
-
is == @should
|
20
|
-
end
|
21
|
-
def log(msg)
|
22
|
-
Puppet::Util::Log.create(
|
23
|
-
:level => :info,
|
24
|
-
:source => self,
|
25
|
-
:message => msg
|
26
|
-
)
|
27
|
-
end
|
28
|
-
def noop
|
29
|
-
if defined? @noop
|
30
|
-
@noop
|
31
|
-
else
|
32
|
-
false
|
33
|
-
end
|
34
|
-
end
|
35
|
-
def path
|
36
|
-
"fakechange"
|
37
|
-
end
|
38
|
-
def should_to_s(newvalue)
|
39
|
-
newvalue.to_s
|
40
|
-
end
|
41
|
-
def sync
|
42
|
-
if insync?(@is)
|
43
|
-
return nil
|
44
|
-
else
|
45
|
-
@is = @should
|
46
|
-
return :fake_change
|
47
|
-
end
|
48
|
-
end
|
49
|
-
def to_s
|
50
|
-
path
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def mkchange
|
55
|
-
property = FakeProperty.new :resource => "fakeparent"
|
56
|
-
property.is = :start
|
57
|
-
property.should = :finish
|
58
|
-
property.resource = :parent
|
59
|
-
change = nil
|
60
|
-
assert_nothing_raised do
|
61
|
-
change = Puppet::PropertyChange.new(property, :start)
|
62
|
-
end
|
63
|
-
change.transaction = :trans
|
64
|
-
|
65
|
-
assert_equal(:start, change.is, "@is did not get copied")
|
66
|
-
assert_equal(:finish, change.should, "@should did not get copied")
|
67
|
-
assert_equal(%w{fakechange change}, change.path, "path did not get set correctly")
|
68
|
-
|
69
|
-
assert(! change.changed?, "change defaulted to already changed")
|
70
|
-
|
71
|
-
return change
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_go
|
75
|
-
change = mkchange
|
76
|
-
|
77
|
-
coll = logcollector()
|
78
|
-
|
79
|
-
events = nil
|
80
|
-
# First make sure we get an immediate return
|
81
|
-
assert_nothing_raised do
|
82
|
-
events = change.go
|
83
|
-
end
|
84
|
-
assert_instance_of(Array, events, "events were not returned in an array")
|
85
|
-
assert_instance_of(Puppet::Event, events[0], "event array did not contain events")
|
86
|
-
|
87
|
-
event = events.shift
|
88
|
-
{:event => :fake_change, :transaction => :trans, :source => :parent}.each do |method, val|
|
89
|
-
assert_equal(val, event.send(method), "Event did not set %s correctly" % method)
|
90
|
-
end
|
91
|
-
|
92
|
-
# Disabled, because it fails when running the whole suite at once.
|
93
|
-
#assert(coll.detect { |l| l.message == "fake change" }, "Did not log change")
|
94
|
-
assert_equal(change.property.is, change.property.should, "did not call sync method")
|
95
|
-
|
96
|
-
# Now make sure that proxy sources can be set.
|
97
|
-
assert_nothing_raised do
|
98
|
-
change.proxy = :other
|
99
|
-
end
|
100
|
-
# Reset, so we change again
|
101
|
-
change.property.is = :start
|
102
|
-
change.is = :start
|
103
|
-
assert_nothing_raised do
|
104
|
-
events = change.go
|
105
|
-
end
|
106
|
-
|
107
|
-
assert_instance_of(Array, events, "events were not returned in an array")
|
108
|
-
assert_instance_of(Puppet::Event, events[0], "event array did not contain events")
|
109
|
-
|
110
|
-
event = events.shift
|
111
|
-
{:event => :fake_change, :transaction => :trans, :source => :other}.each do |method, val|
|
112
|
-
assert_equal(val, event.send(method), "Event did not set %s correctly" % method)
|
113
|
-
end
|
114
|
-
|
115
|
-
#assert(coll.detect { |l| l.message == "fake change" }, "Did not log change")
|
116
|
-
assert_equal(change.property.is, change.property.should, "did not call sync method")
|
117
|
-
end
|
118
|
-
|
119
|
-
# Related to #542. Make sure changes in noop mode produce the :noop event.
|
120
|
-
def test_noop_event
|
121
|
-
change = mkchange
|
122
|
-
|
123
|
-
assert(! change.skip?, "Change is already being skipped")
|
124
|
-
|
125
|
-
Puppet[:noop] = true
|
126
|
-
|
127
|
-
change.property.noop = true
|
128
|
-
assert(change.noop, "did not set noop")
|
129
|
-
assert(change.skip?, "setting noop did not mark change for skipping")
|
130
|
-
|
131
|
-
event = nil
|
132
|
-
assert_nothing_raised("Could not generate noop event") do
|
133
|
-
event = change.forward
|
134
|
-
end
|
135
|
-
|
136
|
-
assert_equal(1, event.length, "got wrong number of events")
|
137
|
-
assert_equal(:noop, event[0].event, "did not generate noop mode when in noop")
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
data/test/util/loadedfile.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../lib/puppettest'
|
4
|
-
|
5
|
-
require 'puppet'
|
6
|
-
require 'puppet/util/loadedfile'
|
7
|
-
require 'puppettest'
|
8
|
-
|
9
|
-
class TestLoadedFile < Test::Unit::TestCase
|
10
|
-
include PuppetTest
|
11
|
-
def test_file
|
12
|
-
Puppet[:filetimeout] = 0
|
13
|
-
file = nil
|
14
|
-
path = tempfile()
|
15
|
-
File.open(path, "w") { |f| f.puts "yayness" }
|
16
|
-
assert_nothing_raised {
|
17
|
-
file = Puppet::Util::LoadedFile.new(path)
|
18
|
-
}
|
19
|
-
|
20
|
-
assert(!file.changed?, "File incorrectly returned changed")
|
21
|
-
|
22
|
-
File.open(path, "w") { |f| f.puts "booness" }
|
23
|
-
#file.tstamp = File.stat(path).ctime - 5
|
24
|
-
new = File.stat(path).ctime - 5
|
25
|
-
file.tstamp = new
|
26
|
-
|
27
|
-
assert(file.changed?, "File did not catch change")
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_timeout
|
31
|
-
Puppet[:filetimeout] = 50
|
32
|
-
path = tempfile()
|
33
|
-
|
34
|
-
File.open(path, "w") { |f| f.puts "yay" }
|
35
|
-
file = nil
|
36
|
-
assert_nothing_raised {
|
37
|
-
file = Puppet::Util::LoadedFile.new(path)
|
38
|
-
}
|
39
|
-
|
40
|
-
assert_nothing_raised {
|
41
|
-
assert(!file.changed?,
|
42
|
-
"File thought it changed immediately")
|
43
|
-
}
|
44
|
-
|
45
|
-
sleep 1
|
46
|
-
File.open(path, "w") { |f| f.puts "yay" }
|
47
|
-
#file.tstamp = File.stat(path).ctime - 5
|
48
|
-
|
49
|
-
assert(!file.changed?,
|
50
|
-
"File was marked as changed too soon")
|
51
|
-
|
52
|
-
Puppet[:filetimeout] = 0
|
53
|
-
assert(file.changed?,
|
54
|
-
"File was not marked as changed soon enough")
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_stamp
|
58
|
-
file = tempfile()
|
59
|
-
File.open(file, "w") { |f| f.puts "" }
|
60
|
-
obj = nil
|
61
|
-
assert_nothing_raised {
|
62
|
-
obj = Puppet::Util::LoadedFile.new(file)
|
63
|
-
}
|
64
|
-
|
65
|
-
# Make sure we don't refresh
|
66
|
-
Puppet[:filetimeout] = 50
|
67
|
-
|
68
|
-
stamp = File.stat(file).ctime
|
69
|
-
|
70
|
-
assert_equal(stamp, obj.stamp)
|
71
|
-
|
72
|
-
sleep 1
|
73
|
-
# Now change the file, and make sure the stamp doesn't update yet
|
74
|
-
File.open(file, "w") { |f| f.puts "" }
|
75
|
-
assert_equal(stamp, obj.stamp,
|
76
|
-
"File prematurely refreshed")
|
77
|
-
|
78
|
-
Puppet[:filetimeout] = 0
|
79
|
-
assert_equal(File.stat(file).ctime, obj.stamp,
|
80
|
-
"File did not refresh")
|
81
|
-
end
|
82
|
-
|
83
|
-
# Testing #394.
|
84
|
-
def test_changed_missing_file
|
85
|
-
file = tempfile()
|
86
|
-
File.open(file, "w") { |f| f.puts "" }
|
87
|
-
obj = nil
|
88
|
-
assert_nothing_raised {
|
89
|
-
obj = Puppet::Util::LoadedFile.new(file)
|
90
|
-
}
|
91
|
-
Puppet[:filetimeout] = -10
|
92
|
-
|
93
|
-
assert_nothing_raised {
|
94
|
-
obj.changed?
|
95
|
-
}
|
96
|
-
|
97
|
-
# Now remove the file
|
98
|
-
File.unlink(file)
|
99
|
-
|
100
|
-
assert_nothing_raised("removed file threw an error") {
|
101
|
-
assert(obj.changed?, "File was not considered changed when missing")
|
102
|
-
}
|
103
|
-
end
|
104
|
-
|
105
|
-
# Make sure negative values always result in change notifications.
|
106
|
-
def test_negative_always_changes
|
107
|
-
file = tempfile()
|
108
|
-
File.open(file, "w") { |f| f.puts "" }
|
109
|
-
obj = nil
|
110
|
-
assert_nothing_raised {
|
111
|
-
obj = Puppet::Util::LoadedFile.new(file)
|
112
|
-
}
|
113
|
-
|
114
|
-
assert(! obj.changed?, "file with no change considered changed")
|
115
|
-
# Now set a negative value
|
116
|
-
Puppet[:filetimeout] = -1
|
117
|
-
|
118
|
-
assert(obj.changed?, "negative file timeout did not disable checking")
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|