Merge tag 'samba-4.6.2' into v4-6-test
[Samba.git] / examples / ad-bench / time_ldap.sh
blob586c56873ebbce327d39c2938664edb553bcad9c
1 #!/bin/bash
3 ITERATIONS=100
5 source `dirname $0`/utils.sh
7 PRINCIPAL=$(get_principal $1)
8 PASSWORD=$(get_password $1)
9 REALM=$(get_realm $1)
10 NT_DOM=$(get_nt_dom $1)
11 SERVER=$2
13 search_users () {
14 ${NET} ads search '(objectCategory=user)' sAMAccountName -k -s $CONFIG_FILE -S ${SERVER} > /dev/null
15 RET=$?
16 if [ $RET -ne 0 ]; then
17 echo "${NET} returned error: $RET"
18 exit 1
22 search_groups () {
23 ${NET} ads search '(objectCategory=group)' sAMAccountName -k -s $CONFIG_FILE -S ${SERVER} > /dev/null
24 if [ $RET -ne 0 ]; then
25 echo "${NET} returned error: $RET"
26 exit 1
30 search_computers () {
31 ${NET} ads search '(objectCategory=computer)' sAMAccountName -k -s $CONFIG_FILE -S ${SERVER} > /dev/null
32 if [ $RET -ne 0 ]; then
33 echo "${NET} returned error: $RET"
34 exit 1
38 search_wildcard () {
39 ${NET} ads search '(objectCategory=*)' sAMAccountName -k -s $CONFIG_FILE -S ${SERVER} > /dev/null
40 if [ $RET -ne 0 ]; then
41 echo "${NET} returned error: $RET"
42 exit 1
46 search_unindexed () {
47 ${NET} ads search '(description=Built-in account for adminstering the computer/domain)' sAMAccountName -k -s $CONFIG_FILE -S ${SERVER} > /dev/null
48 if [ $RET -ne 0 ]; then
49 echo "${NET} returned error: $RET"
50 exit 1
54 set_up () {
55 set_krb_env
56 setup_kinit
57 call_kinit "${PRINCIPAL}" "${PASSWORD}"
58 write_configfile "${REALM}" "${NT_DOM}"
61 tear_down () {
62 ${KDESTROY}
63 restore_krb_env
66 set_up
68 echo -e "\tSEARCH INDEXED $2"
70 START_TIME=$(start_timer)
72 echo -en "\t"
73 for i in $( ${SEQ} 1 $ITERATIONS ); do
74 search_users
75 search_groups
76 search_computers
77 echo -n "."
78 done
79 echo "done"
81 STOP_TIME=$(stop_timer)
83 TOTAL_TIME=$( total_time $START_TIME $STOP_TIME )
85 echo -e "\t\ttotal time:\t\t${TOTAL_TIME}s"
87 LOGINS_PER_MINUTE=$(iterations_per_minute $START_TIME $STOP_TIME $ITERATIONS)
89 echo -e "\t\titerations/min:\t\t$LOGINS_PER_MINUTE"
91 ########################
93 echo -e "\tSEARCH WILDCARD $2"
95 START_TIME=$(start_timer)
97 echo -en "\t"
98 for i in $( ${SEQ} 1 $ITERATIONS ); do
99 search_wildcard
100 echo -n "."
101 done
102 echo "done"
104 STOP_TIME=$(stop_timer)
106 TOTAL_TIME=$( total_time $START_TIME $STOP_TIME )
108 echo -e "\t\ttotal time:\t\t${TOTAL_TIME}s"
110 LOGINS_PER_MINUTE=$(iterations_per_minute $START_TIME $STOP_TIME $ITERATIONS)
112 echo -e "\t\titerations/min:\t\t$LOGINS_PER_MINUTE"
114 ########################
116 echo -e "\tSEARCH UNINDEXED $2"
118 START_TIME=$(start_timer)
120 echo -en "\t"
121 for i in $( ${SEQ} 1 $ITERATIONS ); do
122 search_unindexed
123 echo -n "."
124 done
125 echo "done"
127 STOP_TIME=$(stop_timer)
129 TOTAL_TIME=$( total_time $START_TIME $STOP_TIME )
131 echo -e "\t\ttotal time:\t\t${TOTAL_TIME}s"
133 LOGINS_PER_MINUTE=$(iterations_per_minute $START_TIME $STOP_TIME $ITERATIONS)
135 echo -e "\t\titerations/min:\t\t$LOGINS_PER_MINUTE"
137 tear_down