Ejemplo n.º 1
0
  def test_build(self, read_actual_component_mock):
    for component in LiveStatus.COMPONENTS:
      config = AmbariConfig().getConfig()
      config.set('agent', 'prefix', "ambari_agent" + os.sep + "dummy_files")
      livestatus = LiveStatus('', component['serviceName'], component['componentName'], {}, config, {})
      livestatus.versionsHandler.versionsFilePath = "ambari_agent" + os.sep + "dummy_files" + os.sep + "dummy_current_stack"
      result = livestatus.build()
      print "LiveStatus of {0}: {1}".format(component['serviceName'], str(result))
      self.assertEquals(len(result) > 0, True, 'Livestatus should not be empty')
      if component['componentName'] == 'GANGLIA_SERVER':
        self.assertEquals(result['stackVersion'],'{"stackName":"HDP","stackVersion":"1.2.2"}',
                      'Livestatus should contain component stack version')

    # Test build status for CLIENT component (in LiveStatus.CLIENT_COMPONENTS)
    read_actual_component_mock.return_value = "some tags"
    livestatus = LiveStatus('c1', 'HDFS', 'HDFS_CLIENT', { }, config, {})
    result = livestatus.build()
    self.assertTrue(len(result) > 0, 'Livestatus should not be empty')
    self.assertTrue(result.has_key('configurationTags'))
    # Test build status with forsed_component_status
    ## Alive
    livestatus = LiveStatus('c1', 'HDFS', 'HDFS_CLIENT', { }, config, {})
    result = livestatus.build(forsed_component_status = LiveStatus.LIVE_STATUS)
    self.assertTrue(len(result) > 0, 'Livestatus should not be empty')
    self.assertTrue(result['status'], LiveStatus.LIVE_STATUS)
    ## Dead
    livestatus = LiveStatus('c1', 'HDFS', 'HDFS_CLIENT', { }, config, {})
    result = livestatus.build(forsed_component_status = LiveStatus.DEAD_STATUS)
    self.assertTrue(len(result) > 0, 'Livestatus should not be empty')
    self.assertTrue(result['status'], LiveStatus.DEAD_STATUS)

    livestatus = LiveStatus('c1', 'TEZ', 'TEZ_CLIENT', { }, config, {})
    result = livestatus.build(forsed_component_status = LiveStatus.LIVE_STATUS)
    self.assertTrue(len(result) > 0, 'Livestatus should not be empty')
    self.assertTrue(result['status'], LiveStatus.LIVE_STATUS)
 def test_build(self):
   for component in LiveStatus.COMPONENTS:
     config = AmbariConfig().getConfig()
     config.set('agent', 'prefix', "dummy_files")
     livestatus = LiveStatus('', component['serviceName'], component['componentName'], {}, config)
     livestatus.versionsHandler.versionsFilePath = os.path.join("dummy_files","dummy_current_stack")
     result = livestatus.build()
     print "LiveStatus of {0}: {1}".format(component['serviceName'], str(result))
     self.assertEquals(len(result) > 0, True, 'Livestatus should not be empty')
     if component['componentName'] == 'GANGLIA_SERVER':
       self.assertEquals(result['stackVersion'],'{"stackName":"HDP","stackVersion":"1.2.2"}',
                     'Livestatus should contain component stack version')
 def test_build(self):
     for component in LiveStatus.COMPONENTS:
         config = AmbariConfig().getConfig()
         config.set('agent', 'prefix', "dummy_files")
         livestatus = LiveStatus('', component['serviceName'],
                                 component['componentName'], {}, config)
         livestatus.versionsHandler.versionsFilePath = os.path.join(
             "dummy_files", "dummy_current_stack")
         result = livestatus.build()
         print "LiveStatus of {0}: {1}".format(component['serviceName'],
                                               str(result))
         self.assertEquals(
             len(result) > 0, True, 'Livestatus should not be empty')
         if component['componentName'] == 'GANGLIA_SERVER':
             self.assertEquals(
                 result['stackVersion'],
                 '{"stackName":"HDP","stackVersion":"1.2.2"}',
                 'Livestatus should contain component stack version')
Ejemplo n.º 4
0
 def test_build_predefined(self, read_actual_component_mock):
   read_actual_component_mock.return_value = "actual_component"
   """
   Tests that if live status us defined (using default parameter),
   then no StatusCheck is executed
   """
   config = AmbariConfig().getConfig()
   config.set('agent', 'prefix', "ambari_agent" + os.sep + "dummy_files")
   livestatus = LiveStatus('', 'SOME_UNKNOWN_SERVICE',
                           'SOME_UNKNOWN_COMPONENT', {}, config, {})
   result = livestatus.build(component_status="STARTED")
   result_str = pprint.pformat(result)
   self.assertEqual(result_str,
                    "{'clusterName': '',\n "
                    "'componentName': 'SOME_UNKNOWN_COMPONENT',\n "
                    "'configurationTags': 'actual_component',\n "
                    "'msg': '',\n 'serviceName': 'SOME_UNKNOWN_SERVICE',\n "
                    "'stackVersion': '',\n 'status': 'STARTED'}")
Ejemplo n.º 5
0
 def test_build_predefined(self, getStatus_mock, read_actual_component_mock):
   read_actual_component_mock.return_value = "actual_component"
   """
   Tests that if live status us defined (using default parameter),
   then no StatusCheck is executed
   """
   config = AmbariConfig().getConfig()
   config.set('agent', 'prefix', "ambari_agent" + os.sep + "dummy_files")
   livestatus = LiveStatus('', 'SOME_UNKNOWN_SERVICE',
                           'SOME_UNKNOWN_COMPONENT', {}, config, {})
   livestatus.versionsHandler.versionsFilePath = "ambari_agent" + \
                     os.sep + "dummy_files" + os.sep + "dummy_current_stack"
   result = livestatus.build(forsed_component_status = "STARTED")
   result_str = pprint.pformat(result)
   self.assertEqual(result_str,
                    "{'clusterName': '',\n "
                    "'componentName': 'SOME_UNKNOWN_COMPONENT',\n "
                    "'configurationTags': 'actual_component',\n "
                    "'msg': '',\n 'serviceName': 'SOME_UNKNOWN_SERVICE',\n "
                    "'stackVersion': '',\n 'status': 'STARTED'}")
   self.assertFalse(getStatus_mock.called)