Commit a56625a2 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Migrate test/ganeti.*.py from constants to pathutils



File system paths moved from constants to pathutils.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 57fe4a5b
...@@ -42,6 +42,7 @@ from ganeti import ht ...@@ -42,6 +42,7 @@ from ganeti import ht
from ganeti import objects from ganeti import objects
from ganeti import compat from ganeti import compat
from ganeti import rpc from ganeti import rpc
from ganeti import pathutils
from ganeti.masterd import iallocator from ganeti.masterd import iallocator
from ganeti.hypervisor import hv_xen from ganeti.hypervisor import hv_xen
...@@ -304,50 +305,50 @@ class TestClusterVerifyFiles(unittest.TestCase): ...@@ -304,50 +305,50 @@ class TestClusterVerifyFiles(unittest.TestCase):
cluster = objects.Cluster(modify_etc_hosts=True, cluster = objects.Cluster(modify_etc_hosts=True,
enabled_hypervisors=[constants.HT_XEN_HVM]) enabled_hypervisors=[constants.HT_XEN_HVM])
files_all = set([ files_all = set([
constants.CLUSTER_DOMAIN_SECRET_FILE, pathutils.CLUSTER_DOMAIN_SECRET_FILE,
constants.RAPI_CERT_FILE, pathutils.RAPI_CERT_FILE,
constants.RAPI_USERS_FILE, pathutils.RAPI_USERS_FILE,
]) ])
files_opt = set([ files_opt = set([
constants.RAPI_USERS_FILE, pathutils.RAPI_USERS_FILE,
hv_xen.XL_CONFIG_FILE, hv_xen.XL_CONFIG_FILE,
constants.VNC_PASSWORD_FILE, pathutils.VNC_PASSWORD_FILE,
]) ])
files_mc = set([ files_mc = set([
constants.CLUSTER_CONF_FILE, pathutils.CLUSTER_CONF_FILE,
]) ])
files_vm = set([ files_vm = set([
hv_xen.XEND_CONFIG_FILE, hv_xen.XEND_CONFIG_FILE,
hv_xen.XL_CONFIG_FILE, hv_xen.XL_CONFIG_FILE,
constants.VNC_PASSWORD_FILE, pathutils.VNC_PASSWORD_FILE,
]) ])
nvinfo = { nvinfo = {
master_name: rpc.RpcResult(data=(True, { master_name: rpc.RpcResult(data=(True, {
constants.NV_FILELIST: { constants.NV_FILELIST: {
constants.CLUSTER_CONF_FILE: "82314f897f38b35f9dab2f7c6b1593e0", pathutils.CLUSTER_CONF_FILE: "82314f897f38b35f9dab2f7c6b1593e0",
constants.RAPI_CERT_FILE: "babbce8f387bc082228e544a2146fee4", pathutils.RAPI_CERT_FILE: "babbce8f387bc082228e544a2146fee4",
constants.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4", pathutils.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4",
hv_xen.XEND_CONFIG_FILE: "b4a8a824ab3cac3d88839a9adeadf310", hv_xen.XEND_CONFIG_FILE: "b4a8a824ab3cac3d88839a9adeadf310",
hv_xen.XL_CONFIG_FILE: "77935cee92afd26d162f9e525e3d49b9" hv_xen.XL_CONFIG_FILE: "77935cee92afd26d162f9e525e3d49b9"
}})), }})),
"node2.example.com": rpc.RpcResult(data=(True, { "node2.example.com": rpc.RpcResult(data=(True, {
constants.NV_FILELIST: { constants.NV_FILELIST: {
constants.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a", pathutils.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a",
hv_xen.XEND_CONFIG_FILE: "b4a8a824ab3cac3d88839a9adeadf310", hv_xen.XEND_CONFIG_FILE: "b4a8a824ab3cac3d88839a9adeadf310",
} }
})), })),
"node3.example.com": rpc.RpcResult(data=(True, { "node3.example.com": rpc.RpcResult(data=(True, {
constants.NV_FILELIST: { constants.NV_FILELIST: {
constants.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a", pathutils.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a",
constants.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4", pathutils.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4",
} }
})), })),
"node4.example.com": rpc.RpcResult(data=(True, { "node4.example.com": rpc.RpcResult(data=(True, {
constants.NV_FILELIST: { constants.NV_FILELIST: {
constants.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a", pathutils.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a",
constants.CLUSTER_CONF_FILE: "conf-a6d4b13e407867f7a7b4f0f232a8f527", pathutils.CLUSTER_CONF_FILE: "conf-a6d4b13e407867f7a7b4f0f232a8f527",
constants.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4", pathutils.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4",
constants.RAPI_USERS_FILE: "rapiusers-ea3271e8d810ef3", pathutils.RAPI_USERS_FILE: "rapiusers-ea3271e8d810ef3",
hv_xen.XL_CONFIG_FILE: "77935cee92afd26d162f9e525e3d49b9" hv_xen.XL_CONFIG_FILE: "77935cee92afd26d162f9e525e3d49b9"
} }
})), })),
...@@ -362,21 +363,21 @@ class TestClusterVerifyFiles(unittest.TestCase): ...@@ -362,21 +363,21 @@ class TestClusterVerifyFiles(unittest.TestCase):
self.assertEqual(sorted(errors), sorted([ self.assertEqual(sorted(errors), sorted([
(None, ("File %s found with 2 different checksums (variant 1 on" (None, ("File %s found with 2 different checksums (variant 1 on"
" node2.example.com, node3.example.com, node4.example.com;" " 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" % (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" % (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" % (None, ("File %s is missing from node(s) node4.example.com" %
hv_xen.XEND_CONFIG_FILE)), hv_xen.XEND_CONFIG_FILE)),
(None, ("File %s is missing from node(s) node3.example.com" % (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" (None, ("File %s found with 2 different checksums (variant 1 on"
" master.example.com; variant 2 on node4.example.com)" % " 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" (None, ("File %s is optional, but it must exist on all or no nodes (not"
" found on master.example.com, node2.example.com," " 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" (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)), " found on node2.example.com)" % hv_xen.XL_CONFIG_FILE)),
("nodata.example.com", "Node did not return file checksum data"), ("nodata.example.com", "Node did not return file checksum data"),
......
...@@ -36,6 +36,7 @@ from ganeti import constants ...@@ -36,6 +36,7 @@ from ganeti import constants
from ganeti import cmdlib from ganeti import cmdlib
from ganeti import rpc from ganeti import rpc
from ganeti import compat from ganeti import compat
from ganeti import pathutils
from ganeti.constants import HKR_SUCCESS, HKR_FAIL, HKR_SKIP from ganeti.constants import HKR_SUCCESS, HKR_FAIL, HKR_SKIP
from mocks import FakeConfig, FakeProc, FakeContext from mocks import FakeConfig, FakeProc, FakeContext
...@@ -313,7 +314,7 @@ class TestHooksRunnerEnv(unittest.TestCase): ...@@ -313,7 +314,7 @@ class TestHooksRunnerEnv(unittest.TestCase):
self.assertEqual(env["GANETI_HOOKS_PATH"], hpath) self.assertEqual(env["GANETI_HOOKS_PATH"], hpath)
self.assertEqual(env["GANETI_OP_CODE"], self.op.OP_ID) self.assertEqual(env["GANETI_OP_CODE"], self.op.OP_ID)
self.assertEqual(env["GANETI_HOOKS_VERSION"], str(constants.HOOKS_VERSION)) 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: if "GANETI_OBJECT_TYPE" in env:
self.assertEqual(env["GANETI_OBJECT_TYPE"], constants.HTYPE_GROUP) self.assertEqual(env["GANETI_OBJECT_TYPE"], constants.HTYPE_GROUP)
else: else:
......
...@@ -33,6 +33,7 @@ from ganeti import compat ...@@ -33,6 +33,7 @@ from ganeti import compat
from ganeti import objects from ganeti import objects
from ganeti import errors from ganeti import errors
from ganeti import utils from ganeti import utils
from ganeti import pathutils
from ganeti.hypervisor import hv_kvm from ganeti.hypervisor import hv_kvm
...@@ -199,7 +200,7 @@ class TestConsole(unittest.TestCase): ...@@ -199,7 +200,7 @@ class TestConsole(unittest.TestCase):
cons = self._Test(instance, hvparams) cons = self._Test(instance, hvparams)
self.assertEqual(cons.kind, constants.CONS_SSH) self.assertEqual(cons.kind, constants.CONS_SSH)
self.assertEqual(cons.host, instance.primary_node) 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) self.assertEqual(cons.command[1], constants.SOCAT_PATH)
def testVnc(self): def testVnc(self):
......
...@@ -41,6 +41,7 @@ from ganeti import constants ...@@ -41,6 +41,7 @@ from ganeti import constants
from ganeti import errors from ganeti import errors
from ganeti import ovf from ganeti import ovf
from ganeti import utils from ganeti import utils
from ganeti import pathutils
import testutils import testutils
...@@ -394,14 +395,14 @@ class TestOVFImporter(BetterUnitTest): ...@@ -394,14 +395,14 @@ class TestOVFImporter(BetterUnitTest):
def testOVAUnpackingDirectories(self): def testOVAUnpackingDirectories(self):
self.importer = ovf.OVFImporter(self.ova_package, OPTS_EMPTY) self.importer = ovf.OVFImporter(self.ova_package, OPTS_EMPTY)
self.assertTrue(self.importer.input_dir != None) 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) self.assertTrue(self.importer.temp_dir != None)
def testOVFUnpackingDirectories(self): def testOVFUnpackingDirectories(self):
self.importer = ovf.OVFImporter(self.virtualbox_ovf, self.importer = ovf.OVFImporter(self.virtualbox_ovf,
OPTS_EMPTY) OPTS_EMPTY)
self.assertEquals(self.importer.input_dir , _GetFullFilename("")) 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) self.assertEquals(self.importer.temp_dir , None)
def testOVFSetOutputDirDirectories(self): def testOVFSetOutputDirDirectories(self):
......
...@@ -29,6 +29,7 @@ import unittest ...@@ -29,6 +29,7 @@ import unittest
from ganeti import constants from ganeti import constants
from ganeti import uidpool from ganeti import uidpool
from ganeti import errors from ganeti import errors
from ganeti import pathutils
import testutils import testutils
...@@ -41,14 +42,14 @@ class TestUidPool(testutils.GanetiTestCase): ...@@ -41,14 +42,14 @@ class TestUidPool(testutils.GanetiTestCase):
self.old_uid_max = constants.UIDPOOL_UID_MAX self.old_uid_max = constants.UIDPOOL_UID_MAX
constants.UIDPOOL_UID_MIN = 1 constants.UIDPOOL_UID_MIN = 1
constants.UIDPOOL_UID_MAX = 10 constants.UIDPOOL_UID_MAX = 10
constants.UIDPOOL_LOCKDIR = tempfile.mkdtemp() pathutils.UIDPOOL_LOCKDIR = tempfile.mkdtemp()
def tearDown(self): def tearDown(self):
constants.UIDPOOL_UID_MIN = self.old_uid_min constants.UIDPOOL_UID_MIN = self.old_uid_min
constants.UIDPOOL_UID_MAX = self.old_uid_max constants.UIDPOOL_UID_MAX = self.old_uid_max
for name in os.listdir(constants.UIDPOOL_LOCKDIR): for name in os.listdir(pathutils.UIDPOOL_LOCKDIR):
os.unlink(os.path.join(constants.UIDPOOL_LOCKDIR, name)) os.unlink(os.path.join(pathutils.UIDPOOL_LOCKDIR, name))
os.rmdir(constants.UIDPOOL_LOCKDIR) os.rmdir(pathutils.UIDPOOL_LOCKDIR)
def testParseUidPool(self): def testParseUidPool(self):
self.assertEqualValues( self.assertEqualValues(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment