rouster 0.7 → 0.41

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 (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
@@ -7,25 +7,13 @@ require 'test/unit'
7
7
 
8
8
  class TestNew < Test::Unit::TestCase
9
9
 
10
- # when run under Rake, if named 'setup', @@user_sshkey is not initialized in the
11
- # TestNew namespace (does not matter if running directly). since setup() really
12
- # only needed to be run once anyway, this isn't a huge problem
13
- def test_0_setup
14
- @app = Rouster.new(:name => 'app', :sshtunnel => false)
15
- @app.destroy() if @app.status().eql?('running') # TODO do we really need to do this?
10
+ def setup
11
+ @app = Rouster.new(:name => 'app')
12
+ @app.destroy() if @app.status().eql?('running')
16
13
  @app = nil
17
-
18
- @@user_sshkey = sprintf('%s/.ssh/id_rsa', ENV['HOME'])
19
-
20
- unless File.file?(@@user_sshkey)
21
- #`ssh-keygen -t rsa -q -f #{@@user_sshkey} -N ''` # this will create the file, and we can track with another class variable.. but how do we safely install/uninstall this to localhost ~/.ssh/authorized_keys ?
22
- File.write(@@user_sshkey, '') # either this or `touch`
23
- File.chmod(0600, @@user_sshkey)
24
- end
25
-
26
14
  end
27
15
 
28
- def test_able_to_instantiate
16
+ def test_1_able_to_instantiate
29
17
 
30
18
  assert_nothing_raised do
31
19
  @app = Rouster.new(:name => 'app')
@@ -33,93 +21,62 @@ class TestNew < Test::Unit::TestCase
33
21
 
34
22
  end
35
23
 
36
- def test_defaults
37
-
38
- assert_nothing_raised do
39
- @app = Rouster.new(:name => 'app')
40
- end
41
-
42
- assert_equal('app', @app.name)
43
- assert_equal(false, @app.cache_timeout)
44
- assert_equal(false, @app.instance_variable_get(:@logfile))
45
- assert_equal(false, @app.is_passthrough?())
46
- assert_equal(0, @app.retries)
47
- assert_equal(true, @app.instance_variable_get(:@sshtunnel))
48
- assert_equal(false, @app.instance_variable_get(:@unittest))
49
- assert_equal(false, @app.instance_variable_get(:@vagrant_concurrency))
50
- assert_equal(3, @app.instance_variable_get(:@verbosity_console))
51
- assert_equal(2, @app.instance_variable_get(:@verbosity_logfile))
52
-
53
- end
54
-
55
- def test_good_openssh_tunnel
24
+ def test_2_good_openssh_tunnel
56
25
  @app = Rouster.new(:name => 'app', :sshtunnel => true)
57
26
 
58
27
  # TODO how do we properly test this? we really need the rspec should_call mechanism...
28
+
59
29
  assert_equal(true, @app.is_available_via_ssh?)
60
30
  end
61
31
 
62
- def test_good_advanced_instantiation
32
+ def test_3_good_advanced_instantiation
63
33
 
64
34
  assert_nothing_raised do
65
35
  @app = Rouster.new(
66
- :name => 'app',
67
- :passthrough => false,
68
- :sudo => false,
69
- :verbosity => [4,0],
70
- #:vagrantfile => traverse_up(Dir.pwd, 'Vagrantfile'), # this is what happens anyway..
71
- :sshkey => ENV['VAGRANT_HOME'].nil? ? sprintf('%s/.vagrant.d/insecure_private_key', ENV['HOME']) : sprintf('%s/insecure_private_key', ENV['VAGRANT_HOME']),
72
- :cache_timeout => 10,
73
- :logfile => true,
36
+ :name => 'app',
37
+ :passthrough => true,
38
+ :sudo => false,
39
+ :verbosity => 4,
40
+ #:vagrantfile => traverse_up(Dir.pwd, 'Vagrantfile'), # this is what happens anyway..
41
+ :sshkey => ENV['VAGRANT_HOME'].nil? ? sprintf('%s/.vagrant.d/insecure_private_key', ENV['HOME']) : sprintf('%s/insecure_private_key', ENV['VAGRANT_HOME']),
74
42
  )
75
43
 
44
+
76
45
  end
77
46
 
78
47
  assert_equal('app', @app.name)
79
- assert_equal(false, @app.is_passthrough?())
48
+ assert_equal(true, @app.is_passthrough?())
80
49
  assert_equal(false, @app.uses_sudo?())
81
- assert_equal(4, @app.instance_variable_get(:@verbosity_console))
82
- assert_equal(0, @app.instance_variable_get(:@verbosity_logfile))
50
+ assert_equal(4, @app.verbosity) # is this going to be strinigified?
83
51
  assert_equal(true, File.file?(@app.vagrantfile))
84
52
  assert_equal(true, File.file?(@app.sshkey))
85
- assert_equal(10, @app.cache_timeout)
86
-
87
- ## logfile validation -- do we need to do more here?
88
- logfile = @app.instance_variable_get(:@logfile)
89
-
90
- assert_not_equal(true, logfile)
91
- assert(File.file?(logfile))
92
-
93
- contents = File.read(logfile)
94
- assert_not_nil(contents)
95
53
  end
96
54
 
97
- def test_bad_name_instantiation
55
+ def test_4_bad_name_instantiation
98
56
 
99
- # TODO this is probably wrong, should really be an ArgumentError
100
57
  assert_raise Rouster::InternalError do
101
58
  @app = Rouster.new(:name => 'foo')
102
59
  end
103
60
 
104
- assert_raise Rouster::ArgumentError do
61
+ assert_raise Rouster::InternalError do
105
62
  @app = Rouster.new(:not_a_name => 'test')
106
63
  end
107
64
 
108
65
  end
109
66
 
110
- def test_bad_vagrantfile_instantiation
67
+ def test_5_bad_vagrantfile_instantiation
111
68
 
112
69
  assert_raise Rouster::InternalError do
113
70
  @app = Rouster.new(:name => 'FIZZY') # auto find Vagrantfile
114
71
  end
115
72
 
116
- assert_raise Rouster::ArgumentError do
73
+ assert_raise Rouster::InternalError do
117
74
  @app = Rouster.new(:name => 'testing', :vagrantfile => '/this/file/dne')
118
75
  end
119
76
 
120
77
  end
121
78
 
122
- def test_bad_sshkey_instantiation
79
+ def test_6_bad_sshkey_instantiation
123
80
 
124
81
  assert_raise Rouster::InternalError do
125
82
  @app = Rouster.new(:name => 'app', :sshkey => '/this/file/dne')
@@ -127,177 +84,9 @@ class TestNew < Test::Unit::TestCase
127
84
 
128
85
  end
129
86
 
130
- def test_good_local_passthrough
131
-
132
- assert_nothing_raised do
133
- @app = Rouster.new(:name => 'local', :passthrough => { :type => :local }, :verbosity => 4)
134
- end
135
-
136
- assert_equal('local', @app.name)
137
- assert_equal(true, @app.is_passthrough?())
138
- assert_equal(false, @app.uses_sudo?())
139
- assert_equal(false, @app.is_available_via_ssh?())
140
-
141
- end
142
-
143
- def test_good_remote_passthrough
144
-
145
- omit('not running test_good_remote_passthrough, autogenerated a fake ssh key') if File.file?(@@user_sshkey) and File.read(@@user_sshkey).eql?("")
146
-
147
- host = '127.0.0.1'
148
- `ssh -i #{@@user_sshkey} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null #{host} exit` # if this succeeds, we want to exit immediately so we don't get hung
149
- omit("found an ssh key, but it doesn't appear to be valid for this host") unless $?.success?
150
-
151
- assert_nothing_raised do
152
- @app = Rouster.new(
153
- :name => 'remote',
154
- :sudo => false,
155
- :passthrough => {
156
- :type => :remote,
157
- :host => host,
158
- :user => ENV['USER'],
159
- :key => @@user_sshkey,
160
- :paranoid => false,
161
- },
162
- :verbosity => 4,
163
- )
164
- end
165
-
166
- assert_equal('remote', @app.name)
167
- assert_equal(true, @app.is_passthrough?())
168
- assert_equal(false, @app.uses_sudo?())
169
- assert_equal(true, @app.is_available_via_ssh?())
170
-
171
- end
172
-
173
- def test_paranoia_remote_passthrough
174
-
175
- omit('not running test_good_remote_passthrough, autogenerated a fake ssh key') if File.file?(@@user_sshkey) and File.read(@@user_sshkey).eql?("")
176
-
177
- host = '127.0.0.1'
178
- `ssh -i #{@@user_sshkey} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null #{host} exit` # if this succeeds, we want to exit immediately so we don't get hung
179
- omit("found an ssh key, but it doesn't appear to be valid for this host") unless $?.success?
180
-
181
- assert_nothing_raised do
182
- @app = Rouster.new(
183
- :name => 'remote',
184
- :sudo => false,
185
- :passthrough => {
186
- :type => :remote,
187
- :host => host,
188
- :user => ENV['USER'],
189
- :key => @@user_sshkey,
190
- :paranoid => :very,
191
- },
192
- :verbosity => 4,
193
- )
194
- end
195
-
196
- assert_equal('remote', @app.name)
197
- assert_equal(true, @app.is_passthrough?())
198
- assert_equal(false, @app.uses_sudo?())
199
- assert_equal(true, @app.is_available_via_ssh?())
200
-
201
- end
202
-
203
-
204
- def test_invalid_passthrough
205
-
206
- # invalid type
207
- # missing required parameters
208
-
209
- assert_raise Rouster::ArgumentError do
210
- @app = Rouster.new(:name => 'fizzy', :passthrough => {}, :verbosity => 4)
211
- end
212
-
213
- assert_raise Rouster::ArgumentError do
214
- @app = Rouster.new(:name => 'fizzy', :passthrough => { :type => 'invalid' }, :verbosity => 4)
215
- end
216
-
217
- assert_raise Rouster::ArgumentError do
218
- @app = Rouster.new(:name => 'fizzy', :passthrough => { :type => :remote }, :verbosity => 4)
219
- end
220
-
221
- assert_raise Rouster::ArgumentError do
222
- @app = Rouster.new(:name => 'fizzy', :passthrough => { :type => :remote, :user => 'foo' }, :verbosity => 4)
223
- end
224
-
225
- end
226
-
227
- def test_bad_passthrough
228
-
229
- # invalid key
230
- assert_raise Rouster::InternalError do
231
- @app = Rouster.new(
232
- :name => 'fizzy',
233
- :passthrough => {
234
- :type => :remote,
235
- :key => '/etc/hosts',
236
- :user => 'foo',
237
- :host => 'bar',
238
- },
239
- :verbosity => 4,
240
- )
241
- end
242
-
243
- # key that DNE
244
- assert_raise Rouster::ArgumentError do
245
- @app = Rouster.new(
246
- :name => 'fizzy',
247
- :passthrough => {
248
- :type => :remote,
249
- :key => '/etc/this-file-dne',
250
- :user => 'foo',
251
- :host => 'bar',
252
- },
253
- :verbosity => 4,
254
- )
255
- end
256
-
257
- # host that DNE
258
- assert_raise SocketError do
259
- @app = Rouster.new(
260
- :name => 'fizzy',
261
- :passthrough => {
262
- :type => :remote,
263
- :key => @@user_sshkey,
264
- :user => 'foo',
265
- :host => 'this.host.does.not.exist',
266
-
267
- # don't retry.. too much
268
- :ssh_sleep_ceiling => 1,
269
- :ssh_sleep_time => 1,
270
- },
271
-
272
- :sshtunnel => true,
273
- :verbosity => 4,
274
- )
275
- end
276
-
277
- # IP that doesn't resolve
278
- assert_raise SocketError do
279
- @app = Rouster.new(
280
- :name => 'fizzy',
281
- :passthrough => {
282
- :type => :remote,
283
- :key => @@user_sshkey,
284
- :user => 'foo',
285
- :host => '255.256.257.258',
286
-
287
- :ssh_sleep_ceiling => 1,
288
- :ssh_sleep_time => 1,
289
- },
290
-
291
- :sshtunnel => true,
292
- :verbosity => 4,
293
- )
294
- end
295
-
296
- end
297
87
 
298
88
  def teardown
299
- # if the file is empty, we know we created it (or it doesn't matter)..
300
- File.delete(@@user_sshkey) if File.file?(@@user_sshkey) and File.read(@@user_sshkey).eql?('')
89
+ # noop
301
90
  end
302
91
 
303
92
  end
@@ -49,33 +49,35 @@ class TestPut < Test::Unit::TestCase
49
49
 
50
50
  end
51
51
 
52
+ =begin
53
+ TODO fix tests failing for unknown/incorrect reasons
52
54
  def test_with_suspended_machine
53
55
  @app.is_available_via_ssh?() # make sure we have a tunnel
54
56
  @app.suspend()
55
57
 
56
- #assert_raise Rouster::SSHConnectionError
57
- assert_raise Rouster::FileTransferError do
58
+ assert_raise Net::SSH::Disconnect do
58
59
  @app.put(__FILE__, @kg_local_location)
59
60
  end
60
61
 
61
- #assert_equal(false, @app.is_file?(@kg_local_location), 'when machine is suspended, unable to get from it')
62
+ assert_equal(false, @app.is_file?(@kg_local_location), 'when machine is suspended, unable to get from it')
62
63
  end
63
64
 
64
65
  def test_with_suspended_machine_after_destroying_ssh_tunnel
65
- @app.disconnect_ssh_tunnel()
66
+ @app._vm.channel.destroy_ssh_connection() # make sure we don't have a tunnel
66
67
  @app.suspend()
67
68
 
68
- #assert_raise Rouster::SSHConnectionError do
69
- assert_raise Rouster::FileTransferError do
69
+ assert_raise Rouster::SSHConnectionError do
70
70
  @app.put(__FILE__, @kg_local_location)
71
71
  end
72
72
 
73
- #assert_equal(false, @app.is_file?(@kg_local_location), 'when machine is suspended, and connection is manually destroyed, unable to get from it')
73
+ assert_equal(false, @app.is_file?(@kg_local_location), 'when machine is suspended, and connection is manually destroyed, unable to get from it')
74
74
  end
75
+ =end
75
76
 
76
77
  def teardown
78
+ # TODO we should suspend instead if any test failed for triage
77
79
  #@app.destroy()
78
- #@app.suspend()
80
+ #@ppm.destroy()
79
81
  File.delete(@kg_location) if File.file?(@kg_location).true?
80
82
  end
81
- end
83
+ end
@@ -10,6 +10,7 @@
10
10
  assert_nothing_raised do
11
11
  @app = Rouster.new(:name => 'app', :verbosity => 4)
12
12
  end
13
+
13
14
  end
14
15
 
15
16
  def test_happy_path
@@ -30,13 +31,15 @@
30
31
  sleep 10
31
32
  end
32
33
 
33
- new_uptime = @app.facter(false)['uptime_seconds'].to_i
34
+ new_uptime = @app.facter()['uptime_seconds'].to_i
34
35
 
35
36
  assert_not_equal(original_uptime, new_uptime)
36
37
  assert(original_uptime > new_uptime)
37
38
 
39
+
38
40
  end
39
41
 
42
+
40
43
  def teardown
41
44
  # noop
42
45
  end
@@ -71,7 +71,8 @@ class TestRun < Test::Unit::TestCase
71
71
  end
72
72
 
73
73
  def teardown
74
- @app.suspend()
75
- @app_no_sudo.suspend()
74
+ # TODO we should suspend instead if any test failed for triage
75
+ #@app.destroy()
76
+ #@ppm.destroy()
76
77
  end
77
78
  end
@@ -21,13 +21,11 @@ class TestPuppetApply < Test::Unit::TestCase
21
21
  'test/puppet/modules/role/manifests/ui.pp' => 'modules/role/manifests/ui.pp',
22
22
  }
