Files
impala/tests/run-js-tests.sh
Surya Hebbar e9acc12a86 IMPALA-12415: Implement tests for graphical query timeline in webUI
To help with testing the query timeline web page, the tests have been
integrated using JEST testing framework based on nodejs.

'run_js_tests.sh' runs JEST test suits, after it fetches nodejs binaries
and related nodejs packages, if they are not present locally.

NodeJS binaries are stored within the ${IMPALA_TOOLCHAIN} directory.

'jest-environment-jsdom' supports rendering DOM elements and
testing them without the requirement of a browser.

For implementing unit and integration tests, the script
has been divided into multiple properly functioning modules,
that are imported as ES6 modules.

Unit tests have been written for the following query profile parsing
functions.

- mapTimeseriesCounters() - Test whether the method correctly searches
and maps the profile's counter's indexes based on counter_name even
in reverse order

- accumulateTimeseriesValues() - Test whether the method correctly
accumlates values after parsing values from 'data' in
'time_series_counters' while updating 'max_samples'

- generateTimesamples() - Test whether time sample values generated
based on 'max_samples' are correct, with different 'max_samples'

- clearTimeseriesValues() - Test whether Timeseries arrays are being
properly truncated in the correct range

- initializeUtilizationMetrics() - Test whether aggregate arrays and
time sample arrays are correctly allocated based on counters and
'max_samples'

- getSvg*() - Test whether all getSvg methods are correctly setting
attributes and returning expected attributes in elements

Unit tests produce JUnitXML for integration with jenkins jobs,
these are stored in ${IMPALA_JS_TEST_LOGS_DIR}.

Change-Id: I0caf0a0beee23821f78c0b3fe1aeb7dbf92d6a3e
Reviewed-on: http://gerrit.cloudera.org:8080/20538
Reviewed-by: Wenzhe Zhou <wzhou@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2023-10-27 22:57:35 +00:00

59 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# 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.
set -euo pipefail
. "$IMPALA_HOME/bin/report_build_error.sh"
setup_report_build_error
: ${IMPALA_JS_TEST_LOGS_DIR:="${IMPALA_LOGS_DIR}/js_tests"}
NODEJS_VERSION=v16.20.2
NODEJS_DISTRO=linux-x64
NODEJS_LIB_PATH="${IMPALA_TOOLCHAIN}/node-${NODEJS_VERSION}"
export IMPALA_NODEJS="${NODEJS_LIB_PATH}/bin/node"
NPM="${NODEJS_LIB_PATH}/bin/npm"
JS_TESTS_DIR="${IMPALA_HOME}/www/scripts/tests"
export IMPALA_JS_TEST_LOGS_DIR;
# Install nodejs locally, if not installed
if [ -r "$IMPALA_NODEJS" ]; then
echo "NodeJS ${NODEJS_VERSION} installation found";
else
echo "Fetching NodeJS ${NODEJS_VERSION}-${NODEJS_DISTRO} binaries ...";
NODE_URL_PREFIX="https://nodejs.org/dist"
NODE_URL_SUFFIX="${NODEJS_VERSION}/node-${NODEJS_VERSION}-${NODEJS_DISTRO}.tar.xz"
curl "${NODE_URL_PREFIX}/${NODE_URL_SUFFIX}" -O
tar -xJf node-${NODEJS_VERSION}-${NODEJS_DISTRO}.tar.xz
mkdir -p "${NODEJS_LIB_PATH}"
mv node-${NODEJS_VERSION}-${NODEJS_DISTRO}/* -t "${NODEJS_LIB_PATH}";
rm -rf node-${NODEJS_VERSION}-${NODEJS_DISTRO}.tar.xz \
node-${NODEJS_VERSION}-${NODEJS_DISTRO}/
fi;
# Install packages in package.json
"$IMPALA_NODEJS" "$NPM" --prefix "${JS_TESTS_DIR}" install
# Run all JEST testing suites (by default *.test.js)
"$IMPALA_NODEJS" "$NPM" --prefix "${JS_TESTS_DIR}" test