mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
perf: Add simple tests for the open/close a database case
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Dec 1 09:40:20 CET 2016 on sn-devel-144
This commit is contained in:
@ -24,3 +24,26 @@ plantestsuite_loadlist("samba4.ldap.ad_dc_performance.python(ad_dc_ntvfs)",
|
|||||||
'$SERVER', '-U"$USERNAME%$PASSWORD"',
|
'$SERVER', '-U"$USERNAME%$PASSWORD"',
|
||||||
'--workgroup=$DOMAIN',
|
'--workgroup=$DOMAIN',
|
||||||
'$LOADLIST', '$LISTOPT'])
|
'$LOADLIST', '$LISTOPT'])
|
||||||
|
|
||||||
|
plantestsuite_loadlist("samba4.ldap.ad_dc_multi_bind.ntlm.python(ad_dc_ntvfs)",
|
||||||
|
"ad_dc_ntvfs",
|
||||||
|
[python, os.path.join(samba4srcdir,
|
||||||
|
"dsdb/tests/python/ad_dc_multi_bind.py"),
|
||||||
|
'$SERVER', '-U"$USERNAME%$PASSWORD"', '-k no',
|
||||||
|
'--workgroup=$DOMAIN',
|
||||||
|
'$LOADLIST', '$LISTOPT'])
|
||||||
|
|
||||||
|
plantestsuite_loadlist("samba4.ldap.ad_dc_multi_bind.krb5.python(ad_dc_ntvfs)",
|
||||||
|
"ad_dc_ntvfs",
|
||||||
|
[python, os.path.join(samba4srcdir,
|
||||||
|
"dsdb/tests/python/ad_dc_multi_bind.py"),
|
||||||
|
'$SERVER', '-U"$USERNAME%$PASSWORD"', '-k yes',
|
||||||
|
'--realm=$REALM',
|
||||||
|
'$LOADLIST', '$LISTOPT'])
|
||||||
|
|
||||||
|
plantestsuite_loadlist("samba4.ldb.multi_connect.python(ad_dc_ntvfs)",
|
||||||
|
"ad_dc_ntvfs",
|
||||||
|
[python, os.path.join(samba4srcdir,
|
||||||
|
"dsdb/tests/python/ad_dc_multi_bind.py"),
|
||||||
|
'tdb://$PREFIX_ABS/ad_dc_ntvfs/private/sam.ldb'
|
||||||
|
'$LOADLIST', '$LISTOPT'])
|
||||||
|
94
source4/dsdb/tests/python/ad_dc_multi_bind.py
Normal file
94
source4/dsdb/tests/python/ad_dc_multi_bind.py
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import optparse
|
||||||
|
import sys
|
||||||
|
sys.path.insert(0, 'bin/python')
|
||||||
|
|
||||||
|
import os
|
||||||
|
import samba
|
||||||
|
import samba.getopt as options
|
||||||
|
import random
|
||||||
|
import tempfile
|
||||||
|
import shutil
|
||||||
|
import time
|
||||||
|
|
||||||
|
from samba.netcmd.main import cmd_sambatool
|
||||||
|
|
||||||
|
# We try to use the test infrastructure of Samba 4.3+, but if it
|
||||||
|
# doesn't work, we are probably in a back-ported patch and trying to
|
||||||
|
# run on 4.1 or something.
|
||||||
|
#
|
||||||
|
# Don't copy this horror into ordinary tests -- it is special for
|
||||||
|
# performance tests that want to apply to old versions.
|
||||||
|
try:
|
||||||
|
from samba.tests.subunitrun import SubunitOptions, TestProgram
|
||||||
|
ANCIENT_SAMBA = False
|
||||||
|
except ImportError:
|
||||||
|
ANCIENT_SAMBA = True
|
||||||
|
samba.ensure_external_module("testtools", "testtools")
|
||||||
|
samba.ensure_external_module("subunit", "subunit/python")
|
||||||
|
from subunit.run import SubunitTestRunner
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from samba.samdb import SamDB
|
||||||
|
from samba.auth import system_session
|
||||||
|
from ldb import Message, MessageElement, Dn, LdbError
|
||||||
|
from ldb import FLAG_MOD_ADD, FLAG_MOD_REPLACE, FLAG_MOD_DELETE
|
||||||
|
from ldb import SCOPE_BASE, SCOPE_SUBTREE, SCOPE_ONELEVEL
|
||||||
|
|
||||||
|
parser = optparse.OptionParser("ad_dc_mulit_bind.py [options] <host>")
|
||||||
|
sambaopts = options.SambaOptions(parser)
|
||||||
|
parser.add_option_group(sambaopts)
|
||||||
|
parser.add_option_group(options.VersionOptions(parser))
|
||||||
|
|
||||||
|
if not ANCIENT_SAMBA:
|
||||||
|
subunitopts = SubunitOptions(parser)
|
||||||
|
parser.add_option_group(subunitopts)
|
||||||
|
|
||||||
|
# use command line creds if available
|
||||||
|
credopts = options.CredentialsOptions(parser)
|
||||||
|
parser.add_option_group(credopts)
|
||||||
|
opts, args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
if len(args) < 1:
|
||||||
|
parser.print_usage()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
host = args[0]
|
||||||
|
|
||||||
|
lp = sambaopts.get_loadparm()
|
||||||
|
creds = credopts.get_credentials(lp)
|
||||||
|
|
||||||
|
class UserTests(samba.tests.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(UserTests, self).setUp()
|
||||||
|
self.lp = lp
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
super(UserTests, self).tearDown()
|
||||||
|
|
||||||
|
def test_1000_binds(self):
|
||||||
|
|
||||||
|
for x in range(1, 1000):
|
||||||
|
samdb = SamDB(host, credentials=creds,
|
||||||
|
session_info=system_session(self.lp), lp=self.lp)
|
||||||
|
samdb.search(base=samdb.domain_dn(),
|
||||||
|
scope=SCOPE_BASE, attrs=["*"])
|
||||||
|
|
||||||
|
|
||||||
|
if "://" not in host:
|
||||||
|
if os.path.isfile(host):
|
||||||
|
host = "tdb://%s" % host
|
||||||
|
else:
|
||||||
|
host = "ldap://%s" % host
|
||||||
|
|
||||||
|
|
||||||
|
if ANCIENT_SAMBA:
|
||||||
|
runner = SubunitTestRunner()
|
||||||
|
if not runner.run(unittest.makeSuite(UserTests)).wasSuccessful():
|
||||||
|
sys.exit(1)
|
||||||
|
sys.exit(0)
|
||||||
|
else:
|
||||||
|
TestProgram(module=__name__, opts=subunitopts)
|
Reference in New Issue
Block a user