本文整理汇总了Python中charms.layer.apache_bigtop_base.Bigtop.run_smoke_tests方法的典型用法代码示例。如果您正苦于以下问题:Python Bigtop.run_smoke_tests方法的具体用法?Python Bigtop.run_smoke_tests怎么用?Python Bigtop.run_smoke_tests使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charms.layer.apache_bigtop_base.Bigtop
的用法示例。
在下文中一共展示了Bigtop.run_smoke_tests方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestBigtopUnit
# 需要导入模块: from charms.layer.apache_bigtop_base import Bigtop [as 别名]
# 或者: from charms.layer.apache_bigtop_base.Bigtop import run_smoke_tests [as 别名]
#.........这里部分代码省略.........
def test_check_hdfs_setup(self, mock_run, mock_sub):
'''
Verify that our hdfs setup check works as expected, and handles
errors as expected.
'''
class MockException(Exception):
pass
mock_sub.CalledProcessError = MockException
def mock_raise(*args, **kwargs):
raise MockException('foo!')
for s in ['ubuntu', ' ubuntu ', 'ubuntu ', ' ubuntu']:
mock_run.return_value = s
self.assertTrue(self.bigtop.check_hdfs_setup())
for s in ['foo', ' ', '', ' bar', 'notubuntu', 'ubuntu not ']:
mock_run.return_value = s
self.assertFalse(self.bigtop.check_hdfs_setup())
mock_run.side_effect = mock_raise
self.assertFalse(self.bigtop.check_hdfs_setup())
@unittest.skip('noop')
def test_spec(self):
'''Nothing to test that the linter won't handle.'''
@mock.patch('charms.layer.apache_bigtop_base.subprocess')
@mock.patch('charms.layer.apache_bigtop_base.utils.run_as')
@mock.patch('charms.layer.apache_bigtop_base.chdir')
@mock.patch('charms.layer.apache_bigtop_base.chownr')
@mock.patch('charms.layer.apache_bigtop_base.layer.options')
def test_run_smoke_tests(self, mock_options, mock_ownr, mock_chdir,
mock_run, mock_sub):
'''
Verify that we attempt to run smoke tests correctly, and handle
exceptions as expected.
'''
mock_options.return_value = {}
# Returns None if bigtop isn't available.
remove_state('bigtop.available')
self.assertEqual(None, self.bigtop.run_smoke_tests())
# Returns None if we don't pass in a 'smoke_components' arg
set_state('bigtop.available')
self.assertEqual(None, self.bigtop.run_smoke_tests())
# Should return 'success' if all went well.
self.assertEqual(
self.bigtop.run_smoke_tests(smoke_components=['foo', 'bar']),
'success'
)
# Should return error message if subprocess raised an Exception.
class MockException(Exception):
pass
MockException.output = "test output"
mock_sub.CalledProcessError = MockException
def mock_raise(*args, **kwargs):
raise MockException('foo!')
mock_run.side_effect = mock_raise
self.assertEqual(