]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4-dsdb:tests: Fix AD DC performance tests
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 16 Feb 2023 22:46:09 +0000 (11:46 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 8 Mar 2023 04:39:32 +0000 (04:39 +0000)
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 <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/tests/python/ad_dc_medley_performance.py
source4/dsdb/tests/python/ad_dc_performance.py
source4/dsdb/tests/python/ad_dc_provision_performance.py

index 7afdb747490866182f115d81be240c84225ebc3e..3a8316fa0188efba62f32666c7c981ef1a57e45f 100644 (file)
@@ -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)
 
index 6ff84e4389e5c85efe3af9bc50a700973cf7b884..96229bb14af9805b260776813ef878cbb3b16e9a 100644 (file)
@@ -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)
 
index 3ce0eb7a13e5262765bce8533ce69abec3bee13b..3531ced38a0a32ede20a3864a18749daaaad3997 100644 (file)
@@ -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'):