Migrate test/ganeti.*.py from constants to pathutils
authorMichael Hanselmann <hansmi@google.com>
Mon, 17 Sep 2012 16:28:57 +0000 (18:28 +0200)
committerMichael Hanselmann <hansmi@google.com>
Tue, 18 Sep 2012 15:11:06 +0000 (17:11 +0200)
File system paths moved from constants to pathutils.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

test/ganeti.cmdlib_unittest.py
test/ganeti.hooks_unittest.py
test/ganeti.hypervisor.hv_kvm_unittest.py
test/ganeti.ovf_unittest.py
test/ganeti.uidpool_unittest.py

index d83a147..8dff740 100755 (executable)
@@ -42,6 +42,7 @@ from ganeti import ht
 from ganeti import objects
 from ganeti import compat
 from ganeti import rpc
+from ganeti import pathutils
 from ganeti.masterd import iallocator
 from ganeti.hypervisor import hv_xen
 
@@ -304,50 +305,50 @@ class TestClusterVerifyFiles(unittest.TestCase):
     cluster = objects.Cluster(modify_etc_hosts=True,
                               enabled_hypervisors=[constants.HT_XEN_HVM])
     files_all = set([
-      constants.CLUSTER_DOMAIN_SECRET_FILE,
-      constants.RAPI_CERT_FILE,
-      constants.RAPI_USERS_FILE,
+      pathutils.CLUSTER_DOMAIN_SECRET_FILE,
+      pathutils.RAPI_CERT_FILE,
+      pathutils.RAPI_USERS_FILE,
       ])
     files_opt = set([
-      constants.RAPI_USERS_FILE,
+      pathutils.RAPI_USERS_FILE,
       hv_xen.XL_CONFIG_FILE,
-      constants.VNC_PASSWORD_FILE,
+      pathutils.VNC_PASSWORD_FILE,
       ])
     files_mc = set([
-      constants.CLUSTER_CONF_FILE,
+      pathutils.CLUSTER_CONF_FILE,
       ])
     files_vm = set([
       hv_xen.XEND_CONFIG_FILE,
       hv_xen.XL_CONFIG_FILE,
-      constants.VNC_PASSWORD_FILE,
+      pathutils.VNC_PASSWORD_FILE,
       ])
     nvinfo = {
       master_name: rpc.RpcResult(data=(True, {
         constants.NV_FILELIST: {
-          constants.CLUSTER_CONF_FILE: "82314f897f38b35f9dab2f7c6b1593e0",
-          constants.RAPI_CERT_FILE: "babbce8f387bc082228e544a2146fee4",
-          constants.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4",
+          pathutils.CLUSTER_CONF_FILE: "82314f897f38b35f9dab2f7c6b1593e0",
+          pathutils.RAPI_CERT_FILE: "babbce8f387bc082228e544a2146fee4",
+          pathutils.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4",
           hv_xen.XEND_CONFIG_FILE: "b4a8a824ab3cac3d88839a9adeadf310",
           hv_xen.XL_CONFIG_FILE: "77935cee92afd26d162f9e525e3d49b9"
         }})),
       "node2.example.com": rpc.RpcResult(data=(True, {
         constants.NV_FILELIST: {
-          constants.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a",
+          pathutils.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a",
           hv_xen.XEND_CONFIG_FILE: "b4a8a824ab3cac3d88839a9adeadf310",
           }
         })),
       "node3.example.com": rpc.RpcResult(data=(True, {
         constants.NV_FILELIST: {
-          constants.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a",
-          constants.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4",
+          pathutils.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a",
+          pathutils.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4",
           }
         })),
       "node4.example.com": rpc.RpcResult(data=(True, {
         constants.NV_FILELIST: {
-          constants.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a",
-          constants.CLUSTER_CONF_FILE: "conf-a6d4b13e407867f7a7b4f0f232a8f527",
-          constants.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4",
-          constants.RAPI_USERS_FILE: "rapiusers-ea3271e8d810ef3",
+          pathutils.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a",
+          pathutils.CLUSTER_CONF_FILE: "conf-a6d4b13e407867f7a7b4f0f232a8f527",
+          pathutils.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4",
+          pathutils.RAPI_USERS_FILE: "rapiusers-ea3271e8d810ef3",
           hv_xen.XL_CONFIG_FILE: "77935cee92afd26d162f9e525e3d49b9"
           }
         })),
@@ -362,21 +363,21 @@ class TestClusterVerifyFiles(unittest.TestCase):
     self.assertEqual(sorted(errors), sorted([
       (None, ("File %s found with 2 different checksums (variant 1 on"
               " node2.example.com, node3.example.com, node4.example.com;"
-              " variant 2 on master.example.com)" % constants.RAPI_CERT_FILE)),
+              " variant 2 on master.example.com)" % pathutils.RAPI_CERT_FILE)),
       (None, ("File %s is missing from node(s) node2.example.com" %
-              constants.CLUSTER_DOMAIN_SECRET_FILE)),
+              pathutils.CLUSTER_DOMAIN_SECRET_FILE)),
       (None, ("File %s should not exist on node(s) node4.example.com" %
-              constants.CLUSTER_CONF_FILE)),
+              pathutils.CLUSTER_CONF_FILE)),
       (None, ("File %s is missing from node(s) node4.example.com" %
               hv_xen.XEND_CONFIG_FILE)),
       (None, ("File %s is missing from node(s) node3.example.com" %
-              constants.CLUSTER_CONF_FILE)),
+              pathutils.CLUSTER_CONF_FILE)),
       (None, ("File %s found with 2 different checksums (variant 1 on"
               " master.example.com; variant 2 on node4.example.com)" %
-              constants.CLUSTER_CONF_FILE)),
+              pathutils.CLUSTER_CONF_FILE)),
       (None, ("File %s is optional, but it must exist on all or no nodes (not"
               " found on master.example.com, node2.example.com,"
-              " node3.example.com)" % constants.RAPI_USERS_FILE)),
+              " node3.example.com)" % pathutils.RAPI_USERS_FILE)),
       (None, ("File %s is optional, but it must exist on all or no nodes (not"
               " found on node2.example.com)" % hv_xen.XL_CONFIG_FILE)),
       ("nodata.example.com", "Node did not return file checksum data"),
