Merge "Add support to subunit2sql cli to specify a run_at time"
This commit is contained in:
commit
2a4e6c155d
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
features:
|
||||||
|
- A new CLI option, "run_at" is available on the subunit2sql CLI. This
|
||||||
|
enables setting a specific date and time to use for the run_at column
|
||||||
|
of the run being created. If one is not specified the previous default
|
||||||
|
behavior of using the current time is still used.
|
|
@ -7,3 +7,4 @@ python-subunit>=0.0.18
|
||||||
six>=1.5.2
|
six>=1.5.2
|
||||||
SQLAlchemy>=0.8.2
|
SQLAlchemy>=0.8.2
|
||||||
stevedore>=1.3.0
|
stevedore>=1.3.0
|
||||||
|
python-dateutil>=2.4.2
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
import copy
|
import copy
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from dateutil import parser as date_parser
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_db import options
|
from oslo_db import options
|
||||||
from pbr import version
|
from pbr import version
|
||||||
|
@ -47,6 +48,10 @@ SHELL_OPTS = [
|
||||||
help='An optional prefix to identify global test attrs '
|
help='An optional prefix to identify global test attrs '
|
||||||
'and treat it as test metadata instead of test_run '
|
'and treat it as test metadata instead of test_run '
|
||||||
'metadata'),
|
'metadata'),
|
||||||
|
cfg.StrOpt('run_at', default=None,
|
||||||
|
help="The optional datetime string for the run was started, "
|
||||||
|
"If one isn't provided the date and time of when "
|
||||||
|
"subunit2sql is called will be used")
|
||||||
]
|
]
|
||||||
|
|
||||||
_version_ = version.VersionInfo('subunit2sql').version_string()
|
_version_ = version.VersionInfo('subunit2sql').version_string()
|
||||||
|
@ -128,9 +133,13 @@ def process_results(results):
|
||||||
session = api.get_session()
|
session = api.get_session()
|
||||||
run_time = results.pop('run_time')
|
run_time = results.pop('run_time')
|
||||||
totals = get_run_totals(results)
|
totals = get_run_totals(results)
|
||||||
|
if CONF.run_at:
|
||||||
|
run_at = date_parser.parse(CONF.run_at)
|
||||||
|
else:
|
||||||
|
run_at = None
|
||||||
db_run = api.create_run(totals['skips'], totals['fails'],
|
db_run = api.create_run(totals['skips'], totals['fails'],
|
||||||
totals['success'], run_time, CONF.artifacts,
|
totals['success'], run_time, CONF.artifacts,
|
||||||
id=CONF.run_id, session=session)
|
id=CONF.run_id, run_at=run_at, session=session)
|
||||||
if CONF.run_meta:
|
if CONF.run_meta:
|
||||||
api.add_run_metadata(CONF.run_meta, db_run.id, session)
|
api.add_run_metadata(CONF.run_meta, db_run.id, session)
|
||||||
for test in results:
|
for test in results:
|
||||||
|
|
Loading…
Reference in New Issue