From 6f8c121e9713f1219545e757fb2dcd91e2ac846e Mon Sep 17 00:00:00 2001 From: Sipke Vriend Date: Tue, 13 Sep 2022 23:12:56 +1000 Subject: [PATCH 1/2] Allow arbitrary table-field combinations against test suite and run To provide a way for users of TestArchiver to extend the data, add a special metadata name table#:{json-fields} where json-fields is of format {"field1":"value1", "field2":"value2"} and has to correspond exactly to the fields in the table-name table or naturally an exception will be thrown. The creation of the table is left to the user, as TestArchiver can not know what the table is. --- test_archiver/archiver.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test_archiver/archiver.py b/test_archiver/archiver.py index adad7b0..eb28c0e 100644 --- a/test_archiver/archiver.py +++ b/test_archiver/archiver.py @@ -2,6 +2,7 @@ import sys import time +import json from hashlib import sha1 from datetime import datetime, timedelta from collections import defaultdict @@ -321,6 +322,7 @@ def insert_metadata(self): self.metadata["time_adjust_secs_total"] = self.archiver.time_adjust.secs() for name in self.metadata: + table_prefix = 'table#' content = self.metadata[name] data = {'name': name, 'value': content, 'suite_id': self.id, 'test_run_id': self.test_run_id()} @@ -333,6 +335,14 @@ def insert_metadata(self): self.archiver.test_series[series_name] = build_number elif name == 'team': self.archiver.team = content + elif name.startswith(table_prefix): + table = name[len(table_prefix):] + if table: + fields = json.loads(content) + fields['suite_id'] = self.id + fields['test_run_id'] = self.test_run_id() + self.archiver.db.insert(table, fields) + def register_metadata(self, name=None, value=None): if name: From edcdca9694d29ecca7cd65d64f70fc6f59caf61a Mon Sep 17 00:00:00 2001 From: Sipke Vriend Date: Mon, 3 Oct 2022 17:35:27 +1000 Subject: [PATCH 2/2] Update readme with table# metadata information Add documentation to help clarify how the table# metadata can be used to extend any information against a test run. --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index d484ed9..8ecfe39 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,19 @@ There are meta data that are useful to add with the results. Some testing framew `--metadata NAME:VALUE` +### Table Extension metadata + +To allow extension of data tables against test runs, the metadata tag __table#__ can be used with a ____ record specified by a json value. +For example a metadata entry +`table#host_info:{"host_name":"test_machine01", "host_location":"Paris", "user":"James"}` +would result in a record written to the database table __host_info__, with the json specified fields __host_name, host_location, user__ against TestArchiver's __suite_id__ and __test_run_id__. + +This will allow for extended information, specific to a test environment, to be defined as required by a test team. + +This table is not created by TestArchiver, so the user needs to ensure it is created by a different process. + +The full json value is also written to the metadata table as per any other metadata. + ## Test series and teams In the data model, each test result file is represented as single test run. These test runs are linked and organized into builds in in different result series. Depending on the situation the series can be e.g. CI build jobs or different branches. By default if no series is specified the results are linked to a default series with autoincrementing build numbers. Different test runs (from different testing frameworks or parallel executions) that belong together can be organized into the same build. Different test series are additionally organized by team. Series name and build number/id are separated by `#`.