|
| 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 | +# Check Dockerfile at script/posix/Dockerfile |
| 20 | +IMAGE_PJDFSTEST="${IMAGE_PJDFSTEST:-docker.io/sequix/pjdfstest:v1-stargz}" |
| 21 | +CONTEXT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
| 22 | + |
| 23 | +function retry { |
| 24 | + local RETRYNUM=30 |
| 25 | + local RETRYINTERVAL=1 |
| 26 | + local TIMEOUTSEC=180 |
| 27 | + local SUCCESS=false |
| 28 | + for i in $(seq ${RETRYNUM}) ; do |
| 29 | + if eval "timeout ${TIMEOUTSEC} ${@}" ; then |
| 30 | + SUCCESS=true |
| 31 | + break |
| 32 | + fi |
| 33 | + echo "Fail(${i}). Retrying..." |
| 34 | + sleep ${RETRYINTERVAL} |
| 35 | + done |
| 36 | + if [ "${SUCCESS}" == "true" ] ; then |
| 37 | + return 0 |
| 38 | + else |
| 39 | + return 1 |
| 40 | + fi |
| 41 | +} |
| 42 | + |
| 43 | +specList() { |
| 44 | + uname -r |
| 45 | + cat /etc/os-release |
| 46 | + cat /proc/cpuinfo |
| 47 | + cat /proc/meminfo |
| 48 | + mount |
| 49 | + df -T |
| 50 | +} |
| 51 | +echo "Machine spec list:" |
| 52 | +specList |
| 53 | + |
| 54 | +setup() { |
| 55 | + local REPO_CONFIG_DIR=$CONTEXT/config/ |
| 56 | + local CONTAINERD_CONFIG_DIR=/etc/containerd/ |
| 57 | + local REMOTE_SNAPSHOTTER_SOCKET=/run/containerd-stargz-grpc/containerd-stargz-grpc.sock |
| 58 | + local REMOTE_SNAPSHOTTER_CONFIG_DIR=/etc/containerd-stargz-grpc/ |
| 59 | + |
| 60 | + mkdir -p /tmp/out |
| 61 | + PREFIX=/tmp/out/ make clean |
| 62 | + PREFIX=/tmp/out/ make -j2 |
| 63 | + PREFIX=/tmp/out/ make install |
| 64 | + mkdir -p "${CONTAINERD_CONFIG_DIR}" |
| 65 | + cp "${REPO_CONFIG_DIR}"config.containerd.toml "${CONTAINERD_CONFIG_DIR}" |
| 66 | + mkdir -p "${REMOTE_SNAPSHOTTER_CONFIG_DIR}" |
| 67 | + cp "${REPO_CONFIG_DIR}"config.stargz.toml "${REMOTE_SNAPSHOTTER_CONFIG_DIR}" |
| 68 | + |
| 69 | + containerd-stargz-grpc --log-level=debug \ |
| 70 | + --address="${REMOTE_SNAPSHOTTER_SOCKET}" \ |
| 71 | + --config="${REMOTE_SNAPSHOTTER_CONFIG_DIR}config.stargz.toml" \ |
| 72 | + &>/var/log/containerd-stargz-grpc.log & |
| 73 | + retry ls "${REMOTE_SNAPSHOTTER_SOCKET}" |
| 74 | + |
| 75 | + containerd --log-level debug \ |
| 76 | + --config="${CONTAINERD_CONFIG_DIR}config.containerd.toml" \ |
| 77 | + &>/var/log/containerd.log & |
| 78 | + retry ctr version |
| 79 | +} |
| 80 | +echo "Setting up stargz-snaphsotter & containerd..." |
| 81 | +setup |
| 82 | + |
| 83 | +testPosix() { |
| 84 | + local containerID="posix-test_$(basename $(mktemp))" |
| 85 | + ctr-remote image rpull "$IMAGE_PJDFSTEST" |
| 86 | + ctr-remote run --rm --snapshotter=stargz "$IMAGE_PJDFSTEST" "$containerID" >/output || \ |
| 87 | + echo -e "\e[91mPosix test failed!\e[0m" |
| 88 | +} |
| 89 | +echo "Testing posix calls..." |
| 90 | +testPosix |
0 commit comments