Add unittest for gnt-cluster modify --mac-prefix
authorDimitris Bliablias <bl.dimitris@gmail.com>
Fri, 28 Feb 2014 11:00:23 +0000 (13:00 +0200)
committerJose A. Lopes <jabolopes@google.com>
Fri, 28 Feb 2014 12:08:47 +0000 (13:08 +0100)
Add unittest for cluster mac-prefix modification support.

Signed-off-by: Dimitris Bliablias <bl.dimitris@gmail.com>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>

test/py/cmdlib/cluster_unittest.py

index 6fce290..babd87f 100644 (file)
@@ -403,6 +403,23 @@ class TestLUClusterSetParams(CmdlibTestCase):
     self.ExecOpCode(op)
     self.assertEqual(additional_pool, self.cluster.uid_pool)
 
+  def testMacPrefix(self):
+    mac_prefix = "aa:01:02"
+    op = opcodes.OpClusterSetParams(mac_prefix=mac_prefix)
+    self.ExecOpCode(op)
+    self.assertEqual(mac_prefix, self.cluster.mac_prefix)
+
+  def testEmptyMacPrefix(self):
+    mac_prefix = ""
+    op = opcodes.OpClusterSetParams(mac_prefix=mac_prefix)
+    self.ExecOpCodeExpectOpPrereqError(
+      op, "Parameter 'OP_CLUSTER_SET_PARAMS.mac_prefix' fails validation")
+
+  def testInvalidMacPrefix(self):
+    mac_prefix = "az:00:00"
+    op = opcodes.OpClusterSetParams(mac_prefix=mac_prefix)
+    self.ExecOpCodeExpectOpPrereqError(op, "Invalid MAC address prefix")
+
   def testMasterNetmask(self):
     op = opcodes.OpClusterSetParams(master_netmask=26)
     self.ExecOpCode(op)