rouster 0.7 → 0.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -3
  3. data/README.md +7 -241
  4. data/Rakefile +18 -55
  5. data/Vagrantfile +8 -26
  6. data/lib/rouster.rb +183 -404
  7. data/lib/rouster/deltas.rb +118 -577
  8. data/lib/rouster/puppet.rb +34 -209
  9. data/lib/rouster/testing.rb +59 -366
  10. data/lib/rouster/tests.rb +19 -70
  11. data/path_helper.rb +7 -5
  12. data/rouster.gemspec +1 -3
  13. data/test/basic.rb +1 -4
  14. data/test/functional/deltas/test_get_groups.rb +2 -74
  15. data/test/functional/deltas/test_get_packages.rb +4 -86
  16. data/test/functional/deltas/test_get_ports.rb +1 -26
  17. data/test/functional/deltas/test_get_services.rb +4 -43
  18. data/test/functional/deltas/test_get_users.rb +2 -35
  19. data/test/functional/puppet/test_facter.rb +1 -41
  20. data/test/functional/puppet/test_get_puppet_star.rb +68 -0
  21. data/test/functional/test_caching.rb +1 -5
  22. data/test/functional/test_dirs.rb +0 -25
  23. data/test/functional/test_get.rb +6 -10
  24. data/test/functional/test_inspect.rb +1 -1
  25. data/test/functional/test_is_file.rb +1 -17
  26. data/test/functional/test_new.rb +22 -233
  27. data/test/functional/test_put.rb +11 -9
  28. data/test/functional/test_restart.rb +4 -1
  29. data/test/functional/test_run.rb +3 -2
  30. data/test/puppet/test_apply.rb +11 -13
  31. data/test/puppet/test_roles.rb +173 -0
  32. data/test/unit/test_new.rb +0 -88
  33. data/test/unit/test_parse_ls_string.rb +0 -67
  34. data/test/unit/testing/test_validate_file.rb +47 -39
  35. data/test/unit/testing/test_validate_package.rb +10 -36
  36. metadata +6 -46
  37. data/.reek +0 -63
  38. data/.travis.yml +0 -11
  39. data/Gemfile +0 -17
  40. data/Gemfile.lock +0 -102
  41. data/LICENSE +0 -9
  42. data/examples/aws.rb +0 -85
  43. data/examples/openstack.rb +0 -61
  44. data/examples/passthrough.rb +0 -71
  45. data/lib/rouster/vagrant.rb +0 -311
  46. data/plugins/aws.rb +0 -347
  47. data/plugins/openstack.rb +0 -136
  48. data/test/functional/deltas/test_get_crontab.rb +0 -161
  49. data/test/functional/deltas/test_get_os.rb +0 -68
  50. data/test/functional/test_is_in_file.rb +0 -40
  51. data/test/functional/test_passthroughs.rb +0 -94
  52. data/test/functional/test_validate_file.rb +0 -131
  53. data/test/unit/puppet/resources/puppet_run_with_failed_exec +0 -59
  54. data/test/unit/puppet/resources/puppet_run_with_successful_exec +0 -61
  55. data/test/unit/puppet/test_get_puppet_star.rb +0 -91
  56. data/test/unit/puppet/test_puppet_parsing.rb +0 -44
  57. data/test/unit/testing/resources/osx-launchd +0 -285
  58. data/test/unit/testing/resources/rhel-systemd +0 -46
  59. data/test/unit/testing/resources/rhel-systemv +0 -41
  60. data/test/unit/testing/resources/rhel-upstart +0 -20
  61. data/test/unit/testing/test_get_services.rb +0 -178
  62. data/test/unit/testing/test_validate_cron.rb +0 -78
  63. data/test/unit/testing/test_validate_port.rb +0 -103
@@ -8,7 +8,7 @@ class TestDeltasGetPorts < Test::Unit::TestCase
8
8
 
9
9
  def setup
10
10
  assert_nothing_raised do
11
- @app = Rouster.new(:name => 'app', :cache_timeout => 10)
11
+ @app = Rouster.new(:name => 'app')
12
12
  end
