diff options
| -rwxr-xr-x | build.sh | 24 | ||||
| -rw-r--r-- | build_env | 54 | ||||
| -rwxr-xr-x | fb-smoke.sh | 207 | 
3 files changed, 285 insertions, 0 deletions
diff --git a/build.sh b/build.sh new file mode 100755 index 00000000000..2eb5ae75424 --- /dev/null +++ b/build.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +PACKAGES="automake libtool gperftools-devel gperftools-debuginfo gperftools-libs \ +          glib2-devel jemalloc jemalloc-devel fb-gcc flex bison openssl-devel libxml2-devel\ +          libacl-devel userspace-rcu-devel lvm2 python-devel" + +if [ $(/usr/lib/rpm/redhat/dist.sh --distnum) -eq "7" ]; then +  PACKAGES="$PACKAGES libtirpc libtirpc-devel-0.2.4 devtoolset-4-binutils devtoolset-4-gcc devtoolset-4-runtime" +elif [ $(/usr/lib/rpm/redhat/dist.sh --distnum) -eq "6" ]; then +  PACKAGES="$PACKAGES libfbtirpc libfbtirpc-devel libgssglue libgssglue-devel devtoolset-2-binutils devtoolset-2-gcc devtoolset-2-runtime" +else +  echo "Centos $(/usr/lib/rpm/redhat/dist.sh --distnum) is not currently supported" +  exit 1 +fi + +# Skip this for Jekins automated builds (they have these packages already) +# as the sudo will cause the build to fail +[ $USER == "svcscm" ] || sudo yum install $PACKAGES -y + +source ./build_env + +./autogen.sh || exit 1 +./configure $GF_CONF_OPTS +make -j || exit 1 diff --git a/build_env b/build_env new file mode 100644 index 00000000000..5c53cc57b72 --- /dev/null +++ b/build_env @@ -0,0 +1,54 @@ +#!/bin/bash + +# +# Note: The GF_CONF_OPTS (configure) options will only be used for dev or +# test builds.  For RPM builds the configure options are defined in the +# glusterfs.spec.in file. ASAN is not enabled by for RPMs as it degrades +# performance.  In specific instances it can be enabled simply be appending +# the --with-asan option in the %build step of the spec file. +# + +GF_CONF_OPTS="--localstatedir=/var --sysconfdir /var/lib --prefix /usr --libdir /usr/lib64 \ +             --enable-fusermount --enable-api --with-jemalloc  \ +             --with-ipv6-default --with-fbextras --disable-tiering" + +if [ -x /usr/lib/rpm/redhat/dist.sh ]; then +  REDHAT_MAJOR=$(/usr/lib/rpm/redhat/dist.sh --distnum) +else +  REDHAT_MAJOR=0 +fi + +# Enable systemd support on CentOS >= 7 +if [ $REDHAT_MAJOR -ge 7 ]; then +    GF_CONF_OPTS="$GF_CONF_OPTS --with-systemd" +fi +export GF_CONF_OPTS + +# Check if ASAN is enabled +if [ "$ASAN_ENABLED" -eq "1" ]; then +    GF_CONF_OPTS="$GF_CONF_OPTS --with-asan" +fi + +if [ $REDHAT_MAJOR -eq "7" ]; then +  GCC_BIN="/opt/rh/devtoolset-4/root/usr/bin/gcc" +  GCC_LIB="/opt/rh/devtoolset-4/root/lib64" +  DESTDIR='/' # pycompile is finicky in centos7 if --destdir is passed nothing. +elif [ $REDHAT_MAJOR -eq "6" ]; then +  ENGSHARE_GCC_PATH="/mnt/vol/engshare/third-party2/gcc" +  GCC_BIN="$ENGSHARE_GCC_PATH/4.9.x/centos6-native/108cf83/bin/gcc" +  GCC_LIB="$ENGSHARE_GCC_PATH/4.9.x/centos6-native/108cf83/lib64" +else +  echo "Centos $REDHAT_MAJOR is not currently supported" +  exit 1 +fi + +export LIB_DIR="$GCC_LIB" +export CC="$GCC_BIN" + +#export CC="/mnt/vol/engshare/third-party2/gcc/4.9.x/centos6-native/108cf83/bin/gcc" + +# If you think this should all be done in configure.ac you'd be 100% +# correct; aside from the fact that it simply doesn't work when done there :). +# You'll find the debug symbols are not present in resultant binaries nor is +# the code un-optimized. +export CFLAGS="-O0 -ggdb -fPIC -Wall -Werror -L${LIB_DIR}" diff --git a/fb-smoke.sh b/fb-smoke.sh new file mode 100755 index 00000000000..72299a6a041 --- /dev/null +++ b/fb-smoke.sh @@ -0,0 +1,207 @@ +#!/bin/bash + +# +# Tests +# +DESIRED_TESTS="\ + tests/basic/*.t\ + tests/basic/afr/*.t\ + tests/basic/distribute/*.t\ + tests/basic/dht/*.t\ + tests/features/brick-min-free-space.t\ + " + +KNOWN_FLAKY_TESTS="\ + tests/basic/afr/shd-autofix-nogfid.t\ + tests/basic/accept-v6v4.t\ + tests/basic/bd.t\ + tests/basic/fop-throttling.t\ + tests/basic/fops-sanity.t\ + tests/basic/mgmt_v3-locks.t\ + tests/basic/mount.t\ + tests/basic/pump.t\ + tests/basic/rpm.t\ + tests/basic/uss.t\ + tests/basic/volume-snapshot.t\ +" + +# +# Helpers +# +function elapsed_since { +    start=$1 +    (("$SECONDS" - "$start")) +} + +function flaky { +    local f +    for f in ${KNOWN_FLAKY_TESTS}; do +        if [ "$f" == "$1" ]; then +            return 0 +        fi +    done +    return 1 +} + +function outfile { +    printf "/tmp/%s.out" "$(echo "$f" | tr / -)" +} + +function exit_test { +    if [ "$STOP_ON_FAIL" -eq "1" ]; then +        print_result +        exit "$1" +    fi +} + +function test { +    f=$1 +    printf "%s" "$f" +    local start +    start=$SECONDS +    local out +    out=$(outfile "$f") + +    for i in $(seq 1 "$ATTEMPT"); do +        DEBUG=1 timeout --foreground "$TEST_TIMEOUT" prove -v "$f" &> "$out.$i" + +        if [ "$?" -eq "0" ]; then +            SUCCESS=$SUCCESS+1 +            printf " PASS (%s s)\n" "$(elapsed_since $start)" +            rm -f "$out.$i" +            return 0 +        else +            printf " %s" "($i/$ATTEMPT)" +        fi +    done + +    if [[ $? -eq 124 || $? -eq 137 ]]; then +        FAILED_TESTS+=($f) +        FAIL=$FAIL+1 +        printf " TIMEOUT (%s s)\n" "$(elapsed_since $start)" +        exit_test 1 +    else +        FAILED_TESTS+=($f) +        FAIL=$FAIL+1 +        printf " FAIL (%s s)\n" "$(elapsed_since $start)" +        exit_test 1 +    fi +} + +function flakytest { +    f=$1 + +    if [ "$SKIP_FLAKY" -eq "1" ]; then +        SKIP=$SKIP+1 +    else +        printf "<flaky> " +        test "$f" +    fi +} + +function print_result { +    echo +    echo "== RESULTS ==" +    echo "TESTS    : $TOTAL" +    echo "SUCCESS  : $SUCCESS" +    echo "FAIL     : $FAIL" +    echo "SKIP     : $SKIP" + +    if [ "$FAIL" -gt "0" ]; then +        echo +        echo "== FAILED TESTS ==" +        echo "${FAILED_TESTS[@]}" +        echo +        echo "== LOGS ==" +        "ls /tmp/*.out.*" +        echo +        echo "== END ==" +    fi +} + +function run_remote { +    if [ ! -d "$FBCODE" ]; then +        echo "fbcode does not exists. Please checkout fbcode" +        return 1 +    fi + +    local flags='' +    if [ "$VERBOSE" -eq "1" ]; then +        flags="$flags -v" +    fi + +    if [ "$VALGRIND" -eq "1" ]; then +        flags="$flags --valgrind" +    fi + +    if [ "$ASAN" -eq "1" ]; then +        flags="$flags --asan" +    fi + +    "$FBCODE/storage/gluster/gluster-build/fb-gluster-test.py" $flags --tester --n "$N" --hosts "$REMOTE_HOSTS" --tests "$REMOTE_TESTS" +} + +# +# Main +# +declare -i TOTAL=0 +declare -i SUCCESS=0 +declare -i FAIL=0 +declare -i SKIP=0 +declare -a FAILED_TESTS + +TEST_TIMEOUT=${TEST_TIMEOUT:=300} +SKIP_FLAKY=${SKIP_FLAKY:=1} +STOP_ON_FAIL=${STOP_ON_FAIL:=0} +FBCODE=${FBCODE:="$HOME/fbsource/fbcode"} +N=${N:=0} +REMOTE_HOSTS=${REMOTE_HOSTS:="$(smcc ls-hosts -s gluster.build.ash | xargs)"} +REMOTE=${REMOTE:=0} +REMOTE_TESTS=${REMOTE_TESTS:='smoke'} +VERBOSE=${VERBOSE:=0} +VALGRIND=${VALGRIND:=0} +ASAN=${ASAN:=0} + +if [ "$REMOTE" -eq "1" ]; then +    run_remote +    exit $? +fi + +if [ "$SKIP_FLAKY" -eq "0" ]; then +    ATTEMPT=${ATTEMPT:=3} +else +    ATTEMPT=${ATTEMPT:=1} +fi + +echo "== SETTINGS ==" +echo "TEST_TIMEOUT = $TEST_TIMEOUT s" +echo "SKIP_FLAKY   = $SKIP_FLAKY" +echo "STOP_ON_FAIL = $STOP_ON_FAIL" +echo "ATTEMPT      = $ATTEMPT" +echo "REMOTE       = $REMOTE" +echo "FBCODE       = $FBCODE" +echo + +# try cleaning up the environment +rm -f /tmp/*.out.* || true + +# sanity check +if ! cmp -s ./glusterfsd/src/.libs/glusterfsd $(which glusterfsd) +then +  echo "Installed gluster does not match local, perhaps you ought make install?" +  exit 1 +fi + +echo "== TESTS ==" +for f in ${DESIRED_TESTS} +do +    TOTAL=$TOTAL+1 +    if flaky "$f"; then +        flakytest "$f" +    else +        test "$f" +    fi +done + +print_result +exit $FAIL  | 
