TestLiveStatus.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python2.6
  2. '''
  3. Licensed to the Apache Software Foundation (ASF) under one
  4. or more contributor license agreements. See the NOTICE file
  5. distributed with this work for additional information
  6. regarding copyright ownership. The ASF licenses this file
  7. to you under the Apache License, Version 2.0 (the
  8. "License"); you may not use this file except in compliance
  9. with the License. You may obtain a copy of the License at
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. Unless required by applicable law or agreed to in writing, software
  12. distributed under the License is distributed on an "AS IS" BASIS,
  13. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. See the License for the specific language governing permissions and
  15. limitations under the License.
  16. '''
  17. from unittest import TestCase
  18. from ambari_agent.LiveStatus import LiveStatus
  19. from ambari_agent.AmbariConfig import AmbariConfig
  20. import socket
  21. import os
  22. class TestLiveStatus(TestCase):
  23. def test_build(self):
  24. for component in LiveStatus.COMPONENTS:
  25. config = AmbariConfig().getConfig()
  26. config.set('agent', 'prefix', "dummy_files")
  27. livestatus = LiveStatus('', component['serviceName'], component['componentName'], {}, config)
  28. livestatus.versionsHandler.versionsFilePath = os.path.join("dummy_files","dummy_current_stack")
  29. result = livestatus.build()
  30. print "LiveStatus of {0}: {1}".format(component['serviceName'], str(result))
  31. self.assertEquals(len(result) > 0, True, 'Livestatus should not be empty')
  32. if component['componentName'] == 'GANGLIA_SERVER':
  33. self.assertEquals(result['stackVersion'],'{"stackName":"HDP","stackVersion":"1.2.2"}',
  34. 'Livestatus should contain component stack version')