test_service_check.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env python
  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 mock.mock import MagicMock, call, patch
  18. from stacks.utils.RMFTestCase import *
  19. import datetime
  20. import resource_management.libraries.functions
  21. @patch.object(resource_management.libraries.functions, "get_unique_id_and_date", new = MagicMock(return_value=''))
  22. class TestStormServiceCheck(RMFTestCase):
  23. def test_service_check(self):
  24. self.executeScript("2.1.1/services/STORM/package/scripts/service_check.py",
  25. classname="ServiceCheck",
  26. command="service_check",
  27. config_file="default.json"
  28. )
  29. self.assertResourceCalled('File', '/tmp/wordCount.jar',
  30. content = StaticFile('wordCount.jar'),
  31. )
  32. self.assertResourceCalled('Execute', 'env JAVA_HOME=/usr/jdk64/jdk1.7.0_45 storm jar /tmp/wordCount.jar storm.starter.WordCountTopology WordCount -c nimbus.host=c6402.ambari.apache.org',
  33. logoutput = True,
  34. )
  35. self.assertResourceCalled('Execute', 'env PATH=$PATH:/usr/jdk64/jdk1.7.0_45/bin storm kill WordCount')