1
test_name "The source attribute"
3
step "Ensure the test environment is clean"
4
on agents, 'rm -f /tmp/source_file_test.txt'
6
# TODO: Add tests for puppet:// URIs with master/agent setups.
7
step "when using a puppet:/// URI with a master/agent setup"
8
step "when using a puppet://$server/ URI with a master/agent setup"
10
step "when using a local file path"
12
on agents, "echo 'Yay, this is the local file.' > /tmp/local_source_file_test.txt"
14
manifest = "file { '/tmp/source_file_test.txt': source => '/tmp/local_source_file_test.txt', ensure => present }"
16
apply_manifest_on agents, manifest
18
on agents, 'test "$(cat /tmp/source_file_test.txt)" = "Yay, this is the local file."'
20
step "Ensure the test environment is clean"
21
on agents, 'rm -f /tmp/source_file_test.txt'
23
step "when using a puppet:/// URI with puppet apply"
25
on agents, 'puppet agent --configprint modulepath' do
26
modulepath = stdout.split(':')[0]
27
modulepath = modulepath.chomp
28
on agents, "mkdir -p #{modulepath}/test_module/files"
29
on agents, "echo 'Yay, this is the puppet:/// file.' > #{modulepath}/test_module/files/test_file.txt"
32
on agents, %q{echo "file { '/tmp/source_file_test.txt': source => 'puppet:///modules/test_module/test_file.txt', ensure => present }" > /tmp/source_test_manifest.pp}
33
on agents, "puppet apply /tmp/source_test_manifest.pp"
35
on agents, 'test "$(cat /tmp/source_file_test.txt)" = "Yay, this is the puppet:/// file."'
37
# Oops. We (Jesse & Jacob) ended up writing this before realizing that you
38
# can't actually specify "source => 'http://...'". However, we're leaving it
39
# here, since there have been feature requests to support doing this.
40
# -- Mon, 07 Mar 2011 16:12:56 -0800
42
#step "Ensure the test environment is clean"
43
#on agents, 'rm -f /tmp/source_file_test.txt'
45
#step "when using an http:// file path"
47
#File.open '/tmp/puppet-acceptance-webrick-script.rb', 'w' do |file|
48
# file.puts %q{#!/usr/bin/env ruby
52
#class Simple < WEBrick::HTTPServlet::AbstractServlet
53
# def do_GET(request, response)
54
# status, content_type, body = do_stuff_with(request)
56
# response.status = status
57
# response['Content-Type'] = content_type
58
# response.body = body
61
# def do_stuff_with(request)
62
# return 200, "text/plain", "you got a page"
66
#class SimpleTwo < WEBrick::HTTPServlet::AbstractServlet
67
# def do_GET(request, response)
68
# status, content_type, body = do_stuff_with(request)
70
# response.status = status
71
# response['Content-Type'] = content_type
72
# response.body = body
75
# def do_stuff_with(request)
76
# return 200, "text/plain", "you got a different page"
80
#server = WEBrick::HTTPServer.new :Port => 8081
81
#trap "INT" do server.shutdown end
82
#trap "TERM" do server.shutdown end
83
#trap "QUIT" do server.shutdown end
85
#server.mount "/", SimpleTwo
86
#server.mount "/foo.txt", Simple
91
#scp_to master, '/tmp/puppet-acceptance-webrick-script.rb', '/tmp'
92
#on master, "chmod +x /tmp/puppet-acceptance-webrick-script.rb && /tmp/puppet-acceptance-webrick-script.rb &"
94
#manifest = "file { '/tmp/source_file_test.txt': source => 'http://#{master}:8081/foo.txt', ensure => present }"
96
#apply_manifest_on agents, manifest
98
#on agents, 'test "$(cat /tmp/source_file_test.txt)" = "you got a page"'
100
#on master, "killall puppet-acceptance-webrick-script.rb"