summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-04-15 12:34:38 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-04-16 14:37:46 +0200
commit2c362dc379217da3c213b4698543ddfe4b7bd9cf (patch)
treefdfd003c3a4b2a663b94b2ef739d4065edfebd32 /test
parent0c2f80c405a15d63293ae0b7ae89bdbf9f04e771 (diff)
downloadjustbuild-2c362dc379217da3c213b4698543ddfe4b7bd9cf.tar.gz
Add test verifying serve build logs contain error messages
Diffstat (limited to 'test')
-rw-r--r--test/end-to-end/serve-service/TARGETS17
-rw-r--r--test/end-to-end/serve-service/data/targets/TARGETS.fail7
-rw-r--r--test/end-to-end/serve-service/failure-report.sh91
3 files changed, 115 insertions, 0 deletions
diff --git a/test/end-to-end/serve-service/TARGETS b/test/end-to-end/serve-service/TARGETS
index a26a208b..180d8133 100644
--- a/test/end-to-end/serve-service/TARGETS
+++ b/test/end-to-end/serve-service/TARGETS
@@ -137,6 +137,22 @@
, "repos": ["describe (data)"]
, "keep": ["out/describe.orig", "out/describe"]
}
+, "failure-report (data)":
+ { "type": "install"
+ , "files": {"ROOT": "data/ROOT", "TARGETS": "data/targets/TARGETS.fail"}
+ }
+, "failure-report":
+ { "type": ["end-to-end", "with serve"]
+ , "name": ["failure-report"]
+ , "test": ["failure-report.sh"]
+ , "deps":
+ [ ["end-to-end", "mr-tool-under-test"]
+ , ["end-to-end", "tool-under-test"]
+ , "describe (locally installed)"
+ ]
+ , "repos": ["failure-report (data)"]
+ , "keep": ["out/log", "out/serve.log", "out/failure.log"]
+ }
, "serve-many-targets (data)":
{ "type": "install"
, "files": {"ROOT": "data/ROOT", "TARGETS": "data/targets/TARGETS.transform"}
@@ -175,6 +191,7 @@
, "serve-query-target-cache-value"
, "describe"
, "deduplication-of-serve-requests"
+ , "failure-report"
]
, { "type": "if"
, "cond": {"type": "var", "name": "TEST_COMPATIBLE_REMOTE"}
diff --git a/test/end-to-end/serve-service/data/targets/TARGETS.fail b/test/end-to-end/serve-service/data/targets/TARGETS.fail
new file mode 100644
index 00000000..6930a32a
--- /dev/null
+++ b/test/end-to-end/serve-service/data/targets/TARGETS.fail
@@ -0,0 +1,7 @@
+{ "": {"type": "export", "target": "FaIlInGtArGeT"}
+, "FaIlInGtArGeT":
+ { "type": "generic"
+ , "outs": ["out.txt"]
+ , "cmds": ["echo -n FaIl", "echo UrEmEsSaGe", "exit 42"]
+ }
+}
diff --git a/test/end-to-end/serve-service/failure-report.sh b/test/end-to-end/serve-service/failure-report.sh
new file mode 100644
index 00000000..438035d9
--- /dev/null
+++ b/test/end-to-end/serve-service/failure-report.sh
@@ -0,0 +1,91 @@
+#!/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
+
+env
+
+readonly JUST="${PWD}/bin/tool-under-test"
+readonly JUST_MR="${PWD}/bin/mr-tool-under-test"
+readonly LBR="${TEST_TMPDIR}/local-build-root"
+readonly OUT="${PWD}/out"
+mkdir -p "${OUT}"
+
+
+COMPAT=""
+if [ "${COMPATIBLE:-}" = "YES" ]; then
+ COMPAT="--compatible"
+fi
+
+mkdir work
+cd work
+touch ROOT
+
+cat > repos.json <<EOF
+{ "repositories":
+ { "":
+ { "repository":
+ { "type": "git"
+ , "commit": "$COMMIT_0"
+ , "pragma": {"absent": true}
+ , "repository": "http://non-existent.example.org/data.git"
+ , "branch": "master"
+ , "subdir": "."
+ }
+ }
+ }
+}
+EOF
+
+echo Repo config
+echo
+cat repos.json
+echo
+
+echo Remotely failing build
+echo
+"${JUST_MR}" --norc --local-build-root "${LBR}" \
+ --remote-serve-address ${SERVE} \
+ -r ${REMOTE_EXECUTION_ADDRESS} ${COMPAT} \
+ --just "${JUST}" \
+ build -f "${OUT}/log" --serve-errors-log "${OUT}/serve.log" 2>&1 \
+ && exit 1 || :
+echo
+cat "${OUT}/serve.log"
+echo
+SERVE_LOG=$(jq -rM '.[0][1]' "${OUT}/serve.log")
+echo Serve log has blob ${SERVE_LOG}
+echo
+# The serve log blob must be mentioned in the log file
+grep ${SERVE_LOG} "${OUT}/log"
+echo
+# Fetch the failure log
+"${JUST_MR}" --norc --local-build-root "${LBR}" \
+ --remote-serve-address ${SERVE} \
+ -r ${REMOTE_EXECUTION_ADDRESS} ${COMPAT} \
+ --just "${JUST}" \
+ install-cas -o "${OUT}/failure.log" ${SERVE_LOG} 2>&1
+echo
+cat "${OUT}/failure.log"
+echo
+# Failure log must contain error message
+grep FaIlUrEmEsSaGe "${OUT}/failure.log"
+# Failure log must contain exit code
+grep 42 "${OUT}/failure.log"
+# Failure log must contain failing targets
+grep FaIlInGtArGeT "${OUT}/failure.log"
+
+echo
+echo OK