librpc/rpc: make use of dcerpc_binding_set*() in dcerpc_binding_from_tower()
[Samba.git] / examples / ad-bench / time_user.sh
blob5380115628b70c5c700f0b5516008848dd938f6a
1 #!/bin/bash
2 # AD-Bench user add/remove benchmark
4 # Copyright (C) 2009 Kai Blin <kai@samba.org>
6 # This file is part of AD-Bench, an Active Directory benchmark tool
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.
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.
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/>.
21 ITERATIONS=100
23 source `dirname $0`/utils.sh
25 PRINCIPAL=$(get_principal $1)
26 PASSWORD=$(get_password $1)
27 REALM=$(get_realm $1)
28 NT_DOM=$(get_nt_dom $1)
29 SERVER=$2
31 add_user () {
32 USER=$1
33 ${NET} ads user add "${USER}" 'Sup3rS3cr3T!' -k -s $CONFIG_FILE -S ${SERVER} > /dev/null
34 RET=$?
35 if [ $RET -ne 0 ]; then
36 echo "${NET} ads user add returned error: $RET"
37 exit 1
41 del_user () {
42 USER=$1
43 ${NET} ads user delete "${USER}" -k -s $CONFIG_FILE -S ${SERVER} > /dev/null
44 RET=$?
45 if [ $RET -ne 0 ]; then
46 echo "${NET} returned error: $RET"
47 exit 1
51 enum_user () {
52 ${NET} ads user -k -s $CONFIG_FILE -S $SERVER > /dev/null
53 RET=$?
54 if [ $RET -ne 0 ]; then
55 echo "${NET} returned error: $RET"
56 exit 1
60 info_user () {
61 USER=$1
62 ${NET} ads user info "${USER}" -k -s $CONFIG_FILE -S ${SERVER} > /dev/null
63 RET=$?
64 if [ $RET -ne 0 ]; then
65 echo "${NET} returned error: $RET"
66 exit 1
70 set_up () {
71 set_krb_env
72 setup_kinit
73 call_kinit "${PRINCIPAL}" "${PASSWORD}"
74 write_configfile "${REALM}" "${NT_DOM}"
77 tear_down () {
78 ${KDESTROY}
79 restore_krb_env
82 set_up
84 echo -e "\tUSER $SERVER"
86 START_TIME=$(start_timer)
88 echo -en "\t"
89 for i in $( ${SEQ} 1 $ITERATIONS ); do
90 USER=$( echo "ad_test_$(pad_number $i 3)" )
91 add_user $USER
92 echo -n "."
93 done
94 echo "done"
96 enum_user
98 # Requires winbind, which requires root perms to start. Skip this for now
99 #echo -en "\t"
100 #for i in $( ${SEQ} 1 $ITERATIONS ); do
101 # USER=$( echo "ad_test_$(pad_number $i 3)" )
102 # info_user $USER
103 # echo -n "."
104 #done
105 #echo "done"
107 echo -en "\t"
108 for i in $( ${SEQ} 1 $ITERATIONS ); do
109 USER=$( echo "ad_test_$(pad_number $i 3)" )
110 del_user $USER
111 echo -n "."
112 done
113 echo "done"
115 STOP_TIME=$(stop_timer)
117 TOTAL_TIME=$( total_time $START_TIME $STOP_TIME )
119 echo -e "\t\ttotal time:\t\t${TOTAL_TIME}s"
121 LOGINS_PER_MINUTE=$(iterations_per_minute $START_TIME $STOP_TIME $ITERATIONS)
123 echo -e "\t\titerations/min:\t\t$LOGINS_PER_MINUTE"
125 tear_down