315
if echo "$line" | grep -q '^__OCFT__'; then
316
parse_die "reserved key word '__OCFT__'."
318
echo "declare $line" >>$CASES_DIR/${agent}_var
301
321
echo "$line" >>$CASES_DIR/${agent}_setup
324
echo "$line" >>$CASES_DIR/${agent}_cleanup
304
327
host=$(echo ${trunk[0]} | awk -F@ '{print $2}')
305
328
if [ -n "$host" ]; then
306
329
if ! echo "$hosts" | grep -q "$host"; then
330
echo "$host" >>$CASES_DIR/${agent}_hosts
307
331
hosts=$hosts$'\n'$host
309
333
# Initialize remote shell
310
334
backbash_start $host
311
335
backbash $host <<CMD
312
OCFT_VERBOSE=\$OCFT_VERBOSE
336
__OCFT__VERBOSE=\$__OCFT__VERBOSE
315
338
backbash $host <$OCFT_DIR/caselib
316
339
backbash $host <<'CMD'
317
MYROOT="$cfg_agent_root"
319
if [ -n "$cfg_install_package" ]; then
321
agent_install ${cfg_install_package[@]}
324
if [ -r "$CASES_DIR/${agent}_setup" ]; then
326
agent_setup $agent <<'END'
327
$(cat "$CASES_DIR/${agent}_setup")
340
$(test -r $CASES_DIR/${agent}_var && cat $CASES_DIR/${agent}_var)
342
__OCFT__MYROOT="$cfg_agent_root"
343
__OCFT__showhost="${host}: "
345
$(test -n "$cfg_install_package" && echo "agent_install ${cfg_install_package[@]}")
363
379
if [ -z "${branch[1]}" ]; then
364
380
if [ "${branch[0]}" = "start" ]; then
366
agent_run $(add_quotes 1 "$agent") status $cfg_hang_timeout
368
if [ \$rc -eq \$OCF_ERR_UNIMPLEMENTED ]; then
369
agent_run $(add_quotes 1 "$agent") monitor $cfg_hang_timeout
382
agent_run $(add_quotes 1 "$cfg_agent") monitor $cfg_hang_timeout
373
if [ \$rc -eq \$OCF_SUCCESS ]; then
385
if [ \$__OCFT__rc -eq \$OCF_SUCCESS -o \$__OCFT__rc -eq \$OCF_RUNNING_MASTER ]; then
374
386
: #The status I want, so I can do nothing.
375
elif [ \$rc -eq \$OCF_NOT_RUNNING ]; then
376
if [ -n "\$OCFT_VERBOSE" ]; then
377
echo $(add_quotes 2 " \${showhost}Running agent: ./$agent start")
387
elif [ \$__OCFT__rc -eq \$OCF_NOT_RUNNING ]; then
388
if [ -n "\$__OCFT__VERBOSE" ]; then
389
echo $(add_quotes 2 " \${__OCFT__showhost}Running agent: ./$cfg_agent ${branch[0]}")
379
agent_run $(add_quotes 1 "$agent") start $cfg_hang_timeout
380
check_success \$? $(add_quotes 1 "./$agent start")
391
agent_run $(add_quotes 1 "$cfg_agent") start $cfg_hang_timeout
392
check_success \$? $(add_quotes 1 "./$cfg_agent ${branch[0]}")
382
check_success \$rc $(add_quotes 1 "./$agent status|monitor")
394
check_success \$__OCFT__rc $(add_quotes 1 "./$cfg_agent monitor")
385
397
elif [ "${branch[0]}" = "stop" ]; then
387
agent_run $(add_quotes 1 "$agent") status $cfg_hang_timeout
389
if [ \$rc -eq \$OCF_ERR_UNIMPLEMENTED ]; then
390
agent_run $(add_quotes 1 "$agent") monitor $cfg_hang_timeout
399
agent_run $(add_quotes 1 "$cfg_agent") monitor $cfg_hang_timeout
394
if [ \$rc -eq \$OCF_NOT_RUNNING ]; then
402
if [ \$__OCFT__rc -eq \$OCF_NOT_RUNNING ]; then
395
403
: #The status I want, so I can do nothing.
396
elif [ \$rc -eq \$OCF_SUCCESS ]; then
397
if [ -n "\$OCFT_VERBOSE" ]; then
398
echo $(add_quotes 2 " \${showhost}Running agent: ./$agent stop")
404
elif [ \$__OCFT__rc -eq \$OCF_SUCCESS -o \$__OCFT__rc -eq \$OCF_RUNNING_MASTER ]; then
405
if [ -n "\$__OCFT__VERBOSE" ]; then
406
echo $(add_quotes 2 " \${__OCFT__showhost}Running agent: ./$cfg_agent ${branch[0]}")
400
agent_run $(add_quotes 1 "$agent") stop $cfg_hang_timeout
401
check_success \$? $(add_quotes 1 "./$agent stop")
408
agent_run $(add_quotes 1 "$cfg_agent") stop $cfg_hang_timeout
409
check_success \$? $(add_quotes 1 "./$cfg_agent ${branch[0]}")
403
check_success \$rc $(add_quotes 1 "./$agent status|monitor")
411
check_success \$__OCFT__rc $(add_quotes 1 "./$cfg_agent monitor")
406
elif [ "${branch[0]}" = "status" -o "${branch[0]}" = "monitor" ]; then
414
elif [ "${branch[0]}" = "monitor" ]; then
408
agent_run $(add_quotes 1 "$agent") $(add_quotes 1 "${branch[0]}") $cfg_hang_timeout
416
if [ -n "\$__OCFT__VERBOSE" ]; then
417
echo $(add_quotes 2 " \${__OCFT__showhost}Running agent: ./$cfg_agent ${branch[0]}")
419
agent_run $(add_quotes 1 "$cfg_agent") $(add_quotes 1 "${branch[0]}") $cfg_hang_timeout
412
agent_run $(add_quotes 1 "$agent") $(add_quotes 1 "${branch[0]}") $cfg_hang_timeout
413
check_success \$? $(add_quotes 1 "./$agent ${branch[0]}")
423
if [ -n "\$__OCFT__VERBOSE" ]; then
424
echo $(add_quotes 2 " \${__OCFT__showhost}Running agent: ./$cfg_agent ${branch[0]}")
426
agent_run $(add_quotes 1 "$cfg_agent") $(add_quotes 1 "${branch[0]}") $cfg_hang_timeout
427
check_success \$? $(add_quotes 1 "./$cfg_agent ${branch[0]}")
418
432
test -n $(add_quotes 2 "\$${branch[1]}")
419
433
check_success \$? $(add_quotes 1 "test -n \"\$${branch[1]}\"")
420
if [ -n "\$OCFT_VERBOSE" ]; then
421
echo $(add_quotes 2 " \${showhost}Running agent: ./$agent ${branch[0]}")
423
agent_run $(add_quotes 1 "$agent") $(add_quotes 1 "${branch[0]}") $cfg_hang_timeout
425
if [ -n "\$OCFT_VERBOSE" ]; then
426
echo -n " \${showhost}Checking return value:"
428
if [ -n "\${retval[ret]}" ]; then
429
retstr="\${retval[ret]}"
434
if [ -n "\$__OCFT__VERBOSE" ]; then
435
echo $(add_quotes 2 " \${__OCFT__showhost}Running agent: ./$cfg_agent ${branch[0]}")
437
agent_run $(add_quotes 1 "$cfg_agent") $(add_quotes 1 "${branch[0]}") $cfg_hang_timeout
439
if [ -n "\$__OCFT__VERBOSE" ]; then
440
echo -n " \${__OCFT__showhost}Checking return value:"
442
if [ -n "\${__OCFT__retval[__OCFT__ret]}" ]; then
443
__OCFT__retstr="\${__OCFT__retval[__OCFT__ret]}"
445
__OCFT__retstr=\$__OCFT__ret
433
if [ \$ret -eq \$${branch[1]} ]; then
434
if [ -n "\$OCFT_VERBOSE" ]; then
435
echo -e $(add_quotes 2 " \\033[32mOK\\033[0m. The return value '\\033[34m\$retstr\\033[0m' == '\\033[34m${branch[1]}\\033[0m'")
447
if [ \$__OCFT__ret -eq \$${branch[1]} ]; then
448
if [ -n "\$__OCFT__VERBOSE" ]; then
449
echo -e $(add_quotes 2 " \\033[32mOK\\033[0m. The return value '\\033[34m\$__OCFT__retstr\\033[0m' == '\\033[34m${branch[1]}\\033[0m'")
437
451
echo -e "\t\\033[32mOK\\033[0m."
440
if [ -n "\$OCFT_VERBOSE" ]; then
441
echo -en $(add_quotes 2 " \\033[31mFAILED\\033[0m. The return value '\\033[34m\$retstr\\033[0m' != '\\033[34m${branch[1]}\\033[0m'. ")
454
if [ -n "\$__OCFT__VERBOSE" ]; then
455
echo -en $(add_quotes 2 " \\033[31mFAILED\\033[0m. The return value '\\033[34m\$__OCFT__retstr\\033[0m' != '\\033[34m${branch[1]}\\033[0m'. ")
443
echo -en "\t\\033[31mFAILED\\033[0m. Agent returns unexpected value: '\$retstr'. "
457
echo -en "\t\\033[31mFAILED\\033[0m. Agent returns unexpected value: '\$__OCFT__retstr'. "
445
459
echo "See details below:"
446
460
cat /tmp/.ocft_runlog
484
498
parse_die "unimplemented statement: ${trunk[0]}"
487
done <$CASES_DIR/${agent}.preparse
488
rm -f $CASES_DIR/${agent}.preparse
489
rm -f $CASES_DIR/${agent}_setup
501
done <$CASES_DIR/${agent}_preparse
503
if [ -r "$CASES_DIR/${agent}_setup" ]; then
504
cat >$CASES_DIR/setup_${agent}.sh <<EOF
508
# Summary: SETUP before test
510
echo "Initializing '$cfg_agent' ..."
512
. $OCFT_DIR/caselib || {
513
echo "ERROR: '$OCFT_DIR/caselib' not found."
517
$(test -r "$CASES_DIR/${agent}_var" && cat $CASES_DIR/${agent}_var)
518
$(test -n "$cfg_install_package" && echo "agent_install ${cfg_install_package[@]}")
521
for host in $(test -r $CASES_DIR/${agent}_hosts && cat $CASES_DIR/${agent}_hosts); do
522
cat >>$CASES_DIR/setup_${agent}.sh <<EOF
523
# Initialize remote shell
526
__OCFT__VERBOSE=\$__OCFT__VERBOSE
528
backbash $host <$OCFT_DIR/caselib
529
backbash $host <<'CMD'
530
$(test -r "$CASES_DIR/${agent}_var" && cat $CASES_DIR/${agent}_var)
532
__OCFT__MYROOT="$cfg_agent_root"
533
__OCFT__showhost="${host}: "
535
$(test -n "$cfg_install_package" && echo "agent_install ${cfg_install_package[@]}")
537
$(cat $CASES_DIR/${agent}_setup)
538
check_success \$? "SETUP-AGENT"
543
cat >>$CASES_DIR/setup_${agent}.sh <<EOF
544
$(cat $CASES_DIR/${agent}_setup)
545
check_success \$? "SETUP-AGENT"
551
chmod a+x $CASES_DIR/setup_${agent}.sh
554
if [ -r "$CASES_DIR/${agent}_cleanup" ]; then
555
cat >$CASES_DIR/cleanup_${agent}.sh <<EOF
559
# Summary: CLEANUP after test
561
echo "Cleaning '$cfg_agent' ..."
563
. $OCFT_DIR/caselib || {
564
echo "ERROR: '$OCFT_DIR/caselib' not found."
568
$(test -r "$CASES_DIR/${agent}_var" && cat $CASES_DIR/${agent}_var)
569
$(test -n "$cfg_install_package" && echo "agent_install ${cfg_install_package[@]}")
571
$(cat $CASES_DIR/${agent}_cleanup)
572
check_success \$? "CLEANUP-AGENT"
575
for host in $(test -r $CASES_DIR/${agent}_hosts && cat $CASES_DIR/${agent}_hosts); do
576
cat >>$CASES_DIR/cleanup_${agent}.sh <<EOF
577
# Initialize remote shell
580
__OCFT__VERBOSE=\$__OCFT__VERBOSE
582
backbash $host <$OCFT_DIR/caselib
583
backbash $host <<'CMD'
584
$(test -r "$CASES_DIR/${agent}_var" && cat $CASES_DIR/${agent}_var)
586
__OCFT__MYROOT="$cfg_agent_root"
587
__OCFT__showhost="${host}: "
589
$(test -n "$cfg_install_package" && echo "agent_install ${cfg_install_package[@]}")
591
$(cat $CASES_DIR/${agent}_cleanup)
592
check_success \$? "CLEANUP-AGENT"
597
cat >>$CASES_DIR/cleanup_${agent}.sh <<EOF
602
chmod a+x $CASES_DIR/cleanup_${agent}.sh
496
local sh shs agents line ret
612
local sh shs testsh agents line ret
498
614
if ! cd $CASES_DIR >/dev/null 2>&1; then
499
615
die "cases directory not found."
502
export OCFT_VERBOSE=$opt_verbose
618
export __OCFT__VERBOSE=$opt_verbose
504
620
if [ $# -eq 0 ]; then
505
621
agents=($(ls -1 *.sh 2>/dev/null | sed 's/.*_\([^_]*\)\.sh$/\1/' | sort | uniq))