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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/.reek +63 -0
  4. data/.travis.yml +11 -0
  5. data/Gemfile +17 -0
  6. data/Gemfile.lock +102 -0
  7. data/README.md +233 -7
  8. data/Rakefile +52 -34
  9. data/Vagrantfile +26 -8
  10. data/examples/aws.rb +85 -0
  11. data/examples/openstack.rb +61 -0
  12. data/examples/passthrough.rb +71 -0
  13. data/lib/rouster.rb +380 -262
  14. data/lib/rouster/deltas.rb +470 -138
  15. data/lib/rouster/puppet.rb +155 -26
  16. data/lib/rouster/testing.rb +205 -46
  17. data/lib/rouster/tests.rb +40 -11
  18. data/lib/rouster/vagrant.rb +311 -0
  19. data/path_helper.rb +3 -4
  20. data/plugins/aws.rb +347 -0
  21. data/plugins/openstack.rb +136 -0
  22. data/test/basic.rb +4 -1
  23. data/test/functional/deltas/test_get_crontab.rb +64 -2
  24. data/test/functional/deltas/test_get_groups.rb +74 -2
  25. data/test/functional/deltas/test_get_os.rb +68 -0
  26. data/test/functional/deltas/test_get_packages.rb +73 -6
  27. data/test/functional/deltas/test_get_ports.rb +26 -1
  28. data/test/functional/deltas/test_get_services.rb +43 -5
  29. data/test/functional/deltas/test_get_users.rb +35 -2
  30. data/test/functional/puppet/test_facter.rb +41 -1
  31. data/test/functional/test_caching.rb +2 -2
  32. data/test/functional/test_inspect.rb +1 -1
  33. data/test/functional/test_is_file.rb +17 -1
  34. data/test/functional/test_is_in_file.rb +40 -0
  35. data/test/functional/test_new.rb +233 -22
  36. data/test/functional/test_passthroughs.rb +94 -0
  37. data/test/functional/test_put.rb +2 -2
  38. data/test/functional/test_validate_file.rb +104 -3
  39. data/test/puppet/test_apply.rb +8 -6
  40. data/test/unit/puppet/resources/puppet_run_with_failed_exec +59 -0
  41. data/test/unit/puppet/resources/puppet_run_with_successful_exec +61 -0
  42. data/test/unit/puppet/test_get_puppet_star.rb +27 -4
  43. data/test/unit/puppet/test_puppet_parsing.rb +44 -0
  44. data/test/unit/test_new.rb +88 -0
  45. data/test/unit/test_parse_ls_string.rb +67 -0
  46. data/test/unit/testing/resources/osx-launchd +285 -0
  47. data/test/unit/testing/resources/rhel-systemd +46 -0
  48. data/test/unit/testing/resources/rhel-systemv +41 -0
  49. data/test/unit/testing/resources/rhel-upstart +20 -0
  50. data/test/unit/testing/test_get_services.rb +178 -0
  51. data/test/unit/testing/test_validate_cron.rb +78 -0
  52. data/test/unit/testing/test_validate_package.rb +36 -10
  53. data/test/unit/testing/test_validate_port.rb +5 -0
  54. metadata +42 -21
  55. 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
@@ -75,7 +75,7 @@ class TestPut < Test::Unit::TestCase
75
75
 
76
76
  def teardown
77
77
  #@app.destroy()
78
- @app.suspend()
78
+ #@app.suspend()
79
79
  File.delete(@kg_location) if File.file?(@kg_location).true?
80
80
  end
81
- end
81
+ end
@@ -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
 
@@ -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
- ## TODO figure out a better pattern here -- scp tunnel is under 'vagrant' context, but dirs created with 'root'
25
- @app.sudo = false
26
- @app.run('mkdir -p manifests/hieradata')
27
- @app.run('mkdir -p modules/role/manifests')
28
- @app.sudo = true
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', 'app' ],
91
+ :contains => [ 'localhost', '127.0.0.1' ],
90
92
  :ensure => 'present',
91
93
  :group => 'root',
92
94
  :owner => 'root',
