Skip to content

Commit

Permalink
selftest: Port DrsBaseTestCase._net_drs_replicate() to self.runsubcmd()
Browse files Browse the repository at this point in the history
This avoids forking a subprocess with self.check_run()

Signed-off-by: Andrew Bartlett <[email protected]>
Reviewed-by: Douglas Bagnall <[email protected]>
  • Loading branch information
abartlet committed Jul 27, 2017
1 parent 24de78e commit 09ce35e
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions source4/torture/drs/python/drs_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,32 @@ def _samba_tool_cmdline(self, drs_command):
# bin/samba-tool drs <drs_command> <cmdline_auth>
return "%s drs %s %s" % (samba_tool_cmd, drs_command, cmdline_auth)

def _samba_tool_cmd_list(self, drs_command):
# make command line credentials string
creds = self.get_credentials()
cmdline_auth = "-U%s/%s%%%s" % (creds.get_domain(),
creds.get_username(), creds.get_password())
# bin/samba-tool drs <drs_command> <cmdline_auth>
return ["drs", drs_command, cmdline_auth]

def _net_drs_replicate(self, DC, fromDC, nc_dn=None, forced=True, local=False, full_sync=False):
if nc_dn is None:
nc_dn = self.domain_dn
# make base command line
samba_tool_cmdline = self._samba_tool_cmdline("replicate")
samba_tool_cmdline = self._samba_tool_cmd_list("replicate")
# bin/samba-tool drs replicate <Dest_DC_NAME> <Src_DC_NAME> <Naming Context>
samba_tool_cmdline += [DC, fromDC, nc_dn]

if forced:
samba_tool_cmdline += " --sync-forced"
samba_tool_cmdline += ["--sync-forced"]
if local:
samba_tool_cmdline += " --local"
samba_tool_cmdline += ["--local"]
if full_sync:
samba_tool_cmdline += " --full-sync"
# bin/samba-tool drs replicate <Dest_DC_NAME> <Src_DC_NAME> <Naming Context>
cmd_line = "%s %s %s %s" % (samba_tool_cmdline, DC, fromDC, nc_dn)
return self.check_output(cmd_line)
samba_tool_cmdline += ["--full-sync"]

(result, out, err) = self.runsubcmd(*samba_tool_cmdline)
self.assertCmdSuccess(result, out, err)
self.assertEquals(err,"","Shouldn't be any error messages")

def _enable_inbound_repl(self, DC):
# make base command line
Expand Down

0 comments on commit 09ce35e

Please sign in to comment.