23
23
 
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
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
31
29
 
32
30
  required_files.each_pair do |source,dest|
33
31
  @app.put(source, dest)
@@ -88,7 +86,7 @@ class TestPuppetApply < Test::Unit::TestCase
88
86
 
89
87
  app_expected_files = {
90
88
  '/etc/hosts' => {
91
- :contains => [ 'localhost', '127.0.0.1' ],
89
+ :contains => [ 'localhost', 'app' ],
92
90
  :ensure => 'present',
93
91
  :group => 'root',
94
92
  :owner => 'root',
@@ -123,23 +121,23 @@ class TestPuppetApply < Test::Unit::TestCase
123
121
 
124
122
  # manually specified testing
125
123
  app_expected_files.each_pair do |f,e|
126
- assert_equal(true, @app.validate_file(f,e), "file[#{f}] expectation[#{e}]")
124
+ assert_equal(true, @app.validate_file(f,e))
127
125
  end
128
126
 
129
127
  app_expected_groups.each_pair do |g,e|
130
- assert_equal(true, @app.validate_group(g,e), "group[#{g}] expectation[#{e}]")
128
+ assert_equal(true, @app.validate_group(g,e))
131
129
  end
132
130
 
133
131
  app_expected_packages.each_pair do |p,e|
134
- assert_equal(true, @app.validate_package(p, e), "package[#{p}] expectation[#{e}]")
132
+ assert_equal(true, @app.validate_package(p, e))
135
133
  end
136
134
 
137
135
  app_expected_services.each_pair do |s,e|
138
- assert_equal(true, @app.validate_service(s,e), "service[#{s}] expectation[#{e}]")
136
+ assert_equal(true, @app.validate_service(s,e))
139
137
  end
140
138
 
141
139
  app_expected_users.each_pair do |u,e|
142
- assert_equal(true, @app.validate_user(u,e), "user[#{u}] expectation[#{e}]")
140
+ assert_equal(true, @app.validate_user(u,e))
143
141
  end
144
142
 
145
143
  end