diff options
author | Josh Durgin <josh.durgin@dreamhost.com> | 2012-01-27 11:45:26 -0800 |
---|---|---|
committer | Josh Durgin <josh.durgin@dreamhost.com> | 2012-01-27 17:07:46 -0800 |
commit | 0f9c6b433405e0d7d38adbb2d1ebc3c169c7bb1c (patch) | |
tree | 2ce96d075d3761d935e9cf7b24fcbd713939c4a3 | |
parent | 097bc5cb1dbc83d8b09d4cb95c3c5abd1874de77 (diff) | |
download | ceph-0f9c6b433405e0d7d38adbb2d1ebc3c169c7bb1c.tar.gz |
test: add script for checking admin socket 'objecter_requests' output
Just a couple internal consistency checks for now. More specific ones
would depend on workload.
Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
-rwxr-xr-x | src/test/admin_socket/objecter_requests | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/test/admin_socket/objecter_requests b/src/test/admin_socket/objecter_requests new file mode 100755 index 00000000000..bd09d9ba1d5 --- /dev/null +++ b/src/test/admin_socket/objecter_requests @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +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'] + 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 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() |