Zhou Zheng Sheng has uploaded a new change for review. Change subject: Add NFS storage domain functional tests ......................................................................
Add NFS storage domain functional tests Test creating NFS storage domain, pool, image, volume. Test creating VM with the NFS storage. How to verify: 1. build and install VDSM rpms, including vdsm-tests 2. start VDSM service 3. cd /usr/share/vdsm/tests 4. ./run_tests.sh -m 'nfs' functional/xmlrpcTests.py Change-Id: Ic9c24369af552b5d58e0f5704075d6f351792775 Signed-off-by: Zhou Zheng Sheng <[email protected]> --- M tests/functional/xmlrpcTests.py 1 file changed, 82 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/05/13105/1 diff --git a/tests/functional/xmlrpcTests.py b/tests/functional/xmlrpcTests.py index b9ec45b..2fdd240 100644 --- a/tests/functional/xmlrpcTests.py +++ b/tests/functional/xmlrpcTests.py @@ -49,6 +49,7 @@ raise SkipTest("XML-RPC Bindings are disabled") _mkinitrd = CommandPath("mkinird", "/usr/bin/mkinitrd") +_exportfs = CommandPath("exportfs", "/usr/sbin/exportfs") def readableBy(filePath, user): @@ -205,7 +206,7 @@ self.assertVdsOK(destroyResult) - @permutations([['localfs'], ['iscsi'], ['glusterfs']]) + @permutations([['localfs'], ['iscsi'], ['glusterfs'], ['nfs']]) def testStorage(self, backendType): conf = storageLayouts[backendType] with RollbackContext() as rollback: @@ -225,7 +226,7 @@ return drives @skipNoKVM - @permutations([['localfs'], ['iscsi']]) + @permutations([['localfs'], ['iscsi'], ['nfs']]) def testSimpleVMWithStorage(self, backendType): conf = storageLayouts[backendType] drives = self._generateDriveConf(conf) @@ -565,6 +566,52 @@ return args +def exportNFS(path): + rc, out, err = execCmd([_exportfs.cmd, '-o', 'rw,insecure,sync', + '127.0.0.1:%s' % path]) + return rc + + +def unexportNFS(path): + rc, out, err = execCmd([_exportfs.cmd, '-u', '127.0.0.1:%s' % path]) + return rc + + +class NFSServer(BackendServer): + def _createBackend(self, backends, rollback): + uid = pwd.getpwnam(VDSM_USER)[2] + gid = grp.getgrnam(VDSM_GROUP)[2] + + rootDir = tempfile.mkdtemp(prefix='nfs', dir=_VARTMP) + undo = lambda: os.rmdir(rootDir) + rollback.prependDefer(undo) + os.chown(rootDir, uid, gid) + os.chmod(rootDir, 0755) + + connections = {} + for uuid, subDir in backends.iteritems(): + path = os.path.join(rootDir, subDir) + os.mkdir(path) + undo = lambda path=path: shutil.rmtree(path, ignore_errors=True) + rollback.prependDefer(undo) + os.chown(path, uid, gid) + os.chmod(path, 0775) + self.asserts.assertEquals(0, exportNFS(path)) + undo = lambda path=path: self.asserts.assertEquals( + 0, unexportNFS(path)) + rollback.prependDefer(undo) + + connections[uuid] = {'type': 'nfs', + 'params': {'export': '127.0.0.1:%s' % path}} + + return connections + + def _genTypeSpecificArgs(self, connections, rollback): + args = {uuid: conn['params']['export'] + for uuid, conn in connections.iteritems()} + return args + + storageLayouts = \ {'localfs': {'server': LocalFSServer, @@ -602,8 +649,39 @@ "47bd7538-c48b-4b94-ba94-def922151d48"], "9af9bd7f-6167-4ae8-aac6-95a5e5f36f60": [ "bace8f68-4c5a-43f2-acb4-fa8daf58c0f9"]}}}, - 'nfs': {'server': 'blah', 'conn': 'blah', 'sd': 'blah', 'sp': 'blah', - 'img': 'blah', 'layout': 'blah'}, + 'nfs': + {'server': NFSServer, + 'conn': { + 'backends': { + '7663ae6f-045e-4bfa-b3cf-7ab738ee42c9': 'nfs0', + '402b9d69-d3f7-4855-87c3-95257ffc8c6a': 'nfs1'}, + 'timeout': 30}, + 'sd': { + "c29e3337-27c2-4fd6-8caa-9404e0455769": { + "name": "test nfs domain0", "type": "nfs", "class": "Data", + "connUUID": "7663ae6f-045e-4bfa-b3cf-7ab738ee42c9"}, + "78e5e27e-833c-4977-b940-58b4f83599ac": { + "name": "test nfs domain1", "type": "nfs", "class": "Data", + "connUUID": "402b9d69-d3f7-4855-87c3-95257ffc8c6a"}}, + 'sp': { + "01da0617-2da4-4081-8ad0-60b4e18d26bb": { + "name": "nfs storage pool", "master_ver": 1, "host": 1, + "master_uuid": "c29e3337-27c2-4fd6-8caa-9404e0455769"}}, + 'img': { + "ca31643e-699b-4268-86d0-fd377bf85f3b": { + "description": "Test nfs volume0", "type": "leaf", + "volid": "b74f92d5-4846-4918-91ed-2028677a628c", + "format": "cow", "preallocate": "sparse", "size": 20971520}, + "a913f26d-c880-4c0b-bc21-2901b6ba912a": { + "description": "test nfs volume1", "type": "leaf", + "volid": "15a87231-5bab-41d3-8c74-b9f7bc1d8c46", + "format": "cow", "preallocate": "sparse", "size": 20971520}}, + 'layout': { + "01da0617-2da4-4081-8ad0-60b4e18d26bb": { + "c29e3337-27c2-4fd6-8caa-9404e0455769": [ + "ca31643e-699b-4268-86d0-fd377bf85f3b"], + "78e5e27e-833c-4977-b940-58b4f83599ac": [ + "a913f26d-c880-4c0b-bc21-2901b6ba912a"]}}}, 'iscsi': { 'server': IscsiServer, 'conn': { -- To view, visit http://gerrit.ovirt.org/13105 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic9c24369af552b5d58e0f5704075d6f351792775 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Zhou Zheng Sheng <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