13
13
 
14
14
  @app.up()
@@ -95,7 +95,6 @@ class TestDeltasGetPorts < Test::Unit::TestCase
95
95
  }
96
96
 
97
97
  @app.deltas[:ports] = stock
98
- @app.cache[:ports] = Time.now.to_i # since we're faking the contents, we also need to fake other artifacts that would have been generated
99
98
 
100
99
  assert_equal(true, @app.is_port_open?(1234, 'tcp', true))
101
100
  assert_equal(true, @app.is_port_active?(22, 'tcp', true))
@@ -108,35 +107,11 @@ class TestDeltasGetPorts < Test::Unit::TestCase
108
107
  assert_equal(false, @app.is_port_active?(1234, 'tcp', true))
109
108
 
110
109
  # caching/argument default validation -- can't currently do this, don't know what ports will be open on others systems
111
- # TODO but can fix this by running some ncatish commands
112
110
  #assert_equal(true, @app.is_port_active?(22))
113
111
  #assert_equal(true, @app.is_port_open?(1234))
114
112
 
115
113
  end
116
114
 
117
- def test_happy_path_cache_invalidation
118
- res1, res2 = nil, nil
119
-
120
- assert_nothing_raised do
121
- res1 = @app.get_ports(true)
122
- end
123
-
124
- first_cache_time = @app.cache[:ports]
125
-
126
- sleep (@app.cache_timeout + 1)
127
-
128
- assert_nothing_raised do
129
- res2 = @app.get_ports(true)
130
- end
131
-
132
- second_cache_time = @app.cache[:ports]
133
-
134
- assert_equal(res1, res2)
135
- assert_not_equal(first_cache_time, second_cache_time)
136
- assert(second_cache_time > first_cache_time)
137
-
138
- end
139
-
140
115
  def teardown
141
116
  @app = nil
142
117
  end
@@ -8,12 +8,13 @@ class TestDeltasGetServices < Test::Unit::TestCase
8
8
 
9
9
  def setup
10
10
  assert_nothing_raised do
11
- @app = Rouster.new(:name => 'app', :cache_timeout => 10)
11
+ @app = Rouster.new(:name => 'app')
12
12
  end
13
13
 
14
14
  @app.up()
15
15
 
16
- @allowed_states = %w(exists installed operational running stopped unsure)
16
+ # eventually this should be standardized (and symbolized?)
17
+ @allowed_states = %w(exists operational running stopped)
17
18
  end
18
19
 
19
20
  def test_happy_path
@@ -28,51 +29,11 @@ class TestDeltasGetServices < Test::Unit::TestCase
28
29
 
29
30
  res.each_key do |k|
30
31
  assert_not_nil(res[k])
31
- assert(@allowed_states.member?(res[k]))
32
32
  end
33
33
 
34
- # this isn't the best validation, but does prove a point - no nil keys/values
35
- assert_nothing_raised do
36
- res.keys.sort
37
- res.values.sort
38
- end
39
-
40
- end
41
-
42
- def test_happy_path_caching
43
-
44
- assert_nil(@app.deltas[:services])
45
-
46
- assert_nothing_raised do
47
- @app.get_services(true)
48
- end
49
-
50
- assert_equal(Hash, @app.deltas[:services].class)
51
-
52
34
  end
53
35
 
54
- def test_happy_path_cache_invalidation
55
- res1, res2 = nil, nil
56
-
57
- assert_nothing_raised do
58
- res1 = @app.get_services(true)
59
- end
60
-
61
- first_cache_time = @app.cache[:services]
62
-
63
- sleep (@app.cache_timeout + 1)
64
-
65
- assert_nothing_raised do
66
- res2 = @app.get_services(true)
67
- end
68
-
69
- second_cache_time = @app.cache[:services]
70
-
71
- assert_equal(res1, res2)
72
- assert_not_equal(first_cache_time, second_cache_time)
73
- assert(second_cache_time > first_cache_time)
74
-
75
- end
36
+ # TODO add some caching tests
76
37
 
77
38
  def teardown
