Skip to content

Commit bbf46b2

Browse files
author
Pavel Kosov
committed
[LNT] Fix profile assigning to tests
report.json may contain the following content: “Tests”: [ {“Data”: [ 123 ], “Name”: “nts.SomeTest.test:subTest1.exec”}, {“Data”: [ 456 ], “Name”: “nts.SomeTest.test:subTest2.exec”}, {“Data”: [ “base64_encoded_profile_data” ], “Name”: “nts.SomeTest.profile”} ] This report.json contains 2 tests (execution_time) and 1 profile data which must be assigned to both tests. Currently LNT creates 3 tests. First 2 tests do not have a profile data. 3rd test does not have any metric, but has the profile data. This patch implements the correct processing such reports. OS Laboratory. Huawei Russian Research Institute. Saint-Petersburg Reviewed By: thopre Differential Revision: https://reviews.llvm.org/D115702
1 parent e4ede11 commit bbf46b2

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

lnt/server/db/testsuitedb.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,10 +1038,14 @@ def _importSampleValues(self, session, tests_data, run, config):
10381038
test_cache = dict((test.name, test)
10391039
for test in session.query(self.Test))
10401040

1041-
profiles = dict()
10421041
field_dict = dict([(f.name, f) for f in self.sample_fields])
10431042
all_samples_to_add = []
1043+
is_profile_only = lambda td : len(td) == 2 and 'profile' in td
10441044
for test_data in tests_data:
1045+
if is_profile_only(test_data):
1046+
# Ignore for now profile data without other metrics
1047+
continue
1048+
10451049
name = test_data['name']
10461050
test = test_cache.get(name)
10471051
if test is None:
@@ -1066,10 +1070,42 @@ def _importSampleValues(self, session, tests_data, run, config):
10661070
all_samples_to_add.append(sample)
10671071
for sample, value in zip(samples, values):
10681072
if key == 'profile':
1069-
profile = self.Profile(value, config, name)
1070-
sample.profile = profiles.get(hash(value), profile)
1073+
sample.profile = self.Profile(value, config, name)
10711074
else:
10721075
sample.set_field(field, value)
1076+
1077+
for test_data in tests_data:
1078+
if not is_profile_only(test_data):
1079+
continue
1080+
name = test_data['name']
1081+
test = test_cache.get(name)
1082+
tests = [test_cache[test_name] for test_name in test_cache \
1083+
if test_name.startswith(name + '.test:')]
1084+
if test is not None:
1085+
tests.append(test)
1086+
1087+
value = test_data['profile']
1088+
new_profile = self.Profile(value, config, name)
1089+
count = 0
1090+
for test in tests:
1091+
sample_exist = False
1092+
for sample in all_samples_to_add:
1093+
if sample.test == test:
1094+
if sample.profile is None:
1095+
sample.profile = new_profile
1096+
count += 1
1097+
sample_exist = True
1098+
else:
1099+
logger.warning('Test %s already contains the profile data. ' \
1100+
'Profile %s was ignored.', test.name, name)
1101+
if not sample_exist:
1102+
logger.warning('The test %s is invalid. It contains the profile, ' \
1103+
'but no any samples. Consider removing it.', test.name)
1104+
if count == 0:
1105+
logger.warning('Cannot find test(s) for the profile %s', name)
1106+
else:
1107+
logger.info('The profile %s was added to %d test(s).', name, count)
1108+
10731109
session.add_all(all_samples_to_add)
10741110

10751111
def importDataFromDict(self, session, data, config, select_machine,

lnt/testing/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ def __init__(self, metric_rename, machine_param_rename, run_param_rename):
485485
'.hash.status': 'hash_status',
486486
'.mem': 'mem_bytes',
487487
'.score': 'score',
488+
'.profile': 'profile',
488489
}, machine_param_rename={
489490
'name': 'hostname', # Avoid name clash with actual machine name.
490491
}, run_param_rename={

0 commit comments

Comments
 (0)