c55148d71d
The content of this branch was automatically imported from Fedora ELN with the following as its source: https://src.fedoraproject.org/rpms/corosync#f5d04d3ef888057942681da291d516392bfd597b
624 lines
30 KiB
Bash
624 lines
30 KiB
Bash
#!/bin/bash
|
|
|
|
# This file was autogenerated at 2019-05-13T13:43:38+02:00 from 90bd97ada89befa1a63133335a419ad7311c3d75
|
|
|
|
# Copyright (c) 2019, Red Hat, Inc.
|
|
#
|
|
# Permission to use, copy, modify, and/or distribute this software for any
|
|
# purpose with or without fee is hereby granted, provided that the above
|
|
# copyright notice and this permission notice appear in all copies.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND RED HAT, INC. DISCLAIMS ALL WARRANTIES
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
|
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RED HAT, INC. BE LIABLE
|
|
# FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
#
|
|
# Author: Jan Friesse <jfriesse@redhat.com>
|
|
|
|
|
|
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
# !!! Script overwrites corosync.conf, authkey and qdevice/qnetd certificates !!!
|
|
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
# Home https://github.com/jfriesse/csts/tree/master/smoke
|
|
|
|
# -e is really important
|
|
set -xe
|
|
set -o pipefail
|
|
|
|
# Variables changing test behavior
|
|
PREFIX="/"
|
|
|
|
COROSYNC_SYSCONFD="${PREFIX}etc/corosync"
|
|
COROSYNC_CONF="${COROSYNC_SYSCONFD}/corosync.conf"
|
|
COROSYNC_AUTHKEY="${COROSYNC_SYSCONFD}/authkey"
|
|
COROSYNC_CLUSTER_NAME="smoketestcluster"
|
|
|
|
TOKEN_TIMEOUT=1000
|
|
MAX_REPEATS=60
|
|
|
|
####################
|
|
# Helper functions #
|
|
####################
|
|
get_ip() {
|
|
ip_res=$(ip route get 8.8.8.8)
|
|
# Format is "8.8.8.8 via ROUTE_IPADDR dev DEV src IPADDR uid NUMBER"
|
|
# Remove everything up to "src " and then everything after " "
|
|
addr=${ip_res##*src }
|
|
addr=${addr%% *}
|
|
|
|
echo "$addr"
|
|
}
|
|
|
|
# generate_corosync_conf crypto [token] [qdevice]
|
|
# crypto can be on or off
|
|
# when token is defined it is used for token timeout
|
|
# when qdevice is set to on qdevice section is created and second node is added
|
|
generate_corosync_conf() {
|
|
case "$1" in
|
|
"on")
|
|
cipher="aes256"
|
|
hash="sha256"
|
|
;;
|
|
"off")
|
|
cipher="none"
|
|
hash="none"
|
|
;;
|
|
*)
|
|
# Unknown crypto
|
|
exit 1
|
|
esac
|
|
|
|
token=$TOKEN_TIMEOUT
|
|
if [ ! -z "$2" ];then
|
|
token="$2"
|
|
fi
|
|
qdevice="$3"
|
|
true_command=`which true`
|
|
|
|
cat << _EOF_
|
|
totem {
|
|
version: 2
|
|
cluster_name: $COROSYNC_CLUSTER_NAME
|
|
transport: knet
|
|
crypto_cipher: $cipher
|
|
crypto_hash: $hash
|
|
token: $token
|
|
}
|
|
|
|
logging {
|
|
to_logfile: yes
|
|
logfile: /var/log/cluster/corosync.log
|
|
to_syslog: yes
|
|
}
|
|
|
|
quorum {
|
|
provider: corosync_votequorum
|
|
_EOF_
|
|
|
|
if [ "$qdevice" == "on" ];then
|
|
cat << _EOF_
|
|
device {
|
|
votes: 1
|
|
model: net
|
|
net {
|
|
host: $LOCAL_IP
|
|
algorithm: ffsplit
|
|
}
|
|
heuristics {
|
|
mode: sync
|
|
exec_true: $true_command
|
|
}
|
|
}
|
|
_EOF_
|
|
fi
|
|
|
|
cat << _EOF_
|
|
}
|
|
|
|
nodelist {
|
|
node {
|
|
nodeid: 1
|
|
ring0_addr: $LOCAL_IP
|
|
}
|
|
_EOF_
|
|
|
|
if [ "$qdevice" == "on" ];then
|
|
cat << _EOF_
|
|
node {
|
|
nodeid: 2
|
|
ring0_addr: 192.0.2.2
|
|
}
|
|
_EOF_
|
|
fi
|
|
|
|
cat << _EOF_
|
|
}
|
|
_EOF_
|
|
}
|
|
|
|
# service_start service
|
|
service_start() {
|
|
# service service must be inactive
|
|
systemctl is-active "$1" && exit 1 || true
|
|
|
|
systemctl start "$1"
|
|
|
|
systemctl is-active "$1"
|
|
}
|
|
|
|
# service_stop service
|
|
service_stop() {
|
|
systemctl is-active "$1" || exit 1
|
|
|
|
systemctl stop "$1"
|
|
|
|
systemctl is-active "$1" && exit 1 || true
|
|
}
|
|
|
|
######################
|
|
# Computed variables #
|
|
######################
|
|
LOCAL_IP=$(get_ip)
|
|
|
|
##################
|
|
# C test sources #
|
|
##################
|
|
|
|
# Test sources are encoded as a base64 string and piped to base64 to store them in /tmp
|
|
# corosync-api-test.c
|
|
echo "LyoKICogQ29weXJpZ2h0IChjKSAyMDE5LCBSZWQgSGF0LCBJbmMuCiAqCiAqIFBlcm1pc3Npb24g
|
|
dG8gdXNlLCBjb3B5LCBtb2RpZnksIGFuZC9vciBkaXN0cmlidXRlIHRoaXMgc29mdHdhcmUgZm9y
|
|
IGFueQogKiBwdXJwb3NlIHdpdGggb3Igd2l0aG91dCBmZWUgaXMgaGVyZWJ5IGdyYW50ZWQsIHBy
|
|
b3ZpZGVkIHRoYXQgdGhlIGFib3ZlCiAqIGNvcHlyaWdodCBub3RpY2UgYW5kIHRoaXMgcGVybWlz
|
|
c2lvbiBub3RpY2UgYXBwZWFyIGluIGFsbCBjb3BpZXMuCiAqCiAqIFRI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mludAptYWlu
|
|
KHZvaWQpCnsKCWludCBpOwoJcGlkX3QgZm9ya19yZXM7CglwaWRfdCB3YWl0X3JlczsKCWludCBz
|
|
dGF0dXM7CgoJRU5URVIoKTsKCglzZXRsaW5lYnVmKHN0ZG91dCk7CgoJZm9yIChpID0gMDsgaSA8
|
|
IE5PX0NISUxEUzsgaSsrKSB7CgkJbXlfaWQgPSBpOwoKCQlmb3JrX3JlcyA9IGZvcmsoKTsKCgkJ
|
|
aWYgKGZvcmtfcmVzID09IC0xKSB7CgkJCXBlcnJvcigiZm9yayIpOwoJCX0KCgkJaWYgKGZvcmtf
|
|
cmVzID09IDApIHsKCQkJLyoKCQkJICogQ2hpbGQKCQkJICovCgkJCWJyZWFrIDsKCQl9IGVsc2Ug
|
|
ewoJCQkvKgoJCQkgKiBQYXJlbnQKCQkJICovCgkJCW15X2lkID0gLTE7CgkJfQoJfQoKCWlmIChm
|
|
b3JrX3JlcyA9PSAwKSB7CgkJLyoKCQkgKiBDaGlsZCBydW5zIHRoZSB0ZXN0CgkJICovCgkJdGVz
|
|
dF9jcGcoKTsKCX0gZWxzZSB7CgkJLyoKCQkgKiBXYWl0IGZvciBjaGlsZHMKCQkgKi8KCQlmb3Ig
|
|
KGkgPSAwOyBpIDwgTk9fQ0hJTERTOyBpKyspIHsKCQkJd2FpdF9yZXMgPSB3YWl0KCZzdGF0dXMp
|
|
OwoJCQlpZiAod2FpdF9yZXMgPT0gLTEpIHsKCQkJCXBlcnJvcigid2FpdCIpOwoJCQl9CgoJCQlh
|
|
c3NlcnQoV0lGRVhJVEVEKHN0YXR1cykpOwoJCQlhc3NlcnQoV0VYSVRTVEFUVVMoc3RhdHVzKSA9
|
|
PSAwKTsKCQl9Cgl9CgoJTEVBVkUoKTsKCglyZXR1cm4gKDApOwp9Cg==" | base64 -d | tee "/tmp/corosync-api-test-mp.c"
|
|
# - corosync-api-test-mp.c
|
|
##################
|
|
# Test functions #
|
|
##################
|
|
test_corosync_v() {
|
|
# Check corosync -v exits without error and
|
|
# result version contain numbers in path format [0-9]*.[0-9]*.[0-9]
|
|
ver_res=$(corosync -v)
|
|
[ "$ver_res" != "${ver_res/[0-9]*\.[0-9]*\.[0-9]/}" ]
|
|
}
|
|
|
|
test_corosync_keygen() {
|
|
rm -f "$COROSYNC_AUTHKEY"
|
|
corosync-keygen
|
|
|
|
# File exists
|
|
[ -f "$COROSYNC_AUTHKEY" ]
|
|
|
|
# ... and is not empty (wc format is "SIZE FILENAME" - remove FILENAME part)
|
|
wc_res=$(wc -c "$COROSYNC_AUTHKEY")
|
|
[ "${wc_res%% *}" -gt 0 ]
|
|
}
|
|
|
|
# test_corosync_start crypto
|
|
# crypto can be on or off
|
|
test_corosync_start() {
|
|
generate_corosync_conf "$1" > "$COROSYNC_CONF"
|
|
cat "$COROSYNC_CONF"
|
|
|
|
service_start "corosync"
|
|
}
|
|
|
|
test_corosync_stop() {
|
|
service_stop "corosync"
|
|
}
|
|
|
|
test_corosync_quorumtool() {
|
|
quorumtool_res_file=`mktemp`
|
|
# This is already fixed in upstream db38e3958c4f88d5d06e8f7c83d6d90334d9fbd2
|
|
(corosync-quorumtool -ips || true) | tee "$quorumtool_res_file"
|
|
|
|
# Ensure this is single node cluster
|
|
grep -qi '^Nodes:.*1$' "$quorumtool_res_file"
|
|
# Current node id is 1
|
|
grep -qi '^Node ID:.*1$' "$quorumtool_res_file"
|
|
# Is quorate (libquorum)
|
|
grep -qi '^Quorate:.*Yes$' "$quorumtool_res_file"
|
|
# Quorum is 1
|
|
grep -qi '^Quorum:.*1' "$quorumtool_res_file"
|
|
# Is quorate (libvotequorum)
|
|
grep -qi '^Flags:.*Quorate' "$quorumtool_res_file"
|
|
|
|
rm -f "$quorumtool_res_file"
|
|
}
|
|
|
|
test_corosync_cmapctl() {
|
|
cmapctl_res_file=`mktemp`
|
|
corosync-cmapctl | tee "$cmapctl_res_file"
|
|
# cluster_name key exists in full output
|
|
grep -qi '^totem.cluster_name (str) = smoketestcluster$' "$cmapctl_res_file"
|
|
|
|
corosync-cmapctl "totem." | tee "$cmapctl_res_file"
|
|
# cluster_name key exists in reduced output
|
|
grep -qi '^totem.cluster_name (str) = smoketestcluster$' "$cmapctl_res_file"
|
|
|
|
# cluster_name key should be returned
|
|
corosync-cmapctl -g "totem.cluster_name" | tee "$cmapctl_res_file"
|
|
grep -qi '^totem.cluster_name (str) = smoketestcluster$' "$cmapctl_res_file"
|
|
|
|
rm -f "$cmapctl_res_file"
|
|
}
|
|
|
|
# test_corosync_reload - requires stopped corosync
|
|
test_corosync_reload() {
|
|
cmapctl_res_file=`mktemp`
|
|
|
|
test_corosync_start "off"
|
|
|
|
# Get current token timeout
|
|
corosync-cmapctl -g "runtime.config.totem.token" | tee "$cmapctl_res_file"
|
|
cmapctl_res=$(cat "$cmapctl_res_file")
|
|
# Format is runtime.config.totem.token (u32) = value
|
|
token_pre_reload=${cmapctl_res##* }
|
|
[ "$token_pre_reload" -eq "$TOKEN_TIMEOUT" ]
|
|
|
|
# Generate new corosync.conf with token_timeout*10
|
|
new_token_timeout=$((TOKEN_TIMEOUT*10))
|
|
generate_corosync_conf "off" "$new_token_timeout" > "$COROSYNC_CONF"
|
|
cat "$COROSYNC_CONF"
|
|
|
|
# Main call of the test
|
|
corosync-cfgtool -R
|
|
|
|
# Check that new token timeout is in use
|
|
corosync-cmapctl -g "runtime.config.totem.token" | tee "$cmapctl_res_file"
|
|
cmapctl_res=$(cat "$cmapctl_res_file")
|
|
# Format is runtime.config.totem.token (u32) = value
|
|
token_post_reload=${cmapctl_res##* }
|
|
[ "$token_post_reload" -eq "$new_token_timeout" ]
|
|
|
|
test_corosync_stop
|
|
|
|
rm -f "$cmapctl_res_file"
|
|
}
|
|
|
|
test_corosync_api() {
|
|
cflags=$(pkg-config --cflags libcpg)
|
|
libs=$(pkg-config --libs libcpg)
|
|
|
|
gcc -ggdb -Wall $cflags "/tmp/corosync-api-test.c" \
|
|
$libs -o "/tmp/corosync-api-test"
|
|
|
|
/tmp/corosync-api-test
|
|
}
|
|
|
|
test_corosync_api_mp() {
|
|
cflags=$(pkg-config --cflags libcpg)
|
|
libs=$(pkg-config --libs libcpg)
|
|
|
|
gcc -ggdb -Wall $cflags "/tmp/corosync-api-test-mp.c" \
|
|
$libs -o "/tmp/corosync-api-test-mp"
|
|
|
|
/tmp/corosync-api-test-mp
|
|
}
|
|
|
|
test_corosync_man_pages() {
|
|
# At least these man pages should be installed
|
|
expected_mp="corosync corosync.conf corosync-cfgtool corosync-cmapctl
|
|
corosync-keygen corosync-quorumtool"
|
|
|
|
for mp in $expected_mp;do
|
|
man -w "$mp"
|
|
done
|
|
}
|
|
|
|
########
|
|
# main #
|
|
########
|
|
if [ -z "$PREFIX" ];then
|
|
echo "PREFIX not defined. Do not run *.inc.sh directly"
|
|
exit 1
|
|
fi
|
|
|
|
test_corosync_v
|
|
test_corosync_keygen
|
|
test_corosync_man_pages
|
|
|
|
for crypto in "off" "on";do
|
|
test_corosync_start "$crypto"
|
|
test_corosync_quorumtool
|
|
test_corosync_cmapctl
|
|
test_corosync_api
|
|
test_corosync_api_mp
|
|
test_corosync_stop
|
|
done
|
|
|
|
test_corosync_reload
|