From: Tim Beale Date: Thu, 11 Oct 2018 01:47:28 +0000 (+1300) Subject: traffic_replay: Generate users faster by writing to local DB X-Git-Tag: tdb-1.3.17~1105 X-Git-Url: http://git.samba.org/samba.git/?p=garming%2Fsamba-autobuild%2F.git;a=commitdiff_plain;h=b40daca6d4c886f2cea5efce38a5e945410d65d8 traffic_replay: Generate users faster by writing to local DB We can create user accounts much faster if the LDB connection talks directly to the local sam.ldb file rather than going via LDAP. This patch allows the 'host' argument to the tool to be a .ldb file (e.g. "/usr/local/samba/private/sam.ldb") instead of a server name/IP. In most cases, the traffic_replay tool wants to run on a remote device (because the point of it is to send traffic to the DC). However, the --generate-users-only is one case where the tool can be run locally, directly on the test DC. (The traffic_replay user generation is handy for standalone testing, because it also handles assigning group memberships to the generated user accounts). Note that you also need to use '--option="ldb:nosync = true"' to get the improvement in performance. Signed-off-by: Tim Beale Reviewed-by: Douglas Bagnall --- diff --git a/script/traffic_replay b/script/traffic_replay index 6578c84e635..3f4ff9bf14e 100755 --- a/script/traffic_replay +++ b/script/traffic_replay @@ -30,6 +30,8 @@ from samba import gensec, get_debug_level from samba.emulate import traffic import samba.getopt as options from samba.logger import get_samba_logger +from samba.samdb import SamDB +from samba.auth import system_session def print_err(*args, **kwargs): @@ -306,8 +308,16 @@ def main(): opts.number_of_groups))) sys.exit(1) + # Get an LDB connection. try: - ldb = traffic.openLdb(host, creds, lp) + # if we're only adding users, then it's OK to pass a sam.ldb filepath + # as the host, which creates the users much faster. In all other cases + # we should be connecting to a remote DC + if opts.generate_users_only and os.path.isfile(host): + ldb = SamDB(url="ldb://{0}".format(host), + session_info=system_session(), lp=lp) + else: + ldb = traffic.openLdb(host, creds, lp) except: logger.error(("\nInitial LDAP connection failed! Did you supply " "a DNS host name and the correct credentials?"))