index ddeb105..f7384bd 100755 (executable)
@@ -36,6 +36,7 @@ from ganeti import constants
 from ganeti import cmdlib
 from ganeti import rpc
 from ganeti import compat
+from ganeti import pathutils
 from ganeti.constants import HKR_SUCCESS, HKR_FAIL, HKR_SKIP
 
 from mocks import FakeConfig, FakeProc, FakeContext
@@ -313,7 +314,7 @@ class TestHooksRunnerEnv(unittest.TestCase):
     self.assertEqual(env["GANETI_HOOKS_PATH"], hpath)
     self.assertEqual(env["GANETI_OP_CODE"], self.op.OP_ID)
     self.assertEqual(env["GANETI_HOOKS_VERSION"], str(constants.HOOKS_VERSION))
-    self.assertEqual(env["GANETI_DATA_DIR"], constants.DATA_DIR)
+    self.assertEqual(env["GANETI_DATA_DIR"], pathutils.DATA_DIR)
     if "GANETI_OBJECT_TYPE" in env:
       self.assertEqual(env["GANETI_OBJECT_TYPE"], constants.HTYPE_GROUP)
     else:
index 2c12e46..230efff 100755 (executable)
@@ -33,6 +33,7 @@ from ganeti import compat
 from ganeti import objects
 from ganeti import errors
 from ganeti import utils
+from ganeti import pathutils
 
 from ganeti.hypervisor import hv_kvm
 
@@ -199,7 +200,7 @@ class TestConsole(unittest.TestCase):
     cons = self._Test(instance, hvparams)
     self.assertEqual(cons.kind, constants.CONS_SSH)
     self.assertEqual(cons.host, instance.primary_node)
-    self.assertEqual(cons.command[0], constants.KVM_CONSOLE_WRAPPER)
+    self.assertEqual(cons.command[0], pathutils.KVM_CONSOLE_WRAPPER)
     self.assertEqual(cons.command[1], constants.SOCAT_PATH)
 
   def testVnc(self):
index 5be3faf..fa9197c 100644 (file)
@@ -41,6 +41,7 @@ from ganeti import constants
 from ganeti import errors
 from ganeti import ovf
 from ganeti import utils
+from ganeti import pathutils
 
 import testutils
 
@@ -394,14 +395,14 @@ class TestOVFImporter(BetterUnitTest):
   def testOVAUnpackingDirectories(self):
     self.importer = ovf.OVFImporter(self.ova_package, OPTS_EMPTY)
     self.assertTrue(self.importer.input_dir != None)
-    self.assertEquals(self.importer.output_dir , constants.EXPORT_DIR)
+    self.assertEquals(self.importer.output_dir , pathutils.EXPORT_DIR)
     self.assertTrue(self.importer.temp_dir != None)
 
   def testOVFUnpackingDirectories(self):
     self.importer = ovf.OVFImporter(self.virtualbox_ovf,
       OPTS_EMPTY)
     self.assertEquals(self.importer.input_dir , _GetFullFilename(""))
-    self.assertEquals(self.importer.output_dir , constants.EXPORT_DIR)
+    self.assertEquals(self.importer.output_dir , pathutils.EXPORT_DIR)
     self.assertEquals(self.importer.temp_dir , None)
 
   def testOVFSetOutputDirDirectories(self):
index 3dd45ed..cbffa8e 100755 (executable)
@@ -29,6 +29,7 @@ import unittest
 from ganeti import constants
 from ganeti import uidpool
 from ganeti import errors
+from ganeti import pathutils
 
 import testutils
 
@@ -41,14 +42,14 @@ class TestUidPool(testutils.GanetiTestCase):
     self.old_uid_max = constants.UIDPOOL_UID_MAX
     constants.UIDPOOL_UID_MIN = 1
     constants.UIDPOOL_UID_MAX = 10
-    constants.UIDPOOL_LOCKDIR = tempfile.mkdtemp()
+    pathutils.UIDPOOL_LOCKDIR = tempfile.mkdtemp()
 
   def tearDown(self):
     constants.UIDPOOL_UID_MIN = self.old_uid_min
     constants.UIDPOOL_UID_MAX = self.old_uid_max
-    for name in os.listdir(constants.UIDPOOL_LOCKDIR):
-      os.unlink(os.path.join(constants.UIDPOOL_LOCKDIR, name))
-    os.rmdir(constants.UIDPOOL_LOCKDIR)
+    for name in os.listdir(pathutils.UIDPOOL_LOCKDIR):
+      os.unlink(os.path.join(pathutils.UIDPOOL_LOCKDIR, name))
+    os.rmdir(pathutils.UIDPOOL_LOCKDIR)
 
   def testParseUidPool(self):
     self.assertEqualValues(