From: Joseph Sutton Date: Thu, 16 Feb 2023 22:46:09 +0000 (+1300) Subject: s4-dsdb:tests: Fix AD DC performance tests X-Git-Tag: talloc-2.4.1~1454 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=38468aa6e8fd8db3aec9c860ab5c8edf1be83e3c;p=thirdparty%2Fsamba.git s4-dsdb:tests: Fix AD DC performance tests Calling cmd._run() directly would fail due to the 'command_name' attribute being absent, so these tests would fail to run. Fix this by using the samba.netcmd.main.samba_tool helper function. Check the return code as well for good measure. Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- diff --git a/source4/dsdb/tests/python/ad_dc_medley_performance.py b/source4/dsdb/tests/python/ad_dc_medley_performance.py index 7afdb747490..3a8316fa018 100644 --- a/source4/dsdb/tests/python/ad_dc_medley_performance.py +++ b/source4/dsdb/tests/python/ad_dc_medley_performance.py @@ -14,7 +14,7 @@ import shutil import time import itertools -from samba.netcmd.main import cmd_sambatool +from samba.netcmd.main import samba_tool # 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 @@ -176,13 +176,13 @@ class UserTests(samba.tests.TestCase): server = host.split('://', 1)[1] else: server = host - cmd = cmd_sambatool.subcommands['domain'].subcommands['join'] - result = cmd._run("samba-tool domain join", - creds.get_realm(), - "dc", "-U%s%%%s" % (creds.get_username(), - creds.get_password()), - '--targetdir=%s' % tmpdir, - '--server=%s' % server) + result = samba_tool('domain', 'join', + creds.get_realm(), + "dc", "-U%s%%%s" % (creds.get_username(), + creds.get_password()), + '--targetdir=%s' % tmpdir, + '--server=%s' % server) + self.assertIsNone(result) shutil.rmtree(tmpdir) diff --git a/source4/dsdb/tests/python/ad_dc_performance.py b/source4/dsdb/tests/python/ad_dc_performance.py index 6ff84e4389e..96229bb14af 100644 --- a/source4/dsdb/tests/python/ad_dc_performance.py +++ b/source4/dsdb/tests/python/ad_dc_performance.py @@ -13,7 +13,7 @@ import tempfile import shutil import time -from samba.netcmd.main import cmd_sambatool +from samba.netcmd.main import samba_tool # 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 @@ -136,13 +136,13 @@ class UserTests(samba.tests.TestCase): server = host.split('://', 1)[1] else: server = host - cmd = cmd_sambatool.subcommands['domain'].subcommands['join'] - result = cmd._run("samba-tool domain join", - creds.get_realm(), - "dc", "-U%s%%%s" % (creds.get_username(), - creds.get_password()), - '--targetdir=%s' % tmpdir, - '--server=%s' % server) + result = samba_tool('domain', 'join', + creds.get_realm(), + "dc", "-U%s%%%s" % (creds.get_username(), + creds.get_password()), + '--targetdir=%s' % tmpdir, + '--server=%s' % server) + self.assertIsNone(result) shutil.rmtree(tmpdir) diff --git a/source4/dsdb/tests/python/ad_dc_provision_performance.py b/source4/dsdb/tests/python/ad_dc_provision_performance.py index 3ce0eb7a13e..3531ced38a0 100644 --- a/source4/dsdb/tests/python/ad_dc_provision_performance.py +++ b/source4/dsdb/tests/python/ad_dc_provision_performance.py @@ -12,7 +12,7 @@ import tempfile import shutil import subprocess -from samba.netcmd.main import cmd_sambatool +from samba.netcmd.main import samba_tool # 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 @@ -95,10 +95,10 @@ class UserTests(samba.tests.TestCase): self._test_provision_subprocess() def test_02_00_provision_cmd_sambatool(self): - cmd = cmd_sambatool.subcommands['domain'].subcommands['provision'] - result = cmd._run("samba-tool domain provision", - '--targetdir=%s' % self.tmpdir, - '--use-ntvfs') + result = samba_tool('domain', 'provision', + '--targetdir=%s' % self.tmpdir, + '--use-ntvfs') + self.assertIsNone(result) def test_03_00_provision_server_role(self): for role in ('member', 'server', 'member', 'standalone'):