def _get_running_postgres_segments(self, segments): running_segments = [] for seg in segments: datadir = self.dereference_remote_symlink( seg.getSegmentDataDirectory(), seg.getSegmentHostName()) pid = get_pid_from_remotehost(seg.getSegmentHostName(), datadir) if pid is not None: if check_pid_on_remotehost(pid, seg.getSegmentHostName()): if is_pid_postmaster(datadir, pid, seg.getSegmentHostName()): running_segments.append(seg) else: logger.info( "Skipping to stop segment %s on host %s since it is not a postgres process" % (seg.getSegmentDataDirectory(), seg.getSegmentHostName())) else: logger.debug( "Skipping to stop segment %s on host %s since process with pid %s is not running" % (seg.getSegmentDataDirectory(), seg.getSegmentHostName(), pid)) else: logger.debug( "Skipping to stop segment %s on host %s since pid could not be found" % (seg.getSegmentDataDirectory(), seg.getSegmentHostName())) return running_segments
def _get_running_postgres_segments(self, segments): running_segments = [] for seg in segments: datadir = self.dereference_remote_symlink(seg.getSegmentDataDirectory(), seg.getSegmentHostName()) pid = get_pid_from_remotehost(seg.getSegmentHostName(), datadir) if pid is not None: if check_pid_on_remotehost(pid, seg.getSegmentHostName()): if is_pid_postmaster(datadir, pid, seg.getSegmentHostName()): running_segments.append(seg) else: logger.info("Skipping to stop segment %s on host %s since it is not a postgres process" % (seg.getSegmentDataDirectory(), seg.getSegmentHostName())) else: logger.debug("Skipping to stop segment %s on host %s since process with pid %s is not running" % (seg.getSegmentDataDirectory(), seg.getSegmentHostName(), pid)) else: logger.debug("Skipping to stop segment %s on host %s since pid could not be found" % (seg.getSegmentDataDirectory(), seg.getSegmentHostName())) return running_segments
def test_is_pid_postmaster_pid_doesnt_exists_remote(self, mock1, mock2): pid = 1234 datadir = '/data/primary/gpseg0' remoteHost = 'smdw' self.assertFalse(is_pid_postmaster(datadir, pid, remoteHost=remoteHost))
def test_is_pid_postmaster_pgrep_failed(self, mock1, mock2): pid = '1234' datadir = '/data/primary/gpseg0' self.assertTrue(is_pid_postmaster(datadir, pid))
def test_is_pid_postmaster_no_result(self, mock1, mock2): pid = '1234' datadir = None self.assertFalse(is_pid_postmaster(datadir, pid))
def test_is_pid_postmaster_pid_doesnt_exists(self, mock1, mock2): pid = 1234 datadir = '/data/primary/gpseg0' self.assertFalse(is_pid_postmaster(datadir, pid))
def test_is_pid_postmaster_pgrep_failed_remote(self, mock1, mock2): pid = '1234' datadir = '/data/primary/gpseg0' remoteHost = 'smdw' self.assertTrue(is_pid_postmaster(datadir, pid, remoteHost=remoteHost))
def test_is_pid_postmaster_no_result_remote(self, mock1, mock2): pid = '1234' datadir = None remoteHost = 'smdw' self.assertFalse(is_pid_postmaster(datadir, pid, remoteHost=remoteHost))