Skip to content

Apache DataFusion SQL Query Engine

ARROW-5875: [FlightRPC] integration tests for Flight features

David Li990af416e9fb
diff --git a/dev/archery/archery/integration/runner.py b/dev/archery/archery/integration/runner.py
index f66df96992..b9bb94deba 100644
--- a/dev/archery/archery/integration/runner.py
+++ b/dev/archery/archery/integration/runner.py
@@ -26,6 +26,7 @@ import sys
import tempfile
import traceback
+from .scenario import Scenario
from .tester_cpp import CPPTester
from .tester_go import GoTester
from .tester_java import JavaTester
@@ -49,10 +50,11 @@ class Outcome:
class IntegrationRunner(object):
- def __init__(self, json_files, testers, tempdir=None, debug=False,
- stop_on_error=True, gold_dirs=None, serial=False,
- match=None, **unused_kwargs):
+ def __init__(self, json_files, flight_scenarios, testers, tempdir=None,
+ debug=False, stop_on_error=True, gold_dirs=None,
+ serial=False, match=None, **unused_kwargs):
self.json_files = json_files
+ self.flight_scenarios = flight_scenarios
self.testers = testers
self.temp_dir = tempdir or tempfile.mkdtemp()
self.debug = debug
@@ -251,7 +253,8 @@ class IntegrationRunner(object):
log('##########################################################')
case_runner = partial(self._run_flight_test_case, producer, consumer)
- self._run_test_cases(producer, consumer, case_runner, self.json_files)
+ self._run_test_cases(producer, consumer, case_runner,
+ self.json_files + self.flight_scenarios)
def _run_flight_test_case(self, producer, consumer, test_case):
"""
@@ -259,9 +262,8 @@ class IntegrationRunner(object):
"""
outcome = Outcome()
- json_path = test_case.path
log('=' * 58)
- log('Testing file {0}'.format(json_path))
+ log('Testing file {0}'.format(test_case.name))
log('=' * 58)
if producer.name in test_case.skip:
@@ -280,10 +282,17 @@ class IntegrationRunner(object):
else:
try:
- with producer.flight_server() as port:
+ if isinstance(test_case, Scenario):
+ server = producer.flight_server(test_case.name)
+ client_args = {'scenario_name': test_case.name}
+ else:
+ server = producer.flight_server()
+ client_args = {'json_path': test_case.path}
+
+ with server as port:
# Have the client upload the file, then download and
# compare
- consumer.flight_request(port, json_path)
+ consumer.flight_request(port, **client_args)
except Exception:
traceback.print_exc(file=printer.stdout)
outcome.failure = Failure(test_case, producer, consumer,
@@ -328,7 +337,14 @@ def run_all_tests(with_cpp=True, with_java=True, with_js=True,
)
json_files = static_json_files + generated_json_files
- runner = IntegrationRunner(json_files, testers, **kwargs)
+ # Additional integration test cases for Arrow Flight.
+ flight_scenarios = [
+ Scenario(
+ "auth:basic_proto",
+ description="Authenticate using the BasicAuth protobuf."),
+ ]
+
+ runner = IntegrationRunner(json_files, flight_scenarios, testers, **kwargs)
runner.run()
if run_flight:
runner.run_flight()
diff --git a/dev/archery/archery/integration/scenario.py b/dev/archery/archery/integration/scenario.py
new file mode 100644
index 0000000000..1fcbca64e6
--- /dev/null
+++ b/dev/archery/archery/integration/scenario.py
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+class Scenario:
+ """
+ An integration test scenario for Arrow Flight.
+
+ Does not correspond to a particular IPC JSON file.
+ """
+
+ def __init__(self, name, description, skip=None):
+ self.name = name
+ self.description = description
+ self.skip = skip or set()
diff --git a/dev/archery/archery/integration/tester.py b/dev/archery/archery/integration/tester.py
index 298298e4ef..122e4f2e4a 100644
--- a/dev/archery/archery/integration/tester.py
+++ b/dev/archery/archery/integration/tester.py
@@ -50,7 +50,7 @@ class Tester(object):
def validate(self, json_path, arrow_path):
raise NotImplementedError
- def flight_server(self):
+ def flight_server(self, scenario_name=None):
"""Start the Flight server on a free port.
This should be a context manager that returns the port as the
@@ -58,5 +58,5 @@ class Tester(object):
"""
raise NotImplementedError
- def flight_request(self, port, json_path):
+ def flight_request(self, port, json_path=None, scenario_name=None):
raise NotImplementedError
diff --git a/dev/archery/archery/integration/tester_cpp.py b/dev/archery/archery/integration/tester_cpp.py
index fed3f0904a..d35c9550e5 100644
--- a/dev/archery/archery/integration/tester_cpp.py
+++ b/dev/archery/archery/integration/tester_cpp.py
@@ -76,8 +76,10 @@ class CPPTester(Tester):
self.run_shell_command(cmd)
@contextlib.contextmanager
- def flight_server(self):
+ def flight_server(self, scenario_name=None):
cmd = self.FLIGHT_SERVER_CMD + ['-port=0']
+ if scenario_name:
+ cmd = cmd + ["-scenario", scenario_name]
if self.debug:
log(' '.join(cmd))
server = subprocess.Popen(cmd,
@@ -98,11 +100,17 @@ class CPPTester(Tester):
server.kill()
server.wait(5)
- def flight_request(self, port, json_path):
+ def flight_request(self, port, json_path=None, scenario_name=None):
cmd = self.FLIGHT_CLIENT_CMD + [
'-port=' + str(port),
- '-path=' + json_path,
]
+ if json_path:
+ cmd.extend(('-path', json_path))
+ elif scenario_name:
+ cmd.extend(('-scenario', scenario_name))
+ else:
+ raise TypeError("Must provide one of json_path or scenario_name")
+
if self.debug:
log(' '.join(cmd))
run_cmd(cmd)
diff --git a/dev/archery/archery/integration/tester_java.py b/dev/archery/archery/integration/tester_java.py
index 1c8e960cd9..3656a2cd1a 100644
--- a/dev/archery/archery/integration/tester_java.py
+++ b/dev/archery/archery/integration/tester_java.py
@@ -96,19 +96,29 @@ class JavaTester(Tester):
log(' '.join(cmd))
run_cmd(cmd)
- def flight_request(self, port, json_path):
+ def flight_request(self, port, json_path=None, scenario_name=None):
cmd = ['java'] + self.JAVA_OPTS + \
['-cp', self.ARROW_FLIGHT_JAR, self.ARROW_FLIGHT_CLIENT,
- '-port', str(port), '-j', json_path]
+ '-port', str(port)]
+
+ if json_path:
+ cmd.extend(('-j', json_path))
+ elif scenario_name:
+ cmd.extend(('-scenario', scenario_name))
+ else:
+ raise TypeError("Must provide one of json_path or scenario_name")
+
if self.debug:
log(' '.join(cmd))
run_cmd(cmd)
@contextlib.contextmanager
- def flight_server(self):
+ def flight_server(self, scenario_name=None):
cmd = ['java'] + self.JAVA_OPTS + \
['-cp', self.ARROW_FLIGHT_JAR, self.ARROW_FLIGHT_SERVER,
'-port', '0']
+ if scenario_name:
+ cmd.extend(('-scenario', scenario_name))
if self.debug:
log(' '.join(cmd))
server = subprocess.Popen(cmd, stdout=subprocess.PIPE,