コード例 #1
0
    def setup_class(self):
        patches = create_start_patcher(
            patch_function='__init__',
            patch_object=AwsClient,
            side_effect=dummy_iaas_client_constructor)
        self.awsClientPatch = patches['patcher_start']
        self.patchers.append(patches['patcher'])

        patches = create_start_patcher(
            patch_function='__init__',
            patch_object=AzureClient,
            side_effect=dummy_iaas_client_constructor)
        self.azureClientPatch = patches['patcher_start']
        self.patchers.append(patches['patcher'])

        patches = create_start_patcher(
            patch_function='__init__',
            patch_object=GcpClient,
            side_effect=dummy_iaas_client_constructor)
        self.gcpClientPatch = patches['patcher_start']
        self.patchers.append(patches['patcher'])

        patches = create_start_patcher(
            patch_function='__init__',
            patch_object=OpenstackClient,
            side_effect=dummy_iaas_client_constructor)
        self.openstackClientPatch = patches['patcher_start']
        self.patchers.append(patches['patcher'])
コード例 #2
0
    def setup_class(self):
        self.patchers.append(
            create_start_patcher(patch_function='create_aws_session',
                                 patch_object=AwsClient,
                                 side_effect=get_dummy_aws_session)['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='last_operation',
                                 patch_object=BaseClient)['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='shell',
                                 patch_object=BaseClient,
                                 side_effect=mock_shell)['patcher'])
        os.environ['SF_BACKUP_RESTORE_LOG_DIRECTORY'] = log_dir
        os.environ['SF_BACKUP_RESTORE_LAST_OPERATION_DIRECTORY'] = log_dir

        self.testAwsClient = AwsClient(operation_name, configuration,
                                       directory_persistent,
                                       directory_work_list, poll_delay_time,
                                       poll_maximum_time)
        self.testAwsClientBlobOps = AwsClient(operation_name_blob_ops,
                                              configuration_blob_ops,
                                              directory_persistent,
                                              directory_work_list,
                                              poll_delay_time,
                                              poll_maximum_time)
コード例 #3
0
 def setup_class(self):
     self.patchers.append(
         create_start_patcher(
             patch_function=
             'google.oauth2.service_account.Credentials.from_service_account_info'
         )['patcher'])
     self.patchers.append(
         create_start_patcher(
             patch_function='googleapiclient.discovery.build',
             return_value=ComputeClient())['patcher'])
     self.patchers.append(
         create_start_patcher(patch_function='google.cloud.storage.Client',
                              return_value=StorageClient())['patcher'])
コード例 #4
0
 def test_gcp_client_raises_availability_zone_exception(self):
     mock_blob_upload_patcher = create_start_patcher(
         patch_function='google.cloud.storage.Blob.upload_from_string'
     )['patcher']
     mock_blob_delete_patcher = create_start_patcher(
         patch_function='google.cloud.storage.Blob.delete')['patcher']
     configuration['instance_id'] = invalid_vm_id
     with pytest.raises(
             Exception,
             message=
             'Could not retrieve the availability zone of the instance.'):
         GcpClient(operation_name, configuration, directory_persistent,
                   directory_work_list, poll_delay_time, poll_maximum_time)
     mock_blob_upload_patcher.stop()
     mock_blob_delete_patcher.stop()
