From ac3fc8b7ae3619703fd482718147423137df7399 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Wed, 21 Feb 2024 15:07:17 +0100 Subject: test just-mr and serve: Check git-tree repository root creation Extends test coverage for the interaction between 'just-mr setup' and the serve endpoint for git-tree repositories. --- test/end-to-end/serve-service/TARGETS | 1 + .../serve-service/serve-git-tree-root/TARGETS | 19 +++++ .../serve-service/serve-git-tree-root/absent.sh | 74 ++++++++++++++++ .../serve-service/serve-git-tree-root/present.sh | 99 ++++++++++++++++++++++ 4 files changed, 193 insertions(+) create mode 100644 test/end-to-end/serve-service/serve-git-tree-root/TARGETS create mode 100644 test/end-to-end/serve-service/serve-git-tree-root/absent.sh create mode 100644 test/end-to-end/serve-service/serve-git-tree-root/present.sh (limited to 'test') diff --git a/test/end-to-end/serve-service/TARGETS b/test/end-to-end/serve-service/TARGETS index 9d29a9ca..c8d519ef 100644 --- a/test/end-to-end/serve-service/TARGETS +++ b/test/end-to-end/serve-service/TARGETS @@ -140,6 +140,7 @@ [ [["./", "serve-archive-root", "TESTS"], "serve-archive-root"] , [["./", "serve-git-root", "TESTS"], "serve-git-root"] , [["./", "serve-file-root", "TESTS"], "serve-file-root"] + , [["./", "serve-git-tree-root", "TESTS"], "serve-git-tree-root"] ] } } diff --git a/test/end-to-end/serve-service/serve-git-tree-root/TARGETS b/test/end-to-end/serve-service/serve-git-tree-root/TARGETS new file mode 100644 index 00000000..664c08c4 --- /dev/null +++ b/test/end-to-end/serve-service/serve-git-tree-root/TARGETS @@ -0,0 +1,19 @@ +{ "present": + { "type": ["end-to-end", "with serve"] + , "name": ["present"] + , "test": ["present.sh"] + , "deps": + [["end-to-end", "mr-tool-under-test"], ["end-to-end", "tool-under-test"]] + , "repos": [["end-to-end/serve-service", "serve-tree (data)"]] + } +, "absent": + { "type": ["end-to-end", "with serve"] + , "name": ["absent"] + , "test": ["absent.sh"] + , "deps": + [["end-to-end", "mr-tool-under-test"], ["end-to-end", "tool-under-test"]] + , "repos": [["end-to-end/serve-service", "serve-tree (data)"]] + } +, "TESTS": + {"type": "install", "tainted": ["test"], "deps": ["present", "absent"]} +} diff --git a/test/end-to-end/serve-service/serve-git-tree-root/absent.sh b/test/end-to-end/serve-service/serve-git-tree-root/absent.sh new file mode 100644 index 00000000..0eb6b444 --- /dev/null +++ b/test/end-to-end/serve-service/serve-git-tree-root/absent.sh @@ -0,0 +1,74 @@ +#!/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. + + +### +# This test checks that an absent root can successfully be made by asking +# the serve endpoint to set it up for us when we have no local knowledge. +## + +set -eu + +readonly JUST="${PWD}/bin/tool-under-test" +readonly JUST_MR="${PWD}/bin/mr-tool-under-test" +readonly LBR="${TEST_TMPDIR}/local-build-root" + +COMPAT="" +if [ "${COMPATIBLE:-}" = "YES" ]; then + COMPAT="--compatible" +fi + +ENDPOINT_ARGS="-r ${REMOTE_EXECUTION_ADDRESS} -R ${SERVE} ${COMPAT}" + +### +# Setup sample repos config with present and absent repos +## + +mkdir work +cd work + +touch ROOT +cat > repos.json < repos.json <&1 + ${JUST} gc --local-build-root ${LBR} 2>&1 + + CONF=$("${JUST_MR}" --norc -C repos.json \ + --just "${JUST}" \ + --local-build-root "${LBR}" \ + --log-limit 6 \ + setup main) + cat "${CONF}" + echo + test $(jq -r '.repositories.main.workspace_root[1]' "${CONF}") = "${TREE_0}" + +else + + echo --- + echo Checking expected failures + + "${JUST_MR}" --norc -C repos.json \ + --just "${JUST}" \ + --local-build-root "${LBR}" \ + --log-limit 6 \ + ${ENDPOINT_ARGS} setup main 2>&1 && exit 1 || : + echo Failed as expected +fi + +echo OK -- cgit v1.2.3