summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-03-01 18:10:42 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-03-05 11:05:10 +0100
commit9701d10ffc08d1f46ddc583b086c1939d83a79d5 (patch)
treef77ce14db3346ffaaabeaef018bf3c588e9c1e6c /test
parent87ffb737c8cbeb22af5331612e56bece7f019f1d (diff)
downloadjustbuild-9701d10ffc08d1f46ddc583b086c1939d83a79d5.tar.gz
Add a test verifying that foreign files correctly use serve
... by using the distdir request of the serve API.
Diffstat (limited to 'test')
-rw-r--r--test/end-to-end/serve-service/serve-distdir-root/TARGETS24
-rw-r--r--test/end-to-end/serve-service/serve-distdir-root/foreign-file-data/data.txt1
-rw-r--r--test/end-to-end/serve-service/serve-distdir-root/foreign-file-data/the-targets-file8
-rw-r--r--test/end-to-end/serve-service/serve-distdir-root/foreign-file.sh87
4 files changed, 119 insertions, 1 deletions
diff --git a/test/end-to-end/serve-service/serve-distdir-root/TARGETS b/test/end-to-end/serve-service/serve-distdir-root/TARGETS
index 106b9afd..11ccde78 100644
--- a/test/end-to-end/serve-service/serve-distdir-root/TARGETS
+++ b/test/end-to-end/serve-service/serve-distdir-root/TARGETS
@@ -40,9 +40,31 @@
, "serve-distdir (data)"
]
}
+, "foreign-file":
+ { "type": ["end-to-end", "with serve"]
+ , "name": ["foreign-file"]
+ , "test": ["foreign-file.sh"]
+ , "deps":
+ [ ["end-to-end", "mr-tool-under-test"]
+ , ["end-to-end", "tool-under-test"]
+ , ["TREE", null, "foreign-file-data"]
+ ]
+ , "repos": [["TREE", null, "foreign-file-data"]]
+ }
, "TESTS":
{ "type": "install"
+ , "arguments_config": ["TEST_COMPATIBLE_REMOTE"]
, "tainted": ["test"]
- , "deps": ["present", "absent", "upload"]
+ , "deps":
+ { "type": "++"
+ , "$1":
+ [ ["present", "absent", "upload"]
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "TEST_COMPATIBLE_REMOTE"}
+ , "then": []
+ , "else": ["foreign-file"]
+ }
+ ]
+ }
}
}
diff --git a/test/end-to-end/serve-service/serve-distdir-root/foreign-file-data/data.txt b/test/end-to-end/serve-service/serve-distdir-root/foreign-file-data/data.txt
new file mode 100644
index 00000000..557db03d
--- /dev/null
+++ b/test/end-to-end/serve-service/serve-distdir-root/foreign-file-data/data.txt
@@ -0,0 +1 @@
+Hello World
diff --git a/test/end-to-end/serve-service/serve-distdir-root/foreign-file-data/the-targets-file b/test/end-to-end/serve-service/serve-distdir-root/foreign-file-data/the-targets-file
new file mode 100644
index 00000000..39dcf68d
--- /dev/null
+++ b/test/end-to-end/serve-service/serve-distdir-root/foreign-file-data/the-targets-file
@@ -0,0 +1,8 @@
+{ "": {"type": "export", "target": "to_upper"}
+, "to_upper":
+ { "type": "generic"
+ , "outs": ["out.txt"]
+ , "cmds": ["cat hello.txt | tr a-z A-Z > out.txt"]
+ , "deps": ["hello.txt"]
+ }
+}
diff --git a/test/end-to-end/serve-service/serve-distdir-root/foreign-file.sh b/test/end-to-end/serve-service/serve-distdir-root/foreign-file.sh
new file mode 100644
index 00000000..78b2cc7c
--- /dev/null
+++ b/test/end-to-end/serve-service/serve-distdir-root/foreign-file.sh
@@ -0,0 +1,87 @@
+#!/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 DATA_DIR="${PWD}/foreign-file-data"
+readonly OUT="${TEST_TMPDIR}/out"
+
+ENDPOINT_ARGS="-r ${REMOTE_EXECUTION_ADDRESS} -R ${SERVE}"
+echo
+echo Will use endpoint arguments ${ENDPOINT_ARGS}
+
+DATA_HASH=$(git hash-object "${DATA_DIR}/data.txt")
+TARGET_HASH=$(git hash-object "${DATA_DIR}/the-targets-file")
+
+mkdir work
+cd work
+touch ROOT
+cat > repos.json <<EOF
+{ "repositories":
+ { "data":
+ { "repository":
+ { "type": "foreign file"
+ , "content": "${DATA_HASH}"
+ , "fetch": "http://non-existent.example.org/content.txt"
+ , "name": "hello.txt"
+ , "pragma": {"absent": true}
+ }
+ }
+ , "target":
+ { "repository":
+ { "type": "foreign file"
+ , "content": "${TARGET_HASH}"
+ , "fetch": "http://non-existent.example.org/target.txt"
+ , "name": "TARGETS"
+ , "pragma": {"absent": true}
+ }
+ }
+ , "": {"repository": "data", "target_root": "target"}
+ }
+}
+EOF
+echo
+cat repos.json
+echo
+
+
+# verify we can build
+
+mkdir -p "${OUT}"
+
+"${JUST_MR}" --norc --local-build-root "${LBR}" --just "${JUST}" \
+ ${ENDPOINT_ARGS} \
+ install -o "${OUT}" 2>&1
+
+grep 'HELLO WORLD' "${OUT}/out.txt"
+
+# also verify that the repo config has the repository abent
+
+CONF=$("${JUST_MR}" --norc --local-build-root "${LBR}" ${ENDPOINT_ARGS} setup)
+echo
+echo Configuration used was ${CONF}
+echo
+cat "${CONF}"
+echo
+
+test $(jq '.repositories.""."workspace_root" | length' "${CONF}") -eq 2
+
+echo OK