def main(): idx = sys.argv[1] num = 0 if len(sys.argv) > 2: num = int(sys.argv[2]) es = elasticsearch.Elasticsearch() old_exclude_rum = {'query': {'bool': {'must_not': [{'term': {'context.service.agent.name': 'js-base'}}]}}} exclude_rum = {'query': {'bool': {'must_not': [{'term': {'agent.name': 'js-base'}}]}}} try: orig = es.search(index=idx.replace("7.0.0", "6.6.2"), body=old_exclude_rum, sort="timestamp.us:asc,@timestamp:asc,context.service.agent.name:asc", size=num+1)["hits"]["hits"][num]["_source"] except elasticsearch.exceptions.NotFoundError: orig = None want = es.search(index=idx, body=exclude_rum, sort="timestamp.us:asc,@timestamp:asc,agent.name:asc", size=num+1)["hits"]["hits"][num]["_source"] got = es.search(index=idx+"-migrated", body=exclude_rum, sort="timestamp.us:asc,@timestamp:asc,agent.name:asc", size=num+1)["hits"]["hits"][num]["_source"] print("Diff:") print(jsondiff.JsonDiffer(syntax='symmetric', dump=True, dumper=jsondiff.JsonDumper(indent=True)).diff(want, got)) print() if orig: print("Original:") json.dump(orig, sys.stdout, sort_keys=True) print() print("Wanted:") json.dump(want, sys.stdout, sort_keys=True) print() print("Got:") json.dump(got, sys.stdout, sort_keys=True) print()
def compare_glb( a, b, binary, tweaks=( #tweak_fix_sampler, #tweak_remove_vertexid, #tweak_ignore_nondeterministic_geometry, #tweak_remove_color_minmax, tweak_ignore_generator, tweak_rename_refimage, tweak_ignore_envlight, )): if open(a).read() == open(b).read(): return (True, 'IDENTICAL') glbs = list(map(BaseGlb.create, [a, b])) objs = [json.loads(g.get_json()) for g in glbs] for tweak in tweaks: tweak(objs) details = jsondiff.diff(objs[0], objs[1], syntax='symmetric', dump=True, dumper=jsondiff.JsonDumper(indent=2)) if binary: bin_same, bin_details = binary_diff(glbs[0].bin_chunk, glbs[1].bin_chunk) else: bin_same, bin_details = True, 'n/a' return details == '{}' and bin_same, details + bin_details
def grafana_query_diff(old_queries, new_queries): # type: (dict, dict) -> str """returns human-readable diff between two Grafana query strings""" # dump=True converts the result to a string and replaces the special keys # jsondiff.delete and jsondiff.insert with the strings "$delete" and "$insert" return jsondiff.diff(old_queries, new_queries, dump=True, dumper=jsondiff.JsonDumper(sort_keys=True, indent=2))