Esempio n. 1
0
  def test_dead(self, get_is_live_mock):
    statusCheck = StatusCheck(self.serviceToPidDict, self.pidPathesVars,
      self.globalConfig, self.servicesToLinuxUser)

    statusCheck.pidFilesDict = self.pidFilesDict
    
    get_is_live_mock.side_effect = lambda pid_path : self.is_live_values[pid_path]
    status = statusCheck.getStatus(COMPONENT_DEAD)
    self.assertEqual(status, False)
Esempio n. 2
0
  def test_dead(self, get_is_live_mock):
    statusCheck = StatusCheck(self.serviceToPidDict, self.pidPathVars,
      self.globalConfig, self.servicesToLinuxUser)

    statusCheck.pidFilesDict = self.pidFilesDict
    
    get_is_live_mock.side_effect = lambda pid_path : self.is_live_values[pid_path]
    status = statusCheck.getStatus(COMPONENT_DEAD)
    self.assertEqual(status, False)
Esempio n. 3
0
    def test_live(self, get_is_live_mock):

        statusCheck = StatusCheck(self.serviceToPidDict, self.pidPathesVars,
                                  {}, AmbariConfig.linuxUserPattern)

        statusCheck.pidFilesDict = self.pidFilesDict

        get_is_live_mock.side_effect = lambda pid_path: self.is_live_values[
            pid_path]

        status = statusCheck.getStatus(COMPONENT_LIVE)
        self.assertEqual(status, True)
Esempio n. 4
0
  def test_live(self, get_is_live_mock):

    statusCheck = StatusCheck(self.serviceToPidDict, self.pidPathVars,
      self.globalConfig, self.servicesToLinuxUser)

    self.assertTrue(StatusCheck.USER_PATTERN in self.serviceToPidDict[COMPONENT_LIVE])
    self.assertTrue(StatusCheck.USER_PATTERN in self.serviceToPidDict[COMPONENT_DEAD])

    statusCheck.pidFilesDict = self.pidFilesDict
    
    get_is_live_mock.side_effect = lambda pid_path : self.is_live_values[pid_path]
    
    status = statusCheck.getStatus(COMPONENT_LIVE)
    self.assertEqual(status, True)
Esempio n. 5
0
  def test_live(self, get_is_live_mock):

    statusCheck = StatusCheck(self.serviceToPidDict, self.pidPathesVars,
      self.globalConfig, self.servicesToLinuxUser)

    self.assertTrue(StatusCheck.USER_PATTERN in self.serviceToPidDict[COMPONENT_LIVE])
    self.assertTrue(StatusCheck.USER_PATTERN in self.serviceToPidDict[COMPONENT_DEAD])

    statusCheck.pidFilesDict = self.pidFilesDict
    
    get_is_live_mock.side_effect = lambda pid_path : self.is_live_values[pid_path]
    
    status = statusCheck.getStatus(COMPONENT_LIVE)
    self.assertEqual(status, True)
Esempio n. 6
0
  def test_no_user_mapping(self, error_mock, get_is_live_mock):

    
    badServiceToPidDict = self.serviceToPidDict.copy()
    badServiceToPidDict['BAD_COMPONENT'] = 'prefix' + StatusCheck.USER_PATTERN

    statusCheck = StatusCheck(badServiceToPidDict, self.pidPathVars,
      self.globalConfig, self.servicesToLinuxUser)

    statusCheck.pidFilesDict = self.pidFilesDict

    get_is_live_mock.side_effect = lambda pid_path : self.is_live_values[pid_path]

    status = statusCheck.getStatus(COMPONENT_LIVE)
    self.assertTrue(error_mock.called)
Esempio n. 7
0
  def test_no_user_mapping(self, error_mock, get_is_live_mock):

    
    badServiceToPidDict = self.serviceToPidDict.copy()
    badServiceToPidDict['BAD_COMPONENT'] = 'prefix' + StatusCheck.USER_PATTERN

    statusCheck = StatusCheck(badServiceToPidDict, self.pidPathesVars,
      self.globalConfig, self.servicesToLinuxUser)

    statusCheck.pidFilesDict = self.pidFilesDict

    get_is_live_mock.side_effect = lambda pid_path : self.is_live_values[pid_path]

    status = statusCheck.getStatus(COMPONENT_LIVE)
    self.assertTrue(error_mock.called)
Esempio n. 8
0
  def test_live_if_multiple_pids(self, get_is_live_mock):

    one_more_pid_file_name = string.replace(COMPONENT_LIVE_PID, StatusCheck.USER_PATTERN,
      'any_other_linux_user')
    one_more_pid_full_path = PID_DIR + os.sep + one_more_pid_file_name

    self.pidFilesDict[one_more_pid_file_name] = one_more_pid_full_path
    self.is_live_values[one_more_pid_full_path] = False

    statusCheck = StatusCheck(self.serviceToPidDict, self.pidPathVars,
      self.globalConfig, self.servicesToLinuxUser)

    statusCheck.pidFilesDict = self.pidFilesDict

    get_is_live_mock.side_effect = lambda pid_path : self.is_live_values[pid_path]

    status = statusCheck.getStatus(COMPONENT_LIVE)
    self.assertEqual(status, True)
Esempio n. 9
0
  def test_live_if_multiple_pids(self, get_is_live_mock):

    one_more_pid_file_name = string.replace(COMPONENT_LIVE_PID, StatusCheck.USER_PATTERN,
      'any_other_linux_user')
    one_more_pid_full_path = PID_DIR + os.sep + one_more_pid_file_name

    self.pidFilesDict[one_more_pid_file_name] = one_more_pid_full_path
    self.is_live_values[one_more_pid_full_path] = False

    statusCheck = StatusCheck(self.serviceToPidDict, self.pidPathesVars,
      self.globalConfig, self.servicesToLinuxUser)

    statusCheck.pidFilesDict = self.pidFilesDict

    get_is_live_mock.side_effect = lambda pid_path : self.is_live_values[pid_path]

    status = statusCheck.getStatus(COMPONENT_LIVE)
    self.assertEqual(status, True)