78
39
  @app = nil
@@ -8,7 +8,7 @@ class TestDeltasGetUsers < Test::Unit::TestCase
8
8
 
9
9
  def setup
10
10
  assert_nothing_raised do
11
- @app = Rouster.new(:name => 'app', :cache_timeout => 10)
11
+ @app = Rouster.new(:name => 'app')
12
12
  end
13
13
 
14
14
  @app.up()
@@ -36,40 +36,7 @@ class TestDeltasGetUsers < Test::Unit::TestCase
36
36
 
37
37
  end
38
38
 
39
- def test_happy_path_caching
40
-
41
- assert_nil(@app.deltas[:users])
42
-
43
- assert_nothing_raised do
44
- @app.get_users(true)
45
- end
46
-
47
- assert_equal(Hash, @app.deltas[:users].class)
48
-
49
- end
50
-
51
- def test_happy_path_cache_invalidation
52
- res1, res2 = nil, nil
53
-
54
- assert_nothing_raised do
55
- res1 = @app.get_users(true)
56
- end
57
-
58
- first_cache_time = @app.cache[:users]
59
-
60
- sleep (@app.cache_timeout + 1)
61
-
62
- assert_nothing_raised do
63
- res2 = @app.get_users(true)
64
- end
65
-
66
- second_cache_time = @app.cache[:users]
67
-
68
- assert_equal(res1, res2)
69
- assert_not_equal(first_cache_time, second_cache_time)
70
- assert(second_cache_time > first_cache_time)
71
-
72
- end
39
+ # TODO add some caching tests
73
40
 
74
41
  def teardown
75
42
  @app = nil
@@ -8,7 +8,7 @@ class TestFacter < Test::Unit::TestCase
8
8
 
9
9
  def setup
10
10
  assert_nothing_raised do
11
- @app = Rouster.new(:name => 'app', :cache_timeout => 10)
11
+ @app = Rouster.new(:name => 'app')
12
12
  end
13
13
 
14
14
  @app.up()
@@ -38,46 +38,6 @@ class TestFacter < Test::Unit::TestCase
38
38
  assert_equal(nil, @app.facts)
39
39
  end
40
40
 
41
- def test_caching
42
- # NOTE: this only works if (time_to_run_facter < cache_timeout)
43
-
44
- assert_nothing_raised do
45
- @app.facter(true)
46
- end
47
-
48
- first_cached_time = @app.cache[:facter]
49
-
50
- assert_nothing_raised do
51
- @app.facter(true)
52
- end
53
-
54
- second_cached_time = @app.cache[:facter]
55
-
56
- assert_equal(first_cached_time, second_cached_time)
57
-
58
- end
59
-
60
- def test_cache_invalidation
61
-
62
- assert_nothing_raised do
63
- @app.facter(true)
64
- end
65
-
66
- first_cached_time = @app.cache[:facter]
67
-
68
- sleep (@app.cache_timeout + 1)
69
-
70
- assert_nothing_raised do
71
- @app.facter(true)
72
- end
73
-
74
- second_cached_time = @app.cache[:facter]
75
-
76
- assert_not_equal(first_cached_time, second_cached_time)
77
- assert(second_cached_time > first_cached_time)
78
-
79
- end
80
-
81
41
  def test_custom_facts
82
42
 
83
43
  facts = nil
