-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_saif.py
49 lines (36 loc) · 1.52 KB
/
test_saif.py
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
import unittest
import cli
from runner import execute
import subprocess
class Task(unittest.TestCase):
disk = " ".join(cli.disk_name)
#test physical volume created or not
def test_pvcreate(self):
execute("pvcreate {}".format(Task.disk))
self.output = execute("pvdisplay" )
for i in cli.disk_name:
self.assertRegex(self.output,i, "{} is not present" .format(i))
def test_vgcreate(self):
execute("pvcreate {}" .format(Task.disk))
execute("vgcreate {} {}".format(cli.vgname,Task.disk))
self.output = execute("vgdisplay" )
self.assertRegex(self.output,cli.vgname)
#test volume group created or not
def test_xlvcreate(self):
execute("pvcreate {}" .format(Task.disk))
execute("vgcreate {} {}" .format(cli.vgname, Task.disk))
execute("lvcreate --size {} --name {} {}".format(cli.size,cli.lvname,cli.vgname))
self.output = execute("lvdisplay")
self.assertRegex(self.output,cli.lvname)
def tearDown(self):
disk = " ".join(cli.disk_name)
if(cli.cmd == "pvcreate"):
execute("pvremove {}".format(disk))
if(cli.cmd == "vgcreate"):
execute("vgremove {}".format(cli.vgname))
execute("pvremove {}" .format(disk))
if(cli.cmd == 'lvcreate'):
s = "lvremove {}" .format(cli.vgname)
subprocess.run(s.split(" "))
execute("vgremove {}".format(cli.vgname))
execute("pvremove {}" .format(disk))