forked from jedi4ever/veewee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_realtest.rb
81 lines (70 loc) · 1.91 KB
/
build_realtest.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require 'test/unit'
require 'veewee'
class TestVeeweeBuild < Test::Unit::TestCase
def setup
definition_dir=File.expand_path(File.join(File.dirname(__FILE__),"definitions"))
#ENV['VEEWEE_LOG']="STDOUT"
@ve=Veewee::Environment.new({ :definition_dir => definition_dir })
@definition_name="test_definition"
@[email protected][@definition_name]
@box_name=@definition_name
@vd.postinstall_files=["_test_me.sh"]
@[email protected]["virtualbox"].get_box(@box_name)
end
# First build of box
# - the creation
# - kickstart fetch
# - postinstall execution
def test_box_1_build
assert_nothing_raised {
@box.build({'auto' => true,'force' => true, 'nogui' => true , 'disk_count' => 2})
#@box.build({"auto" => true,"force" => true })
}
end
# Run an ssh command
def test_box_2_ssh
assert_nothing_raised {
[email protected]("who am i")
assert_match(/root/,result.stdout)
}
end
# Type on console
def test_box_3_console_type
assert_nothing_raised {
@box.console_type(['echo "bla" > console.txt<Enter>'])
[email protected]("cat console.txt")
assert_match(/bla/,result.stdout)
}
end
# Are there as many disks as in disk_count?
def test_box_4_check_disk_count
assert_nothing_raised {
[email protected]("lsblk -lo MODEL|grep -i harddisk|wc -l")
assert_match(/#{@box.definition.disk_count}/,result.stdout)
}
end
# Try shutdown
def test_box_5_shutdown
assert_nothing_raised {
@box.halt
}
end
# Now try build again (with no force flag)
def test_box_6_build
#assert_raise(Veewee::Error) {
assert_nothing_raised {
#@box.build({"auto" => true})
@box.build({"auto" => true,'force' => true, 'nogui' => true })
}
end
def test_box_7_destroy
assert_nothing_raised {
@box.destroy
}
end
#
# def teardown
# #@ve.destroy(@vm_name,@vd)
#
# end
end