29
APP_ROOT_DIR=$(dirname "$TEST_TESTS_DIR")
30
31
test_expect_success "docker image build succeeds" '
32
- docker_build "$TEST_TESTS_DIR/../Dockerfile" "$APP_ROOT_DIR" >build-actual ||
32
+ docker_build "$TEST_TESTS_DIR/../Dockerfile" "$APP_ROOT_DIR" | tee build-actual ||
33
test_fsh echo "TEST_TESTS_DIR: $TEST_TESTS_DIR" ||
34
test_fsh echo "APP_ROOT_DIR : $APP_ROOT_DIR" ||
35
test_fsh cat build-actual
41
test_fsh cat build-actual
42
'
43
44
+test_expect_success "write init scripts" '
45
+ echo "ipfs config Foo Bar" > 001.sh &&
46
+ echo "ipfs config Baz Qux" > 002.sh &&
47
+ chmod +x 002.sh
48
+'
49
+
50
test_expect_success "docker image runs" '
45
- DOC_ID=$(docker run -d -p 127.0.0.1:5001:5001 -p 127.0.0.1:8080:8080 "$IMAGE_ID")
51
+ DOC_ID=$(docker run -d \
52
+ -p 127.0.0.1:5001:5001 -p 127.0.0.1:8080:8080 \
53
+ -v "$PWD/001.sh":/container-init.d/001.sh \
54
+ -v "$PWD/002.sh":/container-init.d/002.sh \
55
+ "$IMAGE_ID")
56
'
57
58
test_expect_success "docker container gateway is up" '
63
pollEndpoint -host=/ip4/127.0.0.1/tcp/5001 -http-url http://localhost:5001/version -v -tries 30 -tout 1s
64
'
65
66
+test_expect_success "check that init scripts were run correctly and in the correct order" "
67
+ echo -e \"Sourcing '/container-init.d/001.sh'...\nExecuting '/container-init.d/002.sh'...\" > expected &&
68
+ docker logs $DOC_ID 2>/dev/null | grep -e 001.sh -e 002.sh > actual &&
69
+ test_cmp actual expected
70
+"
71
+
72
+test_expect_success "check that init script configs were applied" '
73
+ echo Bar > expected &&
74
+ docker exec "$DOC_ID" ipfs config Foo > actual &&
75
+ test_cmp actual expected &&
76
+ echo Qux > expected &&
77
+ docker exec "$DOC_ID" ipfs config Baz > actual &&
78
+ test_cmp actual expected
79
+'
80
+
81
test_expect_success "simple ipfs add/cat can be run in docker container" '
82
expected="Hello Worlds" &&
83
HASH=$(docker_exec "$DOC_ID" "echo $(cat expected) | ipfs add | cut -d' ' -f2") &&
99
docker_stop "$DOC_ID"
100
'
101
102
+docker_rm "$DOC_ID"
103
+docker_rmi "$IMAGE_ID"
104
test_done
105