summaryrefslogtreecommitdiff
path: root/test/end-to-end/serve-service
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-12-20 10:44:48 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-12-20 11:22:57 +0100
commitae803a336c1af72ba750fc5839bbe3cb20826861 (patch)
tree367ded3677b995cd8271028a19f283ece852231b /test/end-to-end/serve-service
parent6f830e0d3f39480ce3b382d1d1fa70b768aa5231 (diff)
downloadjustbuild-ae803a336c1af72ba750fc5839bbe3cb20826861.tar.gz
Add end-to-end test serving a tree target from an archive root
Diffstat (limited to 'test/end-to-end/serve-service')
-rw-r--r--test/end-to-end/serve-service/TARGETS50
-rw-r--r--test/end-to-end/serve-service/data/targets/TARGETS.tree3
-rwxr-xr-xtest/end-to-end/serve-service/serve-tree.sh89
3 files changed, 135 insertions, 7 deletions
diff --git a/test/end-to-end/serve-service/TARGETS b/test/end-to-end/serve-service/TARGETS
index f90edd55..774639ef 100644
--- a/test/end-to-end/serve-service/TARGETS
+++ b/test/end-to-end/serve-service/TARGETS
@@ -12,7 +12,11 @@
, "serve-target-remote-build (repo)":
{ "type": "generic"
, "out_dirs": ["src"]
- , "cmds": ["for i in `seq 1 5` ; do echo $i > src/$i.txt ; done"]
+ , "cmds":
+ [ "for i in `seq 1 5` ; do echo $i > src/$i.txt ; done"
+ , "mkdir src/subdir"
+ , "for i in `seq 6 10` ; do echo $i > src/subdir/sub-$i.txt ; done"
+ ]
}
, "serve-target-remote-build (data)":
{ "type": ["@", "rules", "data", "staged"]
@@ -51,15 +55,47 @@
, "deps":
[["end-to-end", "mr-tool-under-test"], ["end-to-end", "tool-under-test"]]
}
+, "serve-tree (data)":
+ { "type": "install"
+ , "files": {"repo/TARGETS": "data/targets/TARGETS.tree"}
+ , "dirs": [["serve-target-remote-build (repo)", "repo"]]
+ }
+, "serve-tree (archive)":
+ { "type": "generic"
+ , "outs": ["src.tar"]
+ , "cmds": ["tar cf src.tar repo"]
+ , "deps": ["serve-tree (data)"]
+ }
+, "serve-tree":
+ { "type": ["end-to-end", "with serve"]
+ , "name": ["serve-tree"]
+ , "test": ["serve-tree.sh"]
+ , "deps":
+ [ ["end-to-end", "mr-tool-under-test"]
+ , ["end-to-end", "tool-under-test"]
+ , "serve-tree (archive)"
+ ]
+ , "repos": ["serve-tree (archive)"]
+ }
, "TESTS":
{ "type": "install"
, "tainted": ["test"]
+ , "arguments_config": ["TEST_COMPATIBLE_REMOTE"]
, "deps":
- [ "serve-target-remote-build"
- , "serve-target-cache-hit"
- , "serve-start-execute"
- , "serve-start-execute-sharding"
- , "serve-export-deps"
- ]
+ { "type": "++"
+ , "$1":
+ [ [ "serve-target-remote-build"
+ , "serve-target-cache-hit"
+ , "serve-start-execute"
+ , "serve-start-execute-sharding"
+ , "serve-export-deps"
+ ]
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "TEST_COMPATIBLE_REMOTE"}
+ , "then": []
+ , "else": ["serve-tree"]
+ }
+ ]
+ }
}
}
diff --git a/test/end-to-end/serve-service/data/targets/TARGETS.tree b/test/end-to-end/serve-service/data/targets/TARGETS.tree
new file mode 100644
index 00000000..04119c62
--- /dev/null
+++ b/test/end-to-end/serve-service/data/targets/TARGETS.tree
@@ -0,0 +1,3 @@
+{ "": {"type": "export", "target": "tree"}
+, "tree": {"type": "install", "dirs": [[["TREE", null, "src"], "."]]}
+}
diff --git a/test/end-to-end/serve-service/serve-tree.sh b/test/end-to-end/serve-service/serve-tree.sh
new file mode 100755
index 00000000..97e287cc
--- /dev/null
+++ b/test/end-to-end/serve-service/serve-tree.sh
@@ -0,0 +1,89 @@
+#!/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 -e
+
+readonly JUST="${PWD}/bin/tool-under-test"
+readonly JUST_MR="${PWD}/bin/mr-tool-under-test"
+readonly LBR_DEBUG="${TEST_TMPDIR}/build-root-DEBUG"
+readonly LBR_A="${TEST_TMPDIR}/build-root-A"
+readonly LBR_B="${TEST_TMPDIR}/build-root-B"
+readonly LBR_C="${TEST_TMPDIR}/build-root-C"
+readonly LBR_D="${TEST_TMPDIR}/build-root-D"
+readonly DISTDIR="${TEST_TMPDIR}/distfiles"
+
+mkdir -p "${DISTDIR}"
+cp src.tar "${DISTDIR}"
+HASH=$(git hash-object src.tar)
+
+REMOTE="-r ${REMOTE_EXECUTION_ADDRESS}"
+
+mkdir work
+cd work
+
+touch ROOT
+cat > repos.json <<EOF
+{ "repositories":
+ { "":
+ { "repository":
+ { "type": "archive"
+ , "content": "$HASH"
+ , "fetch": "http://example.org/src.tar"
+ , "subdir": "repo"
+ }
+ }
+ }
+}
+EOF
+
+echo
+echo MR configuration
+cat repos.json
+echo
+echo Resulting just repo configuraiton
+cat $("${JUST_MR}" --norc --local-build-root "${LBR_DEBUG}" \
+ --distdir "${DISTDIR}" setup)
+echo
+
+echo
+echo Local build
+"${JUST_MR}" --norc --local-build-root "${LBR_A}" --just "${JUST}" \
+ --distdir "${DISTDIR}" build \
+ --dump-artifacts local.json 2>&1
+
+echo
+echo Remote build
+"${JUST_MR}" --norc --local-build-root "${LBR_B}" --just "${JUST}" \
+ --distdir "${DISTDIR}" ${REMOTE} build \
+ --dump-artifacts remote.json 2>&1
+
+echo
+echo Serve build
+"${JUST_MR}" --norc --local-build-root "${LBR_C}" --just "${JUST}" \
+ ${REMOTE} -R ${SERVE} build \
+ --dump-artifacts serve.json 2>&1
+
+echo
+echo Absent build
+echo -n '[""]' > abs
+"${JUST_MR}" --norc --local-build-root "${LBR_D}" --just "${JUST}" \
+ --distdir "${DISTDIR}" ${REMOTE} -R ${SERVE} --absent abs build \
+ --dump-artifacts absent.json 2>&1
+
+diff -u local.json remote.json
+diff -u local.json serve.json
+diff -u local.json absent.json
+
+echo OK