Skip to content

Commit 55e1552

Browse files
committed
[Tests] Add tests of invalid redirect hostname or failed connection
1 parent b3e2433 commit 55e1552

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

tests/cluster/setup.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ set -e
1313
: ${CRC32C:=$(command -v xrdcrc32c)}
1414
: ${STAT:=$(command -v stat)}
1515

16-
servernames=("metaman" "man1" "man2" "srv1" "srv2" "srv3" "srv4")
17-
datanodes=("srv1" "srv2" "srv3" "srv4")
16+
servernames=("metaman" "man1" "man2" "srv1" "srv2" "srv3" "srv4" "srv-bad-redir1" "srv-bad-redir2")
17+
datanodes=("srv1" "srv2" "srv3" "srv4" "srv-bad-redir1" "srv-bad-redir2")
1818

1919
DATAFOLDER="./data"
2020
TMPDATAFOLDER="./rout"
@@ -147,6 +147,10 @@ start(){
147147
generate
148148
set -x
149149
# start for each component
150+
151+
# temporary hostname to start one of the bad redirect servers
152+
echo "127.0.0.1 localhostx" >> /etc/hosts
153+
150154
for i in "${servernames[@]}"; do
151155
${XROOTD} -b -k fifo -n ${i} -l xrootd.log -s xrootd.pid -c ${i}.cfg
152156
done
@@ -157,6 +161,9 @@ start(){
157161
done
158162

159163
sleep 1
164+
165+
# remove remporary hostname
166+
sed -i '$ d' /etc/hosts
160167
}
161168

162169
stop() {

tests/cluster/srv-bad-redir1.cfg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set name = srv4
2+
3+
all.role server
4+
5+
xrd.port 10951
6+
xrootd.redirect localhost:10950 chmod
7+
8+
if exec xrootd
9+
xrd.protocol XrdHttp:10951 libXrdHttp.so
10+
fi
11+
12+
continue @CMAKE_CURRENT_BINARY_DIR@/common.cfg

tests/cluster/srv-bad-redir2.cfg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set name = srv4
2+
3+
all.role server
4+
5+
xrd.port 10952
6+
xrootd.redirect localhostx:10950 chmod
7+
8+
if exec xrootd
9+
xrd.protocol XrdHttp:10952 libXrdHttp.so
10+
fi
11+
12+
continue @CMAKE_CURRENT_BINARY_DIR@/common.cfg

tests/cluster/test.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ fi
2020
: ${HOST_SRV2:=root://localhost:10944}
2121
: ${HOST_SRV3:=root://localhost:10945}
2222
: ${HOST_SRV4:=root://localhost:10946}
23+
: ${HOST_BAD_REDIR1:=root://localhost:10951}
24+
: ${HOST_BAD_REDIR2:=root://localhost:10952}
2325

2426
: ${HOST_HTTP_METAMAN:=${HOST_METAMAN/root/http}}
2527
: ${HOST_HTTP_MAN1:=${HOST_MAN1/root/http}}
@@ -207,5 +209,23 @@ wait
207209

208210
${XRDFS} ${HOST_METAMAN} rmdir ${RMTDATADIR}
209211

212+
XRD_CONNECTIONRETRY=0 ${XRDFS} ${HOST_BAD_REDIR1} chmod /dkjdkjd rwx------ 2> /tmp/err.txt
213+
ret1=$?
214+
grep -q "\[FATAL\] Connection error" /tmp/err.txt
215+
ret2=$?
216+
if [ $ret1 -ne 51 -o $ret2 -ne 0 ]; then
217+
echo "${host}: bad redirect test 1 did not fail as expected"
218+
exit 1
219+
fi
220+
221+
XRD_CONNECTIONRETRY=0 ${XRDFS} ${HOST_BAD_REDIR2} chmod /dkjdkjd rwx------ 2> /tmp/err.txt
222+
ret1=$?
223+
grep -q "\[FATAL\] Invalid address" /tmp/err.txt
224+
ret2=$?
225+
if [ $ret1 -ne 51 -o $ret2 -ne 0 ]; then
226+
echo "${host}: bad redirect test 2 did not fail as expected"
227+
exit 1
228+
fi
229+
210230
echo "ALL TESTS PASSED"
211231
exit 0

0 commit comments

Comments
 (0)