3 # Test smbd let cleanup registered ip addresses in a multichannel
8 echo Usage
: test_smbXsrv_client_ctdb_registered_ips.sh SERVERCONFFILE CTDB_IFACE_IP SHARENAME
16 SMBCLIENT
="$BINDIR/smbclient"
17 SMBSTATUS
="$BINDIR/smbstatus"
19 TIMELIMIT
="$BINDIR/timelimit"
21 incdir
=$
(dirname "$0")/..
/..
/..
/testprogs
/blackbox
22 .
"$incdir"/subunit.sh
34 subunit_start_test
"$name"
35 output
=$
($VALGRIND $SMBCLIENT //$server/$share -c "$cmd" "$@" 2>&1)
37 if [ x
$status = x0
]; then
38 subunit_pass_test
"$name"
40 echo "$output" | subunit_fail_test
"$name"
45 cd "$SELFTEST_TMPDIR" ||
exit 1
47 # Create the smbclient communication pipes.
48 rm -f smbclient1-stdin smbclient1-stdout smbclient1-stderr
49 mkfifo smbclient1-stdin smbclient1-stdout smbclient1-stderr
50 rm -f smbclient2-stdin smbclient2-stdout smbclient2-stderr
51 mkfifo smbclient2-stdin smbclient2-stdout smbclient2-stderr
53 smbstatus_num_sessions
()
55 # We don't check for died processes
56 UID_WRAPPER_INITIAL_RUID
=0 UID_WRAPPER_INITIAL_EUID
=0 "$SMBSTATUS" "$CONF" --fast --json | jq
-M '.sessions | length'
61 UID_WRAPPER_INITIAL_RUID
=0 UID_WRAPPER_INITIAL_EUID
=0 "$CTDB" addip
${CTDB_IFACE_IP}/24 lo
62 UID_WRAPPER_INITIAL_RUID
=0 UID_WRAPPER_INITIAL_EUID
=0 "$CTDB" ipreallocate
67 UID_WRAPPER_INITIAL_RUID
=0 UID_WRAPPER_INITIAL_EUID
=0 "$CTDB" ip
72 UID_WRAPPER_INITIAL_RUID
=0 UID_WRAPPER_INITIAL_EUID
=0 "$CTDB" gettickles
${CTDB_IFACE_IP}
75 ctdb_reload_public_ips
()
77 UID_WRAPPER_INITIAL_RUID
=0 UID_WRAPPER_INITIAL_EUID
=0 "$CTDB" reloadips
0
78 UID_WRAPPER_INITIAL_RUID
=0 UID_WRAPPER_INITIAL_EUID
=0 "$CTDB" ipreallocate
81 testit_grep_count
"step1: smbstatus 0 sessions" '^0$' 1 smbstatus_num_sessions || failed
=$
(expr $failed + 1)
83 test_smbclient
"step2: smbclient against node0[${CTDB_IFACE_IP}]" "${CTDB_IFACE_IP}" "${SHARE}" "ls" -U"${DC_USERNAME}"%"${DC_PASSWORD}" \
84 --option="libsmb:client_guid=6112f7d3-9528-4a2a-8861-0ca129aae6c4" \
85 || failed
=$
(expr $failed + 1)
87 testit_grep_count
"step2: smbstatus 0 sessions" '^0$' 1 smbstatus_num_sessions || failed
=$
(expr $failed + 1)
89 CLI_FORCE_INTERACTIVE
=1
90 export CLI_FORCE_INTERACTIVE
92 testit
"step3: start backgroup smbclient against node0[${CTDB_IFACE_IP}]" true || failed
=$
(expr $failed + 1)
94 # Connect a first time
95 ${SMBCLIENT} //"${CTDB_IFACE_IP}"/"${SHARE}" -U"${DC_USERNAME}"%"${DC_PASSWORD}" \
96 --option="libsmb
:client_guid
=6112f7d3-9528-4a2a-8861-0ca129aae6c4
" \
97 <smbclient1-stdin >smbclient1-stdout 2>smbclient1-stderr &
100 exec 100>smbclient1-stdin 101<smbclient1-stdout 102<smbclient1-stderr
102 testit_grep_count "step3
: smbclient1-stdout
" 'Try "help" to get a list of possible commands.' 1 $TIMELIMIT 15 head -1 smbclient1-stdout || failed=$(expr $failed + 1)
104 testit_grep_count "step3
: smbstatus
1 session
" '^1$' 1 smbstatus_num_sessions || failed=$(expr $failed + 1)
106 testit_grep_count "step3
: ctdb_ip
" "${CTDB_IFACE_IP}" 0 ctdb_ip || failed=$(expr $failed + 1)
107 testit_expect_failure_grep "step3
: ctdb_gettickles
" "Control GET_TCP_TICKLE_LIST failed
" ctdb_gettickles || failed=$(expr $failed + 1)
109 testit "step4
: ctdb_add_public_ip
" ctdb_add_public_ip || failed=$(expr $failed + 1)
111 testit_grep_count "step4
: ctdb_ip
" "^
${CTDB_IFACE_IP} 0\$
" 1 ctdb_ip || failed=$(expr $failed + 1)
112 testit_grep_count "step4
: ctdb_gettickles
" "Num connections
: 0" 1 ctdb_gettickles || failed=$(expr $failed + 1)
114 testit "step5
: start backgroup
2nd smbclient against node0
[${CTDB_IFACE_IP}]" true || failed=$(expr $failed + 1)
115 # Connect a second time
116 ${SMBCLIENT} //"${CTDB_IFACE_IP}"/"${SHARE}" -U"${DC_USERNAME}"%"${DC_PASSWORD}" \
117 --option="libsmb:client_guid=6112f7d3-9528-4a2a-8861-0ca129aae6c4" \
118 <smbclient2-stdin
>smbclient2-stdout
2>smbclient2-stderr
&
121 exec 200>smbclient2-stdin
201<smbclient2-stdout
202<smbclient2-stderr
123 testit_grep_count
"step5: smbclient2-stdout" 'Try "help" to get a list of possible commands.' 1 $TIMELIMIT 15 head -1 smbclient2-stdout || failed
=$
(expr $failed + 1)
125 testit_grep_count
"step5: smbstatus 2 session" '^2$' 1 smbstatus_num_sessions || failed
=$
(expr $failed + 1)
127 # Only one connection was registered with the public address
128 testit_grep_count
"step5: ctdb_ip" "^${CTDB_IFACE_IP} 0\$" 1 ctdb_ip || failed
=$
(expr $failed + 1)
129 testit_grep_count
"step5: ctdb_gettickles NUM" "Num connections: 1" 1 ctdb_gettickles || failed
=$
(expr $failed + 1)
130 testit_grep_count
"step5: ctdb_gettickles DST" "DST: ${CTDB_IFACE_IP}" 1 ctdb_gettickles || failed
=$
(expr $failed + 1)
132 unset CLI_FORCE_INTERACTIVE
135 rm -f smbclient1-stdin smbclient1-stdout smbclient1-stderr
137 testit
"step6: sleep 1 second" true || failed
=$
(expr $failed + 1)
140 testit_grep_count
"step6: smbstatus 1 session" '^1$' 1 smbstatus_num_sessions || failed
=$
(expr $failed + 1)
142 testit_grep_count
"step6: ctdb_ip" "^${CTDB_IFACE_IP} 0\$" 1 ctdb_ip || failed
=$
(expr $failed + 1)
143 testit_grep_count
"step6: ctdb_gettickles NUM" "Num connections: 1" 1 ctdb_gettickles || failed
=$
(expr $failed + 1)
144 testit_grep_count
"step6: ctdb_gettickles DST" "DST: ${CTDB_IFACE_IP}" 1 ctdb_gettickles || failed
=$
(expr $failed + 1)
146 testit
"step7: ctdb_reload_public_ips" ctdb_reload_public_ips || failed
=$
(expr $failed + 1)
148 testit_grep_count
"step7: ctdb_ip" "${CTDB_IFACE_IP}" 0 ctdb_ip || failed
=$
(expr $failed + 1)
149 testit_expect_failure_grep
"step3: ctdb_gettickles" "Control GET_TCP_TICKLE_LIST failed" ctdb_gettickles || failed
=$
(expr $failed + 1)
151 testit
"step7: sleep 2 second" true || failed
=$
(expr $failed + 1)
154 testit_grep_count
"step7: smbstatus 0 sessions" '^0$' 1 smbstatus_num_sessions || failed
=$
(expr $failed + 1)
157 rm -f smbclient2-stdin smbclient2-stdout smbclient2-stderr
159 testok
"$0" "$failed"