Debian Codegraph @

script/ipfs/test.sh

raw
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 IMAGE_NAME="testipfs"
22
23 source "${REPO}/script/util/utils.sh"
24
25 GOBASE_VERSION=$(go_base_version "${REPO}/Dockerfile")
26 IPFS_VERSION=v0.17.0
27
28 TMP_CONTEXT=$(mktemp -d)
29 function cleanup {
30 local ORG_EXIT_CODE="${1}"
31 rm -rf "${TMP_CONTEXT}" || true
32 exit "${ORG_EXIT_CODE}"
33 }
34 trap 'cleanup "$?"' EXIT SIGHUP SIGINT SIGQUIT SIGTERM
35
36 cat <<EOF > "${TMP_CONTEXT}/Dockerfile"
37 FROM golang:${GOBASE_VERSION}
38 RUN apt-get update -y && apt-get install -y fuse3 && \
39 wget https://dist.ipfs.io/go-ipfs/${IPFS_VERSION}/go-ipfs_${IPFS_VERSION}_linux-amd64.tar.gz && \
40 tar -xvzf go-ipfs_${IPFS_VERSION}_linux-amd64.tar.gz && \
41 cd go-ipfs && \
42 bash install.sh
43 COPY ./entrypoint.sh /entrypoint.sh
44 ENTRYPOINT ["/entrypoint.sh"]
45 EOF
46 cp "${CONTEXT}/entrypoint.sh" "${TMP_CONTEXT}/entrypoint.sh"
47 docker build --progress=plain -t "${IMAGE_NAME}" ${DOCKER_BUILD_ARGS:-} "${TMP_CONTEXT}"
48 docker run --rm --privileged \
49 --device /dev/fuse \
50 --tmpfs /tmp:exec,mode=777 \
51 -w /go/src/github.com/containerd/stargz-snapshotter/ipfs \
52 -v "${REPO}:/go/src/github.com/containerd/stargz-snapshotter:ro" \
53 "${IMAGE_NAME}" go test -v -run TestIPFSClient ./client/... --ipfs-api=http://localhost:5001