rouster 0.5 → 0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/.reek +63 -0
- data/.travis.yml +11 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +102 -0
- data/README.md +233 -7
- data/Rakefile +52 -34
- data/Vagrantfile +26 -8
- data/examples/aws.rb +85 -0
- data/examples/openstack.rb +61 -0
- data/examples/passthrough.rb +71 -0
- data/lib/rouster.rb +380 -262
- data/lib/rouster/deltas.rb +470 -138
- data/lib/rouster/puppet.rb +155 -26
- data/lib/rouster/testing.rb +205 -46
- data/lib/rouster/tests.rb +40 -11
- data/lib/rouster/vagrant.rb +311 -0
- data/path_helper.rb +3 -4
- data/plugins/aws.rb +347 -0
- data/plugins/openstack.rb +136 -0
- data/test/basic.rb +4 -1
- data/test/functional/deltas/test_get_crontab.rb +64 -2
- data/test/functional/deltas/test_get_groups.rb +74 -2
- data/test/functional/deltas/test_get_os.rb +68 -0
- data/test/functional/deltas/test_get_packages.rb +73 -6
- data/test/functional/deltas/test_get_ports.rb +26 -1
- data/test/functional/deltas/test_get_services.rb +43 -5
- data/test/functional/deltas/test_get_users.rb +35 -2
- data/test/functional/puppet/test_facter.rb +41 -1
- data/test/functional/test_caching.rb +2 -2
- data/test/functional/test_inspect.rb +1 -1
- data/test/functional/test_is_file.rb +17 -1
- data/test/functional/test_is_in_file.rb +40 -0
- data/test/functional/test_new.rb +233 -22
- data/test/functional/test_passthroughs.rb +94 -0
- data/test/functional/test_put.rb +2 -2
- data/test/functional/test_validate_file.rb +104 -3
- data/test/puppet/test_apply.rb +8 -6
- data/test/unit/puppet/resources/puppet_run_with_failed_exec +59 -0
- data/test/unit/puppet/resources/puppet_run_with_successful_exec +61 -0
- data/test/unit/puppet/test_get_puppet_star.rb +27 -4
- data/test/unit/puppet/test_puppet_parsing.rb +44 -0
- data/test/unit/test_new.rb +88 -0
- data/test/unit/test_parse_ls_string.rb +67 -0
- data/test/unit/testing/resources/osx-launchd +285 -0
- data/test/unit/testing/resources/rhel-systemd +46 -0
- data/test/unit/testing/resources/rhel-systemv +41 -0
- data/test/unit/testing/resources/rhel-upstart +20 -0
- data/test/unit/testing/test_get_services.rb +178 -0
- data/test/unit/testing/test_validate_cron.rb +78 -0
- data/test/unit/testing/test_validate_package.rb +36 -10
- data/test/unit/testing/test_validate_port.rb +5 -0
- metadata +42 -21
- data/test/puppet/test_roles.rb +0 -186
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
require sprintf('%s/../../path_helper', File.dirname(File.expand_path(__FILE__)))
|
|
2
|
+
|
|
3
|
+
require 'rouster'
|
|
4
|
+
require 'test/unit'
|
|
5
|
+
|
|
6
|
+
# most of the real passthrough testing is done in test_new.rb, since the only effective difference should be the target of the SSH connection
|
|
7
|
+
|
|
8
|
+
class TestPassthroughs < Test::Unit::TestCase
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
@@user_sshkey = sprintf('%s/.ssh/id_rsa', ENV['HOME'])
|
|
12
|
+
|
|
13
|
+
unless File.file?(@@user_sshkey)
|
|
14
|
+
File.write(@@user_sshkey, '') # either this or `touch`
|
|
15
|
+
File.chmod(0600, @@user_sshkey)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_functional_local_passthrough
|
|
21
|
+
|
|
22
|
+
assert_nothing_raised do
|
|
23
|
+
@local = Rouster.new(
|
|
24
|
+
:name => 'local',
|
|
25
|
+
:passthrough => {
|
|
26
|
+
:type => :local,
|
|
27
|
+
},
|
|
28
|
+
:verbose => 4,
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
assert(@local.is_passthrough?(), 'worker is a passthrough')
|
|
33
|
+
assert_equal(false, @local.is_available_via_ssh?(), 'worker is available via SSH')
|
|
34
|
+
|
|
35
|
+
# put a file in /tmp/fizz and read it back
|
|
36
|
+
tmpfile = sprintf('/tmp/fizzy.%s.%s', Time.now.to_i, $$)
|
|
37
|
+
content = 'this is some sample text'
|
|
38
|
+
|
|
39
|
+
assert_nothing_raised do
|
|
40
|
+
@local.run("echo #{content} >> #{tmpfile}")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
read = @local.run("cat #{tmpfile}").chomp! # using >> automatically includes \n
|
|
44
|
+
|
|
45
|
+
assert_equal(content, read, 'worker is able to read and write files on system')
|
|
46
|
+
|
|
47
|
+
# TODO better here
|
|
48
|
+
assert_nothing_raised do
|
|
49
|
+
@local.file('/etc/hosts')
|
|
50
|
+
@local.dir('/tmp')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_functional_remote_passthrough
|
|
56
|
+
|
|
57
|
+
omit('not running test_good_remote_passthrough, autogenerated a fake ssh key') if File.file?(@@user_sshkey) and File.read(@@user_sshkey).eql?("")
|
|
58
|
+
|
|
59
|
+
host = '127.0.0.1'
|
|
60
|
+
`ssh -i #{@@user_sshkey} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null #{host} exit`
|
|
61
|
+
omit("found an ssh key, but it doesn't appear to be valid for this host") unless $?.success?
|
|
62
|
+
|
|
63
|
+
assert_nothing_raised do
|
|
64
|
+
@remote = Rouster.new(
|
|
65
|
+
:name => 'remote',
|
|
66
|
+
:passthrough => {
|
|
67
|
+
:type => :remote,
|
|
68
|
+
:host => host,
|
|
69
|
+
:user => ENV['USER'],
|
|
70
|
+
:key => @@user_sshkey,
|
|
71
|
+
},
|
|
72
|
+
:verbosity => 4,
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
assert_equal('remote', @remote.name)
|
|
77
|
+
assert_equal(true, @remote.is_passthrough?())
|
|
78
|
+
assert_equal(false, @remote.uses_sudo?())
|
|
79
|
+
assert_equal(true, @remote.is_available_via_ssh?())
|
|
80
|
+
|
|
81
|
+
# TODO better here
|
|
82
|
+
assert_nothing_raised do
|
|
83
|
+
@remote.file('/etc/hosts')
|
|
84
|
+
@remote.dir('/tmp')
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def teardown
|
|
90
|
+
# if the file is empty, we know we created it (or it doesn't matter)..
|
|
91
|
+
File.delete(@@user_sshkey) if File.file?(@@user_sshkey) and File.read(@@user_sshkey).eql?('')
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
end
|
data/test/functional/test_put.rb
CHANGED
|
@@ -17,9 +17,110 @@ class TestValidateFileFunctional < Test::Unit::TestCase
|
|
|
17
17
|
|
|
18
18
|
def test_negative_functional_fallthrough
|
|
19
19
|
|
|
20
|
-
assert_equal(false, @app.validate_file('/foo', {}, false, true))
|
|
21
|
-
assert_equal(false, @app.validate_file('/fizzy', { :ensure => 'directory' }, false, true))
|
|
22
|
-
assert_equal(false, @app.validate_file('/bang', { :ensure => 'file' }, false, true))
|
|
20
|
+
assert_equal(false, @app.validate_file('/foo', {}, false, true), 'when no expectation is specified, :ensure => present is assumed')
|
|
21
|
+
assert_equal(false, @app.validate_file('/fizzy', { :ensure => 'directory' }, false, true), 'standard DNE directory test')
|
|
22
|
+
assert_equal(false, @app.validate_file('/bang', { :ensure => 'file' }, false, true), '~standard DNE directory test')
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# TODO tests
|
|
27
|
+
# :exists vs. :ensure -> what options are supported?
|
|
28
|
+
# :mode vs. :permissions
|
|
29
|
+
# :size
|
|
30
|
+
# :owner
|
|
31
|
+
# :group
|
|
32
|
+
# :constrain
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_happy_basic
|
|
36
|
+
file = '/tmp/chiddy'
|
|
37
|
+
expectation = { :ensure => 'file' }
|
|
38
|
+
|
|
39
|
+
@app.run("touch #{file}")
|
|
40
|
+
|
|
41
|
+
assert_equal(true, @app.validate_file(file, expectation, false, true))
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_happy_doesnt_contain
|
|
46
|
+
file = '/etc/hosts'
|
|
47
|
+
expectations = {
|
|
48
|
+
:ensure => 'file',
|
|
49
|
+
:doesntcontain => 'fizzybang.12345',
|
|
50
|
+
:notcontains => 'this.isnt.there.either'
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
assert_equal(true, @app.validate_file(file, expectations, false, true))
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_happy_contains_string
|
|
58
|
+
file = '/etc/hosts'
|
|
59
|
+
expectations = {
|
|
60
|
+
:ensure => 'file',
|
|
61
|
+
:contains => 'localhost'
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
assert_equal(true, @app.validate_file(file, expectations, false, true))
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_contains_array_ordering
|
|
69
|
+
|
|
70
|
+
file = '/etc/hosts'
|
|
71
|
+
|
|
72
|
+
expectation1 = {
|
|
73
|
+
:ensure => 'file',
|
|
74
|
+
:contains => [ 'localhost', 'foobar' ]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
expectation2 = {
|
|
78
|
+
:ensure => 'file',
|
|
79
|
+
:contains => [ 'foobar', 'localhost' ]
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
[expectation1, expectation2].each do |expectation|
|
|
83
|
+
assert_equal(false, @app.validate_file(file, expectation, false, true))
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def test_not_contains_array_ordering
|
|
89
|
+
file = '/etc/hosts'
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
expectation1 = {
|
|
93
|
+
:ensure => 'file',
|
|
94
|
+
:notcontains => [ 'localhost', 'foobar']
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
expectation2 = {
|
|
98
|
+
:ensure => 'file',
|
|
99
|
+
:notcontains => [ 'foobar', 'localhost' ],
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
[expectation1, expectation2].each do |expectation|
|
|
103
|
+
assert_equal(false, @app.validate_file(file, expectation, false, true))
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_happy_symlink
|
|
109
|
+
file = '/tmp/bang'
|
|
110
|
+
|
|
111
|
+
@app.run("ln -sf /etc/hosts #{file}")
|
|
112
|
+
|
|
113
|
+
expectations = [
|
|
114
|
+
{ :ensure => 'symlink' },
|
|
115
|
+
{ :ensure => 'link' },
|
|
116
|
+
{ :ensure => 'link', :target => '/etc/hosts' }
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
expectations.each do |e|
|
|
120
|
+
# this is a weird convention, maybe reconsider the calling signature for validate_file
|
|
121
|
+
# thinking something like validate_file(expectations) instead of validate_file(file, expectations)
|
|
122
|
+
assert_equal(true, @app.validate_file(file, e, false, true))
|
|
123
|
+
end
|
|
23
124
|
|
|
24
125
|
end
|
|
25
126
|
|
data/test/puppet/test_apply.rb
CHANGED
|
@@ -21,11 +21,13 @@ class TestPuppetApply < Test::Unit::TestCase
|
|
|
21
21
|
'test/puppet/modules/role/manifests/ui.pp' => 'modules/role/manifests/ui.pp',
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
['manifests/hieradata', 'modules/role/manifests'].each do |dir|
|
|
25
|
+
top = dir.split('/')[0]
|
|
26
|
+
|
|
27
|
+
@app.run("mkdir -p #{dir}")
|
|
28
|
+
@app.run("chown -R vagrant:vagrant #{top}") # because sudo=true, directories will be created with root:root
|
|
29
|
+
|
|
30
|
+
end
|
|
29
31
|
|
|
30
32
|
required_files.each_pair do |source,dest|
|
|
31
33
|
@app.put(source, dest)
|
|
@@ -86,7 +88,7 @@ class TestPuppetApply < Test::Unit::TestCase
|
|
|
86
88
|
|
|
87
89
|
app_expected_files = {
|
|
88
90
|
'/etc/hosts' => {
|
|
89
|
-
:contains => [ 'localhost', '
|
|
91
|
+
:contains => [ 'localhost', '127.0.0.1' ],
|
|
90
92
|
:ensure => 'present',
|
|
91
93
|
:group => 'root',
|
|
92
94
|
:owner => 'root',
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[0;36mDebug: Creating default schedules[0m
|
|
2
|
+
[0;36mDebug: Using settings: adding file resource 'clientyamldir': 'File[/home/vagrant/.puppet/var/client_yaml]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/var/client_yaml"}'[0m
|
|
3
|
+
[0;36mDebug: Using settings: adding file resource 'lastrunreport': 'File[/home/vagrant/.puppet/var/state/last_run_report.yaml]{:loglevel=>:debug, :links=>:follow, :ensure=>:file, :backup=>false, :mode=>"640", :path=>"/home/vagrant/.puppet/var/state/last_run_report.yaml"}'[0m
|
|
4
|
+
[0;36mDebug: Using settings: adding file resource 'confdir': 'File[/home/vagrant/.puppet]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet"}'[0m
|
|
5
|
+
[0;36mDebug: Using settings: adding file resource 'ssldir': 'File[/home/vagrant/.puppet/ssl]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"771", :path=>"/home/vagrant/.puppet/ssl"}'[0m
|
|
6
|
+
[0;36mDebug: Using settings: adding file resource 'privatekeydir': 'File[/home/vagrant/.puppet/ssl/private_keys]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/ssl/private_keys"}'[0m
|
|
7
|
+
[0;36mDebug: Using settings: adding file resource 'client_datadir': 'File[/home/vagrant/.puppet/var/client_data]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/var/client_data"}'[0m
|
|
8
|
+
[0;36mDebug: Using settings: adding file resource 'statedir': 'File[/home/vagrant/.puppet/var/state]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"1755", :path=>"/home/vagrant/.puppet/var/state"}'[0m
|
|
9
|
+
[0;36mDebug: Using settings: adding file resource 'vardir': 'File[/home/vagrant/.puppet/var]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/var"}'[0m
|
|
10
|
+
[0;36mDebug: Using settings: adding file resource 'libdir': 'File[/home/vagrant/.puppet/var/lib]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/var/lib"}'[0m
|
|
11
|
+
[0;36mDebug: Using settings: adding file resource 'publickeydir': 'File[/home/vagrant/.puppet/ssl/public_keys]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/ssl/public_keys"}'[0m
|
|
12
|
+
[0;36mDebug: Using settings: adding file resource 'rundir': 'File[/home/vagrant/.puppet/var/run]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"755", :path=>"/home/vagrant/.puppet/var/run"}'[0m
|
|
13
|
+
[0;36mDebug: Using settings: adding file resource 'privatedir': 'File[/home/vagrant/.puppet/ssl/private]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/ssl/private"}'[0m
|
|
14
|
+
[0;36mDebug: Using settings: adding file resource 'statefile': 'File[/home/vagrant/.puppet/var/state/state.yaml]{:loglevel=>:debug, :links=>:follow, :ensure=>:file, :backup=>false, :mode=>"660", :path=>"/home/vagrant/.puppet/var/state/state.yaml"}'[0m
|
|
15
|
+
[0;36mDebug: Using settings: adding file resource 'clientbucketdir': 'File[/home/vagrant/.puppet/var/clientbucket]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/var/clientbucket"}'[0m
|
|
16
|
+
[0;36mDebug: Using settings: adding file resource 'lastrunfile': 'File[/home/vagrant/.puppet/var/state/last_run_summary.yaml]{:loglevel=>:debug, :links=>:follow, :ensure=>:file, :backup=>false, :mode=>"644", :path=>"/home/vagrant/.puppet/var/state/last_run_summary.yaml"}'[0m
|
|
17
|
+
[0;36mDebug: Using settings: adding file resource 'logdir': 'File[/home/vagrant/.puppet/var/log]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/var/log"}'[0m
|
|
18
|
+
[0;36mDebug: Using settings: adding file resource 'certdir': 'File[/home/vagrant/.puppet/ssl/certs]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/ssl/certs"}'[0m
|
|
19
|
+
[0;36mDebug: Using settings: adding file resource 'graphdir': 'File[/home/vagrant/.puppet/var/state/graphs]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/var/state/graphs"}'[0m
|
|
20
|
+
[0;36mDebug: Using settings: adding file resource 'requestdir': 'File[/home/vagrant/.puppet/ssl/certificate_requests]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/ssl/certificate_requests"}'[0m
|
|
21
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var]: Autorequiring File[/home/vagrant/.puppet][0m
|
|
22
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/ssl/certs]: Autorequiring File[/home/vagrant/.puppet/ssl][0m
|
|
23
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/state]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
24
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/state/graphs]: Autorequiring File[/home/vagrant/.puppet/var/state][0m
|
|
25
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/state/last_run_report.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state][0m
|
|
26
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/run]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
27
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/ssl/certificate_requests]: Autorequiring File[/home/vagrant/.puppet/ssl][0m
|
|
28
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/ssl]: Autorequiring File[/home/vagrant/.puppet][0m
|
|
29
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/state/last_run_summary.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state][0m
|
|
30
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/ssl/private_keys]: Autorequiring File[/home/vagrant/.puppet/ssl][0m
|
|
31
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/client_data]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
32
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/client_yaml]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
33
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/clientbucket]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
34
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/ssl/private]: Autorequiring File[/home/vagrant/.puppet/ssl][0m
|
|
35
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/ssl/public_keys]: Autorequiring File[/home/vagrant/.puppet/ssl][0m
|
|
36
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/log]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
37
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/state/state.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state][0m
|
|
38
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/lib]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
39
|
+
[0;36mDebug: Finishing transaction 69859761088440[0m
|
|
40
|
+
[0;36mDebug: Loaded state in 0.00 seconds[0m
|
|
41
|
+
[0;36mDebug: Loaded state in 0.00 seconds[0m
|
|
42
|
+
[0;32mInfo: Applying configuration version '1427151219'[0m
|
|
43
|
+
[0;36mDebug: /Schedule[daily]: Skipping device resources because running on a host[0m
|
|
44
|
+
[0;36mDebug: /Schedule[monthly]: Skipping device resources because running on a host[0m
|
|
45
|
+
[0;36mDebug: /Schedule[hourly]: Skipping device resources because running on a host[0m
|
|
46
|
+
[1;31mError: Could not find command '/bin/bar'[0m
|
|
47
|
+
[1;31mError: /Stage[main]//Exec[bar]/returns: change from notrun to 0 failed: Could not find command '/bin/bar'[0m
|
|
48
|
+
[0;36mDebug: /Schedule[never]: Skipping device resources because running on a host[0m
|
|
49
|
+
[0;36mDebug: /Schedule[weekly]: Skipping device resources because running on a host[0m
|
|
50
|
+
[0;36mDebug: /Schedule[puppet]: Skipping device resources because running on a host[0m
|
|
51
|
+
[0;36mDebug: Class[Main]: The container Stage[main] will propagate my refresh event[0m
|
|
52
|
+
[0;36mDebug: Finishing transaction 69859760392420[0m
|
|
53
|
+
[0;36mDebug: Storing state[0m
|
|
54
|
+
[0;36mDebug: Stored state in 0.01 seconds[0m
|
|
55
|
+
[mNotice: Finished catalog run in 0.10 seconds[0m
|
|
56
|
+
[0;36mDebug: Using settings: adding file resource 'rrddir': 'File[/home/vagrant/.puppet/var/rrd]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/var/rrd"}'[0m
|
|
57
|
+
[0;36mDebug: Finishing transaction 69859760156920[0m
|
|
58
|
+
[0;36mDebug: Received report to process from centos6.internal.salesforce.com[0m
|
|
59
|
+
[0;36mDebug: Processing report from centos6.internal.salesforce.com with processor Puppet::Reports::Store[0m
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[0;36mDebug: Creating default schedules[0m
|
|
2
|
+
[0;36mDebug: Using settings: adding file resource 'clientyamldir': 'File[/home/vagrant/.puppet/var/client_yaml]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/var/client_yaml"}'[0m
|
|
3
|
+
[0;36mDebug: Using settings: adding file resource 'lastrunreport': 'File[/home/vagrant/.puppet/var/state/last_run_report.yaml]{:loglevel=>:debug, :links=>:follow, :ensure=>:file, :backup=>false, :mode=>"640", :path=>"/home/vagrant/.puppet/var/state/last_run_report.yaml"}'[0m
|
|
4
|
+
[0;36mDebug: Using settings: adding file resource 'confdir': 'File[/home/vagrant/.puppet]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet"}'[0m
|
|
5
|
+
[0;36mDebug: Using settings: adding file resource 'ssldir': 'File[/home/vagrant/.puppet/ssl]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"771", :path=>"/home/vagrant/.puppet/ssl"}'[0m
|
|
6
|
+
[0;36mDebug: Using settings: adding file resource 'privatekeydir': 'File[/home/vagrant/.puppet/ssl/private_keys]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/ssl/private_keys"}'[0m
|
|
7
|
+
[0;36mDebug: Using settings: adding file resource 'client_datadir': 'File[/home/vagrant/.puppet/var/client_data]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/var/client_data"}'[0m
|
|
8
|
+
[0;36mDebug: Using settings: adding file resource 'statedir': 'File[/home/vagrant/.puppet/var/state]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"1755", :path=>"/home/vagrant/.puppet/var/state"}'[0m
|
|
9
|
+
[0;36mDebug: Using settings: adding file resource 'vardir': 'File[/home/vagrant/.puppet/var]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/var"}'[0m
|
|
10
|
+
[0;36mDebug: Using settings: adding file resource 'libdir': 'File[/home/vagrant/.puppet/var/lib]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/var/lib"}'[0m
|
|
11
|
+
[0;36mDebug: Using settings: adding file resource 'publickeydir': 'File[/home/vagrant/.puppet/ssl/public_keys]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/ssl/public_keys"}'[0m
|
|
12
|
+
[0;36mDebug: Using settings: adding file resource 'rundir': 'File[/home/vagrant/.puppet/var/run]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"755", :path=>"/home/vagrant/.puppet/var/run"}'[0m
|
|
13
|
+
[0;36mDebug: Using settings: adding file resource 'privatedir': 'File[/home/vagrant/.puppet/ssl/private]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/ssl/private"}'[0m
|
|
14
|
+
[0;36mDebug: Using settings: adding file resource 'statefile': 'File[/home/vagrant/.puppet/var/state/state.yaml]{:loglevel=>:debug, :links=>:follow, :ensure=>:file, :backup=>false, :mode=>"660", :path=>"/home/vagrant/.puppet/var/state/state.yaml"}'[0m
|
|
15
|
+
[0;36mDebug: Using settings: adding file resource 'clientbucketdir': 'File[/home/vagrant/.puppet/var/clientbucket]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/var/clientbucket"}'[0m
|
|
16
|
+
[0;36mDebug: Using settings: adding file resource 'lastrunfile': 'File[/home/vagrant/.puppet/var/state/last_run_summary.yaml]{:loglevel=>:debug, :links=>:follow, :ensure=>:file, :backup=>false, :mode=>"644", :path=>"/home/vagrant/.puppet/var/state/last_run_summary.yaml"}'[0m
|
|
17
|
+
[0;36mDebug: Using settings: adding file resource 'logdir': 'File[/home/vagrant/.puppet/var/log]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/var/log"}'[0m
|
|
18
|
+
[0;36mDebug: Using settings: adding file resource 'certdir': 'File[/home/vagrant/.puppet/ssl/certs]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/ssl/certs"}'[0m
|
|
19
|
+
[0;36mDebug: Using settings: adding file resource 'graphdir': 'File[/home/vagrant/.puppet/var/state/graphs]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/var/state/graphs"}'[0m
|
|
20
|
+
[0;36mDebug: Using settings: adding file resource 'requestdir': 'File[/home/vagrant/.puppet/ssl/certificate_requests]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/ssl/certificate_requests"}'[0m
|
|
21
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var]: Autorequiring File[/home/vagrant/.puppet][0m
|
|
22
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/ssl/certs]: Autorequiring File[/home/vagrant/.puppet/ssl][0m
|
|
23
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/state]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
24
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/state/graphs]: Autorequiring File[/home/vagrant/.puppet/var/state][0m
|
|
25
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/state/last_run_report.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state][0m
|
|
26
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/run]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
27
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/ssl/certificate_requests]: Autorequiring File[/home/vagrant/.puppet/ssl][0m
|
|
28
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/ssl]: Autorequiring File[/home/vagrant/.puppet][0m
|
|
29
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/state/last_run_summary.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state][0m
|
|
30
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/ssl/private_keys]: Autorequiring File[/home/vagrant/.puppet/ssl][0m
|
|
31
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/client_data]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
32
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/client_yaml]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
33
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/clientbucket]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
34
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/ssl/private]: Autorequiring File[/home/vagrant/.puppet/ssl][0m
|
|
35
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/ssl/public_keys]: Autorequiring File[/home/vagrant/.puppet/ssl][0m
|
|
36
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/log]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
37
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/state/state.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state][0m
|
|
38
|
+
[0;36mDebug: /File[/home/vagrant/.puppet/var/lib]: Autorequiring File[/home/vagrant/.puppet/var][0m
|
|
39
|
+
[0;36mDebug: Finishing transaction 69859761088440[0m
|
|
40
|
+
[0;36mDebug: Loaded state in 0.00 seconds[0m
|
|
41
|
+
[0;36mDebug: Loaded state in 0.00 seconds[0m
|
|
42
|
+
[0;32mInfo: Applying configuration version '1427151219'[0m
|
|
43
|
+
[0;36mDebug: /Schedule[daily]: Skipping device resources because running on a host[0m
|
|
44
|
+
[0;36mDebug: /Schedule[monthly]: Skipping device resources because running on a host[0m
|
|
45
|
+
[0;36mDebug: /Schedule[hourly]: Skipping device resources because running on a host[0m
|
|
46
|
+
[0;36mDebug: Exec[foo](provider=posix): Executing '/bin/echo foo'[0m
|
|
47
|
+
[0;36mDebug: Executing '/bin/echo foo'[0m
|
|
48
|
+
[mNotice: /Stage[main]//Exec[foo]/returns: executed successfully[0m
|
|
49
|
+
[0;36mDebug: /Stage[main]//Exec[foo]: The container Class[Main] will propagate my refresh event[0m
|
|
50
|
+
[0;36mDebug: /Schedule[never]: Skipping device resources because running on a host[0m
|
|
51
|
+
[0;36mDebug: /Schedule[weekly]: Skipping device resources because running on a host[0m
|
|
52
|
+
[0;36mDebug: /Schedule[puppet]: Skipping device resources because running on a host[0m
|
|
53
|
+
[0;36mDebug: Class[Main]: The container Stage[main] will propagate my refresh event[0m
|
|
54
|
+
[0;36mDebug: Finishing transaction 69859760392420[0m
|
|
55
|
+
[0;36mDebug: Storing state[0m
|
|
56
|
+
[0;36mDebug: Stored state in 0.01 seconds[0m
|
|
57
|
+
[mNotice: Finished catalog run in 0.10 seconds[0m
|
|
58
|
+
[0;36mDebug: Using settings: adding file resource 'rrddir': 'File[/home/vagrant/.puppet/var/rrd]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"750", :path=>"/home/vagrant/.puppet/var/rrd"}'[0m
|
|
59
|
+
[0;36mDebug: Finishing transaction 69859760156920[0m
|
|
60
|
+
[0;36mDebug: Received report to process from centos6.internal.salesforce.com[0m
|
|
61
|
+
[0;36mDebug: Processing report from centos6.internal.salesforce.com with processor Puppet::Reports::Store[0m
|
|
@@ -17,20 +17,19 @@ class TestGetPuppetStar < Test::Unit::TestCase
|
|
|
17
17
|
Rouster.send(:public, *Rouster.protected_instance_methods)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def
|
|
20
|
+
def test_happy_27_get_errors
|
|
21
21
|
|
|
22
22
|
output = "[1;35merr: Could not retrieve catalog from remote server: Error 400 on SERVER: no result for [api_vip] in Hiera (YAML/CMS)[0m\nfizzybang\n[1;35merr: Could not retrieve catalog from remote server: Error 400 on SERVER: no result for [foobar] in Hiera (YAML/CMS)[0m"
|
|
23
23
|
@app.output.push(output)
|
|
24
24
|
|
|
25
25
|
assert_not_nil(@app.get_puppet_errors())
|
|
26
26
|
assert_equal(2, @app.get_puppet_errors().size)
|
|
27
|
-
assert_equal(@app.get_puppet_errors(), @app.get_puppet_errors(output)) #
|
|
27
|
+
assert_equal(@app.get_puppet_errors(), @app.get_puppet_errors(output)) # tests that passed args is same as derived
|
|
28
28
|
|
|
29
29
|
assert_nil(@app.get_puppet_notices())
|
|
30
|
-
|
|
31
30
|
end
|
|
32
31
|
|
|
33
|
-
def
|
|
32
|
+
def test_happy_27_get_notices
|
|
34
33
|
|
|
35
34
|
output = "[0;36mnotice: Not using cache on failed catalog[0m\nfizzbang\n[0;36mnotice: Not using cache on failed catalog[0m"
|
|
36
35
|
@app.output.push(output)
|
|
@@ -43,6 +42,30 @@ class TestGetPuppetStar < Test::Unit::TestCase
|
|
|
43
42
|
|
|
44
43
|
end
|
|
45
44
|
|
|
45
|
+
def test_happy_30_get_errors
|
|
46
|
+
|
|
47
|
+
output = "\e[0;32mInfo: Retrieving plugin\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/root_home.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/drac_version.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/sfdc-custom_facts.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/drac_fw_version.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/razor_version.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/oob_mac.rb\e[0m\n\e[1;31mError: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class razor for ops-tools1-1-piab.ops.sfdc.net on node ops-tools1-1-piab.ops.sfdc.net\e[0m\n\e[1;31mWarning: Not using cache on failed catalog\e[0m\n\e[1;31mError: Could not retrieve catalog; skipping run\e[0m\n"
|
|
48
|
+
@app.output.push(output)
|
|
49
|
+
|
|
50
|
+
assert_not_nil(@app.get_puppet_errors())
|
|
51
|
+
assert_equal(2, @app.get_puppet_errors().size)
|
|
52
|
+
assert_equal(@app.get_puppet_errors(), @app.get_puppet_errors(output))
|
|
53
|
+
|
|
54
|
+
assert_nil(@app.get_puppet_notices())
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_happy_30_get_notices
|
|
58
|
+
|
|
59
|
+
output = "\e[0;32mInfo: Retrieving plugin\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/root_home.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/drac_version.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/sfdc-custom_facts.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/drac_fw_version.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/razor_version.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb\e[0m\n\e[0;32mInfo: Loading facts in /var/lib/puppet/lib/facter/oob_mac.rb\e[0m\n\e[0;32mInfo: Caching catalog for ops-tools1-1-piab.ops.sfdc.net\e[0m\n\e[0;32mInfo: Applying configuration version '1385418175'\e[0m\n\e[mNotice: /Stage[main]/Razor::Service/Razor::Api[tag]/Exec[razor-api-tag]/returns: executed successfully\e[0m\n\e[mNotice: /Stage[main]/Razor::Service/Razor::Api[policy]/Exec[razor-api-policy]/returns: executed successfully\e[0m\n\e[mNotice: /Stage[main]/Razor::Service/Razor::Api[model]/Exec[razor-api-model]/returns: executed successfully\e[0m\n\e[mNotice: Finished catalog run in 33.76 seconds\e[0m\n"
|
|
60
|
+
@app.output.push(output)
|
|
61
|
+
|
|
62
|
+
assert_not_nil(@app.get_puppet_notices())
|
|
63
|
+
assert_equal(4, @app.get_puppet_notices().size)
|
|
64
|
+
assert_equal(@app.get_puppet_notices(), @app.get_puppet_notices(output))
|
|
65
|
+
|
|
66
|
+
assert_nil(@app.get_puppet_errors())
|
|
67
|
+
end
|
|
68
|
+
|
|
46
69
|
def test_no_errors
|
|
47
70
|
|
|
48
71
|
output = 'there are no errors here'
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require sprintf('%s/../../../path_helper', File.dirname(File.expand_path(__FILE__)))
|
|
2
|
+
|
|
3
|
+
require 'rouster'
|
|
4
|
+
require 'rouster/puppet'
|
|
5
|
+
require 'test/unit'
|
|
6
|
+
|
|
7
|
+
# this is a unit test, no need for a real Rouster VM
|
|
8
|
+
|
|
9
|
+
class TestGetPuppetStar < Test::Unit::TestCase
|
|
10
|
+
|
|
11
|
+
def setup
|
|
12
|
+
assert_nothing_raised do
|
|
13
|
+
@app = Rouster.new(:name => 'app', :unittest => true)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# expose private methods
|
|
17
|
+
Rouster.send(:public, *Rouster.protected_instance_methods)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_with_successful_exec
|
|
21
|
+
title = 'foo'
|
|
22
|
+
input = File.read(sprintf('%s/../../../test/unit/puppet/resources/puppet_run_with_successful_exec', File.dirname(File.expand_path(__FILE__))))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
assert(@app.did_exec_fire?(title, input))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_with_failed_exec
|
|
29
|
+
title = 'bar'
|
|
30
|
+
input = File.read(sprintf('%s/../../../test/unit/puppet/resources/puppet_run_with_failed_exec', File.dirname(File.expand_path(__FILE__))))
|
|
31
|
+
|
|
32
|
+
assert(@app.did_exec_fire?(title, input))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_looking_for_nonexistent_exec
|
|
36
|
+
title = 'fizzbang'
|
|
37
|
+
input = File.read(sprintf('%s/../../../test/unit/puppet/resources/puppet_run_with_successful_exec', File.dirname(File.expand_path(__FILE__))))
|
|
38
|
+
|
|
39
|
+
assert_false(@app.did_exec_fire?(title, input))
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|