summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-11-16 12:47:38 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-11-21 10:21:29 +0100
commita3aad6ab99845d752d2686051b583e45a9b352b2 (patch)
tree9377f53ce5809ae683af983a8f63a461dbc91e8f
parent19f7756b96f4eb1e75900e45e4488aaa8dfb81d9 (diff)
downloadjustbuild-a3aad6ab99845d752d2686051b583e45a9b352b2.tar.gz
Extend --fetch-absent tests to verify regular fetching from just serve
Whenever a just-serve endpoint is given, fetching archives or Git commits from there is preferrable to fetching them from other sources. Verify in the tests that this actually happens. Co-authored-by: Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com>
-rw-r--r--test/end-to-end/just-mr/fetch-absent-archives.sh41
-rw-r--r--test/end-to-end/just-mr/fetch-absent.sh42
2 files changed, 83 insertions, 0 deletions
diff --git a/test/end-to-end/just-mr/fetch-absent-archives.sh b/test/end-to-end/just-mr/fetch-absent-archives.sh
index 156d909a..52c05cb8 100644
--- a/test/end-to-end/just-mr/fetch-absent-archives.sh
+++ b/test/end-to-end/just-mr/fetch-absent-archives.sh
@@ -21,9 +21,11 @@ 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 LBR_NON_ABSENT="${TEST_TMPDIR}/local-build-root-non-absent"
readonly OUT="${TEST_TMPDIR}/out"
readonly OUT2="${TEST_TMPDIR}/out2"
readonly OUT3="${TEST_TMPDIR}/out3"
+readonly OUT_NON_ABSENT="${TEST_TMPDIR}/out4"
ARCHIVE_CONTENT=$(git hash-object src/data.tar)
echo "Archive has content $ARCHIVE_CONTENT"
@@ -111,4 +113,43 @@ EOF
--fetch-absent install -o "${OUT3}" 2>&1
grep 42 "${OUT3}/out.txt"
+# Now, on a fresh local build root, take the original description
+# without any absent hint. In this way, we verify that even for
+# concrete repositories fetching over the just-serve instance works
+# (as we removed all other ways to get the archive).
+cat > repos.json <<EOF
+{ "repositories":
+ { "":
+ { "repository":
+ { "type": "archive"
+ , "content": "${ARCHIVE_CONTENT}"
+ , "fetch": "http://non-existent.example.org/data.tar"
+ , "subdir": "src"
+ }
+ , "target_root": "targets"
+ }
+ , "targets": {"repository": {"type": "file", "path": "targets"}}
+ }
+}
+EOF
+cat > targets/TARGETS <<'EOF'
+{ "":
+ { "type": "generic"
+ , "outs": ["out.txt"]
+ , "cmds": ["head -c 1 4.txt > out.txt", "cat 2.txt >> out.txt"]
+ , "deps": ["4.txt", "2.txt"]
+ }
+}
+EOF
+echo
+cat repos.json
+echo
+"${JUST_MR}" --norc --local-build-root "${LBR_NON_ABSENT}" \
+ --remote-serve-address ${SERVE} \
+ -r ${REMOTE_EXECUTION_ADDRESS} \
+ --just "${JUST}" \
+ install -o "${OUT_NON_ABSENT}" 2>&1
+grep 42 "${OUT_NON_ABSENT}/out.txt"
+
+
echo DONE
diff --git a/test/end-to-end/just-mr/fetch-absent.sh b/test/end-to-end/just-mr/fetch-absent.sh
index 16f1877f..00c76e7b 100644
--- a/test/end-to-end/just-mr/fetch-absent.sh
+++ b/test/end-to-end/just-mr/fetch-absent.sh
@@ -21,9 +21,11 @@ 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 LBR_NON_ABSENT="${TEST_TMPDIR}/local-build-root-non-absent"
readonly OUT="${TEST_TMPDIR}/out"
readonly OUT2="${TEST_TMPDIR}/out2"
readonly OUT3="${TEST_TMPDIR}/out3"
+readonly OUT_NON_ABSENT="${TEST_TMPDIR}/out4"
mkdir work
cd work
@@ -110,4 +112,44 @@ EOF
--fetch-absent install -o "${OUT3}" 2>&1
grep 42 "${OUT3}/out.txt"
+# Now, on a fresh local build root, take the original description
+# without any absent hint. In this way, we verify that even for
+# concrete repositories fetching over the just-serve instance works
+# (as we removed all other ways to get the commit).
+cat > repos.json <<EOF
+{ "repositories":
+ { "":
+ { "repository":
+ { "type": "git"
+ , "commit": "$COMMIT_0"
+ , "repository": "http://non-existent.example.org/data.git"
+ , "branch": "master"
+ , "subdir": "src"
+ }
+ , "target_root": "targets"
+ }
+ , "targets": {"repository": {"type": "file", "path": "targets"}}
+ }
+}
+EOF
+cat > targets/TARGETS <<'EOF'
+{ "":
+ { "type": "generic"
+ , "outs": ["out.txt"]
+ , "cmds": ["head -c 1 4.txt > out.txt", "cat 2.txt >> out.txt"]
+ , "deps": ["4.txt", "2.txt"]
+ }
+}
+EOF
+echo
+cat repos.json
+echo
+"${JUST_MR}" --norc --local-build-root "${LBR_NON_ABSENT}" \
+ --remote-serve-address ${SERVE} \
+ -r ${REMOTE_EXECUTION_ADDRESS} \
+ --just "${JUST}" \
+ install -o "${OUT_NON_ABSENT}" 2>&1
+grep 42 "${OUT_NON_ABSENT}/out.txt"
+
+
echo DONE