-
Notifications
You must be signed in to change notification settings - Fork 13
/
run_tests.sh
executable file
·65 lines (51 loc) · 1.63 KB
/
run_tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -ex
# Before running this, run ./build.sh
# TODO We need a bit more tests. Perhaps using something like Python would make
# sense for this.
SCRIPT_DIR=$(dirname -- "$(readlink -f -- "$0")")
cd $SCRIPT_DIR/..
IMAGE_DIR=/tmp/ff-test-images
sudo rm -rf $IMAGE_DIR
mkdir -p $IMAGE_DIR
chmod 1777 $IMAGE_DIR # /tmp like permissions
cat <<- EOF > $IMAGE_DIR/show_metrics.sh
#!/bin/bash
echo -n "Metric: "
echo "\$@" | jq -C .
EOF
chmod +x $IMAGE_DIR/show_metrics.sh
echo passphrase > $IMAGE_DIR/encryption_key
docker stop ff || true
sudo bash -c 'echo 0 > /proc/sys/kernel/yama/ptrace_scope'
# In the following, we don't need cap_sys_ptrace, but it makes Docker
# relax its seccomp filters on kcmp(), which CRIU needs.
docker run \
--rm \
--user nobody \
--cap-add=cap_sys_ptrace \
--name ff \
--mount type=bind,source=$IMAGE_DIR,target=/images \
--env FF_METRICS_RECORDER=/images/show_metrics.sh \
fastfreeze-test:latest \
fastfreeze run -v \
--image-url file:/images/test-1 \
--passphrase-file /images/encryption_key -- sleep 30d &
sleep 2 # wait for app started
# Forget to put cap-add, and get Permission Denied
docker exec --env FF_METRICS_RECORDER=/images/show_metrics.sh ff fastfreeze checkpoint -v
wait
docker run \
--rm \
--user nobody \
--cap-add=cap_sys_ptrace \
--name ff \
--mount type=bind,source=$IMAGE_DIR,target=/images \
--env FF_METRICS_RECORDER=/images/show_metrics.sh \
fastfreeze-test:latest \
fastfreeze run -v \
--image-url file:/images/test-1 \
--passphrase-file /images/encryption_key -- sleep 30d &
sleep 2 # wait for app restore
docker exec ff fastfreeze checkpoint
wait