Apache DataFusion SQL Query Engine
ARROW-8827: [Rust] Add initial skeleton for Rust integration tests
Paul Dix279d9e700dcf
diff --git a/dev/archery/archery/cli.py b/dev/archery/archery/cli.pyindex 4266a10e40..7227af7e0d 100644--- a/dev/archery/archery/cli.py+++ b/dev/archery/archery/cli.py@@ -582,6 +582,8 @@ def _set_default(opt, default):help='Include JavaScript in integration tests')@click.option('--with-go', type=bool, default=False,help='Include Go in integration tests')[email protected]('--with-rust', type=bool, default=False,+ help='Include Rust in integration tests')@click.option('--write_generated_json', default=False,help='Generate test JSON to indicated path')@click.option('--run-flight', is_flag=True, default=False,diff --git a/dev/archery/archery/integration/runner.py b/dev/archery/archery/integration/runner.pyindex b9bb94deba..5b0c6c146c 100644--- a/dev/archery/archery/integration/runner.py+++ b/dev/archery/archery/integration/runner.py@@ -29,6 +29,7 @@ import tracebackfrom .scenario import Scenariofrom .tester_cpp import CPPTesterfrom .tester_go import GoTester+from .tester_rust import RustTesterfrom .tester_java import JavaTesterfrom .tester_js import JSTesterfrom .util import (ARROW_ROOT_DEFAULT, guid, SKIP_ARROW, SKIP_FLIGHT,@@ -312,7 +313,7 @@ def get_static_json_files():def run_all_tests(with_cpp=True, with_java=True, with_js=True,- with_go=True, run_flight=False,+ with_go=True, with_rust=False, run_flight=False,tempdir=None, **kwargs):tempdir = tempdir or tempfile.mkdtemp(prefix='arrow-integration-')@@ -330,6 +331,9 @@ def run_all_tests(with_cpp=True, with_java=True, with_js=True,if with_go:testers.append(GoTester(**kwargs))+ if with_rust:+ testers.append(RustTester(**kwargs))+static_json_files = get_static_json_files()generated_json_files = datagen.get_generated_json_files(tempdir=tempdir,diff --git a/dev/archery/archery/integration/tester_rust.py b/dev/archery/archery/integration/tester_rust.pynew file mode 100644index 0000000000..23c2d37386--- /dev/null+++ b/dev/archery/archery/integration/tester_rust.py@@ -0,0 +1,105 @@+# 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.++import os++from .tester import Tester+from .util import run_cmd, ARROW_ROOT_DEFAULT, log+++class RustTester(Tester):+ PRODUCER = True+ CONSUMER = True+ # FLIGHT_SERVER = True+ # FLIGHT_CLIENT = True++ EXE_PATH = os.path.join(ARROW_ROOT_DEFAULT, 'rust/target/debug')++ RUST_INTEGRATION_EXE = os.path.join(EXE_PATH,+ 'arrow-json-integration-test')+ STREAM_TO_FILE = os.path.join(EXE_PATH, 'arrow-stream-to-file')+ FILE_TO_STREAM = os.path.join(EXE_PATH, 'arrow-file-to-stream')++ # FLIGHT_SERVER_CMD = [+ # os.path.join(EXE_PATH, 'flight-test-integration-server')]+ # FLIGHT_CLIENT_CMD = [+ # os.path.join(EXE_PATH, 'flight-test-integration-client'),+ # "-host", "localhost"]++ name = 'Rust'++ def _run(self, arrow_path=None, json_path=None, command='VALIDATE'):+ cmd = [self.RUST_INTEGRATION_EXE, '--integration']++ if arrow_path is not None:+ cmd.append('--arrow=' + arrow_path)++ if json_path is not None:+ cmd.append('--json=' + json_path)++ cmd.append('--mode=' + command)++ if self.debug:+ log(' '.join(cmd))++ run_cmd(cmd)++ def validate(self, json_path, arrow_path):+ return self._run(arrow_path, json_path, 'VALIDATE')++ def json_to_file(self, json_path, arrow_path):+ return self._run(arrow_path, json_path, 'JSON_TO_ARROW')++ def stream_to_file(self, stream_path, file_path):+ cmd = [self.STREAM_TO_FILE, '<', stream_path, '>', file_path]+ self.run_shell_command(cmd)++ def file_to_stream(self, file_path, stream_path):+ cmd = [self.FILE_TO_STREAM, file_path, '>', stream_path]+ self.run_shell_command(cmd)++ # @contextlib.contextmanager+ # def flight_server(self):+ # cmd = self.FLIGHT_SERVER_CMD + ['-port=0']+ # if self.debug:+ # log(' '.join(cmd))+ # server = subprocess.Popen(cmd,+ # stdout=subprocess.PIPE,+ # stderr=subprocess.PIPE)+ # try:+ # output = server.stdout.readline().decode()+ # if not output.startswith("Server listening on localhost:"):+ # server.kill()+ # out, err = server.communicate()+ # raise RuntimeError(+ # "Flight-C++ server did not start properly, "+ # "stdout:\n{}\n\nstderr:\n{}\n"+ # .format(output + out.decode(), err.decode()))+ # port = int(output.split(":")[1])+ # yield port+ # finally:+ # server.kill()+ # server.wait(5)++ # def flight_request(self, port, json_path):+ # cmd = self.FLIGHT_CLIENT_CMD + [+ # '-port=' + str(port),+ # '-path=' + json_path,+ # ]+ # if self.debug:+ # log(' '.join(cmd))+ # run_cmd(cmd)