From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/test/admin_socket/objecter_requests | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 src/test/admin_socket/objecter_requests (limited to 'src/test/admin_socket/objecter_requests') diff --git a/src/test/admin_socket/objecter_requests b/src/test/admin_socket/objecter_requests new file mode 100755 index 000000000..c4c9edf96 --- /dev/null +++ b/src/test/admin_socket/objecter_requests @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 + +import json +import sys + + +def main(): + """ + Read json output of admin socket command 'objecter_requests' from + stdin, and check it for internal consistency and presence of + fields. + """ + read = sys.stdin.read() + reqs = json.loads(read) + + op_types = ['linger_ops', 'ops', 'pool_ops', 'pool_stat_ops', 'statfs_ops', 'command_ops'] + assert sorted(reqs.keys()) == sorted(op_types) + + found_error = check_osd_ops(reqs['ops'] + reqs['linger_ops']) + assert not found_error, "ERRORS FOUND!" + + +def check_osd_ops(ops): + pg_map = {} + locators = {} + osds = {} + found_error = [False] + + def add_to_mapping(mapping, key, value, msg): + if key in mapping: + if mapping[key] != value: + print('%s != %s' % (mapping[key], value)) + print(msg) + found_error[0] = True + else: + mapping[key] = value + + for op in ops: + add_to_mapping( + mapping=pg_map, + key=(op['object_id'], op['object_locator']), + value=op['pg'], + msg='ERROR: two ops for the same object mapped to different pgs', + ) + add_to_mapping( + mapping=locators, + key=op['object_id'], + value=op['object_locator'], + msg='ERROR: requests to the same object had different locators', + ) + add_to_mapping( + mapping=osds, + key=op['pg'], + value=op['osd'], + msg='ERROR: two ops mapped a pg to different osds', + ) + return found_error[0] + +if __name__ == '__main__': + main() -- cgit v1.2.3