Revision 4a96f1d1 test/ganeti.masterd.instance_unittest.py

b/test/ganeti.masterd.instance_unittest.py
26 26
import unittest
27 27

  
28 28
from ganeti import constants
29
from ganeti import errors
29 30
from ganeti import utils
30 31
from ganeti import masterd
31 32

  
32 33
from ganeti.masterd.instance import \
33 34
  ImportExportTimeouts, _TimeoutExpired, _DiskImportExportBase, \
34
  ComputeRemoteExportHandshake, CheckRemoteExportHandshake
35
  ComputeRemoteExportHandshake, CheckRemoteExportHandshake, \
36
  ComputeRemoteImportDiskInfo, CheckRemoteExportDiskInfo
35 37

  
36 38
import testutils
37 39

  
......
86 88
    self.assert_(CheckRemoteExportHandshake(cds, hs))
87 89

  
88 90

  
91
class TestRieDiskInfo(unittest.TestCase):
92
  def test(self):
93
    cds = "bbf46ea9a"
94
    salt = "ee5ad9"
95
    di = ComputeRemoteImportDiskInfo(cds, salt, 0, "node1", 1234)
96
    self.assertEqual(CheckRemoteExportDiskInfo(cds, 0, di),
97
                     ("node1", 1234))
98

  
99
    for i in range(1, 100):
100
      # Wrong disk index
101
      self.assertRaises(errors.GenericError, CheckRemoteExportDiskInfo,
102
                        cds, i, di)
103

  
104
  def testCheckErrors(self):
105
    cds = "0776450535a"
106
    self.assertRaises(errors.GenericError, CheckRemoteExportDiskInfo,
107
                      cds, 0, "")
108
    self.assertRaises(errors.GenericError, CheckRemoteExportDiskInfo,
109
                      cds, 0, ())
110
    self.assertRaises(errors.GenericError, CheckRemoteExportDiskInfo,
111
                      cds, 0, ("", 1, 2, 3, 4, 5))
112

  
113
    # No host/port
114
    self.assertRaises(errors.GenericError, CheckRemoteExportDiskInfo,
115
                      cds, 0, ("", 0, "", ""))
116

  
117
    # Wrong hash
118
    self.assertRaises(errors.GenericError, CheckRemoteExportDiskInfo,
119
                      cds, 0, ("nodeX", 123, "fakehash", "xyz"))
120

  
121

  
89 122
if __name__ == "__main__":
90 123
  testutils.GanetiTestProgram()

Also available in: Unified diff