# HG changeset patch # User David Scott # Date 1269807185 -3600 # Node ID 3eb795a365a3c3f77c395a33d7cbd8f5932d2dcd # Parent e1ff2ddf639451cf2e58d86fefe2425288059a18 CA-36278: add short test for the redo log functionality Signed-off-by: David Scott diff -r e1ff2ddf6394 -r 3eb795a365a3 scripts/tests-metadata-alert --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/tests-metadata-alert Sun Mar 28 21:13:05 2010 +0100 @@ -0,0 +1,79 @@ +#!/bin/sh + +# Test repeatedly blocking and unblocking iSCSI and verifying that we get +# METADATA_LUN_{BROKEN,HEALTHY} alerts. + +# NB the METADATA_LUN must be turned on already. + +set -e + +pool=$(xe pool-list params=uuid --minimal) + +clear_messages() { + IFS=","; for message in $(xe message-list params=uuid --minimal); do + xe message-destroy uuid=$message + done +} + +block(){ + echo "Blocking LUN" + iptables -I OUTPUT -p tcp --dport 3260 -j DROP +} + +unblock(){ + echo "Unblocking LUN" + iptables -F +} + +wait_for_message() { + local healthy=$1 + if [ ${healthy} -eq 1 ]; then + echo "Waiting for LUN healthy" + else + echo "Waiting for LUN broken" + fi + for((retry=1;retry<600;retry++)); do + # Prodding the system with a write here seems to "unstick" it: + xe pool-param-set uuid=${pool} other-config:attempt=${retry} + finished=1 + IFS=","; for message in $(xe message-list params=uuid --minimal); do + name=$(xe message-list uuid=$message params=name --minimal) + echo "Examining ${name}" + if [ "${name}" = "METADATA_LUN_HEALTHY" ]; then + if [ ${healthy} -eq 1 ]; then + echo "${name}-- expected (${retry} s)"; + return 0 + else + echo "${name}-- unexpected"; + return 1 + fi + fi + if [ "${name}" = "METADATA_LUN_BROKEN" ]; then + if [ ${healthy} -eq 1 ]; then + echo "${name}-- unexpected"; + return 1 + else + echo "${name}-- expected (${retry} s)"; + return 0 + fi + fi + done + echo -n . + sleep 1s + done + return 1 +} + +for ((i=0;i<1000;i++)); +do + echo Iteration $i + xe pool-param-set uuid=${pool} name-description=1 + clear_messages + block + xe pool-param-set uuid=${pool} name-description=2 + wait_for_message 0 + clear_messages + unblock + xe pool-param-set uuid=${pool} name-description=3 + wait_for_message 1 +done \ No newline at end of file