s4/torture: Fix misplaced positional arguments for u64 comparison
[gd/samba-autobuild/.git] / examples / ad-bench / time_join.sh
1 #!/bin/bash
2 # AD-Bench Machine join/part benchmark
3 #
4 # Copyright (C) 2009  Kai Blin  <kai@samba.org>
5 #
6 # This file is part of AD-Bench, an Active Directory benchmark tool
7 #
8 # AD-Bench is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # AD-Bench is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with AD-Bench.  If not, see <http://www.gnu.org/licenses/>.
20
21 ITERATIONS=100
22
23 source $(dirname $0)/utils.sh
24
25 PRINCIPAL=$(get_principal $1)
26 PASSWORD=$(get_password $1)
27 REALM=$(get_realm $1)
28 NT_DOM=$(get_nt_dom $1)
29
30 join_domain()
31 {
32         SERVER=$1
33         ${NET} ads join -k --configfile=$CONFIG_FILE -S ${SERVER} >/dev/null
34         RET=$?
35         if [ $RET -ne 0 ]; then
36                 echo "${NET} returned error: $RET"
37                 exit 1
38         fi
39 }
40
41 leave_domain()
42 {
43         SERVER=$1
44         ${NET} ads leave -k --configfile=$CONFIG_FILE -S ${SERVER} >/dev/null
45         if [ $RET -ne 0 ]; then
46                 echo "${NET} returned error: $RET"
47                 exit 1
48         fi
49 }
50
51 set_up()
52 {
53         set_krb_env
54         setup_kinit
55         call_kinit "${PRINCIPAL}" "${PASSWORD}"
56         write_configfile "${REALM}" "${NT_DOM}"
57 }
58
59 tear_down()
60 {
61         ${KDESTROY}
62         restore_krb_env
63 }
64
65 set_up
66
67 echo -e "\tJOIN $2"
68
69 START_TIME=$(start_timer)
70
71 echo -en "\t"
72 for i in $(${SEQ} 1 $ITERATIONS); do
73         join_domain $2
74         leave_domain $2
75         echo -n "."
76 done
77 echo "done"
78
79 STOP_TIME=$(stop_timer)
80
81 TOTAL_TIME=$(total_time $START_TIME $STOP_TIME)
82
83 echo -e "\t\ttotal time:\t\t${TOTAL_TIME}s"
84
85 LOGINS_PER_MINUTE=$(iterations_per_minute $START_TIME $STOP_TIME $ITERATIONS)
86
87 echo -e "\t\titerations/min:\t\t$LOGINS_PER_MINUTE"
88
89 tear_down