diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-05 18:10:57 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-05 18:10:57 +0000 |
commit | b303e8d3b7c31ebccabb0b3238104f5f019c5b6a (patch) | |
tree | 149d9eaa498d97456756605711cb62c5e24fec2d /test/client | |
parent | b36df181f4f2064b3dbbce861912262594044b14 (diff) | |
download | puppet-b303e8d3b7c31ebccabb0b3238104f5f019c5b6a.tar.gz |
Adding the ability to download facts from the central server. This allows facts to be available before the configuration is compiled.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1561 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/client')
-rw-r--r-- | test/client/master.rb | 82 |
1 files changed, 73 insertions, 9 deletions
diff --git a/test/client/master.rb b/test/client/master.rb index 655b3fae6..2f88123b5 100644 --- a/test/client/master.rb +++ b/test/client/master.rb @@ -146,10 +146,8 @@ end } end - client = mkclient() - assert_nothing_raised { - client.send(:getplugins) + Puppet::Client::MasterClient.getplugins } destfile = File.join(Puppet[:plugindest], "myplugin.rb") @@ -177,7 +175,7 @@ end end assert_nothing_raised { - client.send(:getplugins) + Puppet::Client::MasterClient.getplugins } destfile = File.join(Puppet[:pluginpath], "myplugin.rb") @@ -194,13 +192,79 @@ end assert(! obj.validattr?(:argument), "Old namevar is still valid") + end - # Now make sure it works with multiple paths specified. - newdir = tempfile() - Dir.mkdir(newdir) - Puppet[:pluginpath] = [Puppet[:pluginpath], newdir].join(":") + def test_getfacts + Puppet[:factsource] = tempfile() + Dir.mkdir(Puppet[:factsource]) - client.send(:getplugins) + myfact = File.join(Puppet[:factsource], "myfact.rb") + File.open(myfact, "w") do |f| + f.puts %{Facter.add("myfact") do + setcode { "yayness" } +end +} + end + + assert_nothing_raised { + Puppet::Client::MasterClient.getfacts + } + + destfile = File.join(Puppet[:factdest], "myfact.rb") + + assert(File.exists?(destfile), "Did not get fact") + + assert_equal("yayness", Facter["myfact"].value, + "Did not get correct fact value") + + # Now modify the file and make sure the type is replaced + File.open(myfact, "w") do |f| + f.puts %{Facter.add("myfact") do + setcode { "funtest" } +end +} + end + + assert_nothing_raised { + Puppet::Client::MasterClient.getfacts + } + + assert_equal("funtest", Facter["myfact"].value, + "Did not reload fact") + end + + # Make sure we load all facts on startup. + def test_loadfacts + dirs = [tempfile(), tempfile()] + count = 0 + names = [] + dirs.each do |dir| + Dir.mkdir(dir) + name = "fact%s" % count + names << name + file = File.join(dir, "%s.rb" % name) + + # Write out a plugin file + File.open(file, "w") do |f| + f.puts %{Facter.add("#{name}") do setcode { "#{name}" } end } + end + count += 1 + end + + Puppet[:factpath] = dirs.join(":") + + names.each do |name| + assert_nil(Facter.value(name), "Somehow retrieved invalid fact") + end + + assert_nothing_raised { + Puppet::Client::MasterClient.loadfacts + } + + names.each do |name| + assert_equal(name, Facter.value(name), + "Did not retrieve facts") + end end end |