Skip to content

Commit d6cee1e

Browse files
author
Roey Darwish Dror
committed
Merge branch 'hotfix/0.26.2'
2 parents c069d29 + d745b10 commit d6cee1e

File tree

6 files changed

+54
-4
lines changed

6 files changed

+54
-4
lines changed

flask_app/app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
app_name: scotty
2-
APP_VERSION: 0.26.1
2+
APP_VERSION: 0.26.2
33
SECURITY_PASSWORD_HASH: sha512_crypt
44
SQLALCHEMY_TRACK_MODIFICATIONS: false

flask_app/blueprints/trackers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
})
2626
def create():
2727
tracker = request.json['tracker']
28-
if tracker['type'] not in ('jira', 'file'):
28+
if tracker['type'] not in ('jira', 'file', 'faulty'):
2929
return 'Bad tracker type', http.client.BAD_REQUEST
3030

3131
tracker_model = Tracker(

flask_app/issue_trackers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ def _refresh_file(url, issues):
1717
issue.open = data[issue.id_in_tracker]
1818

1919

20+
def _refresh_faulty():
21+
raise Exception("Tracker Error")
22+
23+
2024
def _refresh_jira(url, config, issues):
2125
config = confetti.Config(json.loads(config))
2226
jira = JIRA(url, basic_auth=(config.root.username, config.root.password))
@@ -42,5 +46,7 @@ def refresh(tracker, issues):
4246
_refresh_file(tracker.url, issues)
4347
elif tracker.type == "jira":
4448
_refresh_jira(tracker.url, tracker.config, issues)
49+
elif tracker.type == "faulty":
50+
_refresh_faulty()
4551
else:
4652
raise ValueError("Unknown tracker type {}".format(tracker.type))

flask_app/tasks.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,21 @@ def refresh_issue_trackers():
297297
for tracker in trackers:
298298
issues = db.session.query(Issue).filter_by(tracker_id=tracker.id)
299299
logger.info("Refreshing tracker {} - {} of type {}", tracker.id, tracker.url, tracker.type)
300-
issue_trackers.refresh(tracker, issues)
300+
try:
301+
issue_trackers.refresh(tracker, issues)
302+
except Exception:
303+
APP.raven.captureException()
304+
301305
db.session.commit()
302306

303307

304308
@queue.task
305309
@needs_app_context
306310
def nightly():
307-
refresh_issue_trackers()
311+
try:
312+
refresh_issue_trackers()
313+
except Exception:
314+
APP.raven.captureException()
308315
vacuum()
309316
validate_checksum()
310317

tests/slashconf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ def tracker(scotty):
172172
return FileTracker.create(scotty)
173173

174174

175+
@slash.fixture
176+
def faulty_tracker(scotty):
177+
return scotty.create_tracker('faulty_tracker', 'faulty', '', '')
178+
179+
175180
@slash.fixture
176181
def issue(tracker):
177182
return tracker.create_issue()

tests/test_deployment/test__vacuum.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,38 @@ def test_multiple_issues(tracker, scotty, beam, server_config, long_term_beam):
106106
scotty.check_beam_state(long_term_beam, False)
107107

108108

109+
def test_faulty_tracker(tracker, scotty, beam, issue, server_config, faulty_tracker, local_beam_dir):
110+
vacuum_threshold = server_config['VACUUM_THRESHOLD']
111+
112+
beam = scotty.get_beam(scotty.beam_up(local_beam_dir))
113+
114+
beam_with_issue = scotty.get_beam(scotty.beam_up(local_beam_dir))
115+
beam_with_issue.set_issue_association(issue.id_in_scotty, True)
116+
beam_with_issue.update()
117+
118+
faulty_issue = scotty.create_issue(faulty_tracker, '1')
119+
beam_with_faulty_issue = scotty.get_beam(scotty.beam_up(local_beam_dir))
120+
beam_with_faulty_issue.set_issue_association(faulty_issue, True)
121+
beam_with_faulty_issue.update()
122+
123+
assert beam_with_issue.purge_time is None
124+
assert beam_with_faulty_issue.purge_time is None
125+
assert beam.purge_time is vacuum_threshold
126+
scotty.sleep(_DAY * vacuum_threshold)
127+
128+
for beam in [beam_with_faulty_issue, beam_with_faulty_issue, beam]:
129+
beam.update()
130+
131+
scotty.check_beam_state(beam, True)
132+
scotty.check_beam_state(beam_with_faulty_issue, False)
133+
scotty.check_beam_state(beam_with_issue, False)
134+
135+
issue.set_state(False)
136+
scotty.sleep(_DAY)
137+
beam_with_issue.update()
138+
scotty.check_beam_state(beam_with_issue, True)
139+
140+
109141
def test_multiple_issues_and_multiple_beams(local_beam_dir, tracker, scotty, server_config, long_term_beam):
110142
vacuum_threshold = server_config['VACUUM_THRESHOLD']
111143
beam1 = scotty.get_beam(scotty.beam_up(local_beam_dir))

0 commit comments

Comments
 (0)