Пример #1
0
 def test_skte_t996_move_file(self):
     # 上传文件用于移动
     filename = config.file_name  # 移动源文件名称
     file = '{}{}'.format(config.file_url, filename)  # 源文件及其路径
     target = config.ceph_path  # 文件上传的目的地址,同时也是移动文件的源地址
     send_file_m_req.upload_file(self.token, file, target)
     # 创建文件夹作为移动目的地址
     folder = 'T996 movefolder'
     send_file_m_req.create_folder(self.token, target, folder)
     # 移动文件
     move_source = '{}{}'.format(config.ceph_path, config.file_name)
     move_sources = []
     move_sources.append(move_source)  # 移动的源文件及其路径列表
     move_target = '{}{}'.format(target, folder)  # 文件移动的目标地址
     send_file_m_req.move_file(self.token, move_sources, move_target)
     # 校验移动结果
     filename_target = send_file_m_req.get_file_list(
         self.token, move_target)  # 移动目的地址文件名列表
     if filename not in filename_target:
         logger.log_error(
             'file/folder {} move failed, target address do not find it'.
             format(filename))
         assert False
     filename_source = send_file_m_req.get_file_list(self.token,
                                                     target)  # 移动源地址文件名列表
     if filename in filename_source:
         logger.log_error(
             'file/folder {} move failed, source address have not moved it away'
             .format(filename))
         assert False
     # 删除文件夹
     path_folder = []
     path_folder.append('{}{}'.format(target, folder))
     send_file_m_req.delete_files_and_folders(self.token, path_folder)
Пример #2
0
 def test_skte_t1023_t1030_share_and_cancel_files_in_bulk(self):
     target = config.ceph_path  # 上传路径
     filename1 = 'iris.csv'  # 上传文件名称
     file1 = '{}{}'.format(config.file_url, filename1)  # 源文件及其路径
     filePath1 = '{}{}'.format(target, filename1)  # 上传后文件及其路径
     filename2 = 'iris.txt'
     file2 = '{}{}'.format(config.file_url, filename2)
     filePath2 = '{}{}'.format(target, filename2)
     paths = []
     paths.append(filePath1)
     paths.append(filePath2)
     # 上传文件用于共享/取消共享操作
     send_file_m_req.upload_file(self.token, file1, target)
     send_file_m_req.upload_file(self.token, file2, target)
     # 共享文件给用户
     uuid = get_uuid_from_token(self.token)  # 文件所有者的uuid,同时也是文件共享者的uuid
     shareuser_token = send_user_m_req.get_token_simple(
         config.user_name_b, config.user_passwd_b)  # 被共享用户的token
     sharer_uuid = get_uuid_from_token(shareuser_token)  # 被共享用户的uuid
     share_uuid = send_file_m_req.share_files_batch(self.token,
                                                    sharePaths=paths,
                                                    owner_id=uuid,
                                                    share_id=uuid,
                                                    users=[sharer_uuid])
     # 验证文件共享结果: 1)共享用户在“我的共享”文件夹下可看到共享文件 2)被共享用户在“接收的共享”文件夹下可看到被共享文件
     my_share_file = send_file_m_req.get_shared_file_list(
         self.token, owner_id=uuid)  # 共享用户查看"我的共享"文件夹,返回其下可查看到的文件列表
     if filename1 and filename2 not in my_share_file:
         logger.log_error(
             'user {} cannot find shared file {} and {}'.format(
                 config.user_name_a, filename1, filename2))
         assert False
     share_file_list = send_file_m_req.get_shared_file_list(
         shareuser_token,
         user_id=sharer_uuid)  # 被共享用户查看"接收的共享",返回其下可查看到的文件列表
     if filename1 and filename2 not in share_file_list:
         logger.log_error(
             'user {} cannot find shared file {} and {}'.format(
                 config.user_name_b, filename1, filename2))
         assert False
     # 取消共享文件
     send_file_m_req.cancel_shared_file(self.token, share_uuid)
     # 验证文件共享结果: 1)共享用户的“我的共享”文件夹下已移除共享文件 2)被共享用户已在“接收的共享”文件夹下移除被共享文件
     my_share_file = send_file_m_req.get_shared_file_list(
         self.token, owner_id=uuid)  # 共享用户查看"我的共享"文件夹,返回其下可查看到的文件列表
     if filename1 and filename2 in my_share_file:
         logger.log_error(
             'user {} should not find unshared file {} and {}'.format(
                 config.user_name_a, filename1, filename2))
         assert False
     share_file_list = send_file_m_req.get_shared_file_list(
         shareuser_token,
         user_id=sharer_uuid)  # 被共享用户查看"接收的共享",返回其下可查看到的文件列表
     if filename1 and filename2 in share_file_list:
         logger.log_error(
             'user {} should not find unshared file {} and {}'.format(
                 config.user_name_b, filename1, filename2))
         assert False
     # 删除文件
     send_file_m_req.delete_files_and_folders(self.token, paths)
 def test_skte_t1006_delete_file(self):
     filename = config.file_name
     file = '{}{}'.format(config.file_url, filename)
     target = config.ceph_path
     paths = []
     paths.append('{}{}'.format(target, filename))
     # 上传文件用于删除操作
     send_file_m_req.upload_file(self.token, file, target)
     # 删除文件
     send_file_m_req.delete_files_and_folders(self.token, paths)