コード例 #5
0
    def setup_class(self):
        self.patchers.append(
            create_start_patcher(patch_function='last_operation',
                                 patch_object=BaseClient)['patcher'])
        self.patchers.append(
            create_start_patcher(
                patch_function='keystoneauth1.identity.v3.Password')
            ['patcher'])
        self.patchers.append(
            create_start_patcher(
                patch_function='keystoneauth1.session.Session')['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='get_project_id',
                                 patch_object=KeystoneSession)['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='create_cinder_client',
                                 patch_object=OpenstackClient,
                                 return_value=CinderClient())['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='create_nova_client',
                                 patch_object=OpenstackClient,
                                 return_value=NovaClient())['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='create_swift_client',
                                 patch_object=OpenstackClient,
                                 return_value=SwiftClient())['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='create_swift_service',
                                 patch_object=OpenstackClient,
                                 return_value=SwiftService())['patcher'])

        os.environ['SF_BACKUP_RESTORE_LOG_DIRECTORY'] = log_dir
        os.environ['SF_BACKUP_RESTORE_LAST_OPERATION_DIRECTORY'] = log_dir

        self.osClient = OpenstackClient(operation_name, configuration,
                                        directory_persistent,
                                        directory_work_list, poll_delay_time,
                                        poll_maximum_time)
 def setup_class(self):
     # self.patchers.append(create_start_patcher(patch_function='__init__',patch_object=AliClient,side_effect=get_dummy_ali_session)['patcher'])
     # self.patchers.append(create_start_patcher(patch_function='get_container',patch_object=AliClient,side_effect=get_dummy_container)['patcher'])
     # self.patchers.append(create_start_patcher(patch_function='last_operation', patch_object=BaseClient)['patcher'])
     # self.patchers.append(create_start_patcher(patch_function='shell', patch_object=BaseClient, side_effect=mock_shell)['patcher'])
     self.patchers.append(
         create_start_patcher(
             patch_function='lib.clients.AliClient.AcsClient',
             return_value=ComputeClient()))
     self.patchers.append(
         create_start_patcher(
             patch_function='lib.clients.AliClient.oss2.Auth',
             return_value=StorageClient()))
     self.patchers.append(
         create_start_patcher(
             patch_function='lib.clients.AliClient.oss2.Bucket',
             return_value=Bucket(valid_container)))
     self.patchers.append(
         create_start_patcher(
             patch_function='lib.clients.AliClient.CommonRequest',
             return_value=CR()))
     self.patchers.append(
         create_start_patcher(patch_function='shell',
                              patch_object=BaseClient,
                              side_effect=mock_shell))
     self.patchers.append(
         create_start_patcher(patch_function='_get_device_of_volume',
                              patch_object=BaseClient,
                              side_effect=get_device_of_volume))
     self.patchers.append(
         create_start_patcher(
             patch_function='lib.clients.AliClient.RequestHeader',
             return_value=RequestHeader()))
     os.environ['SF_BACKUP_RESTORE_LOG_DIRECTORY'] = log_dir
     os.environ['SF_BACKUP_RESTORE_LAST_OPERATION_DIRECTORY'] = log_dir
     self.aliClient = AliClient(operation_name, configuration,
                                directory_persistent, directory_work_list,
                                poll_delay_time, poll_maximum_time)
コード例 #7
0
    def setup_class(self):
        self.patchers.append(
            create_start_patcher(patch_function='_get_device_of_volume',
                                 patch_object=BaseClient,
                                 side_effect=get_device_of_volume)['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='delete_snapshot',
                                 patch_object=BaseClient,
                                 return_value=True)['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='delete_volume',
                                 patch_object=BaseClient,
                                 return_value=True)['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='glob',
                                 patch_object=glob,
                                 side_effect=mockglob)['patcher'])
        self.patchers.append(
            create_start_patcher(
                patch_function='generate_name_by_prefix',
                patch_object=BaseClient,
                side_effect=generate_name_by_prefix)['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='shell',
                                 patch_object=BaseClient,
                                 side_effect=shell)['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='last_operation',
                                 patch_object=BaseClient)['patcher'])
        self.patchers.append(
            create_start_patcher(
                patch_function=
                'google.oauth2.service_account.Credentials.from_service_account_info'
            )['patcher'])
        self.patchers.append(
            create_start_patcher(
                patch_function='googleapiclient.discovery.build',
                return_value=ComputeClient())['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='google.cloud.storage.Client',
                                 return_value=StorageClient())['patcher'])
        self.patchers.append(
            create_start_patcher(
                patch_function='google.cloud.storage.Blob.upload_from_string')
            ['patcher'])
        self.patchers.append(
            create_start_patcher(
                patch_function='google.cloud.storage.Blob.delete')['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='upload_from_filename',
                                 patch_object=Blob,
                                 side_effect=upload_from_filename)['patcher'])
        self.patchers.append(
            create_start_patcher(patch_function='download_to_filename',
                                 patch_object=Blob,
                                 side_effect=download_to_filename)['patcher'])

        os.environ['SF_BACKUP_RESTORE_LOG_DIRECTORY'] = log_dir
        os.environ['SF_BACKUP_RESTORE_LAST_OPERATION_DIRECTORY'] = log_dir

        self.gcpClient = GcpClient(operation_name, configuration,
                                   directory_persistent, directory_work_list,
                                   poll_delay_time, poll_maximum_time)