2019-07-26 15:08:01 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
# This script does the following:
|
|
|
|
# 1. Retrieves gcloud service account token
|
|
|
|
# 2. Activates gcloud service account
|
|
|
|
# 3. Connects to google Firebase (using TestArmada's Flank tool)
|
|
|
|
# 4. Executes UI tests
|
|
|
|
# 5. Puts test artifacts into the test_artifacts folder
|
|
|
|
|
|
|
|
# NOTE:
|
|
|
|
# Flank supports sharding across multiple devices at a time, but gcloud API
|
|
|
|
# only supports 1 defined APK per test run.
|
|
|
|
|
|
|
|
|
|
|
|
# If a command fails then do not proceed and fail this script too.
|
|
|
|
set -e
|
|
|
|
|
|
|
|
#########################
|
|
|
|
# The command line help #
|
|
|
|
#########################
|
|
|
|
display_help() {
|
|
|
|
echo "Usage: $0 Build_Variant [Number_Shards...]"
|
|
|
|
echo
|
|
|
|
echo "Examples:"
|
|
|
|
echo "To run UI tests on ARM device shard (1 test / shard)"
|
2019-08-29 00:02:17 +00:00
|
|
|
echo "$ ui-test.sh arm64-v8a -1"
|
2019-07-26 15:08:01 +00:00
|
|
|
echo
|
|
|
|
echo "To run UI tests on X86 device (on 3 shards)"
|
2019-08-29 00:02:17 +00:00
|
|
|
echo "$ ui-test.sh x86 3"
|
2019-07-26 15:08:01 +00:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
2019-11-07 16:38:17 +00:00
|
|
|
get_abs_filename() {
|
|
|
|
relative_filename="$1"
|
|
|
|
echo "$(cd "$(dirname "$relative_filename")" && pwd)/$(basename "$relative_filename")"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-26 15:08:01 +00:00
|
|
|
# Basic parameter check
|
|
|
|
if [[ $# -lt 1 ]]; then
|
|
|
|
echo "Error: please provide at least one build variant (arm|x86)"
|
|
|
|
display_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-08-29 00:02:17 +00:00
|
|
|
device_type="$1" # arm64-v8a | armeabi-v7a | x86_64 | x86
|
2019-11-07 16:38:17 +00:00
|
|
|
APK_APP="$2"
|
|
|
|
APK_TEST="$3"
|
|
|
|
if [[ ! -z "$4" ]]; then
|
|
|
|
num_shards=$4
|
2019-07-26 15:08:01 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
JAVA_BIN="/usr/bin/java"
|
|
|
|
PATH_TEST="./automation/taskcluster/androidTest"
|
2019-09-23 11:42:36 +00:00
|
|
|
FLANK_BIN="/builds/worker/test-tools/flank.jar"
|
2020-04-30 21:01:35 +00:00
|
|
|
ARTIFACT_DIR="/builds/worker/artifacts"
|
|
|
|
RESULTS_DIR="${ARTIFACT_DIR}/results"
|
2019-07-26 15:08:01 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "ACTIVATE SERVICE ACCT"
|
|
|
|
echo
|
|
|
|
# this is where the Google Testcloud project ID is set
|
2019-11-07 16:38:17 +00:00
|
|
|
gcloud config set project "$GOOGLE_PROJECT"
|
2019-07-26 15:08:01 +00:00
|
|
|
echo
|
|
|
|
|
2019-11-07 16:38:17 +00:00
|
|
|
gcloud auth activate-service-account --key-file "$GOOGLE_APPLICATION_CREDENTIALS"
|
2019-07-26 15:08:01 +00:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
|
2019-08-29 00:02:17 +00:00
|
|
|
# Disable exiting on error. If the tests fail we want to continue
|
2019-07-26 15:08:01 +00:00
|
|
|
# and try to download the artifacts. We will exit with the actual error code later.
|
|
|
|
set +e
|
|
|
|
|
2019-08-29 00:02:17 +00:00
|
|
|
if [[ "${device_type}" =~ ^(arm64-v8a|armeabi-v7a|x86_64|x86)$ ]]; then
|
|
|
|
flank_template="${PATH_TEST}/flank-${device_type}.yml"
|
2019-12-03 05:43:40 +00:00
|
|
|
elif [[ "${device_type}" == "x86-start-test" ]]; then
|
|
|
|
flank_template="${PATH_TEST}/flank-x86-start-test.yml"
|
|
|
|
elif [[ "${device_type}" == "arm-start-test" ]]; then
|
|
|
|
flank_template="${PATH_TEST}/flank-armeabi-v7a-start-test.yml"
|
2020-07-16 14:08:00 +00:00
|
|
|
elif [[ "${device_type}" == "x86-screenshots-tests" ]]; then
|
|
|
|
flank_template="${PATH_TEST}/flank-x86-screenshots-tests.yml"
|
2019-07-26 15:08:01 +00:00
|
|
|
else
|
2020-03-27 21:19:59 +00:00
|
|
|
echo "FAILURE: flank config file not found!"
|
2019-08-27 20:29:52 +00:00
|
|
|
exitcode=1
|
2019-07-26 15:08:01 +00:00
|
|
|
fi
|
|
|
|
|
2019-11-07 16:38:17 +00:00
|
|
|
APK_APP="$(get_abs_filename $APK_APP)"
|
|
|
|
APK_TEST="$(get_abs_filename $APK_TEST)"
|
2019-12-03 05:43:40 +00:00
|
|
|
echo "device_type: ${device_type}"
|
2019-11-07 16:38:17 +00:00
|
|
|
echo "APK_APP: ${APK_APP}"
|
2019-09-23 02:19:10 +00:00
|
|
|
echo "APK_TEST: ${APK_TEST}"
|
2019-07-26 15:08:01 +00:00
|
|
|
|
|
|
|
# function to exit script with exit code from test run.
|
|
|
|
# (Only 0 if all test executions passed)
|
|
|
|
function failure_check() {
|
2019-12-03 05:43:40 +00:00
|
|
|
echo
|
|
|
|
echo
|
2019-07-26 15:08:01 +00:00
|
|
|
if [[ $exitcode -ne 0 ]]; then
|
2020-03-27 21:19:59 +00:00
|
|
|
echo "FAILURE: UI test run failed, please check above URL"
|
2019-12-03 05:43:40 +00:00
|
|
|
else
|
2020-05-04 14:34:06 +00:00
|
|
|
echo "All UI test(s) have passed!"
|
2019-07-26 15:08:01 +00:00
|
|
|
fi
|
2019-12-03 05:43:40 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "RESULTS"
|
|
|
|
echo
|
2020-04-30 21:01:35 +00:00
|
|
|
|
|
|
|
mkdir -p /builds/worker/artifacts/github
|
|
|
|
chmod +x $PATH_TEST/parse-ui-test.py
|
|
|
|
$PATH_TEST/parse-ui-test.py \
|
|
|
|
--exit-code "${exitcode}" \
|
|
|
|
--log flank.log \
|
|
|
|
--results "${RESULTS_DIR}" \
|
|
|
|
--output-md "${ARTIFACT_DIR}/github/customCheckRunText.md" \
|
|
|
|
--device-type "${device_type}"
|
2019-07-26 15:08:01 +00:00
|
|
|
}
|
|
|
|
|
2019-10-03 16:30:55 +00:00
|
|
|
echo
|
|
|
|
echo "FLANK VERSION"
|
|
|
|
echo
|
2019-11-07 16:38:17 +00:00
|
|
|
$JAVA_BIN -jar $FLANK_BIN --version
|
2019-10-03 16:30:55 +00:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
|
2019-07-26 15:08:01 +00:00
|
|
|
echo
|
|
|
|
echo "EXECUTE TEST(S)"
|
|
|
|
echo
|
2020-04-30 21:01:35 +00:00
|
|
|
# Note that if --local-results-dir is "results", timestamped sub-directory will
|
|
|
|
# contain the results. For any other value, the directory itself will have the results.
|
2020-05-14 14:27:56 +00:00
|
|
|
set -o pipefail && $JAVA_BIN -jar $FLANK_BIN android run \
|
2020-04-30 21:01:35 +00:00
|
|
|
--config=$flank_template \
|
|
|
|
--max-test-shards=$num_shards \
|
|
|
|
--app=$APK_APP --test=$APK_TEST \
|
|
|
|
--local-result-dir="${RESULTS_DIR}" \
|
|
|
|
--project=$GOOGLE_PROJECT \
|
|
|
|
| tee flank.log
|
|
|
|
|
2019-07-26 15:08:01 +00:00
|
|
|
exitcode=$?
|
|
|
|
failure_check
|
|
|
|
|
2019-12-03 05:43:40 +00:00
|
|
|
exit $exitcode
|