Пример #4
0
 def test_skte_t1014_t1029_share_and_cancel_file(self):
     filename = config.file_name  # 上传文件名称
     file = '{}{}'.format(config.file_url, filename)  # 源文件及其路径
     target = config.ceph_path  # 上传路径
     filePath = '{}{}'.format(target, filename)  # 上传后文件及其路径
     # 上传文件用于共享/取消共享操作
     send_file_m_req.upload_file(self.token, file, target)
     # 共享文件给全局
     uuid = get_uuid_from_token(self.token)  # 文件所有者的uuid,同时也是文件共享者的uuid
     share_uuid = send_file_m_req.share_file(self.token,
                                             owner_uuid=uuid,
                                             sharePath=filePath,
                                             isGlobal=True)
     # 验证文件共享结果: 1)共享用户在“我的共享”文件夹下可看到共享文件 2)被共享用户在“接收的共享”文件夹下可看到被共享文件
     my_share_file = send_file_m_req.get_shared_file_list(
         self.token, owner_id=uuid)  # 共享用户查看"我的共享"文件夹,返回其下可查看到的文件列表
     if filename not in my_share_file:
         logger.log_error('user {} cannot find shared file {}'.format(
             config.user_name_a, filename))
         assert False
     shareuser_token = send_user_m_req.get_token_simple(
         config.user_name_b, config.user_passwd_b)  # 被共享用户的token
     sharer_uuid = get_uuid_from_token(shareuser_token)  # 被共享用户的uuid
     share_file_list = send_file_m_req.get_shared_file_list(
         shareuser_token,
         user_id=sharer_uuid)  # 被共享用户查看"接收的共享",返回其下可查看到的文件列表
     if filename not in share_file_list:
         logger.log_error('user {} cannot find shared file {}'.format(
             config.user_name_b, filename))
         assert False
     # 取消共享文件
     send_file_m_req.cancel_shared_file(self.token, share_uuid)
     # 验证文件共享结果: 1)共享用户的“我的共享”文件夹下已移除共享文件 2)被共享用户已在“接收的共享”文件夹下移除被共享文件
     my_share_file = send_file_m_req.get_shared_file_list(
         self.token, owner_id=uuid)  # 共享用户查看"我的共享"文件夹,返回其下可查看到的文件列表
     if filename in my_share_file:
         logger.log_error('user {} should not find unshared file {}'.format(
             config.user_name_a, filename))
         assert False
     share_file_list = send_file_m_req.get_shared_file_list(
         shareuser_token,
         user_id=sharer_uuid)  # 被共享用户查看"接收的共享",返回其下可查看到的文件列表
     if filename in share_file_list:
         logger.log_error('user {} should not find unshared file {}'.format(
             config.user_name_b, filename))
         assert False
     # 删除文件
     paths = []
     paths.append(filePath)
     send_file_m_req.delete_files_and_folders(self.token, paths)
