test/data/proc_drbd83_sync.txt \
test/data/proc_drbd83_sync_want.txt \
test/data/proc_drbd83_sync_krnl2.6.39.txt \
+ test/data/qa-minimal-nodes-instances-only.json \
test/data/sys_drbd_usermode_helper.txt \
test/data/vgreduce-removemissing-2.02.02.txt \
test/data/vgreduce-removemissing-2.02.66-fail.txt \
_INSTANCE_CHECK_KEY = "instance-check"
_ENABLED_HV_KEY = "enabled-hypervisors"
-#: Cluster-wide run-time value of the exclusive storage flag
-_exclusive_storage = None
-
-
#: QA configuration (L{_QaConfig})
_config = None
"""
self._data = data
+ #: Cluster-wide run-time value of the exclusive storage flag
+ self._exclusive_storage = None
+
@classmethod
def Load(cls, filename):
"""Loads a configuration file and produces a configuration object.
"""
return self.GetEnabledHypervisors()[0]
+ def SetExclusiveStorage(self, value):
+ """Set the expected value of the C{exclusive_storage} flag for the cluster.
+
+ """
+ self._exclusive_storage = bool(value)
+
+ def GetExclusiveStorage(self):
+ """Get the expected value of the C{exclusive_storage} flag for the cluster.
+
+ """
+ value = self._exclusive_storage
+ assert value is not None
+ return value
+
+ def IsTemplateSupported(self, templ):
+ """Is the given disk template supported by the current configuration?
+
+ """
+ if self.GetExclusiveStorage():
+ return templ in constants.DTS_EXCL_STORAGE
+ else:
+ return True
+
def Load(path):
"""Loads the passed configuration file.
def SetExclusiveStorage(value):
- """Set the expected value of the exclusive_storage flag for the cluster.
+ """Wrapper for L{_QaConfig.SetExclusiveStorage}.
"""
- global _exclusive_storage # pylint: disable=W0603
-
- _exclusive_storage = bool(value)
+ return GetConfig().SetExclusiveStorage(value)
def GetExclusiveStorage():
- """Get the expected value of the exclusive_storage flag for the cluster.
+ """Wrapper for L{_QaConfig.GetExclusiveStorage}.
"""
- val = _exclusive_storage
- assert val is not None
- return val
+ return GetConfig().GetExclusiveStorage()
def IsTemplateSupported(templ):
- """Is the given disk template supported by the current configuration?
+ """Wrapper for L{_QaConfig.GetExclusiveStorage}.
"""
- if GetExclusiveStorage():
- return templ in constants.DTS_EXCL_STORAGE
- else:
- return True
+ return GetConfig().IsTemplateSupported(templ)
def AcquireNode(exclude=None):
--- /dev/null
+{
+ "name": "xen-test-qa-minimal-nodes-instances-only",
+
+ "disk": ["1G", "512M"],
+ "disk-growth": ["2G", "768M"],
+
+ "nodes": [
+ {
+ "# Master node": null,
+ "primary": "xen-test-0",
+ "secondary": "192.0.2.1"
+ },
+
+ {
+ "primary": "xen-test-1",
+ "secondary": "192.0.2.2"
+ },
+
+ {
+ "primary": "xen-test-2",
+ "secondary": "192.0.2.3"
+ },
+
+ {
+ "primary": "xen-test-3",
+ "secondary": "192.0.2.4"
+ }
+ ],
+
+ "instances": [
+ {
+ "name": "xen-test-inst1",
+ "nic.mac/0": "AA:00:00:11:11:11"
+ },
+ {
+ "name": "xen-test-inst2",
+ "nic.mac/0": "AA:00:00:22:22:22"
+ }
+ ],
+
+ "tests": {
+ "default": false
+ },
+
+ "# vim: set syntax=javascript :": null
+}
self.assertEqual(self.config.GetMasterNode(), self.config["nodes"][0])
+class TestQaConfig(unittest.TestCase):
+ def setUp(self):
+ filename = \
+ testutils.TestDataFilename("qa-minimal-nodes-instances-only.json")
+
+ self.config = qa_config._QaConfig.Load(filename)
+
+ def testExclusiveStorage(self):
+ self.assertRaises(AssertionError, self.config.GetExclusiveStorage)
+
+ for value in [False, True, 0, 1, 30804, ""]:
+ self.config.SetExclusiveStorage(value)
+ self.assertEqual(self.config.GetExclusiveStorage(), bool(value))
+
+ for template in constants.DISK_TEMPLATES:
+ if value and template not in constants.DTS_EXCL_STORAGE:
+ self.assertFalse(self.config.IsTemplateSupported(template))
+ else:
+ self.assertTrue(self.config.IsTemplateSupported(template))
+
+
if __name__ == "__main__":
testutils.GanetiTestProgram()