@@ -0,0 +1,59 @@
1
+ Debug: Creating default schedules
2
+ Debug: 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"}'
3
+ Debug: 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"}'
4
+ Debug: Using settings: adding file resource 'confdir': 'File[/home/vagrant/.puppet]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet"}'
5
+ Debug: 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"}'
6
+ Debug: 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"}'
7
+ Debug: 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"}'
8
+ Debug: 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"}'
9
+ Debug: Using settings: adding file resource 'vardir': 'File[/home/vagrant/.puppet/var]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/var"}'
10
+ Debug: 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"}'
11
+ Debug: 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"}'
12
+ Debug: 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"}'
13
+ Debug: 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"}'
14
+ Debug: 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"}'
15
+ Debug: 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"}'
16
+ Debug: 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"}'
17
+ Debug: 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"}'
18
+ Debug: 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"}'
19
+ Debug: 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"}'
20
+ Debug: 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"}'
21
+ Debug: /File[/home/vagrant/.puppet/var]: Autorequiring File[/home/vagrant/.puppet]
22
+ Debug: /File[/home/vagrant/.puppet/ssl/certs]: Autorequiring File[/home/vagrant/.puppet/ssl]
23
+ Debug: /File[/home/vagrant/.puppet/var/state]: Autorequiring File[/home/vagrant/.puppet/var]
24
+ Debug: /File[/home/vagrant/.puppet/var/state/graphs]: Autorequiring File[/home/vagrant/.puppet/var/state]
25
+ Debug: /File[/home/vagrant/.puppet/var/state/last_run_report.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state]
26
+ Debug: /File[/home/vagrant/.puppet/var/run]: Autorequiring File[/home/vagrant/.puppet/var]
27
+ Debug: /File[/home/vagrant/.puppet/ssl/certificate_requests]: Autorequiring File[/home/vagrant/.puppet/ssl]
28
+ Debug: /File[/home/vagrant/.puppet/ssl]: Autorequiring File[/home/vagrant/.puppet]
29
+ Debug: /File[/home/vagrant/.puppet/var/state/last_run_summary.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state]
30
+ Debug: /File[/home/vagrant/.puppet/ssl/private_keys]: Autorequiring File[/home/vagrant/.puppet/ssl]
31
+ Debug: /File[/home/vagrant/.puppet/var/client_data]: Autorequiring File[/home/vagrant/.puppet/var]
32
+ Debug: /File[/home/vagrant/.puppet/var/client_yaml]: Autorequiring File[/home/vagrant/.puppet/var]
33
+ Debug: /File[/home/vagrant/.puppet/var/clientbucket]: Autorequiring File[/home/vagrant/.puppet/var]
34
+ Debug: /File[/home/vagrant/.puppet/ssl/private]: Autorequiring File[/home/vagrant/.puppet/ssl]
35
+ Debug: /File[/home/vagrant/.puppet/ssl/public_keys]: Autorequiring File[/home/vagrant/.puppet/ssl]
36
+ Debug: /File[/home/vagrant/.puppet/var/log]: Autorequiring File[/home/vagrant/.puppet/var]
37
+ Debug: /File[/home/vagrant/.puppet/var/state/state.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state]
38
+ Debug: /File[/home/vagrant/.puppet/var/lib]: Autorequiring File[/home/vagrant/.puppet/var]
39
+ Debug: Finishing transaction 69859761088440
40
+ Debug: Loaded state in 0.00 seconds
41
+ Debug: Loaded state in 0.00 seconds
42
+ Info: Applying configuration version '1427151219'
43
+ Debug: /Schedule[daily]: Skipping device resources because running on a host
44
+ Debug: /Schedule[monthly]: Skipping device resources because running on a host
45
+ Debug: /Schedule[hourly]: Skipping device resources because running on a host
46
+ Error: Could not find command '/bin/bar'
47
+ Error: /Stage[main]//Exec[bar]/returns: change from notrun to 0 failed: Could not find command '/bin/bar'
48
+ Debug: /Schedule[never]: Skipping device resources because running on a host
49
+ Debug: /Schedule[weekly]: Skipping device resources because running on a host
50
+ Debug: /Schedule[puppet]: Skipping device resources because running on a host
51
+ Debug: Class[Main]: The container Stage[main] will propagate my refresh event
52
+ Debug: Finishing transaction 69859760392420
53
+ Debug: Storing state
54
+ Debug: Stored state in 0.01 seconds
55
+ Notice: Finished catalog run in 0.10 seconds
56
+ Debug: 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"}'
57
+ Debug: Finishing transaction 69859760156920
58
+ Debug: Received report to process from centos6.internal.salesforce.com
59
+ Debug: Processing report from centos6.internal.salesforce.com with processor Puppet::Reports::Store
@@ -0,0 +1,61 @@
1
+ Debug: Creating default schedules
2
+ Debug: 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"}'
3
+ Debug: 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"}'
4
+ Debug: Using settings: adding file resource 'confdir': 'File[/home/vagrant/.puppet]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet"}'
5
+ Debug: 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"}'
6
+ Debug: 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"}'
7
+ Debug: 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"}'
8
+ Debug: 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"}'
9
+ Debug: Using settings: adding file resource 'vardir': 'File[/home/vagrant/.puppet/var]{:loglevel=>:debug, :links=>:follow, :ensure=>:directory, :backup=>false, :path=>"/home/vagrant/.puppet/var"}'
10
+ Debug: 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"}'
11
+ Debug: 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"}'
12
+ Debug: 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"}'
13
+ Debug: 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"}'
14
+ Debug: 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"}'
15
+ Debug: 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"}'
16
+ Debug: 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"}'
17
+ Debug: 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"}'
18
+ Debug: 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"}'
19
+ Debug: 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"}'
20
+ Debug: 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"}'
21
+ Debug: /File[/home/vagrant/.puppet/var]: Autorequiring File[/home/vagrant/.puppet]
22
+ Debug: /File[/home/vagrant/.puppet/ssl/certs]: Autorequiring File[/home/vagrant/.puppet/ssl]
23
+ Debug: /File[/home/vagrant/.puppet/var/state]: Autorequiring File[/home/vagrant/.puppet/var]
24
+ Debug: /File[/home/vagrant/.puppet/var/state/graphs]: Autorequiring File[/home/vagrant/.puppet/var/state]
25
+ Debug: /File[/home/vagrant/.puppet/var/state/last_run_report.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state]
26
+ Debug: /File[/home/vagrant/.puppet/var/run]: Autorequiring File[/home/vagrant/.puppet/var]
27
+ Debug: /File[/home/vagrant/.puppet/ssl/certificate_requests]: Autorequiring File[/home/vagrant/.puppet/ssl]
28
+ Debug: /File[/home/vagrant/.puppet/ssl]: Autorequiring File[/home/vagrant/.puppet]
29
+ Debug: /File[/home/vagrant/.puppet/var/state/last_run_summary.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state]
30
+ Debug: /File[/home/vagrant/.puppet/ssl/private_keys]: Autorequiring File[/home/vagrant/.puppet/ssl]
31
+ Debug: /File[/home/vagrant/.puppet/var/client_data]: Autorequiring File[/home/vagrant/.puppet/var]
32
+ Debug: /File[/home/vagrant/.puppet/var/client_yaml]: Autorequiring File[/home/vagrant/.puppet/var]
33
+ Debug: /File[/home/vagrant/.puppet/var/clientbucket]: Autorequiring File[/home/vagrant/.puppet/var]
34
+ Debug: /File[/home/vagrant/.puppet/ssl/private]: Autorequiring File[/home/vagrant/.puppet/ssl]
35
+ Debug: /File[/home/vagrant/.puppet/ssl/public_keys]: Autorequiring File[/home/vagrant/.puppet/ssl]
36
+ Debug: /File[/home/vagrant/.puppet/var/log]: Autorequiring File[/home/vagrant/.puppet/var]
37
+ Debug: /File[/home/vagrant/.puppet/var/state/state.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state]
38
+ Debug: /File[/home/vagrant/.puppet/var/lib]: Autorequiring File[/home/vagrant/.puppet/var]
39
+ Debug: Finishing transaction 69859761088440
40
+ Debug: Loaded state in 0.00 seconds
41
+ Debug: Loaded state in 0.00 seconds
42
+ Info: Applying configuration version '1427151219'
43
+ Debug: /Schedule[daily]: Skipping device resources because running on a host
44
+ Debug: /Schedule[monthly]: Skipping device resources because running on a host
45
+ Debug: /Schedule[hourly]: Skipping device resources because running on a host
46
+ Debug: Exec[foo](provider=posix): Executing '/bin/echo foo'
47
+ Debug: Executing '/bin/echo foo'
48
+ Notice: /Stage[main]//Exec[foo]/returns: executed successfully
49
+ Debug: /Stage[main]//Exec[foo]: The container Class[Main] will propagate my refresh event
50
+ Debug: /Schedule[never]: Skipping device resources because running on a host
51
+ Debug: /Schedule[weekly]: Skipping device resources because running on a host
52
+ Debug: /Schedule[puppet]: Skipping device resources because running on a host
53
+ Debug: Class[Main]: The container Stage[main] will propagate my refresh event
54
+ Debug: Finishing transaction 69859760392420
55
+ Debug: Storing state
56
+ Debug: Stored state in 0.01 seconds
57
+ Notice: Finished catalog run in 0.10 seconds
58
+ Debug: 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"}'
59
+ Debug: Finishing transaction 69859760156920
60
+ Debug: Received report to process from centos6.internal.salesforce.com
61
+ Debug: Processing report from centos6.internal.salesforce.com with processor Puppet::Reports::Store
@@ -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 test_happy_get_errors
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)\nfizzybang\n[1;35merr: Could not retrieve catalog from remote server: Error 400 on SERVER: no result for [foobar] in Hiera (YAML/CMS)"
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)) # could be split out to a different test
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 test_happy_get_notices
32
+ def test_happy_27_get_notices
34
33
 
35
34
  output = "[0;36mnotice: Not using cache on failed catalog\nfizzbang\n[0;36mnotice: Not using cache on failed catalog"
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
+