Пример #5
0
    def test_SKTE_T1016_rename(self):
        # Title: 重命名文件
        # Owner:qingzhen
        # PreCondition:创造测试文件夹T1016,上传测试文件iris.csv
        target = config.ceph_path
        file = '{}{}'.format(config.file_url, config.file_name)
        send_file_m_req.create_folder(self.token, target, 'T1016')
        send_file_m_req.upload_file(self.token, file, target + 'T1016')
        # 1. 重命名iris.csv为reame.csv成功。
        send_file_m_req.rename_file_folder(self.token, target + 'T1016/' + config.file_name , 'rename.csv')
        # 2. 上传文件iris.csv,重名为rename.csv失败
        send_file_m_req.upload_file(self.token, file, target + 'T1016')
        send_file_m_req.rename_file_folder(self.token, target + 'T1016/' + config.file_name, 'rename.csv',resultcode = '400')

        # Reset :删除文件夹
        send_file_m_req.delete_files_and_folders(self.token, paths= [target+'T1016'])
 def test_skte_t1001_copy_file(self):
     # 上传文件用于拷贝
     filename = config.file_name  # 拷贝源文件名称
     file = '{}{}'.format(config.file_url, filename)  # 源文件及其路径
     target = config.ceph_path  # 文件上传的目的地址,同时也是拷贝文件的源地址
     send_file_m_req.upload_file(self.token, file, target)
     # 创建拷贝目的地址文件夹
     folder = 'T1001 copyfolder'
     send_file_m_req.create_folder(self.token, target, folder)
     # 拷贝文件
     copy_source = '{}{}'.format(config.ceph_path, config.file_name)
     copy_sources = []
     copy_sources.append(copy_source)  # 拷贝的源文件及其路径列表
     copy_target = '{}{}'.format(target, folder)  # 文件拷贝的目标地址
     send_file_m_req.copy_file(self.token, copy_sources, copy_target)
     # 校验拷贝结果
     filename_target = send_file_m_req.get_file_list(
         self.token, copy_target)  # 拷贝目的地址文件名列表
     if filename not in filename_target:
         logger.log_error(
             'file/folder {} copy failed, target address do not find it'.
             format(filename))
         assert False
     filename_source = send_file_m_req.get_file_list(self.token,
                                                     target)  # 拷贝源地址文件名列表
     if filename not in filename_source:
         logger.log_error(
             'file/folder {} copy failed, source address do not find it'.
             format(filename))
         assert False
     # 删除文件和文件夹
     # paths = []
     # paths.append('{}{}'.format(target, config.file_name))
     # paths.append('{}{}'.format(target, folder))
     # send_file_m_req.delete_files_and_folders(self.token, paths)    # 批量删除文件和文件夹有bug,http://jira.iluvatar.ai:8080/browse/SDXTEST-468,文件和文件夹暂时分开删除
     # 删除文件
     path_file = []
     path_file.append('{}{}'.format(target, config.file_name))
     send_file_m_req.delete_files_and_folders(self.token, path_file)
     # 删除文件夹
     path_folder = []
     path_folder.append('{}{}'.format(target, folder))
     send_file_m_req.delete_files_and_folders(self.token, path_folder)
    def test_skte_t1007_delete_folder(self):
        # Title: 删除文件夹
        # Owner:qingzhen
        # PreCondition:创建测试目录T1007,上传iris.csv文件到该目录成功,并检查宿主机上对应user volumn下文件夹存在
        target = config.ceph_path
        file = '{}{}'.format(config.file_url, config.file_name)
        send_file_m_req.create_folder(self.token, target, 'T1007')
        send_file_m_req.upload_file(self.token, file, target + 'T1007')
        user_uuid = get_uuid_from_token(self.token)
        volume_id = send_file_m_req.get_volume_id_by_user_uuid(user_uuid)

        # 1. 删除文件夹
        send_file_m_req.delete_files_and_folders(self.token,
                                                 paths=[target + 'T1007'])
        time.sleep(2)

        # 2. 在对应user volume下检查文件夹删除成功
        foler_check = '/SkyDiscovery/cephfs/data/user/volume_{}/T1007'.format(
            volume_id)
        assert check_files_folders_exist(input_path_list=[foler_check],
                                         isExistCheck=False)
