diff options
Diffstat (limited to 'tests/basic/peer-parsing.t')
| -rw-r--r-- | tests/basic/peer-parsing.t | 52 | 
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/basic/peer-parsing.t b/tests/basic/peer-parsing.t new file mode 100644 index 00000000000..210ec8ccd90 --- /dev/null +++ b/tests/basic/peer-parsing.t @@ -0,0 +1,52 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc + +PEER_DIR=/var/lib/glusterd/peers +TEST mkdir -p $PEER_DIR + +declare -i HOST_NUM=100 + +create_random_peer_files() { +        for i in $(seq 0 9); do +                local peer_uuid=$(uuidgen) +                # The rules for quoting and variable substitution in +                # here documents would force this to be even less +                # readable that way. +                ( +                        echo "state=1" +                        echo "uuid=$peer_uuid" +                        echo "hostname=127.0.0.$HOST_NUM" +                ) > $PEER_DIR/$peer_uuid +                HOST_NUM+=1 +        done +} + +create_non_peer_file() { +        echo "random stuff" > $PEER_DIR/not_a_peer_file +} + +create_malformed_peer_file() { +        echo "more random stuff" > $PEER_DIR/$(uuidgen) +} + +# We create lots of files, in batches, to ensure that our bogus ones are +# properly interspersed with the valid ones. + +TEST create_random_peer_files +TEST create_non_peer_file +TEST create_random_peer_files +TEST create_malformed_peer_file +TEST create_random_peer_files + +# There should be 30 peers, not counting the two bogus files. +TEST glusterd +N_PEERS=$($CLI peer status | grep ^Uuid: | wc -l) +TEST [ "$N_PEERS" = "30" ] + +# For extra credit, check the logs for messages about bogus files. + +cleanup + + +  | 
