xref: /netbsd-src/external/bsd/openldap/dist/tests/scripts/lloadd-all (revision e670fd5c413e99c2f6a37901bb21c537fcd322d2)
1*e670fd5cSchristos#! /bin/sh
2*e670fd5cSchristos# $OpenLDAP$
3*e670fd5cSchristos## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4*e670fd5cSchristos##
5*e670fd5cSchristos## Copyright 1998-2021 The OpenLDAP Foundation.
6*e670fd5cSchristos## All rights reserved.
7*e670fd5cSchristos##
8*e670fd5cSchristos## Redistribution and use in source and binary forms, with or without
9*e670fd5cSchristos## modification, are permitted only as authorized by the OpenLDAP
10*e670fd5cSchristos## Public License.
11*e670fd5cSchristos##
12*e670fd5cSchristos## A copy of this license is available in the file LICENSE in the
13*e670fd5cSchristos## top-level directory of the distribution or, alternatively, at
14*e670fd5cSchristos## <http://www.OpenLDAP.org/license.html>.
15*e670fd5cSchristos
16*e670fd5cSchristos. $SRCDIR/scripts/defines.sh
17*e670fd5cSchristos
18*e670fd5cSchristosTB="" TN=""
19*e670fd5cSchristosif test -t 1 ; then
20*e670fd5cSchristos    TB=`$SHTOOL echo -e "%B" 2>/dev/null`
21*e670fd5cSchristos    TN=`$SHTOOL echo -e "%b" 2>/dev/null`
22*e670fd5cSchristosfi
23*e670fd5cSchristos
24*e670fd5cSchristosFAILCOUNT=0
25*e670fd5cSchristosSKIPCOUNT=0
26*e670fd5cSchristosSLEEPTIME=10
27*e670fd5cSchristos
28*e670fd5cSchristosecho ">>>>> Executing all LDAP tests for the Load Balancer"
29*e670fd5cSchristos
30*e670fd5cSchristosif [ -n "$NOEXIT" ]; then
31*e670fd5cSchristos    echo "Result    Test" > $TESTWD/results
32*e670fd5cSchristosfi
33*e670fd5cSchristos
34*e670fd5cSchristosfor CMD in $SRCDIR/scripts/lloadd/test*; do
35*e670fd5cSchristos    case "$CMD" in
36*e670fd5cSchristos        *~)        continue;;
37*e670fd5cSchristos        *.bak)    continue;;
38*e670fd5cSchristos        *.orig)    continue;;
39*e670fd5cSchristos        *.sav)    continue;;
40*e670fd5cSchristos        *)        test -f "$CMD" || continue;;
41*e670fd5cSchristos    esac
42*e670fd5cSchristos
43*e670fd5cSchristos    # remove cruft from prior test
44*e670fd5cSchristos    if test $PRESERVE = yes ; then
45*e670fd5cSchristos        /bin/rm -rf $TESTDIR/db.*
46*e670fd5cSchristos    else
47*e670fd5cSchristos        /bin/rm -rf $TESTDIR
48*e670fd5cSchristos    fi
49*e670fd5cSchristos    if test $BACKEND = ndb ; then
50*e670fd5cSchristos        mysql --user root <<EOF
51*e670fd5cSchristos        drop database if exists db_1;
52*e670fd5cSchristos        drop database if exists db_2;
53*e670fd5cSchristos        drop database if exists db_3;
54*e670fd5cSchristos        drop database if exists db_4;
55*e670fd5cSchristos        drop database if exists db_5;
56*e670fd5cSchristos        drop database if exists db_6;
57*e670fd5cSchristosEOF
58*e670fd5cSchristos    fi
59*e670fd5cSchristos
60*e670fd5cSchristos    BCMD=`basename $CMD`
61*e670fd5cSchristos    if [ -x "$CMD" ]; then
62*e670fd5cSchristos        echo ">>>>> Starting ${TB}$BCMD${TN} for $BACKEND..."
63*e670fd5cSchristos        START=`date +%s`
64*e670fd5cSchristos        $CMD
65*e670fd5cSchristos        RC=$?
66*e670fd5cSchristos        END=`date +%s`
67*e670fd5cSchristos
68*e670fd5cSchristos        if test $RC -eq 0 ; then
69*e670fd5cSchristos            echo ">>>>> $BCMD completed ${TB}OK${TN} for $BACKEND after $(( $END - $START )) seconds."
70*e670fd5cSchristos        else
71*e670fd5cSchristos            echo ">>>>> $BCMD ${TB}failed${TN} for $BACKEND after $(( $END - $START )) seconds"
72*e670fd5cSchristos            FAILCOUNT=`expr $FAILCOUNT + 1`
73*e670fd5cSchristos
74*e670fd5cSchristos            if [ -n "$NOEXIT" ]; then
75*e670fd5cSchristos                echo "Continuing."
76*e670fd5cSchristos            else
77*e670fd5cSchristos                echo "(exit $RC)"
78*e670fd5cSchristos                exit $RC
79*e670fd5cSchristos            fi
80*e670fd5cSchristos        fi
81*e670fd5cSchristos    else
82*e670fd5cSchristos        echo ">>>>> Skipping ${TB}$BCMD${TN} for $BACKEND."
83*e670fd5cSchristos        SKIPCOUNT=`expr $SKIPCOUNT + 1`
84*e670fd5cSchristos        RC="-"
85*e670fd5cSchristos    fi
86*e670fd5cSchristos
87*e670fd5cSchristos    if [ -n "$NOEXIT" ]; then
88*e670fd5cSchristos        echo "$RC    $BCMD" >> $TESTWD/results
89*e670fd5cSchristos    fi
90*e670fd5cSchristos
91*e670fd5cSchristos#    echo ">>>>> waiting $SLEEPTIME seconds for things to exit"
92*e670fd5cSchristos#    sleep $SLEEPTIME
93*e670fd5cSchristos    echo ""
94*e670fd5cSchristosdone
95*e670fd5cSchristos
96*e670fd5cSchristosif [ -n "$NOEXIT" ]; then
97*e670fd5cSchristos    if [ "$FAILCOUNT" -gt 0 ]; then
98*e670fd5cSchristos        cat $TESTWD/results
99*e670fd5cSchristos        echo "$FAILCOUNT tests for $BACKEND ${TB}failed${TN}. Please review the test log."
100*e670fd5cSchristos    else
101*e670fd5cSchristos        echo "All executed tests for $BACKEND ${TB}succeeded${TN}."
102*e670fd5cSchristos    fi
103*e670fd5cSchristosfi
104*e670fd5cSchristos
105*e670fd5cSchristosecho "$SKIPCOUNT tests for the Load Balancer were ${TB}skipped${TN}."
106