~ubuntu-branches/ubuntu/lucid/puppet/lucid

« back to all changes in this revision

Viewing changes to test/other/events.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
 
9
9
class TestEvents < Test::Unit::TestCase
10
 
        include PuppetTest
 
10
    include PuppetTest
11
11
 
12
12
    def test_simplesubscribe
13
13
        name = tempfile()
14
 
        file = Puppet.type(:file).create(
 
14
        file = Puppet::Type.type(:file).new(
15
15
            :name => name,
16
16
            :ensure => "file"
17
17
        )
18
 
        exec = Puppet.type(:exec).create(
 
18
        exec = Puppet::Type.type(:exec).new(
19
19
            :name => "echo true",
20
20
            :path => "/usr/bin:/bin",
21
21
            :refreshonly => true,
22
 
            :subscribe => [[file.class.name, file.name]] 
 
22
            :subscribe => Puppet::Resource::Reference.new(file.class.name, file.name)
23
23
        )
24
24
 
25
25
        comp = mk_catalog("eventtesting", file, exec)
31
31
 
32
32
    def test_simplerequire
33
33
        name = tempfile()
34
 
        file = Puppet.type(:file).create(
 
34
        file = Puppet::Type.type(:file).new(
35
35
            :name => name,
36
36
            :ensure => "file"
37
37
        )
38
 
        exec = Puppet.type(:exec).create(
 
38
        exec = Puppet::Type.type(:exec).new(
39
39
            :name => "echo true",
40
40
            :path => "/usr/bin:/bin",
41
41
            :refreshonly => true,
42
 
            :require => [[file.class.name, file.name]] 
 
42
            :require => Puppet::Resource::Reference.new(file.class.name, file.name)
43
43
        )
44
44
 
45
45
 
57
57
        files = []
58
58
 
59
59
        4.times { |i|
60
 
            files << Puppet.type(:file).create(
 
60
            files << Puppet::Type.type(:file).new(
61
61
                :name => tempfile(),
62
62
                :ensure => "file"
63
63
            )
64
64
        }
65
65
 
66
66
        fname = tempfile()
67
 
        exec = Puppet.type(:exec).create(
 
67
        exec = Puppet::Type.type(:exec).new(
68
68
            :name => "touch %s" % fname,
69
69
            :path => "/usr/bin:/bin",
70
70
            :refreshonly => true
71
71
        )
72
72
 
73
73
        exec[:subscribe] = files.collect { |f|
74
 
            ["file", f.name]
 
74
            Puppet::Resource::Reference.new(:file, f.name)
75
75
        }
76
76
 
77
77
        comp = mk_catalog(exec, *files)
84
84
    def test_refreshordering
85
85
        file = tempfile()
86
86
 
87
 
        exec1 = Puppet.type(:exec).create(
 
87
        exec1 = Puppet::Type.type(:exec).new(
88
88
            :title => "one",
89
89
            :name => "echo one >> %s" % file,
90
90
            :path => "/usr/bin:/bin"
91
91
        )
92
92
 
93
 
        exec2 = Puppet.type(:exec).create(
 
93
        exec2 = Puppet::Type.type(:exec).new(
94
94
            :title => "two",
95
95
            :name => "echo two >> %s" % file,
96
96
            :path => "/usr/bin:/bin",
98
98
            :subscribe => exec1
99
99
        )
100
100
 
101
 
        exec3 = Puppet.type(:exec).create(
 
101
        exec3 = Puppet::Type.type(:exec).new(
102
102
            :title => "three",
103
103
            :name => "echo three >> %s" % file,
104
104
            :path => "/usr/bin:/bin",
107
107
        execs = [exec1, exec2, exec3]
108
108
 
109
109
        config = mk_catalog(exec1,exec2,exec3)
110
 
        
 
110
 
111
111
        trans = Puppet::Transaction.new(config)
112
112
        execs.each do |e| assert(config.vertex?(e), "%s is not in graph" % e.title) end
113
113
        trans.prepare
114
114
        execs.each do |e| assert(config.vertex?(e), "%s is not in relgraph" % e.title) end
115
115
        reverse = trans.relationship_graph.reversal
116
116
        execs.each do |e| assert(reverse.vertex?(e), "%s is not in reversed graph" % e.title) end
117
 
        
 
117
 
118
118
        config.apply
119
119
 
120
120
        assert(FileTest.exists?(file), "File does not exist")