[SCM] Samba Shared Repository - branch master updated
Andrew Tridgell
tridge at samba.org
Tue Nov 23 05:02:03 MST 2010
The branch, master has been updated
via f6adad4 wintest: tidyups and new conf variables
via 3a8b67d s4-ldb: added an environment varibale LDB_WARN_UNINDEXED
from 439ff87 s4-tests: Ldap tests now use the get_dsheuristics and set_dsheuristics from SamDB.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit f6adad4d25b884ebdeccdf153d6dbbd016f5d65b
Author: Andrew Tridgell <tridge at samba.org>
Date: Tue Nov 23 20:20:18 2010 +1100
wintest: tidyups and new conf variables
Autobuild-User: Andrew Tridgell <tridge at samba.org>
Autobuild-Date: Tue Nov 23 13:01:10 CET 2010 on sn-devel-104
commit 3a8b67d06cf631f4d883ce40859401eb760bb0f3
Author: Andrew Tridgell <tridge at samba.org>
Date: Tue Nov 23 20:19:49 2010 +1100
s4-ldb: added an environment varibale LDB_WARN_UNINDEXED
when LDB_WARN_UNINDEXED is set, we produce warnings about unindexed
searches. This makes it easier to find performance problems caused by
unindexed searches.
-----------------------------------------------------------------------
Summary of changes:
source4/lib/ldb/ABI/ldb-0.9.19.sigs | 2 +-
source4/lib/ldb/common/ldb_parse.c | 2 +-
source4/lib/ldb/include/ldb.h | 2 +-
source4/lib/ldb/ldb_tdb/ldb_search.c | 14 ++++----
source4/lib/ldb/ldb_tdb/ldb_tdb.c | 4 ++
source4/lib/ldb/ldb_tdb/ldb_tdb.h | 2 +
wintest/conf/abartlet.conf | 3 ++
wintest/conf/tridge.conf | 10 +++++-
wintest/test-s4-howto.py | 53 ++++++++++++++++++++++++++++-----
wintest/wintest.py | 16 ++++------
10 files changed, 78 insertions(+), 30 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/lib/ldb/ABI/ldb-0.9.19.sigs b/source4/lib/ldb/ABI/ldb-0.9.19.sigs
index 53b6b2c..6273870 100644
--- a/source4/lib/ldb/ABI/ldb-0.9.19.sigs
+++ b/source4/lib/ldb/ABI/ldb-0.9.19.sigs
@@ -78,7 +78,7 @@ ldb_error_at: int (struct ldb_context *, int, const char *, const char *, int)
ldb_errstring: const char *(struct ldb_context *)
ldb_extended: int (struct ldb_context *, const char *, void *, struct ldb_result **)
ldb_extended_default_callback: int (struct ldb_request *, struct ldb_reply *)
-ldb_filter_from_tree: char *(TALLOC_CTX *, struct ldb_parse_tree *)
+ldb_filter_from_tree: char *(TALLOC_CTX *, const struct ldb_parse_tree *)
ldb_get_config_basedn: struct ldb_dn *(struct ldb_context *)
ldb_get_create_perms: unsigned int (struct ldb_context *)
ldb_get_default_basedn: struct ldb_dn *(struct ldb_context *)
diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c
index 16b3e21..b4eabf8 100644
--- a/source4/lib/ldb/common/ldb_parse.c
+++ b/source4/lib/ldb/common/ldb_parse.c
@@ -679,7 +679,7 @@ struct ldb_parse_tree *ldb_parse_tree(TALLOC_CTX *mem_ctx, const char *s)
/*
construct a ldap parse filter given a parse tree
*/
-char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, struct ldb_parse_tree *tree)
+char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, const struct ldb_parse_tree *tree)
{
char *s, *s2, *ret;
unsigned int i;
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index eeb939a..1deed84 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -314,7 +314,7 @@ struct ldb_parse_tree {
};
struct ldb_parse_tree *ldb_parse_tree(TALLOC_CTX *mem_ctx, const char *s);
-char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, struct ldb_parse_tree *tree);
+char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, const struct ldb_parse_tree *tree);
/**
Encode a binary blob
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index 5df1e4d..b58243c 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -578,13 +578,13 @@ int ltdb_search(struct ltdb_context *ctx)
* callback error */
if ( ! ctx->request_terminated && ret != LDB_SUCCESS) {
/* Not indexed, so we need to do a full scan */
-#if 0
- /* useful for debugging when slow performance
- * is caused by unindexed searches */
- char *expression = ldb_filter_from_tree(ctx, ctx->tree);
- printf("FULL SEARCH: %s\n", expression);
- talloc_free(expression);
-#endif
+ if (ltdb->warn_unindexed) {
+ /* useful for debugging when slow performance
+ * is caused by unindexed searches */
+ char *expression = ldb_filter_from_tree(ctx, ctx->tree);
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb FULL SEARCH: %s\n", expression);
+ talloc_free(expression);
+ }
if (match_count != 0) {
/* the indexing code gave an error
* after having returned at least one
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 2e88989..066d408 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -1463,6 +1463,10 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url,
return LDB_ERR_OPERATIONS_ERROR;
}
+ if (getenv("LDB_WARN_UNINDEXED")) {
+ ltdb->warn_unindexed = true;
+ }
+
ltdb->sequence_number = 0;
module = ldb_module_new(ldb, ldb, "ldb_tdb backend", <db_ops);
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
index 493c276..33313b0 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
@@ -34,6 +34,8 @@ struct ltdb_private {
struct ltdb_idxptr *idxptr;
bool prepared_commit;
int read_lock_count;
+
+ bool warn_unindexed;
};
/*
diff --git a/wintest/conf/abartlet.conf b/wintest/conf/abartlet.conf
index ea8a5cf..fb0a590 100644
--- a/wintest/conf/abartlet.conf
+++ b/wintest/conf/abartlet.conf
@@ -15,6 +15,9 @@ VM_RESTORE : virsh snapshot-revert ${VMNAME} ${SNAPSHOT}
# interfaces to create
INTERFACE : virbr0:0
+
+# this is an additional IP that will be used for named to listen
+# on. It should not be the primary IP of the interface
INTERFACE_IP : 192.168.122.2
INTERFACE_NET : 192.168.122.0/24
diff --git a/wintest/conf/tridge.conf b/wintest/conf/tridge.conf
index 1288526..f5081ed 100644
--- a/wintest/conf/tridge.conf
+++ b/wintest/conf/tridge.conf
@@ -14,11 +14,17 @@ VM_POWEROFF : su tridge -c "VBoxManage controlvm ${VMNAME} poweroff"
VM_RESTORE : su tridge -c "VBoxManage snapshot ${VMNAME} restore ${SNAPSHOT} && VBoxManage startvm ${VMNAME}"
# interfaces to listen on
-INTERFACES : virbr0
+INTERFACE : virbr0:0
+
+# this is an additional IP that will be used for named to listen
+# on. It should not be the primary IP of the interface
+INTERFACE_IP : 10.0.0.2
+INTERFACE_NET : 10.0.0.0/24
# how to run bind9
-BIND9 : /usr/sbin/named -u bind
+BIND9 : /usr/sbin/named
RNDC : /usr/sbin/rndc
+BIND_USER : bind
# provision information
REALM : HOWTO.TRIDGELL.NET
diff --git a/wintest/test-s4-howto.py b/wintest/test-s4-howto.py
index b28370a..ec96581 100755
--- a/wintest/test-s4-howto.py
+++ b/wintest/test-s4-howto.py
@@ -14,6 +14,7 @@ def check_prerequesites(t):
t.putenv("KRB5_CONFIG", '${PREFIX}/private/krb5.conf')
t.run_cmd('ifconfig ${INTERFACE} ${INTERFACE_IP} up')
+
def build_s4(t):
'''build samba4'''
t.info('Building s4')
@@ -24,6 +25,7 @@ def build_s4(t):
t.run_cmd('rm -rf ${PREFIX}')
t.run_cmd('make -j install')
+
def provision_s4(t, func_level="2008", interface=None):
'''provision s4 as a DC'''
t.info('Provisioning s4')
@@ -38,7 +40,9 @@ def provision_s4(t, func_level="2008", interface=None):
t.run_cmd('bin/samba-tool newuser testdenied ${PASSWORD1}')
t.run_cmd('bin/samba-tool group addmembers "Allowed RODC Password Replication Group" testallowed')
+
def start_s4(t, interface=None):
+ '''startup samba4'''
t.info('Starting Samba4')
t.chdir("${PREFIX}")
t.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail=False)
@@ -47,7 +51,9 @@ def start_s4(t, interface=None):
'--option', 'interfaces=%s' % interface])
t.port_wait("localhost", 139)
+
def test_smbclient(t):
+ '''test smbclient'''
t.info('Testing smbclient')
t.chdir('${PREFIX}')
t.cmd_contains("bin/smbclient --version", ["Version 4.0"])
@@ -63,7 +69,9 @@ def test_smbclient(t):
child.sendline("cd ..")
child.sendline("rmdir testdir")
+
def create_shares(t):
+ '''create some test shares'''
t.info("Adding test shares")
t.chdir('${PREFIX}')
t.write_file("etc/smb.conf", '''
@@ -80,6 +88,7 @@ def create_shares(t):
def restart_bind(t):
+ '''restart the test environment version of bind'''
t.info("Restarting bind9")
t.putenv('KEYTAB_FILE', '${PREFIX}/private/dns.keytab')
t.putenv('KRB5_KTNAME', '${PREFIX}/private/dns.keytab')
@@ -88,7 +97,7 @@ def restart_bind(t):
t.run_cmd("chown -R ${BIND_USER} var/named")
nameserver = t.get_nameserver()
- if nameserver == t.vars['INTERFACE_IP']:
+ if nameserver == t.getvar('INTERFACE_IP'):
raise RuntimeError("old /etc/resolv.conf must not contain %s as a nameserver, this will create loops with the generated dns configuration")
t.setvar('DNSSERVER', nameserver)
@@ -138,10 +147,10 @@ options {
default-port 953;
};
''')
-
+
t.run_cmd("${RNDC} -c ${PREFIX}/etc/rndc.conf stop", checkfail=False)
t.port_wait("${INTERFACE_IP}", 53, wait_for_fail=True)
- t.bind_child = t.run_child("${BIND9} -u ${BIND_USER} -c ${PREFIX}/etc/named.conf -g")
+ t.bind_child = t.run_child("${BIND9} -u ${BIND_USER} -n 1 -c ${PREFIX}/etc/named.conf -g")
t.run_cmd("mv -f /etc/resolv.conf /etc/resolv.conf.wintest-bak")
t.write_file("/etc/resolv.conf", '''
@@ -162,11 +171,15 @@ nameserver ${INTERFACE_IP}
t.run_cmd("${RNDC} -c ${PREFIX}/etc/rndc.conf freeze")
t.run_cmd("${RNDC} -c ${PREFIX}/etc/rndc.conf thaw")
+
def restore_resolv_conf(t):
+ '''restore the /etc/resolv.conf after testing is complete'''
if getattr(t, 'resolv_conf_backup', False):
t.run_cmd("mv -f %s /etc/resolv.conf" % t.resolv_conf_backup)
+
def test_dns(t):
+ '''test that DNS is OK'''
t.info("Testing DNS")
t.cmd_contains("host -t SRV _ldap._tcp.${LCREALM}.",
['_ldap._tcp.${LCREALM} has SRV record 0 100 389 ${HOSTNAME}.${LCREALM}'])
@@ -176,6 +189,7 @@ def test_dns(t):
['${HOSTNAME}.${LCREALM} has address'])
def test_kerberos(t):
+ '''test that kerberos is OK'''
t.info("Testing kerberos")
t.run_cmd("kdestroy")
t.kinit("administrator@${REALM}", "${PASSWORD1}")
@@ -183,12 +197,14 @@ def test_kerberos(t):
def test_dyndns(t):
+ '''test that dynamic DNS is working'''
t.chdir('${PREFIX}')
t.run_cmd("sbin/samba_dnsupdate --fail-immediately")
t.run_cmd("${RNDC} -c ${PREFIX}/etc/rndc.conf flush")
def run_winjoin(t, vm):
+ '''join a windows box to our domain'''
t.setwinvars(vm)
t.info("Joining a windows box to the domain")
@@ -264,6 +280,7 @@ SafeModeAdminPassword=${PASSWORD1}
def test_dcpromo(t, vm):
+ '''test that dcpromo worked'''
t.setwinvars(vm)
t.info("Checking the dcpromo join is OK")
t.chdir('${PREFIX}')
@@ -361,6 +378,7 @@ def test_dcpromo(t, vm):
def run_dcpromo_rodc(t, vm):
+ '''run a RODC dcpromo to join a windows DC to the samba domain'''
t.setwinvars(vm)
t.info("Joining a w2k8 box to the domain as a RODC")
t.vm_poweroff("${WIN_VM}", checkfail=False)
@@ -405,6 +423,7 @@ RebootOnCompletion=No
def test_dcpromo_rodc(t, vm):
+ '''test the RODC dcpromo worked'''
t.setwinvars(vm)
t.info("Checking the w2k8 RODC join is OK")
t.chdir('${PREFIX}')
@@ -427,14 +446,18 @@ def test_dcpromo_rodc(t, vm):
t.info("Checking if new users are available on windows")
t.run_cmd('bin/samba-tool newuser test2 ${PASSWORD2}')
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k no", ['Sharename', 'Remote IPC'])
t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k yes", ['Sharename', 'Remote IPC'])
+ t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k no", ['LOGON_FAILURE'])
+ t.retry_cmd("bin/samba-tool drs replicate ${WIN_HOSTNAME} ${HOSTNAME} ${BASEDN} -k yes", ["was successful"])
+ t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k no", ['Sharename', 'Remote IPC'])
t.run_cmd('bin/samba-tool user delete test2 -Uadministrator@${LCREALM}%${PASSWORD1}')
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2}", ['LOGON_FAILURE'])
+ t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k yes", ['LOGON_FAILURE'])
+ t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k no", ['LOGON_FAILURE'])
t.vm_poweroff("${WIN_VM}")
def join_as_dc(t, vm):
+ '''join a windows domain as a DC'''
t.setwinvars(vm)
t.info("Joining ${WIN_VM} as a second DC using samba-tool join DC")
t.chdir('${PREFIX}')
@@ -450,6 +473,7 @@ def join_as_dc(t, vm):
def test_join_as_dc(t, vm):
+ '''test the join of a windows domain as a DC'''
t.setwinvars(vm)
t.info("Checking the DC join is OK")
t.chdir('${PREFIX}')
@@ -502,6 +526,7 @@ def test_join_as_dc(t, vm):
def join_as_rodc(t, vm):
+ '''join a windows domain as a RODC'''
t.setwinvars(vm)
t.info("Joining ${WIN_VM} as a RODC using samba-tool join DC")
t.chdir('${PREFIX}')
@@ -517,6 +542,7 @@ def join_as_rodc(t, vm):
def test_join_as_rodc(t, vm):
+ '''test a windows domain RODC join'''
t.setwinvars(vm)
t.info("Checking the RODC join is OK")
t.chdir('${PREFIX}')
@@ -661,6 +687,13 @@ def test_howto(t):
t.info("Howto test: All OK")
+def test_cleanup(t):
+ '''cleanup after tests'''
+ restore_resolv_conf(t)
+ if getattr(t, 'bind_child', False):
+ t.bind_child.kill()
+
+
if __name__ == '__main__':
parser = optparse.OptionParser("test-howto.py")
parser.add_option("--conf", type='string', default='', help='config file')
@@ -670,6 +703,7 @@ if __name__ == '__main__':
parser.add_option("--clean", action='store_true', default=False, help='clean the tree')
parser.add_option("--prefix", type='string', default=None, help='override install prefix')
parser.add_option("--sourcetree", type='string', default=None, help='override sourcetree location')
+ parser.add_option("--nocleanup", action='store_true', default=False, help='disable cleanup code')
opts, args = parser.parse_args()
@@ -703,7 +737,10 @@ if __name__ == '__main__':
try:
test_howto(t)
except Exception, str:
- restore_resolv_conf(t)
- if getattr(t, 'bind_child', False):
- t.bind_child.kill()
+ if not opts.nocleanup:
+ test_cleanup(t)
raise
+
+ if not opts.nocleanup:
+ test_cleanup(t)
+ t.info("S4 howto test: All OK")
diff --git a/wintest/wintest.py b/wintest/wintest.py
index 4c93017..d7ca5fe 100644
--- a/wintest/wintest.py
+++ b/wintest/wintest.py
@@ -17,6 +17,10 @@ class wintest():
'''set a substitution variable'''
self.vars[varname] = value
+ def getvar(self, varname):
+ '''return a substitution variable'''
+ return self.vars[varname]
+
def setwinvars(self, vm, prefix='WIN'):
'''setup WIN_XX vars based on a vm name'''
for v in ['VM', 'HOSTNAME', 'USER', 'PASS', 'SNAPSHOT', 'BASEDN', 'REALM', 'DOMAIN']:
@@ -282,12 +286,6 @@ class wintest():
child.expect('Ethernet adapter ')
child.expect("[\w\s]+")
self.setvar("WIN_NIC", child.after)
- child.expect(['DHCP Enabled', 'Dhcp Enabled'])
- i = child.expect(['Yes', 'No'])
- if i == 0:
- self.setvar("WIN_DHCP", True)
- else:
- self.setvar("WIN_DHCP", False)
child.expect(['IPv4 Address', 'IP Address'])
child.expect('\d+.\d+.\d+.\d+')
self.setvar('WIN_IPV4_ADDRESS', child.after)
@@ -324,12 +322,10 @@ class wintest():
return False
def set_ip(self, child):
- '''fix the IP address to the same value it had when we
+ """fix the IP address to the same value it had when we
connected, but don't use DHCP, and force the DNS server to our
- DNS server. This allows DNS updates to run'''
+ DNS server. This allows DNS updates to run"""
self.get_ipconfig(child)
- if self.vars['WIN_DHCP'] is False:
- return False
child.sendline('netsh')
child.expect('netsh>')
child.sendline('offline')
--
Samba Shared Repository
More information about the samba-cvs
mailing list