Skip to content

Commit 99c6fc5

Browse files
committed
posix filesystem call test suite based on pjdfstest
Signed-off-by: sequix <sequix@163.com>
1 parent f9a427d commit 99c6fc5

File tree

7 files changed

+222
-1
lines changed

7 files changed

+222
-1
lines changed

Makefile

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ GO111MODULE_VALUE=auto
1919
PREFIX ?= out/
2020

2121
CMD=containerd-stargz-grpc ctr-remote
22-
2322
CMD_BINARIES=$(addprefix $(PREFIX),$(CMD))
2423

24+
OUT_POSIX=out-posix
25+
2526
.PHONY: all build check install-check-tools install uninstall clean test test-root test-all integration test-optimize benchmark test-pullsecrets test-cri
2627

2728
all: build
@@ -61,6 +62,7 @@ uninstall:
6162
clean:
6263
@echo "$@"
6364
@rm -f $(CMD_BINARIES)
65+
@rm -f $(OUT_POSIX)
6466

6567
test:
6668
@echo "$@"
@@ -86,3 +88,6 @@ test-pullsecrets:
8688

8789
test-cri:
8890
@./script/cri/test.sh
91+
92+
test-posix:
93+
@./script/posix/test.sh

script/posix/Dockerfile

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright The containerd Authors.
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM golang:1.13
16+
17+
# basic packages
18+
RUN apt-get update -y && \
19+
apt-get --no-install-recommends install -y libbtrfs-dev libseccomp-dev fuse \
20+
apt-transport-https gnupg2 software-properties-common
21+
22+
# runtime dependencies
23+
RUN git clone https://github.com/opencontainers/runc \
24+
$GOPATH/src/github.com/opencontainers/runc && \
25+
cd $GOPATH/src/github.com/opencontainers/runc && \
26+
git checkout d736ef14f0288d6993a1845745d6756cfc9ddd5a && \
27+
GO111MODULE=off make BUILDTAGS='seccomp apparmor' && \
28+
GO111MODULE=off make install && \
29+
git clone https://github.com/containerd/containerd \
30+
$GOPATH/src/github.com/containerd/containerd && \
31+
cd $GOPATH/src/github.com/containerd/containerd && \
32+
git checkout 990076b731ec9446437972b41176a6b0f3b7bcbf && \
33+
GO111MODULE=off make && GO111MODULE=off make install
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[proxy_plugins]
2+
[proxy_plugins.stargz]
3+
type = "snapshot"
4+
address = "/run/containerd-stargz-grpc/containerd-stargz-grpc.sock"
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
noprefetch = false

script/posix/pjdfstest/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM alpine:3.9 AS stage-build
2+
WORKDIR /work
3+
RUN apk add git automake autoconf build-base && \
4+
git clone https://github.com/pjd/pjdfstest.git /work/pjdfstest && \
5+
cd /work/pjdfstest && \
6+
git checkout a75ea1caf843a3a1e6c866b61bf954f68cee4a85 && \
7+
autoreconf -ifs && ./configure && make pjdfstest
8+
9+
FROM alpine:3.9 AS stage-final
10+
WORKDIR /work
11+
COPY --from=stage-build /work/pjdfstest /work/pjdfstest
12+
RUN apk add openssl perl-test-harness-utils
13+
CMD ["prove", "-rv", "/work/pjdfstest/tests"]

script/posix/run.sh

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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

script/posix/test.sh

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
cleanup() {
20+
local ORG_EXIT_CODE="${1}"
21+
rm "${DOCKER_COMPOSE_YAML}" || true
22+
exit "${ORG_EXIT_CODE}"
23+
}
24+
trap 'cleanup "$?"' EXIT SIGHUP SIGINT SIGQUIT SIGTERM
25+
26+
CONTEXT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/"
27+
REPO="${CONTEXT}../../"
28+
29+
echo "Preparing docker-compose.yml..."
30+
DOCKER_COMPOSE_YAML=$(mktemp)
31+
BENCHMARKING_NODE=posix-test
32+
BENCHMARKING_CONTAINER=posix-test
33+
cat <<EOF > "${DOCKER_COMPOSE_YAML}"
34+
version: "3"
35+
services:
36+
${BENCHMARKING_NODE}:
37+
build:
38+
context: "${CONTEXT}/"
39+
dockerfile: Dockerfile
40+
container_name: ${BENCHMARKING_CONTAINER}
41+
privileged: true
42+
working_dir: /go/src/github.com/containerd/stargz-snapshotter
43+
command: tail -f /dev/null
44+
environment:
45+
- NO_PROXY=127.0.0.1,localhost
46+
- HTTP_PROXY=${HTTP_PROXY:-}
47+
- HTTPS_PROXY=${HTTPS_PROXY:-}
48+
- http_proxy=${http_proxy:-}
49+
- https_proxy=${https_proxy:-}
50+
tmpfs:
51+
- /tmp:exec,mode=777
52+
volumes:
53+
- "${REPO}:/go/src/github.com/containerd/stargz-snapshotter:ro"
54+
- "/dev/fuse:/dev/fuse"
55+
- "containerd-data:/var/lib/containerd:delegated"
56+
- "containerd-stargz-grpc-data:/var/lib/containerd-stargz-grpc:delegated"
57+
- "containerd-stargz-grpc-status:/run/containerd-stargz-grpc:delegated"
58+
volumes:
59+
containerd-data:
60+
containerd-stargz-grpc-data:
61+
containerd-stargz-grpc-status:
62+
EOF
63+
64+
echo "Setup posix test environment..."
65+
docker-compose -f "${DOCKER_COMPOSE_YAML}" build ${DOCKER_BUILD_ARGS:-} "${BENCHMARKING_NODE}"
66+
docker-compose -f "${DOCKER_COMPOSE_YAML}" up -d --force-recreate
67+
68+
echo "Posix testing..."
69+
docker exec -i "${BENCHMARKING_CONTAINER}" script/posix/run.sh
70+
71+
echo "Harvesting output..."
72+
docker cp "${BENCHMARKING_CONTAINER}:/output" "${REPO}/out-posix"
73+
74+
echo "Cleaning up benchmark environment..."
75+
docker-compose -f "${DOCKER_COMPOSE_YAML}" down -v

0 commit comments

Comments
 (0)