Upgrade to hacking 0.10.x
Fix up issues detected by new version of hacking Change-Id: Ie12b9f5ccaa1ce5f49ee6bf35d3275bc9dbcbc15
This commit is contained in:
parent
8ff5575c5e
commit
2b97c0d156
@ -64,6 +64,10 @@ except Exception:
|
|||||||
pid_file_module = daemon.pidfile
|
pid_file_module = daemon.pidfile
|
||||||
|
|
||||||
|
|
||||||
|
class ElasticRecheckException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class RecheckWatchBot(irc.bot.SingleServerIRCBot):
|
class RecheckWatchBot(irc.bot.SingleServerIRCBot):
|
||||||
def __init__(self, channels, nickname, password, server, port=6667,
|
def __init__(self, channels, nickname, password, server, port=6667,
|
||||||
server_password=None):
|
server_password=None):
|
||||||
@ -184,7 +188,7 @@ class RecheckWatch(threading.Thread):
|
|||||||
if channel in self.channel_config.events['negative']:
|
if channel in self.channel_config.events['negative']:
|
||||||
self.new_error(channel, event)
|
self.new_error(channel, event)
|
||||||
else:
|
else:
|
||||||
raise Exception('No event or msg specified')
|
raise ElasticRecheckException('No event or msg specified')
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# Import here because it needs to happen after daemonization
|
# Import here because it needs to happen after daemonization
|
||||||
@ -276,9 +280,11 @@ def _main(args, config):
|
|||||||
if fp:
|
if fp:
|
||||||
fp = os.path.expanduser(fp)
|
fp = os.path.expanduser(fp)
|
||||||
if not os.path.exists(fp):
|
if not os.path.exists(fp):
|
||||||
raise Exception("Unable to read layout config file at %s" % fp)
|
raise ElasticRecheckException(
|
||||||
|
"Unable to read layout config file at %s" % fp)
|
||||||
else:
|
else:
|
||||||
raise Exception("Channel Config must be specified in config file.")
|
raise ElasticRecheckException(
|
||||||
|
"Channel Config must be specified in config file.")
|
||||||
|
|
||||||
channel_config = ChannelConfig(yaml.load(open(fp)))
|
channel_config = ChannelConfig(yaml.load(open(fp)))
|
||||||
msgs = MessageConfig(yaml.load(open(fp)))
|
msgs = MessageConfig(yaml.load(open(fp)))
|
||||||
|
@ -113,7 +113,7 @@ class FailEvent(object):
|
|||||||
self.project = event['change']['project']
|
self.project = event['change']['project']
|
||||||
self.url = event['change']['url']
|
self.url = event['change']['url']
|
||||||
self.comment = event["comment"]
|
self.comment = event["comment"]
|
||||||
#TODO(jogo) make FailEvent generate the jobs
|
# TODO(jogo): make FailEvent generate the jobs
|
||||||
self.failed_jobs = failed_jobs
|
self.failed_jobs = failed_jobs
|
||||||
|
|
||||||
def is_openstack_project(self):
|
def is_openstack_project(self):
|
||||||
@ -253,7 +253,7 @@ class Stream(object):
|
|||||||
for i in range(NUMBER_OF_RETRIES):
|
for i in range(NUMBER_OF_RETRIES):
|
||||||
try:
|
try:
|
||||||
for job in event.failed_jobs:
|
for job in event.failed_jobs:
|
||||||
#TODO(jogo) if there are three failed jobs and only the
|
# TODO(jogo): if there are three failed jobs and only the
|
||||||
# last one isn't ready we don't need to keep rechecking
|
# last one isn't ready we don't need to keep rechecking
|
||||||
# the first two
|
# the first two
|
||||||
self._job_console_uploaded(
|
self._job_console_uploaded(
|
||||||
@ -346,7 +346,7 @@ class Stream(object):
|
|||||||
self.gerrit.review(event.project, event.name(), msg)
|
self.gerrit.review(event.project, event.name(), msg)
|
||||||
|
|
||||||
|
|
||||||
class Classifier():
|
class Classifier(object):
|
||||||
"""Classify failed tempest-devstack jobs based.
|
"""Classify failed tempest-devstack jobs based.
|
||||||
|
|
||||||
Given a change and revision, query logstash with a list of known queries
|
Given a change and revision, query logstash with a list of known queries
|
||||||
|
@ -63,7 +63,7 @@ class TestBot(unittest.TestCase):
|
|||||||
|
|
||||||
def test_read_channel_config_not_specified(self):
|
def test_read_channel_config_not_specified(self):
|
||||||
self.fake_config.set('ircbot', 'channel_config', None)
|
self.fake_config.set('ircbot', 'channel_config', None)
|
||||||
with self.assertRaises(Exception) as exc:
|
with self.assertRaises(bot.ElasticRecheckException) as exc:
|
||||||
bot._main([], self.fake_config)
|
bot._main([], self.fake_config)
|
||||||
raised_exc = exc.exception
|
raised_exc = exc.exception
|
||||||
self.assertEqual(str(raised_exc), "Channel Config must be specified "
|
self.assertEqual(str(raised_exc), "Channel Config must be specified "
|
||||||
@ -71,14 +71,14 @@ class TestBot(unittest.TestCase):
|
|||||||
|
|
||||||
def test_read_channel_config_invalid_path(self):
|
def test_read_channel_config_invalid_path(self):
|
||||||
self.fake_config.set('ircbot', 'channel_config', 'fake_path.yaml')
|
self.fake_config.set('ircbot', 'channel_config', 'fake_path.yaml')
|
||||||
with self.assertRaises(Exception) as exc:
|
with self.assertRaises(bot.ElasticRecheckException) as exc:
|
||||||
bot._main([], self.fake_config)
|
bot._main([], self.fake_config)
|
||||||
raised_exc = exc.exception
|
raised_exc = exc.exception
|
||||||
error_msg = "Unable to read layout config file at fake_path.yaml"
|
error_msg = "Unable to read layout config file at fake_path.yaml"
|
||||||
self.assertEqual(str(raised_exc), error_msg)
|
self.assertEqual(str(raised_exc), error_msg)
|
||||||
|
|
||||||
def test__read_no_event_no_msg(self):
|
def test__read_no_event_no_msg(self):
|
||||||
with self.assertRaises(Exception) as exc:
|
with self.assertRaises(bot.ElasticRecheckException) as exc:
|
||||||
self.recheck_watch._read()
|
self.recheck_watch._read()
|
||||||
raised_exc = exc.exception
|
raised_exc = exc.exception
|
||||||
error_msg = 'No event or msg specified'
|
error_msg = 'No event or msg specified'
|
||||||
|
@ -120,8 +120,7 @@ class MockDatetimeYesterday(datetime.datetime):
|
|||||||
|
|
||||||
@mock.patch.object(pyelasticsearch.ElasticSearch, 'search', return_value={})
|
@mock.patch.object(pyelasticsearch.ElasticSearch, 'search', return_value={})
|
||||||
class TestSearchEngine(tests.TestCase):
|
class TestSearchEngine(tests.TestCase):
|
||||||
"""Tests that the elastic search API is called correctly.
|
"""Tests that the elastic search API is called correctly."""
|
||||||
"""
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestSearchEngine, self).setUp()
|
super(TestSearchEngine, self).setUp()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
hacking>=0.5.6,<0.8
|
hacking>=0.10.0,<0.11
|
||||||
|
|
||||||
coverage>=3.6
|
coverage>=3.6
|
||||||
discover
|
discover
|
||||||
|
4
tox.ini
4
tox.ini
@ -32,11 +32,11 @@ commands = python setup.py testr --coverage --coverage-package-name='elastic_rec
|
|||||||
commands = python elastic_recheck/bot.py -f -n --noirc elasticRecheck.conf
|
commands = python elastic_recheck/bot.py -f -n --noirc elasticRecheck.conf
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# H803 Skipped on purpose
|
# H233 Skipped because don't support python3 yet
|
||||||
# E125 Skipped because it's an overreach (and anti-emacs)
|
# E125 Skipped because it's an overreach (and anti-emacs)
|
||||||
# E123 Skipped because it decreases clarity in many cases
|
# E123 Skipped because it decreases clarity in many cases
|
||||||
|
|
||||||
ignore = E123,E125,H803
|
ignore = E123,E125,H233
|
||||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
|
Loading…
Reference in New Issue
Block a user