4 Check that all the classdef versions and class checksums are consistent to prevent accidental mismatch:
6 If one forgets to increase the ClassDef but the streamer info checksum changes this will trigger a test failure. We can distuingish
8 1. ClassDef version changed unnecessary
9 2. forgot to change ClassDef
14 from b2test_utils
import get_object_with_name, get_streamer_checksums
17 EXPECTED_CHECKSUMS = {
18 'Belle2::Const::DetectorSet': (1, 1222446098),
19 'Belle2::ECLCluster': (14, 932603982),
20 'Belle2::EventLevelClusteringInfo': (1, 162935545),
21 'Belle2::EventLevelTrackingInfo': (2, 1667284927),
22 'Belle2::EventMetaData': (4, 2999207747),
23 'Belle2::FileMetaData': (10, 3436593892),
24 'Belle2::KLMCluster': (2, 2615188022),
25 'Belle2::KlId': (2, 230716330),
26 'Belle2::PIDLikelihood': (3, 36434623),
27 'Belle2::RelationContainer': (1, 1725678837),
28 'Belle2::RelationElement': (1, 1883389510),
29 'Belle2::RelationsInterface<TObject>': (0, 3862127315),
30 'Belle2::SoftwareTriggerResult': (5, 241059817),
31 'Belle2::TRGSummary': (7, 1658421299),
32 'Belle2::Track': (4, 839781593),
33 'Belle2::TrackFitResult': (8, 1247854432),
34 'Belle2::V0': (3, 4006259140),
45 "EventLevelTrackingInfo",
48 "EventLevelClusteringInfo",
52 "SoftwareTriggerResult",
55 if __name__ ==
"__main__":
58 objects = [get_object_with_name(object_name)()
for object_name
in OBJECT_NAMES]
65 found = get_streamer_checksums(objects)
67 if 'TObject' in found:
71 print(
"found_checksums = {\n " +
"\n ".join(f
"{k!r}: {v!r}," for k, v
in sorted(found.items())) +
"\n}")
72 for key, (version, checksum)
in found.items():
73 if key
not in EXPECTED_CHECKSUMS:
74 problems.append(f
"There is no {key} in the checksum dictionary!")
81 expected_version, expected_checksum = EXPECTED_CHECKSUMS[key]
83 if expected_version != version
and expected_checksum == checksum:
84 problems.append(f
"The version for {key} has changed (expected={expected_version}, found={version}) "
85 f
"while the checksum has not. This probably means the ClassDef version was increased unnecessarily. "
86 f
"If this is intentional please update the expected version in this test")
87 elif expected_version == version
and expected_checksum != checksum:
88 problems.append(f
"The checksum for {key} has changed (expected={expected_checksum}, found={checksum}) "
89 f
"while the version has not. This probably means you forgot to increase the ClassDef version "
90 f
"after changing the class. Please update the ClassDef version and the expected values in this test")
91 elif expected_version != version
and expected_checksum != checksum:
92 problems.append(f
"The version and checksum for {key} have changed, (expected version={expected_version}, "
93 f
"checksum={expected_checksum}, found version={version}, checksum={checksum}). "
94 f
"Please update the expected values")
95 del EXPECTED_CHECKSUMS[key]
97 for remaining, (version, checksum)
in EXPECTED_CHECKSUMS.items():
98 problems.append(f
"Additional class expected but not needed: {remaining} (version {version}, checksum {checksum})")
101 print(
"Check finished")
103 problems =
"\n\t * ".join([
""] + problems)
104 print(
"Check failed: Most likely a mdst class has been modified and the list of expected checksums needs to be adjusted:",