diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-12-05 11:02:05 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-12-05 16:43:02 +0100 |
commit | f414d322d10ede09fcfb731ecee463a72ef78c13 (patch) | |
tree | a185dd7a65efb52f68e2a6dcb69ba1f8452d9fbf /test/end-to-end | |
parent | a266d84863663ead200e9bf9e53ad4287f5a3bbe (diff) | |
download | justbuild-f414d322d10ede09fcfb731ecee463a72ef78c13.tar.gz |
Add a test verifying that install-cas inspects the local cas
... even if remote-execution arguments are given. Also verify
that failure is correctly reflected in the exit code.
Diffstat (limited to 'test/end-to-end')
-rw-r--r-- | test/end-to-end/remote-execution/TARGETS | 7 | ||||
-rw-r--r-- | test/end-to-end/remote-execution/install-cas-local.sh | 88 |
2 files changed, 95 insertions, 0 deletions
diff --git a/test/end-to-end/remote-execution/TARGETS b/test/end-to-end/remote-execution/TARGETS index fbe3d467..2aae6270 100644 --- a/test/end-to-end/remote-execution/TARGETS +++ b/test/end-to-end/remote-execution/TARGETS @@ -40,6 +40,12 @@ , "out/stdout/local-raw" ] } +, "install-cas-local": + { "type": ["end-to-end", "with remote"] + , "name": ["install-cas-local"] + , "test": ["install-cas-local.sh"] + , "deps": [["", "tool-under-test"]] + } , "dispatch": { "type": ["end-to-end", "with remote"] , "name": ["dispatch"] @@ -85,6 +91,7 @@ , "upload-test" , "install" , "install-cas" + , "install-cas-local" , "dispatch" , "execute" ] diff --git a/test/end-to-end/remote-execution/install-cas-local.sh b/test/end-to-end/remote-execution/install-cas-local.sh new file mode 100644 index 00000000..3fa93578 --- /dev/null +++ b/test/end-to-end/remote-execution/install-cas-local.sh @@ -0,0 +1,88 @@ +#!/bin/sh +# Copyright 2024 Huawei Cloud Computing Technology Co., Ltd. +# +# Licensed 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 -eu + +readonly JUST="${PWD}/bin/tool-under-test" +readonly LBRDIR="${TEST_TMPDIR}/local-build-root" +readonly SETUP_LBRDIR="${TEST_TMPDIR}/build-root-for-setup-only" +readonly FILES_DIR="${TEST_TMPDIR}/data" +readonly OUT="${TEST_TMPDIR}/out" +mkdir -p "${FILES_DIR}" +mkdir -p "${OUT}" + +LOCAL_ARGS="" +REMOTE_ARGS="${LOCAL_ARGS} -r ${REMOTE_EXECUTION_ADDRESS}" +if [ -n "${COMPATIBLE:-}" ] +then + REMOTE_ARGS="${REMOTE_ARGS} --compatible" + LOCAL_ARGS="${LOCAL_ARGS} --compatible" +fi + +# Set up secanrio, by creating a hash that is only known remotely +# and one that is only known locally. Moreover, compute a hash of +# a file unknown to both. + +readonly REMOTE_FILE="${FILES_DIR}/remote" +echo 'This file is only known to ReMoTe!!' > "${REMOTE_FILE}" +REMOTE_HASH=$("${JUST}" add-to-cas --local-build-root "${SETUP_LBRDIR}" ${REMOTE_ARGS} "${REMOTE_FILE}") +echo "Remote file has hash ${REMOTE_HASH}" + +readonly LOCAL_FILE="${FILES_DIR}/local" +echo 'This file is only known LoCaLlY ...' > "${LOCAL_FILE}" +LOCAL_HASH=$("${JUST}" add-to-cas --local-build-root "${LBRDIR}" ${LOCAL_ARGS} "${LOCAL_FILE}") +echo "Local file has hash ${LOCAL_HASH}" + +readonly UNKNOWN_FILE="${FILES_DIR}/unknown" +echo '... for Rumpelstiltskin is my name' > "${UNKNOWN_FILE}" +UNKNOWN_HASH=$("${JUST}" add-to-cas --local-build-root "${SETUP_LBRDIR}" ${LOCAL_ARGS} "${UNKNOWN_FILE}") +echo "Unkown file has hash ${UNKNOWN_HASH}" + +# Verify that with the canonical arguments (as, e.g., just-mr might provide them +# with appropriate rc file) we can get both files correctly. Also verify that +# we get an exit code identifying an error if we failed to fetch the file. + +echo remote, via stdout +"${JUST}" install-cas --local-build-root "${LBRDIR}" ${REMOTE_ARGS} \ + "${REMOTE_HASH}" > "${OUT}/remote" +cmp "${OUT}/remote" "${REMOTE_FILE}" +rm -f "${OUT}/remote" + +echo remote, specified output file +"${JUST}" install-cas --local-build-root "${LBRDIR}" ${REMOTE_ARGS} \ + -o "${OUT}/remote" "${REMOTE_HASH}" 2>&1 +cmp "${OUT}/remote" "${REMOTE_FILE}" + +echo local, via stdout +"${JUST}" install-cas --local-build-root "${LBRDIR}" ${REMOTE_ARGS} \ + "${LOCAL_HASH}" > "${OUT}/local" +cmp "${OUT}/local" "${LOCAL_FILE}" +rm -f "${OUT}/local" + +echo local, specified output file +"${JUST}" install-cas --local-build-root "${LBRDIR}" ${REMOTE_ARGS} \ + -o "${OUT}/local" "${LOCAL_HASH}" 2>&1 +cmp "${OUT}/local" "${LOCAL_FILE}" + +echo unknown, via stdout +"${JUST}" install-cas --local-build-root "${LBRDIR}" ${REMOTE_ARGS} \ + "${UNKNOWN_HASH}" 2>&1 && exit 1 || : + +echo unknown, specified output path +"${JUST}" install-cas --local-build-root "${LBRDIR}" ${REMOTE_ARGS} \ + -o "${OUT}/unknown" "${UNKNOWN_HASH}" 2>&1 && exit 1 || : + +echo OK |