rouster 0.5
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 +7 -0
- data/.gitignore +6 -0
- data/LICENSE +9 -0
- data/README.md +175 -0
- data/Rakefile +65 -0
- data/Vagrantfile +23 -0
- data/examples/bootstrap.rb +113 -0
- data/examples/demo.rb +71 -0
- data/examples/error.rb +30 -0
- data/lib/rouster.rb +737 -0
- data/lib/rouster/deltas.rb +481 -0
- data/lib/rouster/puppet.rb +398 -0
- data/lib/rouster/testing.rb +743 -0
- data/lib/rouster/tests.rb +596 -0
- data/path_helper.rb +21 -0
- data/rouster.gemspec +30 -0
- data/test/basic.rb +10 -0
- data/test/functional/deltas/test_get_crontab.rb +99 -0
- data/test/functional/deltas/test_get_groups.rb +48 -0
- data/test/functional/deltas/test_get_packages.rb +71 -0
- data/test/functional/deltas/test_get_ports.rb +119 -0
- data/test/functional/deltas/test_get_services.rb +43 -0
- data/test/functional/deltas/test_get_users.rb +45 -0
- data/test/functional/puppet/test_facter.rb +59 -0
- data/test/functional/test_caching.rb +124 -0
- data/test/functional/test_destroy.rb +51 -0
- data/test/functional/test_dirs.rb +88 -0
- data/test/functional/test_files.rb +64 -0
- data/test/functional/test_get.rb +76 -0
- data/test/functional/test_inspect.rb +31 -0
- data/test/functional/test_is_dir.rb +118 -0
- data/test/functional/test_is_file.rb +119 -0
- data/test/functional/test_new.rb +92 -0
- data/test/functional/test_put.rb +81 -0
- data/test/functional/test_rebuild.rb +49 -0
- data/test/functional/test_restart.rb +44 -0
- data/test/functional/test_run.rb +77 -0
- data/test/functional/test_status.rb +38 -0
- data/test/functional/test_suspend.rb +31 -0
- data/test/functional/test_up.rb +27 -0
- data/test/functional/test_validate_file.rb +30 -0
- data/test/puppet/manifests/default.pp +9 -0
- data/test/puppet/manifests/hiera.yaml +12 -0
- data/test/puppet/manifests/hieradata/common.json +3 -0
- data/test/puppet/manifests/hieradata/vagrant.json +3 -0
- data/test/puppet/manifests/manifest.pp +78 -0
- data/test/puppet/modules/role/manifests/ui.pp +5 -0
- data/test/puppet/test_apply.rb +149 -0
- data/test/puppet/test_roles.rb +186 -0
- data/test/tunnel_vs_scp.rb +41 -0
- data/test/unit/puppet/test_get_puppet_star.rb +68 -0
- data/test/unit/test_generate_unique_mac.rb +43 -0
- data/test/unit/test_new.rb +31 -0
- data/test/unit/test_parse_ls_string.rb +334 -0
- data/test/unit/test_traverse_up.rb +43 -0
- data/test/unit/testing/test_meets_constraint.rb +55 -0
- data/test/unit/testing/test_validate_file.rb +112 -0
- data/test/unit/testing/test_validate_group.rb +72 -0
- data/test/unit/testing/test_validate_package.rb +69 -0
- data/test/unit/testing/test_validate_port.rb +98 -0
- data/test/unit/testing/test_validate_service.rb +73 -0
- data/test/unit/testing/test_validate_user.rb +92 -0
- metadata +203 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
require sprintf('%s/../../path_helper', File.dirname(File.expand_path(__FILE__)))
|
2
|
+
|
3
|
+
require 'rouster'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
class TestInspect < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
assert_nothing_raised do
|
10
|
+
@app = Rouster.new(:name => 'app')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_happy_path
|
15
|
+
# want to do this with 'assert_method_called' or something similar -- but for now..
|
16
|
+
|
17
|
+
res = @app.inspect()
|
18
|
+
|
19
|
+
assert_match(/passthrough\[false\]/, res)
|
20
|
+
assert_match(/sshkey/, res)
|
21
|
+
assert_match(/status/, res)
|
22
|
+
assert_match(/sudo\[true\]/, res)
|
23
|
+
assert_match(/vagrantfile/, res)
|
24
|
+
assert_match(/verbosity\[4\]/, res)
|
25
|
+
end
|
26
|
+
|
27
|
+
def teardown
|
28
|
+
# noop
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require sprintf('%s/../../path_helper', File.dirname(File.expand_path(__FILE__)))
|
2
|
+
|
3
|
+
require 'rouster'
|
4
|
+
require 'rouster/tests'
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
class TestIsDir < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
assert_nothing_raised do
|
11
|
+
# no reason not to do this as a passthrough once we can
|
12
|
+
@app = Rouster.new(:name => 'app', :sudo => false)
|
13
|
+
@app.up()
|
14
|
+
end
|
15
|
+
|
16
|
+
# create some temporary files
|
17
|
+
@dir_tmp = sprintf('/tmp/rouster-%s.%s', $$, Time.now.to_i)
|
18
|
+
|
19
|
+
@dir_user_rwx = sprintf('%s/user', @dir_tmp)
|
20
|
+
@dir_group_rwx = sprintf('%s/group', @dir_tmp)
|
21
|
+
@dir_other_rwx = sprintf('%s/other', @dir_tmp)
|
22
|
+
@dir_644 = sprintf('%s/sixfourfour', @dir_tmp)
|
23
|
+
@dir_755 = sprintf('%s/sevenfivefive', @dir_tmp)
|
24
|
+
|
25
|
+
@dirs = [@dir_user_rwx, @dir_group_rwx, @dir_other_rwx, @dir_644, @dir_755]
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_user
|
29
|
+
@app.run("mkdir -p #{@dir_user_rwx}")
|
30
|
+
@app.run("chmod 700 #{@dir_user_rwx}")
|
31
|
+
|
32
|
+
assert_equal(true, @app.is_readable?(@dir_user_rwx, 'u'))
|
33
|
+
assert_equal(true, @app.is_writeable?(@dir_user_rwx, 'u'))
|
34
|
+
assert_equal(true, @app.is_executable?(@dir_user_rwx, 'u'))
|
35
|
+
|
36
|
+
assert_equal(false, @app.is_readable?(@dir_user_rwx, 'g'))
|
37
|
+
assert_equal(false, @app.is_writeable?(@dir_user_rwx, 'g'))
|
38
|
+
assert_equal(false, @app.is_executable?(@dir_user_rwx, 'g'))
|
39
|
+
|
40
|
+
assert_equal(false, @app.is_readable?(@dir_user_rwx, 'o'))
|
41
|
+
assert_equal(false, @app.is_writeable?(@dir_user_rwx, 'o'))
|
42
|
+
assert_equal(false, @app.is_executable?(@dir_user_rwx, 'o'))
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_group
|
46
|
+
@app.run("mkdir -p #{@dir_group_rwx}")
|
47
|
+
@app.run("chmod 070 #{@dir_group_rwx}")
|
48
|
+
|
49
|
+
assert_equal(false, @app.is_readable?(@dir_group_rwx, 'u'))
|
50
|
+
assert_equal(false, @app.is_writeable?(@dir_group_rwx, 'u'))
|
51
|
+
assert_equal(false, @app.is_executable?(@dir_group_rwx, 'u'))
|
52
|
+
|
53
|
+
assert_equal(true, @app.is_readable?(@dir_group_rwx, 'g'))
|
54
|
+
assert_equal(true, @app.is_writeable?(@dir_group_rwx, 'g'))
|
55
|
+
assert_equal(true, @app.is_executable?(@dir_group_rwx, 'g'))
|
56
|
+
|
57
|
+
assert_equal(false, @app.is_readable?(@dir_group_rwx, 'o'))
|
58
|
+
assert_equal(false, @app.is_writeable?(@dir_group_rwx, 'o'))
|
59
|
+
assert_equal(false, @app.is_executable?(@dir_group_rwx, 'o'))
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_other
|
63
|
+
@app.run("mkdir -p #{@dir_other_rwx}")
|
64
|
+
@app.run("chmod 007 #{@dir_other_rwx}")
|
65
|
+
|
66
|
+
assert_equal(false, @app.is_readable?(@dir_other_rwx, 'u'))
|
67
|
+
assert_equal(false, @app.is_writeable?(@dir_other_rwx, 'u'))
|
68
|
+
assert_equal(false, @app.is_executable?(@dir_other_rwx, 'u'))
|
69
|
+
|
70
|
+
assert_equal(false, @app.is_readable?(@dir_other_rwx, 'g'))
|
71
|
+
assert_equal(false, @app.is_writeable?(@dir_other_rwx, 'g'))
|
72
|
+
assert_equal(false, @app.is_executable?(@dir_other_rwx, 'g'))
|
73
|
+
|
74
|
+
assert_equal(true, @app.is_readable?(@dir_other_rwx, 'o'))
|
75
|
+
assert_equal(true, @app.is_writeable?(@dir_other_rwx, 'o'))
|
76
|
+
assert_equal(true, @app.is_executable?(@dir_other_rwx, 'o'))
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_644
|
81
|
+
@app.run("mkdir -p #{@dir_644}")
|
82
|
+
@app.run("chmod 644 #{@dir_644}")
|
83
|
+
|
84
|
+
assert_equal(true, @app.is_readable?(@dir_644, 'u'))
|
85
|
+
assert_equal(true, @app.is_writeable?(@dir_644, 'u'))
|
86
|
+
assert_equal(false, @app.is_executable?(@dir_644, 'u'))
|
87
|
+
|
88
|
+
assert_equal(true, @app.is_readable?(@dir_644, 'g'))
|
89
|
+
assert_equal(false, @app.is_writeable?(@dir_644, 'g'))
|
90
|
+
assert_equal(false, @app.is_executable?(@dir_644, 'g'))
|
91
|
+
|
92
|
+
assert_equal(true, @app.is_readable?(@dir_644, 'o'))
|
93
|
+
assert_equal(false, @app.is_writeable?(@dir_644, 'o'))
|
94
|
+
assert_equal(false, @app.is_executable?(@dir_644, 'o'))
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_755
|
98
|
+
@app.run("mkdir -p #{@dir_755}")
|
99
|
+
@app.run("chmod 755 #{@dir_755}")
|
100
|
+
|
101
|
+
assert_equal(true, @app.is_readable?(@dir_755, 'u'))
|
102
|
+
assert_equal(true, @app.is_writeable?(@dir_755, 'u'))
|
103
|
+
assert_equal(true, @app.is_executable?(@dir_755, 'u'))
|
104
|
+
|
105
|
+
assert_equal(true, @app.is_readable?(@dir_755, 'g'))
|
106
|
+
assert_equal(false, @app.is_writeable?(@dir_755, 'g'))
|
107
|
+
assert_equal(true, @app.is_executable?(@dir_755, 'g'))
|
108
|
+
|
109
|
+
assert_equal(true, @app.is_readable?(@dir_755, 'o'))
|
110
|
+
assert_equal(false, @app.is_writeable?(@dir_755, 'o'))
|
111
|
+
assert_equal(true, @app.is_executable?(@dir_755, 'o'))
|
112
|
+
end
|
113
|
+
|
114
|
+
def teardown
|
115
|
+
@app.run(sprintf('rm -r %s', @dir_tmp))
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require sprintf('%s/../../path_helper', File.dirname(File.expand_path(__FILE__)))
|
2
|
+
|
3
|
+
require 'rouster'
|
4
|
+
require 'rouster/tests'
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
class TestIsFile < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
assert_nothing_raised do
|
11
|
+
# no reason not to do this as a passthrough once we can
|
12
|
+
@app = Rouster.new(:name => 'app', :sudo => false)
|
13
|
+
@app.up()
|
14
|
+
end
|
15
|
+
|
16
|
+
# create some temporary files
|
17
|
+
@dir_tmp = sprintf('/tmp/rouster-%s.%s', $$, Time.now.to_i)
|
18
|
+
@app.run("mkdir #{@dir_tmp}")
|
19
|
+
|
20
|
+
@file_user_rwx = sprintf('%s/user', @dir_tmp)
|
21
|
+
@file_group_rwx = sprintf('%s/group', @dir_tmp)
|
22
|
+
@file_other_rwx = sprintf('%s/other', @dir_tmp)
|
23
|
+
@file_644 = sprintf('%s/sixfourfour', @dir_tmp)
|
24
|
+
@file_755 = sprintf('%s/sevenfivefive', @dir_tmp)
|
25
|
+
|
26
|
+
@files = [@file_user_rwx, @file_group_rwx, @file_other_rwx, @file_644, @file_755]
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_user
|
30
|
+
@app.run("touch #{@file_user_rwx}")
|
31
|
+
@app.run("chmod 700 #{@file_user_rwx}")
|
32
|
+
|
33
|
+
assert_equal(true, @app.is_readable?(@file_user_rwx, 'u'))
|
34
|
+
assert_equal(true, @app.is_writeable?(@file_user_rwx, 'u'))
|
35
|
+
assert_equal(true, @app.is_executable?(@file_user_rwx, 'u'))
|
36
|
+
|
37
|
+
assert_equal(false, @app.is_readable?(@file_user_rwx, 'g'))
|
38
|
+
assert_equal(false, @app.is_writeable?(@file_user_rwx, 'g'))
|
39
|
+
assert_equal(false, @app.is_executable?(@file_user_rwx, 'g'))
|
40
|
+
|
41
|
+
assert_equal(false, @app.is_readable?(@file_user_rwx, 'o'))
|
42
|
+
assert_equal(false, @app.is_writeable?(@file_user_rwx, 'o'))
|
43
|
+
assert_equal(false, @app.is_executable?(@file_user_rwx, 'o'))
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_group
|
47
|
+
@app.run("touch #{@file_group_rwx}")
|
48
|
+
@app.run("chmod 070 #{@file_group_rwx}")
|
49
|
+
|
50
|
+
assert_equal(false, @app.is_readable?(@file_group_rwx, 'u'))
|
51
|
+
assert_equal(false, @app.is_writeable?(@file_group_rwx, 'u'))
|
52
|
+
assert_equal(false, @app.is_executable?(@file_group_rwx, 'u'))
|
53
|
+
|
54
|
+
assert_equal(true, @app.is_readable?(@file_group_rwx, 'g'))
|
55
|
+
assert_equal(true, @app.is_writeable?(@file_group_rwx, 'g'))
|
56
|
+
assert_equal(true, @app.is_executable?(@file_group_rwx, 'g'))
|
57
|
+
|
58
|
+
assert_equal(false, @app.is_readable?(@file_group_rwx, 'o'))
|
59
|
+
assert_equal(false, @app.is_writeable?(@file_group_rwx, 'o'))
|
60
|
+
assert_equal(false, @app.is_executable?(@file_group_rwx, 'o'))
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_other
|
64
|
+
@app.run("touch #{@file_other_rwx}")
|
65
|
+
@app.run("chmod 007 #{@file_other_rwx}")
|
66
|
+
|
67
|
+
assert_equal(false, @app.is_readable?(@file_other_rwx, 'u'))
|
68
|
+
assert_equal(false, @app.is_writeable?(@file_other_rwx, 'u'))
|
69
|
+
assert_equal(false, @app.is_executable?(@file_other_rwx, 'u'))
|
70
|
+
|
71
|
+
assert_equal(false, @app.is_readable?(@file_other_rwx, 'g'))
|
72
|
+
assert_equal(false, @app.is_writeable?(@file_other_rwx, 'g'))
|
73
|
+
assert_equal(false, @app.is_executable?(@file_other_rwx, 'g'))
|
74
|
+
|
75
|
+
assert_equal(true, @app.is_readable?(@file_other_rwx, 'o'))
|
76
|
+
assert_equal(true, @app.is_writeable?(@file_other_rwx, 'o'))
|
77
|
+
assert_equal(true, @app.is_executable?(@file_other_rwx, 'o'))
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_644
|
82
|
+
@app.run("touch #{@file_644}")
|
83
|
+
@app.run("chmod 644 #{@file_644}")
|
84
|
+
|
85
|
+
assert_equal(true, @app.is_readable?(@file_644, 'u'))
|
86
|
+
assert_equal(true, @app.is_writeable?(@file_644, 'u'))
|
87
|
+
assert_equal(false, @app.is_executable?(@file_644, 'u'))
|
88
|
+
|
89
|
+
assert_equal(true, @app.is_readable?(@file_644, 'g'))
|
90
|
+
assert_equal(false, @app.is_writeable?(@file_644, 'g'))
|
91
|
+
assert_equal(false, @app.is_executable?(@file_644, 'g'))
|
92
|
+
|
93
|
+
assert_equal(true, @app.is_readable?(@file_644, 'o'))
|
94
|
+
assert_equal(false, @app.is_writeable?(@file_644, 'o'))
|
95
|
+
assert_equal(false, @app.is_executable?(@file_644, 'o'))
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_755
|
99
|
+
@app.run("touch #{@file_755}")
|
100
|
+
@app.run("chmod 755 #{@file_755}")
|
101
|
+
|
102
|
+
assert_equal(true, @app.is_readable?(@file_755, 'u'))
|
103
|
+
assert_equal(true, @app.is_writeable?(@file_755, 'u'))
|
104
|
+
assert_equal(true, @app.is_executable?(@file_755, 'u'))
|
105
|
+
|
106
|
+
assert_equal(true, @app.is_readable?(@file_755, 'g'))
|
107
|
+
assert_equal(false, @app.is_writeable?(@file_755, 'g'))
|
108
|
+
assert_equal(true, @app.is_executable?(@file_755, 'g'))
|
109
|
+
|
110
|
+
assert_equal(true, @app.is_readable?(@file_755, 'o'))
|
111
|
+
assert_equal(false, @app.is_writeable?(@file_755, 'o'))
|
112
|
+
assert_equal(true, @app.is_executable?(@file_755, 'o'))
|
113
|
+
end
|
114
|
+
|
115
|
+
def teardown
|
116
|
+
# noop
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require sprintf('%s/../../path_helper', File.dirname(File.expand_path(__FILE__)))
|
2
|
+
|
3
|
+
require 'rouster'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
# TODO rename this to 'test_instantiate' and flesh out tests for all instantiaion options
|
7
|
+
|
8
|
+
class TestNew < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@app = Rouster.new(:name => 'app')
|
12
|
+
@app.destroy() if @app.status().eql?('running')
|
13
|
+
@app = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_1_able_to_instantiate
|
17
|
+
|
18
|
+
assert_nothing_raised do
|
19
|
+
@app = Rouster.new(:name => 'app')
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_2_good_openssh_tunnel
|
25
|
+
@app = Rouster.new(:name => 'app', :sshtunnel => true)
|
26
|
+
|
27
|
+
# TODO how do we properly test this? we really need the rspec should_call mechanism...
|
28
|
+
|
29
|
+
assert_equal(true, @app.is_available_via_ssh?)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_3_good_advanced_instantiation
|
33
|
+
|
34
|
+
assert_nothing_raised do
|
35
|
+
@app = Rouster.new(
|
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']),
|
42
|
+
)
|
43
|
+
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
assert_equal('app', @app.name)
|
48
|
+
assert_equal(true, @app.is_passthrough?())
|
49
|
+
assert_equal(false, @app.uses_sudo?())
|
50
|
+
assert_equal(4, @app.verbosity) # is this going to be strinigified?
|
51
|
+
assert_equal(true, File.file?(@app.vagrantfile))
|
52
|
+
assert_equal(true, File.file?(@app.sshkey))
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_4_bad_name_instantiation
|
56
|
+
|
57
|
+
assert_raise Rouster::InternalError do
|
58
|
+
@app = Rouster.new(:name => 'foo')
|
59
|
+
end
|
60
|
+
|
61
|
+
assert_raise Rouster::InternalError do
|
62
|
+
@app = Rouster.new(:not_a_name => 'test')
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_5_bad_vagrantfile_instantiation
|
68
|
+
|
69
|
+
assert_raise Rouster::InternalError do
|
70
|
+
@app = Rouster.new(:name => 'FIZZY') # auto find Vagrantfile
|
71
|
+
end
|
72
|
+
|
73
|
+
assert_raise Rouster::InternalError do
|
74
|
+
@app = Rouster.new(:name => 'testing', :vagrantfile => '/this/file/dne')
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_6_bad_sshkey_instantiation
|
80
|
+
|
81
|
+
assert_raise Rouster::InternalError do
|
82
|
+
@app = Rouster.new(:name => 'app', :sshkey => '/this/file/dne')
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def teardown
|
89
|
+
# noop
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require sprintf('%s/../../path_helper', File.dirname(File.expand_path(__FILE__)))
|
2
|
+
|
3
|
+
require 'rouster'
|
4
|
+
require 'rouster/tests'
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
class TestPut < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@app = Rouster.new(:name => 'app')
|
11
|
+
|
12
|
+
@app.up()
|
13
|
+
|
14
|
+
@kg_location = sprintf('/tmp/rouster-test_put.%s.%s', $$, Time.now.to_i)
|
15
|
+
@kb_dne_location = '/tmp/this-doesnt_exist/and/never/will.txt'
|
16
|
+
|
17
|
+
File.delete(@kg_location) if File.file?(@kg_location).true?
|
18
|
+
|
19
|
+
assert_equal(@app.is_available_via_ssh?, true, 'app is available via SSH')
|
20
|
+
assert_equal(File.file?(@kg_location), false, 'test KG file not present')
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_happy_path
|
25
|
+
|
26
|
+
assert_nothing_raised do
|
27
|
+
@app.put(__FILE__, @kg_location)
|
28
|
+
end
|
29
|
+
|
30
|
+
assert(@app.is_file?(@kg_location))
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_local_file_dne
|
34
|
+
|
35
|
+
assert_raise Rouster::FileTransferError do
|
36
|
+
@app.put('this_file_dne', @kg_location)
|
37
|
+
end
|
38
|
+
|
39
|
+
assert_equal(false, @app.is_file?(@kg_location), 'known bad local file DNE')
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_remote_path_dne
|
43
|
+
|
44
|
+
assert_raise Rouster::FileTransferError do
|
45
|
+
@app.put(__FILE__, @kb_dne_location)
|
46
|
+
end
|
47
|
+
|
48
|
+
assert_equal(false, @app.is_file?(@kb_dne_location), 'known bad remote file path DNE')
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_with_suspended_machine
|
53
|
+
@app.is_available_via_ssh?() # make sure we have a tunnel
|
54
|
+
@app.suspend()
|
55
|
+
|
56
|
+
#assert_raise Rouster::SSHConnectionError
|
57
|
+
assert_raise Rouster::FileTransferError do
|
58
|
+
@app.put(__FILE__, @kg_local_location)
|
59
|
+
end
|
60
|
+
|
61
|
+
#assert_equal(false, @app.is_file?(@kg_local_location), 'when machine is suspended, unable to get from it')
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_with_suspended_machine_after_destroying_ssh_tunnel
|
65
|
+
@app.disconnect_ssh_tunnel()
|
66
|
+
@app.suspend()
|
67
|
+
|
68
|
+
#assert_raise Rouster::SSHConnectionError do
|
69
|
+
assert_raise Rouster::FileTransferError do
|
70
|
+
@app.put(__FILE__, @kg_local_location)
|
71
|
+
end
|
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')
|
74
|
+
end
|
75
|
+
|
76
|
+
def teardown
|
77
|
+
#@app.destroy()
|
78
|
+
@app.suspend()
|
79
|
+
File.delete(@kg_location) if File.file?(@kg_location).true?
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require sprintf('%s/../../path_helper', File.dirname(File.expand_path(__FILE__)))
|
2
|
+
|
3
|
+
require 'rouster'
|
4
|
+
require 'rouster/tests'
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
class TestRebuild < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
assert_nothing_raised do
|
11
|
+
@app = Rouster.new(:name => 'app')
|
12
|
+
end
|
13
|
+
|
14
|
+
@uploaded_to = sprintf('/tmp/rouster-test_rebuild.%s.%s', $$, Time.now.to_i)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_1_happy_path
|
18
|
+
@app.up()
|
19
|
+
|
20
|
+
assert_equal(true, @app.is_available_via_ssh?)
|
21
|
+
|
22
|
+
@app.put(__FILE__, @uploaded_to)
|
23
|
+
|
24
|
+
assert_not_nil(@app.is_file?(@uploaded_to))
|
25
|
+
|
26
|
+
assert_nothing_raised do
|
27
|
+
@app.rebuild()
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_equal(false, @app.is_file?(@uploaded_to))
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_2_machine_already_destroyed
|
34
|
+
@app.destroy() if @app.status.eql?('running')
|
35
|
+
|
36
|
+
assert_equal(false, @app.is_available_via_ssh?)
|
37
|
+
|
38
|
+
assert_nothing_raised do
|
39
|
+
@app.rebuild()
|
40
|
+
end
|
41
|
+
|
42
|
+
assert_equal(false, @app.is_file?(@uploaded_to))
|
43
|
+
end
|
44
|
+
|
45
|
+
def teardown
|
46
|
+
# noop
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|