Esempio n. 1
0
def minio_server():
    host, port = 'localhost', find_free_port()
    access_key, secret_key = 'arrow', 'apachearrow'

    address = '{}:{}'.format(host, port)
    env = os.environ.copy()
    env.update({
        'MINIO_ACCESS_KEY': access_key,
        'MINIO_SECRET_KEY': secret_key
    })

    with TemporaryDirectory() as tempdir:
        args = [
            'minio', '--compat', 'server', '--quiet', '--address', address,
            tempdir
        ]
        proc = None
        try:
            proc = subprocess.Popen(args, env=env)
        except (OSError, IOError):
            pytest.skip('`minio` command cannot be located')
        else:
            yield address, access_key, secret_key
        finally:
            if proc is not None:
                proc.kill()
Esempio n. 2
0
def test_flight_server_location_argument():
    locations = [
        None,
        'grpc://localhost:0',
        ('localhost', find_free_port()),
    ]
    for location in locations:
        with FlightServerBase(location) as server:
            assert isinstance(server, FlightServerBase)
Esempio n. 3
0
def gcs_server():
    port = find_free_port()
    env = os.environ.copy()
    args = [sys.executable, '-m', 'testbench', '--port', str(port)]
    proc = None
    try:
        proc = subprocess.Popen(args, env=env)
    except OSError as e:
        pytest.skip(f"Command {args} failed to execute: {e}")
    else:
        yield {
            'connection': ('localhost', port),
            'process': proc,
        }
    finally:
        if proc is not None:
            proc.kill()
Esempio n. 4
0
def test_client_wait_for_available():
    location = ('localhost', find_free_port())
    server = None

    def serve():
        global server
        time.sleep(0.5)
        server = FlightServerBase(location)
        server.serve()

    client = FlightClient(location)
    thread = threading.Thread(target=serve, daemon=True)
    thread.start()

    started = time.time()
    client.wait_for_available(timeout=5)
    elapsed = time.time() - started
    assert elapsed >= 0.5
Esempio n. 5
0
def s3_connection():
    host, port = 'localhost', find_free_port()
    access_key, secret_key = 'arrow', 'apachearrow'
    return host, port, access_key, secret_key
Esempio n. 6
0
    # Implement puts
    
    def do_put(self, context, descriptor, reader, writer):
        self._cache[descriptor.command] = reader.read_all()
        
    # -----------------------------------------------------------------
    # Implement gets

    def do_get(self, context, ticket):
        table = self._cache[ticket.ticket]
        return flight.RecordBatchStream(table)
    
    

port = 1337
location = flight.Location.for_grpc_tcp("localhost", find_free_port())
location

server = DemoServer(location)

thread = threading.Thread(target=lambda: server.serve(), daemon=True)
thread.start()

class DemoClient:
    
    def __init__(self, location, options=None):
        self.con = flight.connect(location)
        self.con.wait_for_available()
        self.options = options
        
    # Call "list-tables" RPC and return results as Python list