#!/bin/bash

# Test farm's cluster snapshot

seq=`basename $0`
echo "QA output created by $seq"

here=`pwd`
tmp=/tmp/$$
status=1        # failure is the default!

# get standard environment, filters and checks
. ./common.rc
. ./common.filter

_cleanup

for i in `seq 0 1`; do
    _start_sheep $i
done

_wait_for_sheep 2

$COLLIE cluster format -c 2

$COLLIE vdi create test 8M

dd if=/dev/urandom | $COLLIE vdi write test
$COLLIE cluster snapshot
$COLLIE vdi read test | md5sum > /tmp/csum.1

dd if=/dev/urandom | $COLLIE vdi write test
$COLLIE cluster snapshot
$COLLIE vdi read test | md5sum > /tmp/csum.2

dd if=/dev/urandom | $COLLIE vdi write test
$COLLIE cluster snapshot -l | _filter_date

$COLLIE cluster snapshot -R 2
$COLLIE vdi read test | md5sum > /tmp/csum.22

$COLLIE cluster snapshot -R 1
$COLLIE vdi read test | md5sum > /tmp/csum.11

diff -u /tmp/csum.1 /tmp/csum.11
diff -u /tmp/csum.2 /tmp/csum.22
