Skip to content

Commit

Permalink
[ FAB-6864 ] Increase default start timeout
Browse files Browse the repository at this point in the history
Some of the tests are timing out on x86.
Increase the default timeout to 3 minutes.

Change-Id: Id22cf6e553308eee05a3e729f5b073174597b3e6
Signed-off-by: Allen Bailey <[email protected]>
  • Loading branch information
rennman committed Nov 7, 2017
1 parent 63b8a57 commit b5373f6
Show file tree
Hide file tree
Showing 16 changed files with 168 additions and 81 deletions.
6 changes: 3 additions & 3 deletions scripts/fvt/cdp_exploit_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export CA_CFG_PATH=/tmp/$TESTCASE
export FABRIC_CA_CLIENT_HOME=$CA_CFG_PATH/admin
mkdir -p /$CADOMAIN/crl/
localip=127.0.0.1
fabricport=17054
fabricport=$CA_DEFAULT_PORT
httpPort=3755
ca_keyfile="/root/$CADOMAIN-key.pem"
ca_certfile="/root/$CADOMAIN-cert.pem"
Expand Down Expand Up @@ -72,7 +72,7 @@ function testLimit {
cd $GOPATH/src/github.com/hyperledger/fabric-ca
$SCRIPTDIR/fabric-ca_setup.sh -K
$SCRIPTDIR/fabric-ca_setup.sh -S -D -X $ca_certfile -k $ca_keyfile 2>&1 | tee $LOGFILE &
pollServer fabric $localip $fabricport $TIMEOUT
pollLogForMsg "Listening on https*://0.0.0.0:$CA_DEFAULT_PORT" $LOGFILE || ErrorExit "Failed to log CA"
enroll admin2 adminpw2
admin_keyfile="$(find /tmp/$TESTCASE/admin/msp/keystore -type f)"
admin_certfile="/tmp/$TESTCASE/admin/msp/signcerts/cert.pem"
Expand All @@ -88,7 +88,7 @@ cp $GOPATH/src/github.com/hyperledger/fabric-ca/testdata/crl.pem /$CADOMAIN/crl/
cd /
python -m SimpleHTTPServer $httpPort &
HTTP_PID=$!
pollServer python localhost "$httpPort" $TIMEOUT || ErrorExit "Failed to start HTTP server"
pollSimpleHttp
cd $c_dir

trap "kill $HTTP_PID; rm -rf /tmp/$TESTCASE/ /tmp/CAs/$CADOMAIN /$CADOMAIN/crl/crl.pem; CleanUp 1; exit 1" INT
Expand Down
77 changes: 38 additions & 39 deletions scripts/fvt/db_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

: ${TESTCASE:="db_resiliency"}
FABRIC_CA="$GOPATH/src/github.com/hyperledger/fabric-ca"
echo $FABRIC_CA
FABRIC_CAEXEC="$FABRIC_CA/bin/fabric-ca"
TESTDATA="$FABRIC_CA/testdata"
SCRIPTDIR="$FABRIC_CA/scripts/fvt"
Expand All @@ -22,7 +21,6 @@ MYSQLSERVERCONFIG="$FABRIC_CA_SERVER_HOME/mysqlserverconfig.yaml"
MYSQLSERVERCONFIG2="$FABRIC_CA_SERVER_HOME/mysqlserverconfig2.yaml"
PGSQLSERVERCONFIG="$FABRIC_CA_SERVER_HOME/pgsqlserverconfig.yaml"
PGSQLSERVERCONFIG2="$FABRIC_CA_SERVER_HOME/pgsqlserverconfig2.yaml"
SERVERLOG="$FABRIC_CA_SERVER_HOME/serverlog.txt"
MSP="$FABRIC_CA_SERVER_HOME/msp"
SERVERCERT="$FABRIC_CA_SERVER_HOME/fabric-ca-cert.pem"
DBNAME="fabric_ca"
Expand All @@ -36,6 +34,8 @@ function cleanup {
function killserver {
echo "killing server $1"
kill -9 $1
pollFabricCa "" "" "$CA_DEFAULT_PORT" stop 30
return $?
}

function existingIdentity {
Expand Down Expand Up @@ -150,8 +150,8 @@ EOF
$PGSQLSERVERCONFIG $PGSQLSERVERCONFIG2
}

$SCRIPTDIR/fabric-ca_setup.sh -R -x $FABRIC_CA_SERVER_HOME
genConfig
cleanup

# MySQL Test
echo "############################ MySQL Test ############################"
Expand All @@ -166,51 +166,51 @@ mysql --host=localhost --user=root --password=mysql -e "drop database $DBNAME;"
mysql --host=localhost --user=root --password=mysql --database=$DBNAME -e "CREATE TABLE users (id VARCHAR(64) NOT NULL, token blob, type VARCHAR(64), affiliation VARCHAR(64), attributes VARCHAR(256), state INTEGER, max_enrollments INTEGER, PRIMARY KEY (id)) DEFAULT CHARSET=utf8 COLLATE utf8_bin;" &> /dev/null

# Starting server first time with one bootstrap user
SERVERLOG="$FABRIC_CA_SERVER_HOME/serverlog.test1a.txt"
$SCRIPTDIR/fabric-ca_setup.sh -S -X -g $MYSQLSERVERCONFIG 2>&1 | tee $SERVERLOG &
pollServer fabric-ca-server 127.0.0.1 17054 20 start
pollLogForMsg "Listening on https*://0.0.0.0:$CA_DEFAULT_PORT" $SERVERLOG || ErrorExit "Failed to log CA startup message"
pid=$(pidof fabric-ca-server)
killserver $pid

killserver $pid && rm $SERVERLOG || ErrorExit "Failed to stop CA"
# Starting server second time with a second bootstrap user
$SCRIPTDIR/fabric-ca_setup.sh -S -X -g $MYSQLSERVERCONFIG2 2>&1 | tee $SERVERLOG &
pollServer fabric-ca-server 127.0.0.1 17054 20 start
pollLogForMsg "Listening on https*://0.0.0.0:$CA_DEFAULT_PORT" $SERVERLOG || ErrorExit "Failed to log CA startup message"
pid=$(pidof fabric-ca-server)
killserver $pid
killserver $pid || ErrorExit "Failed to stop CA"

existingIdentity "a" $SERVERLOG # Check to see that appropriate error message was seen for an already registered user
checkIdentity "c" $SERVERLOG # Check to see that a new identity properly got registered

existingAff "org1" $SERVERLOG
checkAff "org3.department1" $SERVERLOG

# Test scenario where database exist but tables do not exist
# Test scenario where database exists but tables do not exist
# Fabric-ca should create the tables and bootstrap
SERVERLOG="$FABRIC_CA_SERVER_HOME/serverlog.test2a.txt"
echo "############## Test 2 ##############"
echo "Test2: Database exist but tables do not exist"
echo "Test2: Fabric-ca should create the tables and bootstrap"
echo "Dropping and creating an empty '$DBNAME' database"
mysql --host=localhost --user=root --password=mysql -e "drop database fabric_ca;" -e "create database fabric_ca;" &> /dev/null

$SCRIPTDIR/fabric-ca_setup.sh -S -X -g $MYSQLSERVERCONFIG2 2>&1 | tee $SERVERLOG &
pollServer fabric-ca-server 127.0.0.1 17054 20 start
pollLogForMsg "Listening on https*://0.0.0.0:$CA_DEFAULT_PORT" $SERVERLOG || ErrorExit "Failed to log CA startup message"
pid=$(pidof fabric-ca-server)
killserver $pid

killserver $pid || ErrorExit "Failed to stop CA"
checkIdentity "a" $SERVERLOG # Check to see that a new identity properly got registered
checkIdentity "c" $SERVERLOG # Check to see that a new identity properly got registered

# Test scenario where database does not exist
# Fabric-ca should create the database and tables, and bootstrap
SERVERLOG="$FABRIC_CA_SERVER_HOME/serverlog.test3a.txt"
echo "############## Test 3 ##############"
echo "Test3: Database does not exist"
echo "Test3: Fabric-ca should create the database and tables, and bootstrap"
echo "Dropping '$DBNAME' database"
mysql --host=localhost --user=root --password=mysql -e "drop database fabric_ca;" &> /dev/null

$SCRIPTDIR/fabric-ca_setup.sh -S -X -g $MYSQLSERVERCONFIG2 2>&1 | tee $SERVERLOG &
pollServer fabric-ca-server 127.0.0.1 17054 20 start
pollLogForMsg "Listening on https*://0.0.0.0:$CA_DEFAULT_PORT" $SERVERLOG || ErrorExit "Failed to log CA startup message"
pid=$(pidof fabric-ca-server)
killserver $pid
killserver $pid || ErrorExit "Failed to stop CA"

checkIdentity "a" $SERVERLOG # Check to see that a new identity properly got registered
checkIdentity "c" $SERVERLOG # Check to see that a new identity properly got registered
Expand All @@ -222,6 +222,7 @@ echo "############################ PostgresSQL Test ############################
# Test scenario where database and tables exist, plus an already bootstrapped user is present in the users table
# Fabric-ca should create the tables and bootstrap
echo "############## Test 1 ##############"
SERVERLOG="$FABRIC_CA_SERVER_HOME/serverlog.test1b.txt"
echo "Test1: Database and tables exist, plus an already bootstrapped user is present in the users table"
echo "Test1: Fabric-ca should bootstap a newly added identity to the config to the user table"
psql -c "drop database $DBNAME"
Expand All @@ -230,16 +231,15 @@ psql -d fabric_ca -c "CREATE TABLE users (id VARCHAR(64), token bytea, type VARC

# Starting server first time with one bootstrap user
$SCRIPTDIR/fabric-ca_setup.sh -S -X -g $PGSQLSERVERCONFIG 2>&1 | tee $SERVERLOG &
pollServer fabric-ca-server 127.0.0.1 17054 20 start
pollLogForMsg "Listening on https*://0.0.0.0:$CA_DEFAULT_PORT" $SERVERLOG || ErrorExit "Failed to log CA startup message"
pid=$(pidof fabric-ca-server)
killserver $pid
killserver $pid && rm $SERVERLOG || ErrorExit "Failed to stop CA"

sleep 1
# Starting server second time with a second bootstrap user
$SCRIPTDIR/fabric-ca_setup.sh -S -X -g $PGSQLSERVERCONFIG2 2>&1 | tee $SERVERLOG &
pollServer fabric-ca-server 127.0.0.1 17054 20 start
pollLogForMsg "Listening on https*://0.0.0.0:$CA_DEFAULT_PORT" $SERVERLOG || ErrorExit "Failed to log CA startup message"
pid=$(pidof fabric-ca-server)
killserver $pid
killserver $pid || ErrorExit "Failed to stop CA"

existingIdentity "a" $SERVERLOG # Check to see that appropriate error message was seen for an already registered user
checkIdentity "c" $SERVERLOG # Check to see that a new identity properly got registered
Expand All @@ -249,44 +249,47 @@ checkAff "org3.department1" $SERVERLOG

# Test scenario where database exist but tables do not exist
# Fabric-ca should create the tables and bootstrap
SERVERLOG="$FABRIC_CA_SERVER_HOME/serverlog.test2b.txt"
echo "############## Test 2 ##############"
echo "Test2: Database exist but tables do not exist"
echo "Test2: Fabric-ca should create the tables and bootstrap"
psql -c "drop database $DBNAME"
psql -c "create database $DBNAME"

$SCRIPTDIR/fabric-ca_setup.sh -S -X -g $PGSQLSERVERCONFIG2 2>&1 | tee $SERVERLOG &
pollServer fabric-ca-server 127.0.0.1 17054 20 start
pollLogForMsg "Listening on https*://0.0.0.0:$CA_DEFAULT_PORT" $SERVERLOG || ErrorExit "Failed to log CA startup message"
pid=$(pidof fabric-ca-server)
killserver $pid
killserver $pid || ErrorExit "Failed to stop CA"

checkIdentity "a" $SERVERLOG # Check to see that a new identity properly got registered
checkIdentity "c" $SERVERLOG # Check to see that a new identity properly got registered

# Test scenario where database does not exist
# Fabric-ca should create the database and tables, and bootstrap
SERVERLOG="$FABRIC_CA_SERVER_HOME/serverlog.test3b.txt"
echo "############## Test 3 ##############"
echo "Test3: Database does not exist"
echo "Test3: Fabric-ca should create the database and tables, and bootstrap"
psql -c "drop database $DBNAME"

$SCRIPTDIR/fabric-ca_setup.sh -S -X -g $PGSQLSERVERCONFIG2 2>&1 | tee $SERVERLOG &
sleep 6 # Need to allow for Postgres to complete database and table creation
pollServer fabric-ca-server 127.0.0.1 17054 20 start
pollLogForMsg "Listening on https*://0.0.0.0:$CA_DEFAULT_PORT" $SERVERLOG || ErrorExit "Failed to log CA startup message"
pid=$(pidof fabric-ca-server)
killserver $pid
killserver $pid || ErrorExit "Failed to stop CA"

checkIdentity "a" $SERVERLOG # Check to see that a new identity properly got registered
checkIdentity "c" $SERVERLOG # Check to see that a new identity properly got registered

echo "############################ PostgresSQL Test with Client ############################"

kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid` # Shutdown postgres server
pollServer postgres 127.0.0.1 5432 5 stop # Wait for PostgreSQL to stop
pollPostgres "" "" "" stop 2>&1 # Wait for postgres to stop

# Start fabric-ca server connecting to postgres, this will fail
$SCRIPTDIR/fabric-ca_setup.sh -S -X -g $PGSQLSERVERCONFIG2
pollServer fabric-ca-server 127.0.0.1 17054 20 start
SERVERLOG="$FABRIC_CA_SERVER_HOME/serverlog.test1c.txt"
$SCRIPTDIR/fabric-ca_setup.sh -S -X -g $PGSQLSERVERCONFIG2 | tee $SERVERLOG 2>&1 &
pollLogForMsg "Listening on https*://0.0.0.0:$CA_DEFAULT_PORT" $SERVERLOG || ErrorExit "Failed to log CA startup message"

# Enroll with a server that does not have a DB initialized, should expect to get back error
enroll a b 2>&1 | grep "Failed to create user registry for PostgreSQL"
Expand All @@ -296,7 +299,7 @@ fi

# Start postgres server
su postgres -c 'postgres -D /usr/local/pgsql/data' &
pollServer postgres 127.0.0.1 5432 20 start # Wait for PostgreSQL to start
pollPostgres # Wait for postgres to start
sleep 5 # Postgres port is available but sometimes get back 'pq: the database system is starting up' error. Putting in sleep to allow for start up to complete

# Enroll again, this time the server should try to reinitialize the DB before processing enroll request and this should succeed
Expand All @@ -309,12 +312,13 @@ $SCRIPTDIR/fabric-ca_setup.sh -K

echo "############################ MySQL Test with Client ############################"

/etc/init.d/mysql stop
pollServer mysql 127.0.0.1 3306 2 stop # Wait for MySQL to stop
/etc/init.d/mysql stop >/dev/null 2>&1
pollMySql "" "" "" stop # Wait for MySQL to stop

# Start fabric-ca server connecting to MySQL, this will fail
$SCRIPTDIR/fabric-ca_setup.sh -S -X -g $MYSQLSERVERCONFIG2
pollServer fabric-ca-server 127.0.0.1 17054 20 start
SERVERLOG="$FABRIC_CA_SERVER_HOME/serverlog.test2c.txt"
$SCRIPTDIR/fabric-ca_setup.sh -S -X -g $MYSQLSERVERCONFIG2 | tee $SERVERLOG 2>&1 &
pollLogForMsg "Listening on https*://0.0.0.0:$CA_DEFAULT_PORT" $SERVERLOG || ErrorExit "Failed to log CA startup message"

# Enroll with a server that does not have a DB initialized, should expect to get back error
enroll a b 2>&1 | grep "Failed to create user registry for MySQL"
Expand All @@ -324,20 +328,15 @@ fi

# Start mysql server
/usr/bin/mysqld_safe --sql-mode=STRICT_TRANS_TABLES &
pollServer mysql 127.0.0.1 3306 20 start # Wait for MySQL to start
pollMySql # Wait for MySQL to start

# Enroll again, this time the server should try to reinitialize the DB before processing enroll request and this should succeed
enroll a b 2>&1 | grep "Stored client certificate"
if [ $? != 0 ]; then
ErrorMsg "Enroll request should have passed"
fi

$SCRIPTDIR/fabric-ca_setup.sh -K

rm $MYSQLSERVERCONFIG
rm $MYSQLSERVERCONFIG2
rm $PGSQLSERVERCONFIG
rm $PGSQLSERVERCONFIG2
$SCRIPTDIR/fabric-ca_setup.sh -R -x $FABRIC_CA_SERVER_HOME

CleanUp $RC
exit $RC
12 changes: 7 additions & 5 deletions scripts/fvt/enrollments_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export CA_CFG_PATH
function genServerConfig {
case "$1" in
implicit) cat > $SERVERCONFIG <<EOF
debug: true
db:
type: $DRIVER
datasource: $DATASRC
Expand Down Expand Up @@ -92,6 +93,7 @@ EOF
;;
# Max enroll for identities cannot surpass global setting
invalid) cat > $SERVERCONFIG <<EOF
debug: true
db:
type: $DRIVER
datasource: $DATASRC
Expand Down Expand Up @@ -166,7 +168,7 @@ trap "CleanUp 1; exit 1" INT
# explicitly set value
# user can only enroll MAX_ENROLL times
$SCRIPTDIR/fabric-ca_setup.sh -R -x $CA_CFG_PATH
$SCRIPTDIR/fabric-ca_setup.sh -I -S -X -m $MAX_ENROLL
$SCRIPTDIR/fabric-ca_setup.sh -D -I -S -X -m $MAX_ENROLL
i=0
while test $((i++)) -lt "$MAX_ENROLL"; do
enroll
Expand All @@ -187,7 +189,7 @@ trap "CleanUp 1; exit 1" INT
# user can only enroll once
MAX_ENROLL=1
$SCRIPTDIR/fabric-ca_setup.sh -R -x $CA_CFG_PATH
$SCRIPTDIR/fabric-ca_setup.sh -I -S -X -m $MAX_ENROLL
$SCRIPTDIR/fabric-ca_setup.sh -D -I -S -X -m $MAX_ENROLL
i=0
while test $((i++)) -lt "$MAX_ENROLL"; do
enroll
Expand All @@ -207,7 +209,7 @@ trap "CleanUp 1; exit 1" INT
# user enrollment unlimited
MAX_ENROLL=-1
$SCRIPTDIR/fabric-ca_setup.sh -R -x $CA_CFG_PATH
$SCRIPTDIR/fabric-ca_setup.sh -I -S -X -m $MAX_ENROLL
$SCRIPTDIR/fabric-ca_setup.sh -D -I -S -X -m $MAX_ENROLL
i=0
while test $((i++)) -lt "$UNLIMITED"; do
enroll
Expand Down Expand Up @@ -236,8 +238,8 @@ trap "CleanUp 1; exit 1" INT
$SCRIPTDIR/fabric-ca_setup.sh -R -x $CA_CFG_PATH
test -d $CA_CFG_PATH || mkdir $CA_CFG_PATH
genServerConfig invalid
$SCRIPTDIR/fabric-ca_setup.sh -o 1 -S -X -g $SERVERCONFIG
test $? -eq 0 && ErrorMsg "user enrollment > global setting"
$SCRIPTDIR/fabric-ca_setup.sh -o 0 -S -X -g $SERVERCONFIG | grep 'Configuration Error: Requested enrollments (16) exceeds maximum allowable enrollments (15)'
test $? -ne 0 && ErrorMsg "user enrollment > global setting"

$SCRIPTDIR/fabric-ca_setup.sh -L
$SCRIPTDIR/fabric-ca_setup.sh -R -x $CA_CFG_PATH
Expand Down
6 changes: 3 additions & 3 deletions scripts/fvt/fabric-ca_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function startFabricCa() {
local port=${USER_CA_PORT-$CA_DEFAULT_PORT}
port=$((port+$inst))
# if not explcitly set, use default
local server_port="--port $port"
local server_port="--port $port"

if test -n "$FABRIC_CA_SERVER_PROFILE_PORT" ; then
local profile_port=$((FABRIC_CA_SERVER_PROFILE_PORT+$inst))
Expand All @@ -260,7 +260,7 @@ function startFabricCa() {
fi

printf "FABRIC_CA server on $server_addr:$port "
pollServer $FABRIC_CA_SERVEREXEC $server_addr $port $timeout
pollFabricCa "" "$server_addr" "$port" "" "$TIMEOUT"
if test "$?" -eq 0; then
echo "STARTED"
else
Expand Down Expand Up @@ -308,7 +308,7 @@ while getopts "\?hRCISKXLDTAPad:t:l:n:c:k:x:g:m:p:r:o:" option; do
done

: ${LDAP_ENABLE:="false"}
: ${TIMEOUT:="10"}
: ${TIMEOUT:=$DEFAULT_TIMEOUT}
: ${HTTP_PORT:="3755"}
: ${DBNAME:="fabric_ca"}
: ${MAXENROLL:="-1"}
Expand Down
Loading

0 comments on commit b5373f6

Please sign in to comment.