perftest:ndr_pack_performance: remove irrelevant imports, options
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 3 Jan 2024 12:51:56 +0000 (01:51 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 8 Feb 2024 02:48:44 +0000 (02:48 +0000)
This includes removing the ANCIENT_SAMBA switch for pre-4.3, as
nobody cares anymore and many tests would not run correctly anyway.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15574

source4/dsdb/tests/python/ndr_pack_performance.py

index 083abf6621f489821304b75f26f89bb45867d9e9..c0c72cac99e56f192cf4b6caba4f8158df5ac037 100644 (file)
@@ -4,10 +4,7 @@ import optparse
 import sys
 sys.path.insert(0, 'bin/python')
 
-import os
 import samba
-import samba.getopt as options
-import random
 import gzip
 
 # We try to use the test infrastructure of Samba 4.3+, but if it
@@ -16,45 +13,13 @@ import gzip
 #
 # 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.tests.subunitrun import TestProgram
 
 from samba.ndr import ndr_pack, ndr_unpack
 from samba.dcerpc import security
 from samba.dcerpc import drsuapi
 
-parser = optparse.OptionParser("ndr_pack_performance.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)
-
-random.seed(1)
-
 
 BIG_SD_SDDL = ''.join(
     """O:S-1-5-21-3328325300-3937145445-4190589019-512G:S-1-5-2
@@ -246,18 +211,4 @@ class UserTests(samba.tests.TestCase):
         self._test_pack(desc, cycles=20)
 
 
-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.TestLoader().loadTestsFromTestCase(
-            UserTests)).wasSuccessful():
-        sys.exit(1)
-    sys.exit(0)
-else:
-    TestProgram(module=__name__, opts=subunitopts)
+TestProgram(module=__name__)