@@ -0,0 +1,68 @@
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 technically 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')
14
+ end
15
+
16
+ # expose private methods
17
+ Rouster.send(:public, *Rouster.protected_instance_methods)
18
+ end
19
+
20
+ def test_happy_get_errors
21
+
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
+ @app.output.push(output)
24
+
25
+ assert_not_nil(@app.get_puppet_errors())
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
28
+
29
+ assert_nil(@app.get_puppet_notices())
30
+
31
+ end
32
+
33
+ def test_happy_get_notices
34
+
35
+ output = "[0;36mnotice: Not using cache on failed catalog\nfizzbang\n[0;36mnotice: Not using cache on failed catalog"
36
+ @app.output.push(output)
37
+
38
+ assert_not_nil(@app.get_puppet_notices())
39
+ assert_equal(2, @app.get_puppet_notices().size)
40
+ assert_equal(@app.get_puppet_notices(), @app.get_puppet_notices(output))
41
+
42
+ assert_nil(@app.get_puppet_errors())
43
+
44
+ end
45
+
46
+ def test_no_errors
47
+
48
+ output = 'there are no errors here'
49
+ @app.output.push(output)
50
+
51
+ assert_nil(@app.get_puppet_errors())
52
+ end
53
+
54
+ def test_no_notices
55
+
56
+ output = 'there are no notices here'
57
+ @app.output.push(output)
58
+
59
+ assert_nil(@app.get_puppet_notices())
60
+
61
+ end
62
+
63
+ def teardown
64
+ # noop
65
+ end
66
+
67
+ end
68
+
@@ -74,12 +74,8 @@ class TestCaching < Test::Unit::TestCase
74
74
  end
75
75
 
76
76
  def test_ssh_caching
77
-
78
77
  timeout = 100
79
- app = Rouster.new(:name => 'app', :sshtunnel => true, :cache_timeout => timeout)
80
- app.destroy() # should be a no-op if running under rake, doing this to be safe
81
-
82
- app.up()
78
+ app = Rouster.new(:name => 'app', :cache_timeout => timeout)
83
79
 
84
80
  assert_equal(app.cache_timeout, timeout)
85
81
 
@@ -56,31 +56,6 @@ class TestDirs < Test::Unit::TestCase
56
56
 
57
57
  end
58
58
 
