Revision 6b90c22e test/ganeti.bdev_unittest.py

b/test/ganeti.bdev_unittest.py
26 26
import unittest
27 27

  
28 28
from ganeti import bdev
29
from ganeti import errors
29 30

  
30 31

  
31 32
class TestDRBD8Runner(unittest.TestCase):
......
108 109
                     "remote_addr" not in result),
109 110
                    "Should not find network info")
110 111

  
112

  
113
class TestDRBD8Status(unittest.TestCase):
114
  """Testing case for DRBD8 /proc status"""
115

  
116
  def setUp(self):
117
    """Read in txt data"""
118
    self.proc_data = bdev.DRBD8._GetProcData(filename="data/proc_drbd8.txt")
119
    self.mass_data = bdev.DRBD8._MassageProcData(self.proc_data)
120

  
121
  def testMinorNotFound(self):
122
    """Test not-found-minor in /proc"""
123
    self.failUnless(9 not in self.mass_data)
124

  
125
  def testLineNotMatch(self):
126
    """Test wrong line passed to DRBD8Status"""
127
    self.assertRaises(errors.BlockDeviceError, bdev.DRBD8Status, "foo")
128

  
129
  def testMinor0(self):
130
    """Test connected, primary device"""
131
    stats = bdev.DRBD8Status(self.mass_data[0])
132
    self.failUnless(stats.is_connected and stats.is_primary and
133
                    stats.peer_secondary and stats.is_disk_uptodate)
134

  
135
  def testMinor1(self):
136
    """Test connected, secondary device"""
137
    stats = bdev.DRBD8Status(self.mass_data[1])
138
    self.failUnless(stats.is_connected and stats.is_secondary and
139
                    stats.peer_primary and stats.is_disk_uptodate)
140

  
141
  def testMinor4(self):
142
    """Test WFconn device"""
143
    stats = bdev.DRBD8Status(self.mass_data[4])
144
    self.failUnless(stats.is_wfconn and stats.is_primary and
145
                    stats.rrole == 'Unknown' and
146
                    stats.is_disk_uptodate)
147

  
148
  def testMinor6(self):
149
    """Test diskless device"""
150
    stats = bdev.DRBD8Status(self.mass_data[6])
151
    self.failUnless(stats.is_connected and stats.is_secondary and
152
                    stats.peer_primary and stats.is_diskless)
153

  
154
  def testMinor8(self):
155
    """Test standalone device"""
156
    stats = bdev.DRBD8Status(self.mass_data[8])
157
    self.failUnless(stats.is_standalone and
158
                    stats.rrole == 'Unknown' and
159
                    stats.is_disk_uptodate)
160

  
111 161
if __name__ == '__main__':
112 162
  unittest.main()

Also available in: Unified diff