#!/usr/bin/env bash set -ex function expect_false() { if "$@"; then return 1; else return 0; fi } function assert_locked() { local dev_id="${1#/dev/rbd}" local client_addr client_addr="$(< $SYSFS_DIR/$dev_id/client_addr)" local client_id client_id="$(< $SYSFS_DIR/$dev_id/client_id)" # client4324 -> client.4324 client_id="client.${client_id#client}" local watch_cookie watch_cookie="$(rados -p rbd listwatchers rbd_header.$IMAGE_ID | grep $client_id | cut -d ' ' -f 3 | cut -d '=' -f 2)" [[ $(echo -n "$watch_cookie" | grep -c '^') -eq 1 ]] local actual actual="$(rados -p rbd --format=json lock info rbd_header.$IMAGE_ID rbd_lock | python -m json.tool)" local expected expected="$(cat <