Add tests for DRBD setups with empty first resource
authorApollon Oikonomopoulos <apoikos@gmail.com>
Fri, 4 Jul 2014 09:38:26 +0000 (12:38 +0300)
committerKlaus Aehlig <aehlig@google.com>
Fri, 4 Jul 2014 11:37:22 +0000 (13:37 +0200)
Add a DRBD 8.4 configuration with the first resource empty, together
with the relevant Haskell and Python tests.

Signed-off-by: Apollon Oikonomopoulos <apoikos@gmail.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

Makefile.am
test/data/proc_drbd84_emptyfirst.txt [copied from test/data/proc_drbd84.txt with 83% similarity]
test/hs/Test/Ganeti/Storage/Drbd/Parser.hs
test/py/ganeti.storage.drbd_unittest.py

index 001fbba..700d708 100644 (file)
@@ -1224,6 +1224,7 @@ TEST_FILES = \
        test/data/proc_drbd83_sync_want.txt \
        test/data/proc_drbd83_sync_krnl2.6.39.txt \
        test/data/proc_drbd84.txt \
+       test/data/proc_drbd84_emptyfirst.txt \
        test/data/proc_drbd84_sync.txt \
        test/data/proc_meminfo.txt \
        test/data/proc_cpuinfo.txt \
similarity index 83%
copy from test/data/proc_drbd84.txt
copy to test/data/proc_drbd84_emptyfirst.txt
index a8b3cbf..6e51437 100644 (file)
@@ -1,7 +1,6 @@
 version: 8.4.2 (api:1/proto:86-101)
 GIT-hash: 7ad5f850d711223713d6dcadc3dd48860321070c build by root@example.com, 2013-04-10 07:45:25
- 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
-    ns:1048576 nr:0 dw:0 dr:1048776 al:0 bm:64 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
+
  1: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
     ns:0 nr:1048576 dw:1048576 dr:0 al:0 bm:64 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
  2: cs:Unconfigured
index 3796442..4ecaa2f 100644 (file)
@@ -163,6 +163,49 @@ case_drbd84 = testParser (drbdStatusParser []) "proc_drbd84.txt" $
         Nothing
     ]
 
+-- | Test a DRBD 8.4 file with the first resource empty.
+case_drbd84_emptyfirst :: Assertion
+case_drbd84_emptyfirst = testParser (drbdStatusParser [])
+  "proc_drbd84_emptyfirst.txt" $ DRBDStatus
+    ( VersionInfo (Just "8.4.2") (Just "1") (Just "86-101") Nothing
+      (Just "7ad5f850d711223713d6dcadc3dd48860321070c")
+      (Just "root@example.com, 2013-04-10 07:45:25")
+    )
+    [ DeviceInfo 1 Connected (LocalRemote Secondary Primary)
+        (LocalRemote UpToDate UpToDate) 'C' "r-----"
+        (PerfIndicators 0 1048576 1048576 0 0 64 0 0 0 0 (Just 1)
+          (Just 'f') (Just 0))
+        Nothing
+        Nothing
+        Nothing
+        Nothing,
+      UnconfiguredDevice 2,
+      DeviceInfo 4 WFConnection (LocalRemote Primary Unknown)
+        (LocalRemote UpToDate DUnknown) 'C' "r-----"
+        (PerfIndicators 0 0 0 200 0 0 0 0 0 0 (Just 1)
+          (Just 'f') (Just 1048320))
+        Nothing
+        Nothing
+        Nothing
+        Nothing,
+      DeviceInfo 6 Connected (LocalRemote Secondary Primary)
+        (LocalRemote Diskless UpToDate) 'C' "r-----"
+        (PerfIndicators 0 0 0 0 0 0 0 0 0 0 (Just 1) (Just 'b')
+          (Just 0))
+        Nothing
+        Nothing
+        Nothing
+        Nothing,
+      DeviceInfo 8 StandAlone (LocalRemote Secondary Unknown)
+        (LocalRemote UpToDate DUnknown) ' ' "r-----"
+        (PerfIndicators 0 0 0 200 0 0 0 0 0 0 (Just 1)
+          (Just 'f') (Just 1048320))
+        Nothing
+        Nothing
+        Nothing
+        Nothing
+    ]
+
 -- | Test a DRBD 8.3 file with a NULL caracter inside.
 case_drbd83_sync_krnl2_6_39 :: Assertion
 case_drbd83_sync_krnl2_6_39 = testParser (drbdStatusParser [])
