traffic: fix hash non-determinism when loading JSON
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 3 Jan 2019 02:54:37 +0000 (15:54 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Tue, 8 Jan 2019 22:55:33 +0000 (23:55 +0100)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Tim Beale <timbeale@samba.org>
python/samba/emulate/traffic.py

index 21c68f3..b6097cd 100644 (file)
@@ -1216,6 +1216,7 @@ class TrafficModel(object):
             values = self.ngrams.setdefault(k, [])
             for p, count in v.items():
                 values.extend([str(p)] * count)
+            values.sort()
 
         for k, v in d['query_details'].items():
             values = self.query_details.setdefault(str(k), [])
@@ -1224,6 +1225,7 @@ class TrafficModel(object):
                     values.extend([()] * count)
                 else:
                     values.extend([tuple(str(p).split('\t'))] * count)
+            values.sort()
 
         if 'dns' in d:
             for k, v in d['dns'].items():