Пример #8
0
    def test_SKTE_T1020_extract_file(self):
        # Title: 解压文件
        # Owner:qingzhen
        # PreCondition:创建测试目录T1020,上传zip文件到该目录成功
        zip_file = '{}{}'.format(config.file_url, config.zip_file_name)
        target = config.ceph_path
        send_file_m_req.create_folder(self.token, target, 'T1020')
        zip_file_path = '{}T1020'.format(target)
        zip_file_path_full = '{}/{}'.format(zip_file_path,
                                            config.zip_file_name)
        send_file_m_req.upload_file(self.token, zip_file, zip_file_path)
        # 1. 解压zip文件成功
        send_file_m_req.extract_file(self.token, zip_file_path_full,
                                     zip_file_path)
        # 2. 查看解压文件,目录结构如下 iris / iris1 (iris1.csv) + iris2 (iris2.csv + iris3.csv)
        folder_iris1_files = send_file_m_req.get_file_list(
            self.token, '{}/iris/iris1'.format(zip_file_path))
        if 'iris1.csv' not in folder_iris1_files:
            logger.log_error(
                'iris1.csv not include in folder T1020/iris/iris1, actually files under folder are {}'
                .format(folder_iris1_files))
            assert False

        folder_iris2_files = send_file_m_req.get_file_list(
            self.token, '{}/iris/iris2'.format(zip_file_path))  #
        if 'iris2.csv' not in folder_iris2_files:
            logger.log_error(
                'iris2.csv not include in folder T1020/iris/iris2, actually files under folder are {}'
                .format(folder_iris2_files))
            assert False

        if 'iris3.csv' not in folder_iris2_files:
            logger.log_error(
                'iris3.csv not include in folder T1020/iris/iris2, actually files under folder are {}'
                .format(folder_iris2_files))
            assert False

        # Reset:删除zip文件及文件夹
        send_file_m_req.delete_files_and_folders(self.token,
                                                 paths=[target + 'T1020'])
 def test_skte_t1002_copy_folder(self):
     # 上传文件用于文件夹拷贝
     filename = config.file_name  # 上传源文件名称
     file = '{}{}'.format(config.file_url, filename)  # 源文件及其路径
     source_folder = 'T1002'  # 需拷贝的源文件夹名称
     source_path = '{}{}'.format(config.ceph_path,
                                 source_folder)  # 文件上传的目的地址,同时也是拷贝目标
     send_file_m_req.upload_file(self.token, file, source_path)
     # 创建文件夹作为拷贝目的地址
     folder = 'T1002 copyfolder'
     send_file_m_req.create_folder(self.token, config.ceph_path, folder)
     # 拷贝文件夹
     copy_source = source_path
     copy_sources = []
     copy_sources.append(copy_source)  # 拷贝的源文件夹及其路径列表
     copy_target = '{}{}'.format(config.ceph_path, folder)  # 文件夹拷贝的目标地址
     send_file_m_req.copy_file(self.token, copy_sources, copy_target)
     # 校验拷贝结果
     foldername_target = send_file_m_req.get_file_list(
         self.token, copy_target)  # 拷贝目的地址文件名列表
     if source_folder not in foldername_target:
         logger.log_error(
             'file/folder {} copy failed, target address do not find it'.
             format(source_folder))
         assert False
     foldername_target = send_file_m_req.get_file_list(
         self.token, config.ceph_path)  # 拷贝源地址文件名列表
     if source_folder not in foldername_target:
         logger.log_error(
             'file/folder {} copy failed, source address do not find it'.
             format(source_folder))
         assert False
     # 删除文件夹
     path_folder = []
     path_folder.append(copy_source)
     path_folder.append(copy_target)
     send_file_m_req.delete_files_and_folders(self.token, path_folder)
