Beispiel #1
0
    async def run(self):
        await aio.sleep(1)  # wait for repo to startup
        filepath1 = self.create_tmp_file(size_bytes=10 * 1024)
        filepath2 = uuid.uuid4().hex.upper()[0:6]

        # put
        pc = PutfileClient(self.app, Name.from_str('/putfile_client'),
                           Name.from_str(repo_name))
        insert_num = await pc.insert_file(
            filepath1,
            Name.from_str(filepath2),
            segment_size=8000,
            freshness_period=0,
            cpu_count=multiprocessing.cpu_count())
        # get
        gc = GetfileClient(self.app, Name.from_str(repo_name))
        await gc.fetch_file(Name.from_str(filepath2))
        # diff
        assert filecmp.cmp(filepath1, filepath2)
        # delete
        dc = DeleteClient(self.app, Name.from_str('/delete_client'),
                          Name.from_str(repo_name))
        delete_num = await dc.delete_file(Name.from_str(filepath2))
        assert insert_num == delete_num
        # cleanup
        self.files_to_cleanup.append(filepath1)
        self.files_to_cleanup.append(filepath2)
        self.app.shutdown()
async def run_getfile_client(app: NDNApp, **kwargs):
    """
    Async helper function to run the GetfileClient.
    This function is necessary because it's responsible for calling app.shutdown().
    """
    client = GetfileClient(app, kwargs['repo_name'])
    await client.fetch_file(kwargs['name_at_repo'])
    app.shutdown()