samba-tool drs showrepl test: turn subprocess error into failure
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 4 Jul 2018 23:01:58 +0000 (11:01 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 5 Jul 2018 02:01:26 +0000 (04:01 +0200)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/torture/drs/python/samba_tool_drs_showrepl.py

index 40949553eed22f27fc563694301a8b1bc8f93164..54c38c0c6c2060519bbdd4bbecc21fc781704992 100644 (file)
@@ -235,23 +235,29 @@ class SambaToolDrsShowReplTests(drs_base.DrsBaseTestCase):
         self._enable_all_repl(self.dc1)
         self._force_all_reps(samdb1, self.dc1, 'inbound')
         self._force_all_reps(samdb1, self.dc1, 'outbound')
+        try:
+            out = self.check_output(
+                "samba-tool drs showrepl --pull-summary %s %s" %
+                (self.dc1, self.cmdline_creds))
+            self.assertStringsEqual(out, "[ALL GOOD]\n")
+
+            out = self.check_output("samba-tool drs showrepl --pull-summary "
+                                    "--color=yes %s %s" %
+                                    (self.dc1, self.cmdline_creds))
+            self.assertStringsEqual(out, "\033[1;32m[ALL GOOD]\033[0m\n")
+
+            # --verbose output is still quiet when all is good.
+            out = self.check_output(
+                "samba-tool drs showrepl --pull-summary -v %s %s" %
+                (self.dc1, self.cmdline_creds))
+            self.assertStringsEqual(out, "[ALL GOOD]\n")
+            out = self.check_output("samba-tool drs showrepl --pull-summary -v "
+                                    "--color=yes %s %s" %
+                                    (self.dc1, self.cmdline_creds))
 
-        out = self.check_output("samba-tool drs showrepl --pull-summary %s %s" %
-                                (self.dc1, self.cmdline_creds))
-        self.assertStringsEqual(out, "[ALL GOOD]\n")
-
-        out = self.check_output("samba-tool drs showrepl --pull-summary "
-                                "--color=yes %s %s" %
-                                (self.dc1, self.cmdline_creds))
-        self.assertStringsEqual(out, "\033[1;32m[ALL GOOD]\033[0m\n")
+        except samba.tests.BlackboxProcessError as e:
+            self.fail(str(e))
 
-        # --verbose output is still quiet when all is good.
-        out = self.check_output("samba-tool drs showrepl --pull-summary -v %s %s" %
-                                (self.dc1, self.cmdline_creds))
-        self.assertStringsEqual(out, "[ALL GOOD]\n")
-        out = self.check_output("samba-tool drs showrepl --pull-summary -v "
-                                "--color=yes %s %s" %
-                                (self.dc1, self.cmdline_creds))
         self.assertStringsEqual(out, "\033[1;32m[ALL GOOD]\033[0m\n")
 
     def test_samba_tool_showrepl_summary_forced_failure(self):