Skip to content

Commit 024b812

Browse files
committed
Merge branch 'release/2.31.0'
2 parents 6008d95 + 5ee9e8b commit 024b812

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

backslash/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def report_session_start(self, logical_id=NOTHING,
4545
keepalive_interval=NOTHING,
4646
subjects=NOTHING,
4747
infrastructure=NOTHING,
48+
ttl_seconds=NOTHING,
4849
):
4950
"""Reports a new session starting
5051
@@ -59,6 +60,7 @@ def report_session_start(self, logical_id=NOTHING,
5960
'keepalive_interval': keepalive_interval,
6061
'subjects': subjects,
6162
'infrastructure': infrastructure,
63+
'ttl_seconds': ttl_seconds,
6264
}
6365
if parent_logical_id is not None or is_parent_session:
6466
supports_parallel = (self.api.info().endpoints.report_session_start.version >= 2)

backslash/contrib/slash_plugin.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ def get_name(self):
111111

112112
def get_config(self):
113113
return {
114+
"session_ttl_days": 0 // Doc(
115+
'Optional number of days after which this session will be discarded '
116+
'from Backslash') // Cmdline(arg='--session-ttl-days', metavar='DAYS'),
117+
118+
114119
"session_labels": [] // Doc('Specify labels to be added to the session when reported') \
115120
// Cmdline(append="--session-label", metavar="LABEL"),
116121
}
@@ -181,7 +186,11 @@ def _get_initial_session_metadata(self):
181186
return returned
182187

183188
def _get_extra_session_start_kwargs(self):
184-
return {}
189+
returned = {}
190+
ttl_seconds = slash_config.root.plugin_config.backslash.session_ttl_days * 24 * 60 * 60
191+
if ttl_seconds:
192+
returned['ttl_seconds'] = ttl_seconds
193+
return returned
185194

186195
@slash.plugins.register_if(_HAS_TEST_AVOIDED)
187196
@handle_exceptions
@@ -332,6 +341,11 @@ def _update_scm_info(self, test_info):
332341
hexsha = None
333342
test_info['scm_revision'] = hexsha
334343
test_info['scm_dirty'] = bool(repo.untracked_files or repo.index.diff(None) or repo.index.diff(repo.head.commit))
344+
if self.client.api.info().endpoints.report_test_start.version >= 3:
345+
test_info['scm_local_branch'] = repo.active_branch.name
346+
tracking_branch = repo.active_branch.tracking_branch()
347+
if tracking_branch is not None:
348+
test_info['scm_remote_branch'] = tracking_branch.name
335349
except Exception: # pylint: disable=broad-except
336350
_logger.warning('Error when obtaining SCM information', exc_info=True)
337351

backslash/session.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ def send_keepalive(self):
2727
self.client.api.call_function('send_keepalive', {'session_id': self.id})
2828

2929
def report_test_start(self, name, file_name=NOTHING, class_name=NOTHING, test_logical_id=NOTHING, scm=NOTHING,
30-
file_hash=NOTHING, scm_revision=NOTHING, scm_dirty=NOTHING, is_interactive=NOTHING,
31-
variation=NOTHING, metadata=NOTHING, test_index=NOTHING, parameters=NOTHING):
30+
file_hash=NOTHING,
31+
scm_revision=NOTHING, scm_dirty=NOTHING, scm_local_branch=NOTHING, scm_remote_branch=NOTHING,
32+
is_interactive=NOTHING, variation=NOTHING, metadata=NOTHING, test_index=NOTHING, parameters=NOTHING):
3233

3334
params = {
3435
'session_id': self.id,
@@ -37,6 +38,8 @@ def report_test_start(self, name, file_name=NOTHING, class_name=NOTHING, test_lo
3738
'file_hash': file_hash,
3839
'scm_revision': scm_revision,
3940
'scm_dirty': scm_dirty,
41+
'scm_local_branch': scm_local_branch,
42+
'scm_remote_branch': scm_remote_branch,
4043
'class_name': class_name,
4144
'file_name': file_name,
4245
'is_interactive': is_interactive,

docs/changelog.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
Changelog
22
=========
33

4-
* :release: `2.30.0 <8-8-2017>`
4+
* :release:`2.31.0 <10-9-2017>`
5+
* :feature:`52` Support reporting sessions with a specific TTL, marking them for future deletion on the server
6+
* :feature:`51` Report local and remote SCM branches if supported
7+
* :release:`2.30.0 <8-8-2017>`
58
* :feature:`50` Added session_webapp_url property to the Slash plugin
69
* :release:`2.29.0 <6-8-2017>`
710
* :feature:`49` Add hook for intercepting keepalive thread exceptions

0 commit comments

Comments
 (0)