diff options
author | Jeff Darcy <jdarcy@fb.com> | 2017-07-25 17:40:49 -0700 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2017-07-27 04:55:23 +0000 |
commit | 16e8d03c7e4afa4c0e186f8ea50389fc3735e879 (patch) | |
tree | 78743e05841f68da4a79bd623210a452755ddbc5 /tests | |
parent | b90e12134af85635199750967c326761d6c06e86 (diff) |
glusterd: make peerfile parsing more robust
Differential Revision: https://phabricator.intern.facebook.com/D5498639
Change-Id: I3184ed8f3dadbdcffd46f4ade855fa93131efa82
BUG: 1462969
Signed-off-by: Jeff Darcy <jdarcy@fb.com>
Reviewed-on: https://review.gluster.org/17885
Smoke: Gluster Build System <jenkins@build.gluster.org>
Tested-by: Jeff Darcy <jeff@pl.atyp.us>
Reviewed-by: Prashanth Pai <ppai@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'tests')
-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 + + + |