| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Copyright The containerd Authors. |
| 4 |
|
| 5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 |
# you may not use this file except in compliance with the License. |
| 7 |
# You may obtain a copy of the License at |
| 8 |
|
| 9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
|
| 11 |
# Unless required by applicable law or agreed to in writing, software |
| 12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
# See the License for the specific language governing permissions and |
| 15 |
# limitations under the License. |
| 16 |
|
| 17 |
set -euo pipefail |
| 18 |
|
| 19 |
CONTEXT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/" |
| 20 |
REPO="${CONTEXT}../../" |
| 21 |
|
| 22 |
source "${REPO}/script/util/utils.sh" |
| 23 |
|
| 24 |
NODE_IMAGE_NAME_BASE=test-podman-rootless-node-base |
| 25 |
NODE_IMAGE_NAME=test-podman-rootless-node |
| 26 |
|
| 27 |
if [ "${PODMAN_NO_RECREATE:-}" != "true" ] ; then |
| 28 |
echo "Preparing node image..." |
| 29 |
docker build ${DOCKER_BUILD_ARGS:-} --progress=plain -t "${NODE_IMAGE_NAME_BASE}" --target podman-rootless "${REPO}" |
| 30 |
fi |
| 31 |
|
| 32 |
TEST_LOG=$(mktemp) |
| 33 |
STORE_LOG=$(mktemp) |
| 34 |
TMP_CONTEXT=$(mktemp -d) |
| 35 |
function cleanup { |
| 36 |
local ORG_EXIT_CODE="${1}" |
| 37 |
rm -rf "${TMP_CONTEXT}" || true |
| 38 |
rm "${TEST_LOG}" || true |
| 39 |
rm "${STORE_LOG}" || true |
| 40 |
exit "${ORG_EXIT_CODE}" |
| 41 |
} |
| 42 |
trap 'cleanup "$?"' EXIT SIGHUP SIGINT SIGQUIT SIGTERM |
| 43 |
|
| 44 |
cp "${CONTEXT}/run_test.sh" "${TMP_CONTEXT}/run_test.sh" |
| 45 |
cat <<EOF > "${TMP_CONTEXT}/Dockerfile" |
| 46 |
FROM ${NODE_IMAGE_NAME_BASE} |
| 47 |
|
| 48 |
COPY run_test.sh /run_test.sh |
| 49 |
CMD ["/bin/bash", "--login", "/run_test.sh"] |
| 50 |
EOF |
| 51 |
|
| 52 |
docker build ${DOCKER_BUILD_ARGS:-} --progress=plain -t "${NODE_IMAGE_NAME}" "${TMP_CONTEXT}" |
| 53 |
docker run -t --rm --privileged "${NODE_IMAGE_NAME}" | tee "${TEST_LOG}" |
| 54 |
cat "${TEST_LOG}" | grep "${LOG_REMOTE_SNAPSHOT}" | sed -E 's/^[^\{]*(\{.*)$/\1/g' > "${STORE_LOG}" |
| 55 |
check_remote_snapshots "${STORE_LOG}" |