@@ -33,173 +33,6 @@ export GOPATH="$(pwd)/gopath"
3333mkdir -p gopath/bin
3434export PATH=" ../bin:$GOPATH /bin:$PATH "
3535
36- test_install_ipfs_nd () {
37- VERSION=" $1 "
38-
39- # We have to change the PATH as ipfs-update might call fs-repo-migrations
40- test_expect_success " 'ipfs-update install' works for $VERSION " '
41- ipfs-update --verbose install $VERSION > actual 2>&1 ||
42- test_fsh cat actual
43- '
44-
45- test_expect_success " 'ipfs-update install' output looks good" '
46- grep "fetching ipfs version $VERSION" actual &&
47- grep "installation complete." actual ||
48- test_fsh cat actual
49- '
50-
51- test_expect_success " 'ipfs-update version' works for $VERSION " '
52- ipfs-update version > actual
53- '
54-
55- test_expect_success " 'ipfs-update version' output looks good" '
56- echo "$VERSION" >expected &&
57- test_cmp expected actual
58- '
59- }
60-
61- test_init_ipfs_nd () {
62-
63- test_expect_success " ipfs init succeeds" '
64- export IPFS_PATH="$(pwd)/.ipfs" &&
65- ipfs init -b=1024 > /dev/null
66- '
67-
68- test_expect_success " prepare config -- mounting and bootstrap rm" '
69- test_config_set Addresses.API "/ip4/127.0.0.1/tcp/0" &&
70- test_config_set Addresses.Gateway "/ip4/127.0.0.1/tcp/0" &&
71- test_config_set --json Addresses.Swarm "[
72- \"/ip4/0.0.0.0/tcp/0\"
73- ]" &&
74- ipfs bootstrap rm --all ||
75- test_fsh cat "\"$IPFS_PATH/config\""
76- '
77- }
78-
79- test_config_set () {
80-
81- # grab flags (like --bool in "ipfs config --bool")
82- test_cfg_flags=" " # unset in case.
83- test " $# " = 3 && { test_cfg_flags=$1 ; shift ; }
84-
85- test_cfg_key=$1
86- test_cfg_val=$2
87-
88- # when verbose, tell the user what config values are being set
89- test_cfg_cmd=" ipfs config $test_cfg_flags \" $test_cfg_key \" \" $test_cfg_val \" "
90- test " $TEST_VERBOSE " = 1 && echo " $test_cfg_cmd "
91-
92- # ok try setting the config key/val pair.
93- ipfs config $test_cfg_flags " $test_cfg_key " " $test_cfg_val "
94- echo " $test_cfg_val " > cfg_set_expected
95- ipfs config " $test_cfg_key " > cfg_set_actual
96- test_cmp cfg_set_expected cfg_set_actual
97- }
98-
99- test_set_address_vars_nd () {
100- daemon_output=" $1 "
101-
102- test_expect_success " set up address variables" '
103- API_MADDR=$(cat "$IPFS_PATH/api") &&
104- API_ADDR=$(convert_tcp_maddr $API_MADDR) &&
105- API_PORT=$(port_from_maddr $API_MADDR) &&
106-
107- GWAY_MADDR=$(sed -n "s/^Gateway (.*) server listening on //p" "$daemon_output") &&
108- GWAY_ADDR=$(convert_tcp_maddr $GWAY_MADDR) &&
109- GWAY_PORT=$(port_from_maddr $GWAY_MADDR)
110- '
111-
112- if ipfs swarm addrs local > /dev/null 2>&1 ; then
113- test_expect_success " set swarm address vars" '
114- ipfs swarm addrs local > addrs_out &&
115- SWARM_MADDR=$(grep "127.0.0.1" addrs_out) &&
116- SWARM_PORT=$(port_from_maddr $SWARM_MADDR)
117- '
118- fi
119- }
120-
121- convert_tcp_maddr () {
122- echo $1 | awk -F' /' ' { printf "%s:%s", $3, $5 }'
123- }
124-
125- port_from_maddr () {
126- echo $1 | awk -F' /' ' { print $NF }'
127- }
128-
129- test_launch_ipfs_daemon () {
130-
131- args=" $@ "
132-
133- test " $TEST_ULIMIT_PRESET " ! = 1 && ulimit -n 1024
134-
135- test_expect_success " 'ipfs daemon' succeeds" '
136- ipfs daemon $args >actual_daemon 2>daemon_err &
137- '
138-
139- # wait for api file to show up
140- test_expect_success " api file shows up" '
141- test_wait_for_file 20 100ms "$IPFS_PATH/api"
142- '
143-
144- test_set_address_vars_nd actual_daemon
145-
146- # we say the daemon is ready when the API server is ready.
147- test_expect_success " 'ipfs daemon' is ready" '
148- IPFS_PID=$! &&
149- pollEndpoint -ep=/version -host=$API_MADDR -v -tout=1s -tries=60 2>poll_apierr > poll_apiout ||
150- test_fsh cat actual_daemon || test_fsh cat daemon_err || test_fsh cat poll_apierr || test_fsh cat poll_apiout
151- '
152- }
153-
154- test_wait_for_file () {
155- loops=$1
156- delay=$2
157- file=$3
158- fwaitc=0
159- while ! test -f " $file "
160- do
161- if test $fwaitc -ge $loops
162- then
163- echo " Error: timed out waiting for file: $file "
164- return 1
165- fi
166-
167- go-sleep $delay
168- fwaitc=` expr $fwaitc + 1`
169- done
170- }
171-
172-
173- test_kill_repeat_10_sec () {
174- # try to shut down once + wait for graceful exit
175- kill $1
176- for i in $( test_seq 1 100)
177- do
178- go-sleep 100ms
179- ! kill -0 $1 2> /dev/null && return
180- done
181-
182- # if not, try once more, which will skip graceful exit
183- kill $1
184- go-sleep 1s
185- ! kill -0 $1 2> /dev/null && return
186-
187- # ok, no hope. kill it to prevent it messing with other tests
188- kill -9 $1 2> /dev/null
189- return 1
190- }
191-
192- test_kill_ipfs_daemon () {
193-
194- test_expect_success " 'ipfs daemon' is still running" '
195- kill -0 $IPFS_PID
196- '
197-
198- test_expect_success " 'ipfs daemon' can be killed" '
199- test_kill_repeat_10_sec $IPFS_PID
200- '
201- }
202-
20336
20437test_install_ipfs_nd " v0.4.2"
20538
@@ -269,7 +102,6 @@ test_expect_success "get pin lists" '
269102 ipfs pin ls --type=indirect | sort > start_ind_pins
270103'
271104
272-
273105test_kill_ipfs_daemon
274106
275107test_install_ipfs_nd " v0.4.3-dev"
0 commit comments