59
- def test_case_sensitvity
60
- dirs_to_create = ['Fizz', 'foo', 'baz']
61
- dirs_expected_sensitive = ['foo']
62
- dirs_expected_insensitive = ['Fizz', 'foo']
63
-
64
- dirs_to_create.each do |dir|
65
- @app.run(sprintf('mkdir -p %s/%s', @dir, dir))
66
- end
67
-
68
- dirs_actual_sensitive = @app.dirs(@dir, 'f*', false)
69
-
70
- dirs_actual_sensitive.each do |dir|
71
- dir = dir.gsub(/#{@dir}/, '')
72
- assert(dirs_expected_sensitive.member?(dir))
73
- end
74
-
75
- dirs_actual_insensitive = @app.dirs(@dir, 'f*', true)
76
-
77
- dirs_actual_insensitive.each do |dir|
78
- dir = dir.gsub(/#{@dir}/, '')
79
- assert(dirs_expected_insensitive.member?(dir))
80
- end
81
-
82
- end
83
-
84
59
  def teardown
85
60
  @app.run(sprintf('rm -rf %s', @dir))
86
61
  end
@@ -45,8 +45,7 @@ class TestGet < Test::Unit::TestCase
45
45
  def test_remote_path_dne
46
46
 
47
47
  assert_raise Rouster::FileTransferError do
48
- res = @app.get(@kb_dne_location, @kg_local_location)
49
- assert_equal(false, res)
48
+ @app.get(@kb_dne_location, @kg_local_location)
50
49
  end
51
50
 
52
51
  assert_equal(false, File.file?(@kg_local_location), 'known bad remote file path DNE')
@@ -55,7 +54,7 @@ class TestGet < Test::Unit::TestCase
55
54
  def test_with_suspended_machine
56
55
  @app.suspend()
57
56
 
58
- #assert_raise Rouster::SSHConnectionError do <-- this is what we want when the connection is bad, as opposed to permission/disk space issues
57
+ #assert_raise Rouster::SSHConnectionError do <-- why was this ever used?
59
58
  assert_raise Rouster::FileTransferError do
60
59
  @app.get(@kg_remote_location, @kg_local_location)
61
60
  end
@@ -64,13 +63,10 @@ class TestGet < Test::Unit::TestCase
64
63
  end
65
64
 
66
65
  def teardown
67
- File.delete(@kg_local_location) if File.file?(@kg_local_location).true?
68
- end
69
-
70
- def self.shutdown
71
66
  # TODO we should suspend instead if any test failed for triage
72
- #@app.suspend()
73
- #@ppm.suspend()
74
- end
67
+ #@app.destroy()
68
+ #@ppm.destroy()
75
69
 
70
+ File.delete(@kg_local_location) if File.file?(@kg_local_location).true?
71
+ end
76
72
  end
@@ -21,7 +21,7 @@ class TestInspect < Test::Unit::TestCase
21
21
  assert_match(/status/, res)
22
22
  assert_match(/sudo\[true\]/, res)
23
23
  assert_match(/vagrantfile/, res)
24
- assert_match(/verbosity console\[3\] \/ log\[2/, res)
24
+ assert_match(/verbosity\[4\]/, res)
25
25
  end
26
26
 
27
27
  def teardown
@@ -22,9 +22,8 @@ class TestIsFile < Test::Unit::TestCase
22
22
  @file_other_rwx = sprintf('%s/other', @dir_tmp)
23
23
  @file_644 = sprintf('%s/sixfourfour', @dir_tmp)
24
24
  @file_755 = sprintf('%s/sevenfivefive', @dir_tmp)
25
- @symlink = sprintf('%s/symlinking', @dir_tmp)
26
25
 
27
- @files = [@file_user_rwx, @file_group_rwx, @file_other_rwx, @file_644, @file_755, @symlink]
26
+ @files = [@file_user_rwx, @file_group_rwx, @file_other_rwx, @file_644, @file_755]
28
27
  end
29
28
 
30
29
  def test_user
@@ -42,8 +41,6 @@ class TestIsFile < Test::Unit::TestCase
42
41
  assert_equal(false, @app.is_readable?(@file_user_rwx, 'o'))
43
42
  assert_equal(false, @app.is_writeable?(@file_user_rwx, 'o'))
44
43
  assert_equal(false, @app.is_executable?(@file_user_rwx, 'o'))
45
-
46
- assert_equal(false, @app.is_symlink?(@file_755))
47
44
  end
48
45
 
49
46
  def test_group
@@ -61,8 +58,6 @@ class TestIsFile < Test::Unit::TestCase
61
58
  assert_equal(false, @app.is_readable?(@file_group_rwx, 'o'))
62
59
  assert_equal(false, @app.is_writeable?(@file_group_rwx, 'o'))
63
60
  assert_equal(false, @app.is_executable?(@file_group_rwx, 'o'))
64
-
65
- assert_equal(false, @app.is_symlink?(@file_755))
66
61
  end
67
62
 
68
63
  def test_other
@@ -81,7 +76,6 @@ class TestIsFile < Test::Unit::TestCase
81
76
  assert_equal(true, @app.is_writeable?(@file_other_rwx, 'o'))
82
77
  assert_equal(true, @app.is_executable?(@file_other_rwx, 'o'))
83
78
 
84
- assert_equal(false, @app.is_symlink?(@file_755))
85
79
  end
86
80
 
87
81
  def test_644
@@ -99,8 +93,6 @@ class TestIsFile < Test::Unit::TestCase
99
93
  assert_equal(true, @app.is_readable?(@file_644, 'o'))
100
94
  assert_equal(false, @app.is_writeable?(@file_644, 'o'))
101
95
  assert_equal(false, @app.is_executable?(@file_644, 'o'))
102
-
103
- assert_equal(false, @app.is_symlink?(@file_755))
104
96
  end
105
97
 
106
98
  def test_755
@@ -118,14 +110,6 @@ class TestIsFile < Test::Unit::TestCase
118
110
  assert_equal(true, @app.is_readable?(@file_755, 'o'))
119
111
  assert_equal(false, @app.is_writeable?(@file_755, 'o'))
120
112
  assert_equal(true, @app.is_executable?(@file_755, 'o'))
121
-
122
- assert_equal(false, @app.is_symlink?(@file_755))
123
- end
124
-
125
- def test_symlink
126
- @app.run("ln -s /etc/hosts #{@symlink}")
127
-
128
- assert_equal(true, @app.is_symlink?(@symlink))
129
113
  end
130
114
 
131
115
  def teardown