Use pre-defined DB collection names in memcheck_upload.py CLI (#651)
authorVitaliy Urusovskij <vitaliy.urusovskij@intel.com>
Wed, 3 Jun 2020 10:54:38 +0000 (13:54 +0300)
committerGitHub <noreply@github.com>
Wed, 3 Jun 2020 10:54:38 +0000 (13:54 +0300)
Use argparses `choices` for `--db_collection` option.

Also removed unnecessary redefinition of `db_collection` in memcheck_upload.py

tests/stress_tests/scripts/memcheck_upload.py

index d23bc4d..0f6474b 100644 (file)
@@ -165,8 +165,6 @@ def query_timeline(records, db_url, db_collection, max_items=20, similarity=TIME
 def create_memcheck_report(records, db_url, db_collection, output_path):
     """ Create memcheck timeline HTML report for records.
     """
-    if db_collection == 'pre_commit':
-        db_collection = 'commit'  # pre-commit jobs building report from past commits
     records.sort(
         key=lambda item: f"{item['status']}{item['device']}{item['model']}{item['test_name']}")
     timelines = query_timeline(records, db_url, db_collection)
@@ -203,7 +201,8 @@ def main():
     parser.add_argument('--db_url', required=not is_dryrun,
                         help='MongoDB URL in a for "mongodb://server:port".')
     parser.add_argument('--db_collection', required=not is_dryrun,
-                        help=f'Collection name in {DATABASE} database to upload')
+                        help=f'Collection name in {DATABASE} database to upload.',
+                        choices=["commit", "nightly", "weekly"])
     parser.add_argument('--artifact_root', required=True,
                         help=f'A root directory to strip from log path before upload.')
     parser.add_argument('--append', help='JSON to append to each item.')