Пример #10
0
 def test_skte_t997_move_folder(self):
     # 上传文件用于文件夹移动
     filename = config.file_name  # 上传源文件名称
     file = '{}{}'.format(config.file_url, filename)  # 源文件及其路径
     source_folder = 'T997'  # 需移动的源文件夹名称
     source_path = '{}{}'.format(config.ceph_path,
                                 source_folder)  # 文件上传的目的地址,同时也是移动目标
     send_file_m_req.upload_file(self.token, file, source_path)
     # 创建文件夹作为移动目的地址
     folder = 'T997 movefolder'
     send_file_m_req.create_folder(self.token, config.ceph_path, folder)
     # 移动文件夹
     move_source = source_path
     move_sources = []
     move_sources.append(move_source)  # 移动的源文件夹及其路径列表
     move_target = '{}{}'.format(config.ceph_path, folder)  # 文件夹移动的目标地址
     send_file_m_req.move_file(self.token, move_sources, move_target)
     # 校验移动结果
     foldername_target = send_file_m_req.get_file_list(
         self.token, move_target)  # 移动目的地址文件名列表
     if source_folder not in foldername_target:
         logger.log_error(
             'file/folder {} move failed, target address do not find it'.
             format(source_folder))
         assert False
     foldername_target = send_file_m_req.get_file_list(
         self.token, config.ceph_path)  # 移动源地址文件名列表
     if source_folder in foldername_target:
         logger.log_error(
             'file/folder {} move failed, source address have not moved it away'
             .format(source_folder))
         assert False
     # 删除文件夹
     path_folder = []
     path_folder.append(move_target)
     send_file_m_req.delete_files_and_folders(self.token, path_folder)
    def test_skte_t1008_delete_multi_files_folders(self):
        # Title: 删除多个文件或文件夹
        # Owner:qingzhen
        # PreCondition:创建测试目录T1008,上传iris_folder文件夹到该目录成功
        target = config.ceph_path
        # iris_folder文件结构:
        # iris_folder
        #   iris0(iris0_1.csv+iris0_2.csv+iris0_3.csv)
        #   iris1(iris1.csv)
        #   iris2(iris2_1.csv+iris2_2.csv)
        #   iris3.csv
        #   iris4.csv
        #   iris5.csv
        folder = '{}{}'.format(config.file_url, config.folder_name)
        send_file_m_req.create_folder(self.token, target, 'T1008')
        send_file_m_req.upload_file(self.token, folder + '/iris3.csv',
                                    target + 'T1008/' + config.folder_name)
        send_file_m_req.upload_file(self.token, folder + '/iris4.csv',
                                    target + 'T1008/' + config.folder_name)
        send_file_m_req.upload_file(self.token, folder + '/iris5.csv',
                                    target + 'T1008/' + config.folder_name)
        send_file_m_req.upload_file(
            self.token, folder + '/iris0/iris0_1.csv',
            target + 'T1008/' + config.folder_name + '/iris0')
        send_file_m_req.upload_file(
            self.token, folder + '/iris0/iris0_2.csv',
            target + 'T1008/' + config.folder_name + '/iris0')
        send_file_m_req.upload_file(
            self.token, folder + '/iris0/iris0_3.csv',
            target + 'T1008/' + config.folder_name + '/iris0')
        send_file_m_req.upload_file(
            self.token, folder + '/iris1/iris1.csv',
            target + 'T1008/' + config.folder_name + '/iris1')
        send_file_m_req.upload_file(
            self.token, folder + '/iris2/iris2_1.csv',
            target + 'T1008/' + config.folder_name + '/iris2')
        send_file_m_req.upload_file(
            self.token, folder + '/iris2/iris2_2.csv',
            target + 'T1008/' + config.folder_name + '/iris2')

        user_uuid = get_uuid_from_token(self.token)
        volume_id = send_file_m_req.get_volume_id_by_user_uuid(user_uuid)

        # 1. 删除文件夹和文件夹
        delete_paths = [
            target + 'T1008/' + config.folder_name + '/iris0',
            target + 'T1008/' + config.folder_name + '/iris2',
            target + 'T1008/' + config.folder_name + '/iris3.csv',
            target + 'T1008/' + config.folder_name + '/iris5.csv'
        ]
        send_file_m_req.delete_files_and_folders(self.token,
                                                 paths=delete_paths)
        time.sleep(2)

        # 2.在对应user volume下检查文件夹和文件夹删除成功
        user_volume_path = '/SkyDiscovery/cephfs/data/user/volume_{}/'.format(
            volume_id)
        delete_paths_check = [
            user_volume_path + 'T1008/' + config.folder_name + '/iris0',
            user_volume_path + 'T1008/' + config.folder_name + '/iris2',
            user_volume_path + 'T1008/' + config.folder_name + '/iris3.csv',
            user_volume_path + 'T1008/' + config.folder_name + '/iris5.csv'
        ]

        assert check_files_folders_exist(input_path_list=delete_paths_check,
                                         isExistCheck=False)

        # Reset: 删除目录 T1008
        send_file_m_req.delete_files_and_folders(self.token,
                                                 paths=[target + 'T1008'])