[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
Luke Kanies
luke at puppetlabs.com
Wed Jul 14 10:32:28 UTC 2010
The following commit has been merged in the upstream branch:
commit 232ad8fa316dd8f428bf9bdc56bba742f553efea
Author: Luke Kanies <luke at puppetlabs.com>
Date: Mon Apr 12 14:59:48 2010 -0700
Removing tests for code that was removed in the REST refactor
Signed-off-by: Luke Kanies <luke at puppetlabs.com>
diff --git a/lib/puppet/network/client/resource.rb b/lib/puppet/network/client/resource.rb
deleted file mode 100644
index ad32106..0000000
--- a/lib/puppet/network/client/resource.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# The client for interacting with remote Puppet agents to query and modify
-# remote system state.
-class Puppet::Network::Client::Resource < Puppet::Network::Client
- def apply(bucket)
- case bucket
- when Puppet::TransObject
- tmp = Puppet::TransBucket.new
- tmp.push bucket
- bucket = tmp
- bucket.name = Facter["hostname"].value
- bucket.type = "resource"
- when Puppet::TransBucket
- # nothing
- else
- raise Puppet::DevError, "You must pass a transportable object, not a %s" %
- bucket.class
- end
-
- unless @local
- bucket = Base64.encode64(YAML::dump(bucket))
- end
- report = @driver.apply(bucket, "yaml")
-
- return report
- end
-
- def describe(type, name, retrieve = false, ignore = false)
- Puppet.info "Describing %s[%s]" % [type.to_s.capitalize, name]
- text = @driver.describe(type, name, retrieve, ignore, "yaml")
- @local ? text : YAML::load(Base64.decode64(text))
- end
-
- def list(type, ignore = false, base = false)
- bucket = @driver.list(type, ignore, base, "yaml")
- @local ? bucket : YAML::load(Base64.decode64(bucket))
- end
-end
-
diff --git a/test/network/client/resource.rb b/test/network/client/resource.rb
deleted file mode 100755
index c736901..0000000
--- a/test/network/client/resource.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../lib/puppettest'
-
-require 'puppettest'
-require 'puppettest/support/utils'
-require 'puppettest/support/assertions'
-require 'puppet/network/client/resource'
-
-class TestResourceClient < Test::Unit::TestCase
- include PuppetTest::ServerTest
- include PuppetTest::Support::Utils
-
- def setup
- super
-
- Puppet::Type.type(:user).provider(:directoryservice).stubs(:get_macosx_version_major).returns "10.5"
- end
-
- def mkresourceserver
- Puppet::Network::Handler.resource.new
- end
-
- def mkclient
- client = Puppet::Network::Client.resource.new(:Resource => mkresourceserver)
- end
-
- def test_resources
- file = tempfile()
- text = "yayness\n"
- File.open(file, "w") { |f| f.print text }
-
- mkresourceserver()
-
- client = mkclient()
-
- # Test describing
- tresource = client.describe("file", file)
-
- assert(tresource, "Did not get response")
-
- assert_instance_of(Puppet::TransObject, tresource)
-
- resource = tresource.to_ral
- assert_equal(File.stat(file).mode & 007777, resource[:mode], "Did not get mode")
-
- # Now test applying
- result = client.apply(tresource)
- assert(FileTest.exists?(file), "File was not created on apply")
- end
-end
-
diff --git a/test/network/handler/resource.rb b/test/network/handler/resource.rb
deleted file mode 100755
index 48e8129..0000000
--- a/test/network/handler/resource.rb
+++ /dev/null
@@ -1,250 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../lib/puppettest'
-
-require 'puppettest'
-require 'puppettest/support/utils'
-require 'base64'
-require 'cgi'
-
-class TestResourceServer < Test::Unit::TestCase
- include PuppetTest::Support::Utils
- include PuppetTest::ServerTest
-
- def verify_described(type, described)
- described.each do |name, trans|
- obj = nil
- assert_nothing_raised do
- obj = trans.to_ral
- end
-
- assert(obj, "Could not create object")
- assert_nothing_raised do
- obj.retrieve
- end
-
- if trans.type == :package
- assert_equal(Puppet::Type.type(:package).defaultprovider.name, obj[:provider])
- end
- end
- end
-
- def test_describe_file
- # Make a file to describe
- file = tempfile()
- str = "yayness\n"
-
- server = nil
-
- assert_nothing_raised do
- server = Puppet::Network::Handler.resource.new()
- end
-
- [ [nil],
- [[:content, :mode], []],
- [[], [:content]],
- [[:content], [:mode]]
- ].each do |ary|
- retrieve = ary[0] || []
- ignore = ary[1] || []
-
- File.open(file, "w") { |f| f.print str }
-
- result = nil
- assert_nothing_raised do
- result = server.describe("file", file, *ary)
- end
-
- assert(result, "Could not retrieve file information")
-
- assert_instance_of(Puppet::TransObject, result)
-
- object = nil
- assert_nothing_raised do
- object = result.to_ral
- end
-
- assert(object, "Could not create type")
-
- retrieve.each do |property|
- assert(object.should(property), "Did not retrieve %s" % property)
- end
-
- ignore.each do |property|
- assert(! object.should(property), "Incorrectly retrieved %s" % property)
- end
- end
- end
-
- def test_describe_directory
- # Make a file to describe
- file = tempfile()
-
- server = nil
-
- assert_nothing_raised do
- server = Puppet::Network::Handler.resource.new()
- end
-
- [ [nil],
- [[:ensure, :checksum, :mode], []],
- [[], [:checksum]],
- [[:ensure, :checksum], [:mode]]
- ].each do |ary|
- retrieve = ary[0] || []
- ignore = ary[1] || []
-
- Dir.mkdir(file)
-
- result = nil
- assert_nothing_raised do
- result = server.describe("file", file, *ary)
- end
-
- assert(result, "Could not retrieve file information")
-
- assert_instance_of(Puppet::TransObject, result)
-
- # And remove the file, so we can verify it gets recreated
- Dir.rmdir(file)
-
- object = nil
- assert_nothing_raised do
- object = result.to_ral
- end
-
- catalog = mk_catalog(object)
-
- assert(object, "Could not create type")
-
- retrieve.each do |property|
- assert(object.should(property), "Did not retrieve %s" % property)
- end
-
- ignore.each do |property|
- assert(! object.should(property), "Incorrectly retrieved %s" % property)
- end
- end
- end
-
- def test_describe_alltypes
- # Systems get pretty retarded, so I'm going to set the path to some fake
- # data for ports
- #Puppet::Type::ParsedType::Port.path = File.join(basedir,
- # "test/data/types/ports/1")
- #Puppet.err Puppet::Type::ParsedType::Port.path
- server = nil
- assert_nothing_raised do
- server = Puppet::Network::Handler.resource.new()
- end
-
- require 'etc'
-
- # Make the example schedules, for testing
- Puppet::Type.type(:schedule).mkdefaultschedules
-
- Puppet::Type.eachtype do |type|
- unless type.respond_to? :instances
- Puppet.warning "%s does not respond to :instances" % type.name
- next
- end
- next unless type.name == :package
- Puppet.info "Describing each %s" % type.name
-
- # First do a listing from the server
- bucket = nil
- assert_nothing_raised {
- bucket = server.list(type.name)
- }
-
- count = 0
- described = {}
- bucket.each do |obj|
- assert_instance_of(Puppet::TransObject, obj)
- break if count > 5
- described[obj.name] = server.describe(obj.type, obj.name)
- count += 1
- end
-
- verify_described(type, described)
-
- count = 0
- described = {}
- Puppet.info "listing again"
- type.instances.each do |obj|
- assert_instance_of(type, obj)
-
- break if count > 5
- trans = nil
- assert_nothing_raised do
- described[obj.name] = server.describe(type.name, obj.name)
- end
-
- count += 1
- end
-
- if described.empty?
- Puppet.notice "Got no example objects for %s" % type.name
- end
-
- # We separate these, in case the list operation creates objects
- verify_described(type, described)
- end
- end
-
- def test_apply
- server = nil
- assert_nothing_raised do
- server = Puppet::Network::Handler.resource.new(:Local => false)
- end
-
- file = tempfile()
- str = "yayness\n"
-
- File.open(file, "w") { |f| f.print str }
-
- filetrans = nil
- assert_nothing_raised {
- filetrans = server.describe("file", file)
- }
-
- bucket = Puppet::TransBucket.new
- bucket.type = "class"
- bucket.name = "test"
- bucket.push filetrans
-
- oldbucket = bucket.dup
- File.unlink(file)
- assert_nothing_raised {
- server.apply(bucket)
- }
-
- assert(FileTest.exists?(file), "File did not get recreated")
-
- # Now try it as a "nonlocal" server
- server.local = false
- yaml = nil
- assert_nothing_raised {
- yaml = Base64.encode64(YAML::dump(bucket))
- }
-
- File.unlink(file)
-
- if Base64.decode64(yaml) =~ /(.{20}Loglevel.{20})/
- Puppet.warning "YAML is broken on this machine"
- return
- end
- # puts Base64.decode64(yaml)
- objects = nil
- assert_nothing_raised("Could not reload yaml") {
- YAML::load(Base64.decode64(yaml))
- }
-
- # The server is supposed to accept yaml and execute it.
- assert_nothing_raised {
- server.apply(yaml)
- }
- assert(FileTest.exists?(file), "File did not get recreated from YAML")
- end
-end
-
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list