summaryrefslogtreecommitdiff
path: root/test/end-to-end/remote-execution
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-03-23 11:53:00 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-03-23 16:00:15 +0100
commit3497ec5fa892995691c8692cedce7b100a3af6bf (patch)
tree50b8bfdf1260ea4797d2cee87122b97b267736bc /test/end-to-end/remote-execution
parent680ed52991dfcc0987829f416e02e7eae9239472 (diff)
downloadjustbuild-3497ec5fa892995691c8692cedce7b100a3af6bf.tar.gz
Add basic test for install-cas
... also verifying that the local CAS is used, even in the presence of remote execution.
Diffstat (limited to 'test/end-to-end/remote-execution')
-rw-r--r--test/end-to-end/remote-execution/TARGETS8
-rw-r--r--test/end-to-end/remote-execution/install.sh103
2 files changed, 110 insertions, 1 deletions
diff --git a/test/end-to-end/remote-execution/TARGETS b/test/end-to-end/remote-execution/TARGETS
index 3574f6db..81ec99e0 100644
--- a/test/end-to-end/remote-execution/TARGETS
+++ b/test/end-to-end/remote-execution/TARGETS
@@ -19,9 +19,15 @@
, "test": ["upload-test.sh"]
, "deps": [["test/end-to-end", "tool-under-test"]]
}
+, "install":
+ { "type": ["test/end-to-end", "with remote"]
+ , "name": ["install"]
+ , "test": ["install.sh"]
+ , "deps": [["test/end-to-end", "tool-under-test"]]
+ }
, "TESTS":
{ "type": "install"
, "tainted": ["test"]
- , "deps": ["native-protocol", "large-blobs", "upload-test"]
+ , "deps": ["native-protocol", "large-blobs", "upload-test", "install"]
}
}
diff --git a/test/end-to-end/remote-execution/install.sh b/test/end-to-end/remote-execution/install.sh
new file mode 100644
index 00000000..be77da95
--- /dev/null
+++ b/test/end-to-end/remote-execution/install.sh
@@ -0,0 +1,103 @@
+#!/bin/sh
+# Copyright 2023 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 WRKDIR="${PWD}"
+readonly LBRDIR_A="${TEST_TMPDIR}/local-build-root/instance-A"
+readonly LBRDIR_B="${TEST_TMPDIR}/local-build-root/instance-B"
+readonly SRCDIR_A="${TEST_TMPDIR}/src/instance-A"
+readonly SRCDIR_B="${TEST_TMPDIR}/src/instance-B"
+readonly OUTDIR_B="${TEST_TMPDIR}/out/instance-B"
+
+REMOTE_EXECUTION_ARGS="-r ${REMOTE_EXECUTION_ADDRESS}"
+LOCAL_ARGS=""
+if [ "${REMOTE_EXECUTION_PROPERTIES:-}" != "" ]
+then
+ REMOTE_EXECUTION_ARGS="${REMOTE_EXECUTION_ARGS} --remote-execution-property ${REMOTE_EXECUTION_PROPERTIES}"
+fi
+if [ -n "${COMPATIBLE:-}" ]
+then
+ REMOTE_EXECUTION_ARGS="${REMOTE_EXECUTION_ARGS} --compatible"
+ LOCAL_ARGS="--compatible"
+fi
+
+# install-cas from remote execution endpoint
+
+## instance A to upload
+mkdir -p "${SRCDIR_A}"
+cd "${SRCDIR_A}"
+touch ROOT
+
+mkdir -p tree/foo/bar
+mkdir -p tree/baz
+echo content frist file > tree/foo/bar/data.txt
+echo content second file > tree/baz/data.txt
+
+cat > TARGETS <<'EOF'
+{"": {"type": "install", "dirs": [[["TREE", null, "tree"], "."]]}}
+EOF
+
+"${JUST}" build --local-build-root "${LBRDIR_A}" \
+ --dump-artifacts "${WRKDIR}/tree.json" ${REMOTE_EXECUTION_ARGS} 2>&1
+
+## instance B should be able to fetch
+
+cd "${WRKDIR}"
+TREE_ID=$(jq -r '.tree.id' "${WRKDIR}/tree.json")"::t"
+"${JUST}" install-cas --local-build-root "${LBRDIR_B}" \
+ -o "${OUTDIR_B}/first" ${REMOTE_EXECUTION_ARGS} "${TREE_ID}" 2>&1
+
+for f in $(cd "${SRCDIR_A}/tree" && find . -type f)
+do
+ cmp "${SRCDIR_A}/tree/$f" "${OUTDIR_B}/first/$f"
+done
+
+# install-cas has to prefer (at least: use) local CAS, also with remote endpoint
+
+## instance B builds locally, to fill local CAS
+## (using a different tree, not known to the remote execution)
+
+mkdir -p "${SRCDIR_B}"
+cd "${SRCDIR_B}"
+touch ROOT
+
+mkdir -p tree/different/foobar
+mkdir -p tree/bar/other_dir
+echo some other content > tree/different/foobar/file.txt
+echo yet another content > tree/bar/other_dir/file.txt
+
+cat > TARGETS <<'EOF'
+{"": {"type": "install", "dirs": [[["TREE", null, "tree"], "."]]}}
+EOF
+
+"${JUST}" build --local-build-root "${LBRDIR_B}" \
+ --dump-artifacts "${WRKDIR}/tree.json" ${LOCAL_ARGS} 2>&1
+
+## install-cas should work, even though the tree is not known remotely
+
+cd "${WRKDIR}"
+TREE_ID=$(jq -r '.tree.id' "${WRKDIR}/tree.json")"::t"
+"${JUST}" install-cas --local-build-root "${LBRDIR_B}" \
+ -o "${OUTDIR_B}/second" ${REMOTE_EXECUTION_ARGS} "${TREE_ID}" 2>&1
+
+for f in $(cd "${SRCDIR_B}/tree" && find . -type f)
+do
+ cmp "${SRCDIR_B}/tree/$f" "${OUTDIR_B}/second/$f"
+done
+
+echo OK