예제 #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()
예제 #2
0
    async def run(self):
        await aio.sleep(1)  # wait for repo to startup

        filepath = self.create_tmp_file()
        filename = '/TestFlags/file'
        pc = PutfileClient(self.app, Name.from_str('/putfile_client'),
                           Name.from_str(repo_name))
        await pc.insert_file(filepath,
                             Name.from_str(filename),
                             segment_size=8000,
                             freshness_period=0,
                             cpu_count=multiprocessing.cpu_count())

        ret = await self.fetch(Name.from_str('/TestFlags'),
                               must_be_fresh=False,
                               can_be_prefix=False)
        assert ret == None
        ret = await self.fetch(Name.from_str('/TestFlags'),
                               must_be_fresh=False,
                               can_be_prefix=True)
        assert ret != None
        ret = await self.fetch(Name.from_str('/TestFlags'),
                               must_be_fresh=True,
                               can_be_prefix=True)
        assert ret == None

        self.app.shutdown()
예제 #3
0
async def run_putfile_client(app: NDNApp, **kwargs):
    """
    Async helper function to run the PutfileClient.
    This function is necessary because it's responsible for calling app.shutdown().
    """
    client = PutfileClient(app, kwargs['client_prefix'], kwargs['repo_name'])
    await client.insert_file(kwargs['file_path'], kwargs['name_at_repo'],
                             kwargs['segment_size'],
                             kwargs['freshness_period'], kwargs['cpu_count'])
    app.shutdown()
예제 #4
0
async def run_putfile_client(app: NDNApp, **kwargs):
    """
    Async helper function to run the PutfileClient.
    This function is necessary because it's responsible for calling app.shutdown().
    """
    print(kwargs)
    client = PutfileClient(app=app,
                           prefix=kwargs['client_prefix'],
                           repo_name=kwargs['repo_name'])
    await client.insert_file(file_path=kwargs['file_path'],
                             name_at_repo=kwargs['name_at_repo'],
                             segment_size=kwargs['segment_size'],
                             freshness_period=kwargs['freshness_period'],
                             cpu_count=kwargs['cpu_count'],
                             forwarding_hint=kwargs['forwarding_hint'],
                             register_prefix=kwargs['register_prefix'])
    app.shutdown()
예제 #5
0
async def run_putfile_client(app: NDNApp, **kwargs):
    """
    Async helper function to run the PutfileClient.
    This function is necessary because it's responsible for calling app.shutdown().
    """
    client = PutfileClient(app=app,
                           prefix=kwargs['client_prefix'],
                           repo_name=kwargs['repo_name'])

    # Set pubsub to register ``check_prefix`` directly, so all prefixes under ``check_prefix`` will
    # be handled with interest filters. This reduces the number of registered prefixes at NFD, when
    # inserting multiple files with one client
    check_prefix = kwargs['client_prefix']

    await client.insert_file(file_path=kwargs['file_path'],
                             name_at_repo=kwargs['name_at_repo'],
                             segment_size=kwargs['segment_size'],
                             freshness_period=kwargs['freshness_period'],
                             cpu_count=kwargs['cpu_count'],
                             forwarding_hint=kwargs['forwarding_hint'],
                             register_prefix=kwargs['register_prefix'],
                             check_prefix=check_prefix)
    app.shutdown()