Fix gpsegstop unittests
It looks like this is passing in concourse, however, this test suite is
having issues running properly. One of the mocks is not returning the
proper behavior causing the test to fail.
@@ -38,7 +38,8 @@ class SegStopTestCase(unittest.TestCase):
@patch('gppylib.commands.gp.SegmentIsShutDown.is_shutdown', return_value=True)
@patch('gpsegstop.unix.kill_9_segment_processes')
@patch('gpsegstop.pg.ReadPostmasterTempFile.getResults', return_value=(True, 1234, '/tmp/gpseg0'))
- def test_run(self, mock1, mock2, mock3, mock4, mock5):
+ @patch('gpsegstop.unix.check_pid', return_value=False)
+ def test_run(self, mock1, mock2, mock3, mock4, mock5, mock6):
self.segstop.db = '/tmp/gpseg0:1234'
self.segstop.mode = 'smart'
self.segstop.timeout = '10'
@@ -51,7 +52,8 @@ class SegStopTestCase(unittest.TestCase):
@patch('gpsegstop.pg.ReadPostmasterTempFile.getResults', return_value=(True, 1234, '/tmp/gpseg0'))
@patch('gpsegstop.unix.kill_sequence')
@patch('gpsegstop.unix.kill_9_segment_processes')
- def test_run_with_error(self, mock1, mock2, mock3, mock4, mock5):
+ @patch('gpsegstop.unix.check_pid', return_value=False)
+ def test_run_with_error(self, mock1, mock2, mock3, mock4, mock5, mock6):
self.segstop.db = '/tmp/gpseg0:1234'
self.segstop.mode = 'smart'
self.segstop.timeout = '10'
@@ -65,7 +67,8 @@ class SegStopTestCase(unittest.TestCase):
@patch('gpsegstop.pg.ReadPostmasterTempFile.getResults', return_value=(True, 1234, '/tmp/gpseg0'))
@patch('gpsegstop.unix.kill_sequence')
@patch('gpsegstop.unix.kill_9_segment_processes')
- def test_run_with_pg_controldata_error(self, mock1, mock2, mock3, mock4, mock5, mock6):
+ @patch('gpsegstop.unix.check_pid', return_value=False)
+ def test_run_with_pg_controldata_error(self, mock1, mock2, mock3, mock4, mock5, mock6, mock7):
self.segstop.db = '/tmp/gpseg0:1234'
self.segstop.mode = 'smart'
self.segstop.timeout = '10'
@@ -78,7 +81,8 @@ class SegStopTestCase(unittest.TestCase):
@patch('gppylib.commands.gp.SegmentIsShutDown.is_shutdown', return_value=False)
@patch('gpsegstop.pg.ReadPostmasterTempFile.getResults', return_value=(True, 1234, '/tmp/gpseg0'))
@patch('gpsegstop.unix.kill_9_segment_processes')
- def test_run_with_pg_controldata_error_in_immediate_mode(self, mock1, mock2, mock3, mock4, mock5):
+ @patch('gpsegstop.unix.check_pid', return_value=False)
+ def test_run_with_pg_controldata_error_in_immediate_mode(self, mock1, mock2, mock3, mock4, mock5, mock6):
self.segstop.db = '/tmp/gpseg0:1234'
self.segstop.mode = 'immediate'
self.segstop.timeout = '10'
