Skip to content

Apache DataFusion SQL Query Engine

ARROW-1832: [JS] Implement JSON reader for integration tests

Paul Taylorce2b3e53fef2
diff --git a/ci/travis_script_integration.sh b/ci/travis_script_integration.sh
index 9514a30a88..0c415dc486 100755
--- a/ci/travis_script_integration.sh
+++ b/ci/travis_script_integration.sh
@@ -20,6 +20,7 @@
set -e
source $TRAVIS_BUILD_DIR/ci/travis_env_common.sh
+export ARROW_CPP_EXE_PATH=$ARROW_CPP_BUILD_DIR/debug
pushd $ARROW_JAVA_DIR
@@ -28,8 +29,15 @@ mvn -B clean package 2>&1 > mvn_package.log || (cat mvn_package.log && false)
popd
+pushd $ARROW_JS_DIR
+
+# lint and compile JS source
+npm run lint
+npm run build
+
+popd
+
pushd $ARROW_INTEGRATION_DIR
-export ARROW_CPP_EXE_PATH=$ARROW_CPP_BUILD_DIR/debug
CONDA_ENV_NAME=arrow-integration-test
conda create -y -q -n $CONDA_ENV_NAME python=3.5
@@ -45,21 +53,11 @@ python integration_test.py --debug
popd
-pushd $ARROW_JS_DIR
+# pushd $ARROW_JS_DIR
-# lint and compile JS source
-npm run lint
-npm run build
-# create initial test data
-npm run create:testdata
-# run once to write the snapshots
-npm test -- -t ts -u --integration
-# run again to test all builds against the snapshots
-npm test -- --integration
# run tests against source to generate coverage data
-npm run test:coverage -- --integration
+# npm run test:coverage
# Uncomment to upload to coveralls
# cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js;
-
-popd
\ No newline at end of file
+# popd
\ No newline at end of file
diff --git a/integration/integration_test.py b/integration/integration_test.py
index 5468ab19de..79b098a614 100644
--- a/integration/integration_test.py
+++ b/integration/integration_test.py
@@ -868,8 +868,8 @@ class IntegrationRunner(object):
self.debug = debug
def run(self):
- for producer, consumer in itertools.product(self.testers,
- self.testers):
+ for producer, consumer in itertools.product(filter(lambda t: t.PRODUCER, self.testers),
+ filter(lambda t: t.CONSUMER, self.testers)):
self._compare_implementations(producer, consumer)
def _compare_implementations(self, producer, consumer):
@@ -909,6 +909,8 @@ class IntegrationRunner(object):
class Tester(object):
+ PRODUCER = False
+ CONSUMER = False
def __init__(self, debug=False):
self.debug = debug
@@ -927,6 +929,8 @@ class Tester(object):
class JavaTester(Tester):
+ PRODUCER = True
+ CONSUMER = True
_arrow_version = load_version_from_pom()
ARROW_TOOLS_JAR = os.environ.get(
@@ -978,6 +982,8 @@ class JavaTester(Tester):
class CPPTester(Tester):
+ PRODUCER = True
+ CONSUMER = True
EXE_PATH = os.environ.get(
'ARROW_CPP_EXE_PATH',
@@ -1025,6 +1031,41 @@ class CPPTester(Tester):
print(cmd)
os.system(cmd)
+class JSTester(Tester):
+ PRODUCER = False
+ CONSUMER = True
+
+ INTEGRATION_EXE = os.path.join(ARROW_HOME, 'js/bin/integration.js')
+
+ name = 'JS'
+
+ def _run(self, arrow_path=None, json_path=None, command='VALIDATE'):
+ cmd = [self.INTEGRATION_EXE]
+
+ if arrow_path is not None:
+ cmd.extend(['-a', arrow_path])
+
+ if json_path is not None:
+ cmd.extend(['-j', json_path])
+
+ cmd.extend(['--mode', command])
+
+ if self.debug:
+ print(' '.join(cmd))
+
+ run_cmd(cmd)
+
+ def validate(self, json_path, arrow_path):
+ return self._run(arrow_path, json_path, 'VALIDATE')
+
+ def stream_to_file(self, stream_path, file_path):
+ # Just copy stream to file, we can read the stream directly
+ cmd = ['cp', stream_path, file_path]
+ cmd = ' '.join(cmd)
+ if self.debug:
+ print(cmd)
+ os.system(cmd)
+
def get_static_json_files():
glob_pattern = os.path.join(ARROW_HOME, 'integration', 'data', '*.json')
@@ -1032,7 +1073,7 @@ def get_static_json_files():
def run_all_tests(debug=False):
- testers = [CPPTester(debug=debug), JavaTester(debug=debug)]
+ testers = [CPPTester(debug=debug), JavaTester(debug=debug), JSTester(debug=debug)]
static_json_files = get_static_json_files()
generated_json_files = get_generated_json_files()
json_files = static_json_files + generated_json_files