@@ -477,6 +520,7 @@ testSuite "Block/Drbd/Parser"
             'case_drbd80_emptyversion,
             'case_drbd84_sync,
             'case_drbd84,
+            'case_drbd84_emptyfirst,
             'case_drbd83_sync_krnl2_6_39,
             'case_drbd83_sync,
             'case_drbd83_sync_want,
index 41e6487..ff0dd77 100755 (executable)
@@ -289,6 +289,8 @@ class TestDRBD8Status(testutils.GanetiTestCase):
       testutils.TestDataFilename("proc_drbd83_sync_krnl2.6.39.txt")
     proc84_data = testutils.TestDataFilename("proc_drbd84.txt")
     proc84_sync_data = testutils.TestDataFilename("proc_drbd84_sync.txt")
+    proc84_emptyfirst_data = \
+      testutils.TestDataFilename("proc_drbd84_emptyfirst.txt")
 
     self.proc80ev_data = \
       testutils.TestDataFilename("proc_drbd80-emptyversion.txt")
@@ -303,6 +305,8 @@ class TestDRBD8Status(testutils.GanetiTestCase):
     self.drbd_info84 = drbd.DRBD8Info.CreateFromFile(filename=proc84_data)
     self.drbd_info84_sync = \
       drbd.DRBD8Info.CreateFromFile(filename=proc84_sync_data)
+    self.drbd_info84_emptyfirst = \
+      drbd.DRBD8Info.CreateFromFile(filename=proc84_emptyfirst_data)
 
   def testIOErrors(self):
     """Test handling of errors while reading the proc file."""
@@ -329,6 +333,7 @@ class TestDRBD8Status(testutils.GanetiTestCase):
     self.failUnless(not self.drbd_info.HasMinorStatus(9))
     self.failUnless(not self.drbd_info83.HasMinorStatus(9))
     self.failUnless(not self.drbd_info80e.HasMinorStatus(3))
+    self.failUnless(not self.drbd_info84_emptyfirst.HasMinorStatus(0))
 
   def testLineNotMatch(self):
     """Test wrong line passed to drbd_info.DRBD8Status"""
@@ -344,7 +349,8 @@ class TestDRBD8Status(testutils.GanetiTestCase):
 
   def testMinor1(self):
     """Test connected, secondary device"""
-    for info in [self.drbd_info, self.drbd_info83, self.drbd_info84]:
+    for info in [self.drbd_info, self.drbd_info83, self.drbd_info84,
+                 self.drbd_info84_emptyfirst]:
       stats = info.GetMinorStatus(1)
       self.failUnless(stats.is_in_use)
       self.failUnless(stats.is_connected and stats.is_secondary and
@@ -353,13 +359,15 @@ class TestDRBD8Status(testutils.GanetiTestCase):
   def testMinor2(self):
     """Test unconfigured device"""
     for info in [self.drbd_info, self.drbd_info83,
-                 self.drbd_info80e, self.drbd_info84]:
+                 self.drbd_info80e, self.drbd_info84,
+                 self.drbd_info84_emptyfirst]:
       stats = info.GetMinorStatus(2)
       self.failIf(stats.is_in_use)
 
   def testMinor4(self):
     """Test WFconn device"""
-    for info in [self.drbd_info, self.drbd_info83, self.drbd_info84]:
+    for info in [self.drbd_info, self.drbd_info83,
+                 self.drbd_info84, self.drbd_info84_emptyfirst]:
       stats = info.GetMinorStatus(4)
       self.failUnless(stats.is_in_use)
       self.failUnless(stats.is_wfconn and stats.is_primary and
@@ -368,7 +376,8 @@ class TestDRBD8Status(testutils.GanetiTestCase):
 
   def testMinor6(self):
     """Test diskless device"""
-    for info in [self.drbd_info, self.drbd_info83, self.drbd_info84]:
+    for info in [self.drbd_info, self.drbd_info83,
+                 self.drbd_info84, self.drbd_info84_emptyfirst]:
       stats = info.GetMinorStatus(6)
       self.failUnless(stats.is_in_use)
       self.failUnless(stats.is_connected and stats.is_secondary and