Example #1
0
def test_Connect_transform_returns_FDReadStreamConnector_if_input_is_NamedOutputPipe(ostream):
    nop_mock = mock.MagicMock(spec=NamedOutputPipe(
        'test',
        container_path='/bogus/container_path',
        host_path='/bogus/host_path'))
    connection = Connect(nop_mock, ostream)
    assert isinstance(connection.transform(), FDReadStreamConnector)
Example #2
0
def test_Connect_transform_returns_FDWriteStreamConnector_if_output_is_NamedInputPipe(istream):
    nip_mock = mock.MagicMock(spec=NamedInputPipe(
        'test',
        container_path='/bogus/container_path',
        host_path='/bogus/host_path'))
    connection = Connect(istream, nip_mock)
    assert isinstance(connection.transform(), FDWriteStreamConnector)
Example #3
0
    def test_docker_run_girder_file_to_volume(self, params):
        file_id = params.get('fileId')

        result = docker_run.delay(
            TEST_IMAGE, pull_image=True,
            container_args=['read_write', '-i', GirderFileIdToVolume(file_id),
                            '-o', Connect(NamedOutputPipe('out'), HostStdOut())],
            remove_container=True)

        return result.job
Example #4
0
    def test_docker_run_girder_file_to_named_pipe_on_temp_vol(self, params):
        """
        This is a simplified version of test_docker_run_girder_file_to_named_pipe
        it uses the TemporaryVolume, rather than having to setup the volumes
        'manually', this is the approach we should encourage.
        """
        file_id = params.get('fileId')
        pipe_name = 'input_pipe'

        connect = Connect(GirderFileIdToStream(file_id), NamedInputPipe(pipe_name))

        result = docker_run.delay(
            TEST_IMAGE, pull_image=True, container_args=['read', '-p', connect],
            remove_container=True)

        return result.job
Example #5
0
    def test_docker_run_girder_file_to_named_pipe(self, params):
        tmp_dir = params.get('tmpDir')
        file_id = params.get('fileId')
        mount_dir = '/mnt/girder_worker/data'
        pipe_name = 'input_pipe'

        volumes = {tmp_dir: {'bind': mount_dir, 'mode': 'rw'}}

        connect = Connect(GirderFileIdToStream(file_id),
                          NamedInputPipe(pipe_name, mount_dir, tmp_dir))

        result = docker_run.delay(TEST_IMAGE,
                                  pull_image=True,
                                  container_args=['read', '-p', connect],
                                  remove_container=True,
                                  volumes=volumes)

        return result.job
Example #6
0
    def test_docker_run_named_pipe_output(self, params):
        tmp_dir = params.get('tmpDir')
        message = params.get('message')
        mount_dir = '/mnt/girder_worker/data'
        pipe_name = 'output_pipe'

        volumes = {tmp_dir: {'bind': mount_dir, 'mode': 'rw'}}

        connect = Connect(NamedOutputPipe(pipe_name, mount_dir, tmp_dir),
                          HostStdOut())

        result = docker_run.delay(
            TEST_IMAGE,
            pull_image=True,
            container_args=['write', '-p', connect, '-m', message],
            remove_container=True,
            volumes=volumes)

        return result.job
Example #7
0
    def test_docker_run_transfer_encoding_stream(self, params):
        item_id = params.get('itemId')
        file_id = params.get('fileId')
        delimiter = params.get('delimiter')

        headers = {
            'Girder-Token': str(Token().createToken(getCurrentUser())['_id'])
        }
        url = '%s/%s?itemId=%s&delimiter=%s' % (
            getApiUrl(), 'integration_tests/docker/input_stream', item_id, delimiter)

        container_args = [
            'read_write',
            '-i', GirderFileIdToVolume(file_id),
            '-o', Connect(NamedOutputPipe('out'),
                          ChunkedTransferEncodingStream(url, headers))
        ]
        result = docker_run.delay(
            TEST_IMAGE, pull_image=True, container_args=container_args,
            remove_container=True)

        return result.job
def test_Connect_transform_throws_exception_if_no_NamedPipe_provided(
        istream, ostream):
    with pytest.raises(TypeError):
        Connect(istream, ostream).transform()