summaryrefslogtreecommitdiff
path: root/test/end-to-end/target-cache
diff options
context:
space:
mode:
authorAlberto Sartori <alberto.sartori@huawei.com>2023-07-04 11:16:46 +0200
committerAlberto Sartori <alberto.sartori@huawei.com>2023-07-05 12:46:42 +0200
commit4e6dcedc281159b4f405f36647fbf0cb19e92194 (patch)
tree6ebae37022549722ec25d351804c8cb5c4b11434 /test/end-to-end/target-cache
parent73a0cfd270c4a9871d3a78798f1ddd1494df3e60 (diff)
downloadjustbuild-4e6dcedc281159b4f405f36647fbf0cb19e92194.tar.gz
["end-to-end/target-cache", "artifacts-sync"]: add more checks...
...that the expected objects are correctly uploaded to the remote cas
Diffstat (limited to 'test/end-to-end/target-cache')
-rw-r--r--test/end-to-end/target-cache/artifacts-sync.sh51
1 files changed, 48 insertions, 3 deletions
diff --git a/test/end-to-end/target-cache/artifacts-sync.sh b/test/end-to-end/target-cache/artifacts-sync.sh
index 64670aae..8faad9fa 100644
--- a/test/end-to-end/target-cache/artifacts-sync.sh
+++ b/test/end-to-end/target-cache/artifacts-sync.sh
@@ -23,10 +23,17 @@ readonly REMOTE_CACHE="${TMPDIR}/remote_cache"
readonly INFOFILE="${TMPDIR}/info.json"
readonly PIDFILE="${TMPDIR}/pid.txt"
-ARGS=""
if [ "${COMPATIBLE:-}" = "YES" ]; then
ARGS="--compatible"
+ HASH_TYPE="compatible-sha256"
+ TREE_TAG="f"
+else
+ ARGS=""
+ HASH_TYPE="git-sha1"
+ TREE_TAG="t"
fi
+readonly FIRST_GEN="${LOCAL_CACHE}/protocol-dependent/generation-0/$HASH_TYPE"
+readonly TCDIR="$FIRST_GEN/tc"
# ------------------------------------------------------------------------------
# Start local remote execution server
@@ -53,28 +60,66 @@ cleanup() {
}
trap cleanup EXIT
+check_main_blobs() {
+ for entry in "${TCDIR}"/*
+ do
+ for sbdir in "${entry}"/*
+ do
+ for f in "${sbdir}"/*
+ do
+ hash=$(cat $f)
+ TC_ENTRY=$("$JUST" install-cas --local-build-root "${LOCAL_CACHE}" $ARGS ${hash})
+ FILE_HASH=${FILE_HASH:-$(echo $TC_ENTRY | jq -r '.artifacts."libgreet.a".data.id // ""')}
+ TREE_HASH=${TREE_HASH:-$(echo $TC_ENTRY | jq -r '.runfiles.greet.data.id // ""')}
+ "$JUST" install-cas --local-build-root "${LOCAL_CACHE}" ${ARGS} ${FILE_HASH}::f > /dev/null
+ "$JUST" install-cas --local-build-root "${LOCAL_CACHE}" ${ARGS} ${TREE_HASH}::${TREE_TAG} > /dev/null
+ done
+ done
+ done
+}
+
# ------------------------------------------------------------------------------
# Test synchronization of artifacts in the 'artifacts' and 'runfiles' maps
# ------------------------------------------------------------------------------
cd greetlib
sed -i "s|<RULES_PATH>|${RULES_DIR}|" repos.json
+
# Build greetlib remotely
"${JUST_MR}" --norc --just "${JUST}" --local-build-root "${LOCAL_CACHE}" \
- build ${ARGS} -r localhost:${PORT} main 2>&1
+ build ${ARGS} -r localhost:${PORT} --dump-graph graph.json main 2>&1
+
+# Count actions without tc
+EXPECTED=4
+readonly ACTIONS_NO_TC=$(cat graph.json | jq '.actions | length' )
+
+test ${ACTIONS_NO_TC} -eq ${EXPECTED} || printf "Wrong number of actions. %d were expected but found %d\n" ${EXPECTED} ${ACTIONS_NO_TC} > /dev/stderr
+
+# Check the existence of target-cache dir
+test -d ${TCDIR}
+
+check_main_blobs
# Clear remote cache
rm -rf "${REMOTE_CACHE}"
# Build greetlib remotely
"${JUST_MR}" --norc --just "${JUST}" --local-build-root "${LOCAL_CACHE}" \
- build ${ARGS} -r localhost:${PORT} main 2>&1
+ build ${ARGS} -r localhost:${PORT} --dump-graph graph-tc.json main 2>&1
+
+# Count actions with tc
+readonly ACTIONS_TC=$(cat graph-tc.json | jq '.actions | length' )
+
+EXPECTED=2
+test ${ACTIONS_TC} -eq ${EXPECTED} || printf "Wrong number of actions. %d were expected but found %d\n" ${EXPECTED} ${ACTIONS_TC} > /dev/stderr
# ------------------------------------------------------------------------------
# Test synchronization of artifacts in the 'provides' map
# ------------------------------------------------------------------------------
cd ../pydicts
+rm -rf "${REMOTE_CACHE}"
+
# Build pydicts remotely
"${JUST_MR}" --norc --just "${JUST}" --local-build-root "${LOCAL_CACHE}" \
build ${ARGS} -r localhost:${PORT} json_from_py 2>&1