Commit 8502a73c authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3599] Fixed issues with the kea-admin script portability.

The following issues causing failures on the FreeBSD were corrected:
- Don't use sed to replace tabulations from the returned kea version.
Instead the CONCAT mysql function is used.
- Replace &>dev/null with the >/dev/null 2>&1

Additional changes:
- Added a new line before printing existing tables in the mysql.
- Added .gitignore for new files.
parent 35357a30
/kea-admin
/kea-admin.8
......@@ -28,17 +28,17 @@ mysql_execute() {
if [ $# -gt 1 ]; then
QUERY=$1
shift
_RESULT=`echo $QUERY | mysql -N -B $@ | sed "s/\t/./g"`
_RESULT=`echo $QUERY | mysql -N -B $@`
else
_RESULT=$(mysql -N -B --user=$db_user --password=$db_password -e "${1}" $db_name | sed "s/\t/./g")
_RESULT=$(mysql -N -B --user=$db_user --password=$db_password -e "${1}" $db_name)
fi
}
mysql_version() {
mysql_execute "SELECT version,minor FROM schema_version" "$@"
mysql_execute "SELECT CONCAT(version,\".\",minor) FROM schema_version" "$@"
}
mysql_version_print() {
mysql_version "$@"
printf "%s" $_RESULT
}
\ No newline at end of file
}
......@@ -138,7 +138,7 @@ mysql_init() {
if [ $COUNT -gt 0 ]; then
# Let't start with a new line. mysql could have printed something out.
printf "\n"
log_error "Expected empty database $db_name, but there are $COUNT tables: $_RESULT. Aborting."
log_error "Expected empty database $db_name, but there are $COUNT tables: \n$_RESULT. Aborting."
exit 1
fi
......
/memfile_tests.sh
/mysql_tests.sh
......@@ -37,7 +37,7 @@ keaadmin=@abs_top_builddir@/src/bin/admin/kea-admin
# Wipe all tables from the DB:
mysql_wipe() {
printf "Wiping whole database %s\n" $db_name
mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
SET @tables = NULL;
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
FROM information_schema.tables
......@@ -64,35 +64,35 @@ mysql_lease_init_test() {
# Ok, now let's check if the tables are indeed there.
# First table: schema_version. Should have 2 columns: version and minor.
mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
SELECT version, minor FROM schema_version;
EOF
ERRCODE=$?
assert_eq 0 $ERRCODE "schema_version table is missing or broken. (returned status code %d, expected %d)"
# Second table: lease4
mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
SELECT address, hwaddr, client_id, valid_lifetime, expire, subnet_id, fqdn_fwd, fqdn_rev, hostname FROM lease4;
EOF
ERRCODE=$?
assert_eq 0 $ERRCODE "lease4 table is missing or broken. (returned status code %d, expected %d)"
# Third table: lease6
mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
SELECT address, duid, valid_lifetime, expire, subnet_id, pref_lifetime, lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, hwaddr, hwtype, hwaddr_source FROM lease6;
EOF
ERRCODE=$?
assert_eq 0 $ERRCODE "lease6 table is missing or broken. (returned status code %d, expected %d)"
# Fourth table: lease6_types
mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
SELECT lease_type, name FROM lease6_types;
EOF
ERRCODE=$?
assert_eq 0 $ERRCODE "lease6_types table is missing or broken. (returned status code %d, expected %d)"
# Fifth table: lease_hwaddr_source
mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
SELECT hwaddr_source, name FROM lease_hwaddr_source;
EOF
ERRCODE=$?
......@@ -111,7 +111,7 @@ mysql_lease_version_test() {
mysql_wipe
# Ok, now let's create a version 1.7
mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
CREATE TABLE schema_version (
version INT PRIMARY KEY NOT NULL,
minor INT
......@@ -152,14 +152,14 @@ mysql_lease_upgrade_test() {
# Let's check that the new tables are indeed there.
# Third table: lease6
mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
SELECT hwaddr, hwtype, hwaddr_source FROM lease6;
EOF
ERRCODE=$?
assert_eq 0 $ERRCODE "lease6 table not upgraded to 2.0 (returned status code %d, expected %d)"
# Fifth table: lease_hwaddr_source
mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
SELECT hwaddr_source, name FROM lease_hwaddr_source;
EOF
ERRCODE=$?
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment