Commit 162742b4 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

renamed dscsql to cql

parent 11aedc9c
...@@ -995,57 +995,57 @@ fi ...@@ -995,57 +995,57 @@ fi
# ... and at the shell level, so Makefile.am can take action depending on this. # ... and at the shell level, so Makefile.am can take action depending on this.
AM_CONDITIONAL(HAVE_PGSQL, test "$PG_CONFIG" != "") AM_CONDITIONAL(HAVE_PGSQL, test "$PG_CONFIG" != "")
dsc_config="no" cql_config="no"
AC_ARG_WITH([dhcp-dscsql], AC_ARG_WITH([cql],
AC_HELP_STRING([--with-dhcp-dscsql=PATH], AC_HELP_STRING([--with-cql=PATH],
[path to the DataStaxCassandraSQL 'dsc_config' script]), [path to the Cassandra CQL 'cql_config' script]),
[dsc_config="$withval"]) [cql_config="$withval"])
if test "${dsc_config}" = "yes" ; then if test "${cql_config}" = "yes" ; then
DSC_CONFIG="/usr/bin/dsc_config" cql_config="/usr/bin/cql_config"
elif test "${dsc_config}" != "no" ; then elif test "${cql_config}" != "no" ; then
DSC_CONFIG="${withval}" CQL_CONFIG="${withval}"
fi fi
if test "$DSC_CONFIG" != "" ; then if test "$CQL_CONFIG" != "" ; then
if test -d "$DSC_CONFIG" -o ! -x "$DSC_CONFIG" ; then if test -d "$CQL_CONFIG" -o ! -x "$CQL_CONFIG" ; then
AC_MSG_ERROR([--with-dhcp-dscsql should point to a dsc_config program]) AC_MSG_ERROR([--with-cql should point to a cql_config program])
fi fi
DSCSQL_CPPFLAGS=`$DSC_CONFIG --cppflags` CQL_CPPFLAGS=`$CQL_CONFIG --cppflags`
DSCSQL_INCLUDEDIR=`$DSC_CONFIG --includedir` CQL_INCLUDEDIR=`$CQL_CONFIG --includedir`
DSCSQL_CPPFLAGS="$DSCSQL_CPPFLAGS -I$DSCSQL_INCLUDEDIR" CQL_CPPFLAGS="$CQL_CPPFLAGS -I$CQL_INCLUDEDIR"
DSCSQL_LIBS=`$DSC_CONFIG --libdir` CQL_LIBS=`$CQL_CONFIG --libdir`
DSCSQL_LIBS="-L$DSCSQL_LIBS -lcassandra_static -luv" CQL_LIBS="-L$CQL_LIBS -lcassandra_static -luv"
DSCSQL_VERSION=`$DSC_CONFIG --version` CQL_VERSION=`$CQL_CONFIG --version`
AC_SUBST(DSCSQL_CPPFLAGS) AC_SUBST(CQL_CPPFLAGS)
AC_SUBST(DSCSQL_LIBS) AC_SUBST(CQL_LIBS)
# Check that a simple program using DSCSQL functions can compile and link. # Check that a simple program using CQL functions can compile and link.
CPPFLAGS_SAVED="$CPPFLAGS" CPPFLAGS_SAVED="$CPPFLAGS"
LIBS_SAVED="$LIBS" LIBS_SAVED="$LIBS"
CPPFLAGS="$DSCSQL_CPPFLAGS $CPPFLAGS" CPPFLAGS="$CQL_CPPFLAGS $CPPFLAGS"
LIBS="$DSCSQL_LIBS $LIBS" LIBS="$CQL_LIBS $LIBS"
AC_LINK_IFELSE( AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <cassandra.h>], [AC_LANG_PROGRAM([#include <cassandra.h>],
[CassCluster* cluster = cass_cluster_new(); [CassCluster* cluster = cass_cluster_new();
cass_cluster_free(cluster);])], cass_cluster_free(cluster);])],
[AC_MSG_RESULT([checking for DataStax Cassandra SQL headers and library... yes])], [AC_MSG_RESULT([checking for Cassandra CQL headers and library... yes])],
[AC_MSG_RESULT([checking for DataStax Cassandra SQL headers and library... no]) [AC_MSG_RESULT([checking for Cassandra CQL headers and library... no])
AC_MSG_ERROR([Needs DataStax Cassandra SQL library])] AC_MSG_ERROR([Needs Cassandra CQL library])]
) )
CPPFLAGS=$CPPFLAGS_SAVED CPPFLAGS=$CPPFLAGS_SAVED
LIBS=$LIBS_SAVED LIBS=$LIBS_SAVED
# Note that DSCSQL is present in the config.h file # Note that CQL is present in the config.h file
AC_DEFINE([HAVE_DSCSQL], [1], [DSCSQL is present]) AC_DEFINE([HAVE_CQL], [1], [CQL is present])
fi fi
# ... and at the shell level, so Makefile.am can take action depending on this. # ... and at the shell level, so Makefile.am can take action depending on this.
AM_CONDITIONAL(HAVE_DSCSQL, test "$DSC_CONFIG" != "") AM_CONDITIONAL(HAVE_CQL, test "$CQL_CONFIG" != "")
# Check for log4cplus # Check for log4cplus
log4cplus_path="yes" log4cplus_path="yes"
...@@ -1461,7 +1461,7 @@ AC_CONFIG_FILES([compatcheck/Makefile ...@@ -1461,7 +1461,7 @@ AC_CONFIG_FILES([compatcheck/Makefile
src/bin/admin/tests/memfile_tests.sh src/bin/admin/tests/memfile_tests.sh
src/bin/admin/tests/mysql_tests.sh src/bin/admin/tests/mysql_tests.sh
src/bin/admin/tests/pgsql_tests.sh src/bin/admin/tests/pgsql_tests.sh
src/bin/admin/tests/dscsql_tests.sh src/bin/admin/tests/cql_tests.sh
src/hooks/Makefile src/hooks/Makefile
src/hooks/dhcp/Makefile src/hooks/dhcp/Makefile
src/hooks/dhcp/user_chk/Makefile src/hooks/dhcp/user_chk/Makefile
...@@ -1539,7 +1539,7 @@ AC_CONFIG_FILES([compatcheck/Makefile ...@@ -1539,7 +1539,7 @@ AC_CONFIG_FILES([compatcheck/Makefile
src/share/database/scripts/pgsql/Makefile src/share/database/scripts/pgsql/Makefile
src/share/database/scripts/pgsql/upgrade_1.0_to_2.0.sh src/share/database/scripts/pgsql/upgrade_1.0_to_2.0.sh
src/share/database/scripts/pgsql/upgrade_2.0_to_3.0.sh src/share/database/scripts/pgsql/upgrade_2.0_to_3.0.sh
src/share/database/scripts/dscsql/Makefile src/share/database/scripts/cql/Makefile
tools/Makefile tools/Makefile
tools/path_replacer.sh tools/path_replacer.sh
]) ])
...@@ -1673,18 +1673,18 @@ PostgreSQL: ...@@ -1673,18 +1673,18 @@ PostgreSQL:
END END
fi fi
if test "$DSCSQL_CPPFLAGS" != "" ; then if test "$CQL_CPPFLAGS" != "" ; then
cat >> config.report << END cat >> config.report << END
DataStax Cassandra SQL: Cassandra CQL:
DSCSQL_VERSION: ${DSCSQL_VERSION} CQL_VERSION: ${CQL_VERSION}
DSCSQL_CPPFLAGS: ${DSCSQL_CPPFLAGS} CQL_CPPFLAGS: ${CQL_CPPFLAGS}
DSCSQL_LIBS: ${DSCSQL_LIBS} CQL_LIBS: ${CQL_LIBS}
END END
else else
cat >> config.report << END cat >> config.report << END
DataStax Cassandra SQL: Cassandra CQL:
no no
END END
fi fi
......
...@@ -87,7 +87,7 @@ pgsql_version() { ...@@ -87,7 +87,7 @@ pgsql_version() {
return $? return $?
} }
dscsql_execute() { cql_execute() {
QUERY=$1 QUERY=$1
shift shift
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then
...@@ -101,8 +101,8 @@ dscsql_execute() { ...@@ -101,8 +101,8 @@ dscsql_execute() {
return $retcode return $retcode
} }
dscsql_version() { cql_version() {
version=`dscsql_execute "SELECT version, minor FROM schema_version" "$@"` version=`cql_execute "SELECT version, minor FROM schema_version" "$@"`
version=`echo "$version" | grep -A 1 "+" | grep -v "+" | tr -d ' ' | cut -d "|" -f 1-2 --output-delimiter="."` version=`echo "$version" | grep -A 1 "+" | grep -v "+" | tr -d ' ' | cut -d "|" -f 1-2 --output-delimiter="."`
echo $version echo $version
return $? return $?
......
...@@ -55,7 +55,7 @@ usage() { ...@@ -55,7 +55,7 @@ usage() {
printf " - lease-upgrade: Upgrades your lease database scheme\n" printf " - lease-upgrade: Upgrades your lease database scheme\n"
printf " - lease-dump: Dump current leases to a CSV file\n" printf " - lease-dump: Dump current leases to a CSV file\n"
printf "\n" printf "\n"
printf "BACKEND - one of the supported backends: memfile|mysql|pgsql|dscsql\n" printf "BACKEND - one of the supported backends: memfile|mysql|pgsql|cql\n"
printf "\n" printf "\n"
printf "PARAMETERS: Parameters are optional in general, but may be required\n" printf "PARAMETERS: Parameters are optional in general, but may be required\n"
printf " for specific operation.\n" printf " for specific operation.\n"
...@@ -200,12 +200,12 @@ pgsql_init() { ...@@ -200,12 +200,12 @@ pgsql_init() {
exit 0 exit 0
} }
dscsql_init() { cql_init() {
printf "Checking if there is a database initialized already. Please ignore errors.\n" printf "Checking if there is a database initialized already. Please ignore errors.\n"
# Let's try to count the number of tables. Anything above 0 means that there # Let's try to count the number of tables. Anything above 0 means that there
# is some database in place. If there is anything, we abort. Note that # is some database in place. If there is anything, we abort. Note that
# dsc sql may spit out connection or access errors to stderr, we ignore those. # cql may spit out connection or access errors to stderr, we ignore those.
# We should not hide them as they may give hints to user what is wrong with # We should not hide them as they may give hints to user what is wrong with
# his setup. # his setup.
# #
...@@ -213,7 +213,7 @@ dscsql_init() { ...@@ -213,7 +213,7 @@ dscsql_init() {
ERRCODE=$? ERRCODE=$?
if [ $ERRCODE -ne 0 ] if [ $ERRCODE -ne 0 ]
then then
log_error "dscsql_init table query failed, cqlsh status = $ERRCODE" log_error "cql_init table query failed, cqlsh status = $ERRCODE"
exit 1 exit 1
fi fi
...@@ -225,16 +225,16 @@ dscsql_init() { ...@@ -225,16 +225,16 @@ dscsql_init() {
exit 1 exit 1
fi fi
printf "Initializing database using script %s\n" $scripts_dir/dscsql/dhcpdb_create.cql printf "Initializing database using script %s\n" $scripts_dir/cql/dhcpdb_create.cql
cqlsh -u $db_user -p $db_password -e "CREATE KEYSPACE $db_name WITH replication = {'class' : 'SimpleStrategy','replication_factor' : 1};" cqlsh -u $db_user -p $db_password -e "CREATE KEYSPACE $db_name WITH replication = {'class' : 'SimpleStrategy','replication_factor' : 1};"
cqlsh -u $db_user -p $db_password -k $db_name -f $scripts_dir/dscsql/dhcpdb_create.cql cqlsh -u $db_user -p $db_password -k $db_name -f $scripts_dir/cql/dhcpdb_create.cql
ERRCODE=$? ERRCODE=$?
printf "cqlsh returned status code $ERRCODE\n" printf "cqlsh returned status code $ERRCODE\n"
if [ "$ERRCODE" -eq 0 ]; then if [ "$ERRCODE" -eq 0 ]; then
printf "Lease DB version reported after initialization: " printf "Lease DB version reported after initialization: "
dscsql_version cql_version
printf "\n" printf "\n"
fi fi
...@@ -323,30 +323,30 @@ pgsql_upgrade() { ...@@ -323,30 +323,30 @@ pgsql_upgrade() {
exit 0 exit 0
} }
dscsql_upgrade() { cql_upgrade() {
version=`dscsql_version` version=`cql_version`
printf "Lease DB version reported before upgrade: $version\n" printf "Lease DB version reported before upgrade: $version\n"
# Check if the scripts directory exists at all. # Check if the scripts directory exists at all.
if [ ! -d ${scripts_dir}/dscsql ]; then if [ ! -d ${scripts_dir}/cql ]; then
log_error "Invalid scripts directory: ${scripts_dir}/dscsql" log_error "Invalid scripts directory: ${scripts_dir}/cql"
exit 1 exit 1
fi fi
# Check if there are any files in it # Check if there are any files in it
num_files=$(find ${scripts_dir}/dscsql/upgrade*.sh -type f | wc -l) num_files=$(find ${scripts_dir}/cql/upgrade*.sh -type f | wc -l)
if [ $num_files -eq 0 ]; then if [ $num_files -eq 0 ]; then
log_error "No scripts in ${scripts_dir}/dscsql or the directory is not readable or does not have any upgrade* scripts." log_error "No scripts in ${scripts_dir}/cql or the directory is not readable or does not have any upgrade* scripts."
exit 1 exit 1
fi fi
for script in ${scripts_dir}/dscsql/upgrade*.sh for script in ${scripts_dir}/cql/upgrade*.sh
do do
echo "Processing $script file..." echo "Processing $script file..."
sh ${script} -u ${db_user} -p ${db_password} -k ${db_name} sh ${script} -u ${db_user} -p ${db_password} -k ${db_name}
done done
version=`dscsql_version` version=`cql_version`
printf "Lease DB version reported after upgrade: $version\n" printf "Lease DB version reported after upgrade: $version\n"
exit 0 exit 0
} }
...@@ -384,7 +384,7 @@ get_dump_query() { ...@@ -384,7 +384,7 @@ get_dump_query() {
pgsql) pgsql)
invoke="select * from" invoke="select * from"
;; ;;
dscsql) cql)
invoke="select * from" invoke="select * from"
;; ;;
*) *)
...@@ -491,14 +491,14 @@ pgsql_dump() { ...@@ -491,14 +491,14 @@ pgsql_dump() {
exit 0 exit 0
} }
dscsql_dump() { cql_dump() {
# get the correct dump query # get the correct dump query
version=`dscsql_version` version=`cql_version`
retcode=$? retcode=$?
if [ $retcode -ne 0 ] if [ $retcode -ne 0 ]
then then
log_error "lease-dump: dscsql_version failed, exit code $retcode" log_error "lease-dump: cql_version failed, exit code $retcode"
exit 1; exit 1;
fi fi
...@@ -526,10 +526,10 @@ dscsql_dump() { ...@@ -526,10 +526,10 @@ dscsql_dump() {
# 'tr' to translate tabs to commas. We do not use MySQL's output # 'tr' to translate tabs to commas. We do not use MySQL's output
# to file as that requires linux superuser privileges to execute # to file as that requires linux superuser privileges to execute
# the select. # the select.
dscsql_execute "${dump_qry}" > $tmp_file cql_execute "${dump_qry}" > $tmp_file
retcode=$? retcode=$?
if [ $retcode -ne 0 ]; then if [ $retcode -ne 0 ]; then
log_error "lease-dump: dscsql_execute failed, exit code $retcode"; log_error "lease-dump: cql_execute failed, exit code $retcode";
exit 1 exit 1
fi fi
...@@ -569,7 +569,7 @@ if [ -z ${backend} ]; then ...@@ -569,7 +569,7 @@ if [ -z ${backend} ]; then
usage usage
exit 1 exit 1
fi fi
is_in_list "${backend}" "memfile mysql pgsql dscsql" is_in_list "${backend}" "memfile mysql pgsql cql"
if [ ${_inlist} -eq 0 ]; then if [ ${_inlist} -eq 0 ]; then
log_error "invalid backend: ${backend}" log_error "invalid backend: ${backend}"
exit 1 exit 1
...@@ -669,8 +669,8 @@ case ${command} in ...@@ -669,8 +669,8 @@ case ${command} in
pgsql) pgsql)
pgsql_init pgsql_init
;; ;;
dscsql) cql)
dscsql_init cql_init
;; ;;
esac esac
;; ;;
...@@ -686,8 +686,8 @@ case ${command} in ...@@ -686,8 +686,8 @@ case ${command} in
pgsql) pgsql)
pgsql_version pgsql_version
;; ;;
dscsql) cql)
dscsql_version cql_version
;; ;;
esac esac
;; ;;
...@@ -702,8 +702,8 @@ case ${command} in ...@@ -702,8 +702,8 @@ case ${command} in
pgsql) pgsql)
pgsql_upgrade pgsql_upgrade
;; ;;
dscsql) cql)
dscsql_upgrade cql_upgrade
;; ;;
esac esac
;; ;;
...@@ -718,8 +718,8 @@ case ${command} in ...@@ -718,8 +718,8 @@ case ${command} in
pgsql) pgsql)
pgsql_dump pgsql_dump
;; ;;
dscsql) cql)
dscsql_dump cql_dump
;; ;;
esac esac
;; ;;
......
...@@ -10,8 +10,8 @@ if HAVE_PGSQL ...@@ -10,8 +10,8 @@ if HAVE_PGSQL
SHTESTS += pgsql_tests.sh SHTESTS += pgsql_tests.sh
endif endif
if HAVE_DSCSQL if HAVE_CQL
SHTESTS += dscsql_tests.sh SHTESTS += cql_tests.sh
endif endif
noinst_SCRIPTS = $(SHTESTS) noinst_SCRIPTS = $(SHTESTS)
...@@ -20,7 +20,7 @@ EXTRA_DIST += dhcpdb_create_1.0.pgsql ...@@ -20,7 +20,7 @@ EXTRA_DIST += dhcpdb_create_1.0.pgsql
EXTRA_DIST += dhcpdb_create_1.0.cql EXTRA_DIST += dhcpdb_create_1.0.cql
CLEANFILES = *.log CLEANFILES = *.log
DISTCLEANFILES = memfile_tests.sh mysql_tests.sh pgsql_tests.sh dscsql_tests.sh DISTCLEANFILES = memfile_tests.sh mysql_tests.sh pgsql_tests.sh cql_tests.sh
# Execute all test scripts. # Execute all test scripts.
check-local: check-local:
......
#!/bin/sh
# Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Include common test library.
. /home/andrei/work/git/isc-kea-integration/kea/src/lib/testutils/dhcp_test_lib.sh
cql_init_test() {
test_start "cql.init"
# @todo: Implement this
test_finish 0
}
cql_version_test() {
test_start "cql.version"
# @todo: Implement this
test_finish 0
}
cql_upgrade_test() {
test_start "cql.upgrade"
# @todo: Implement this
test_finish 0
}
cql_init_test
cql_version_test
cql_upgrade_test
...@@ -9,30 +9,30 @@ ...@@ -9,30 +9,30 @@
# Include common test library. # Include common test library.
. @abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh . @abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh
dscsql_init_test() { cql_init_test() {
test_start "dscsql.init" test_start "cql.init"
# @todo: Implement this # @todo: Implement this
test_finish 0 test_finish 0
} }
dscsql_version_test() { cql_version_test() {
test_start "dscsql.version" test_start "cql.version"
# @todo: Implement this # @todo: Implement this
test_finish 0 test_finish 0
} }
dscsql_upgrade_test() { cql_upgrade_test() {
test_start "dscsql.upgrade" test_start "cql.upgrade"
# @todo: Implement this # @todo: Implement this
test_finish 0 test_finish 0
} }
dscsql_init_test cql_init_test
dscsql_version_test cql_version_test
dscsql_upgrade_test cql_upgrade_test
...@@ -2,5 +2,5 @@ EXTRA_DIST = mysql.lease4_dump_test.reference.csv \ ...@@ -2,5 +2,5 @@ EXTRA_DIST = mysql.lease4_dump_test.reference.csv \
mysql.lease6_dump_test.reference.csv \ mysql.lease6_dump_test.reference.csv \
pgsql.lease4_dump_test.reference.csv \ pgsql.lease4_dump_test.reference.csv \
pgsql.lease6_dump_test.reference.csv \ pgsql.lease6_dump_test.reference.csv \
dscsql.lease4_dump_test.reference.csv \ cql.lease4_dump_test.reference.csv \
dscsql.lease6_dump_test.reference.csv cql.lease6_dump_test.reference.csv
...@@ -14,24 +14,24 @@ ...@@ -14,24 +14,24 @@
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- This is the Kea schema 1.0 specification for DataStax Cassandra SQL. -- This is the Kea schema 1.0 specification for Cassandra CQL.
-- Note: this is outdated version on purpose and it used to test upgrade -- Note: this is outdated version on purpose and it used to test upgrade
-- process. Do not update this file to 2.0 or any later. -- process. Do not update this file to 2.0 or any later.
-- The schema is reasonably portable (with the exception of the engine -- The schema is reasonably portable (with the exception of the engine
-- specification, which is Datastax Cassandra SQL-specific). Minor changes might be needed for -- specification, which is Cassandra CQL-specific). Minor changes might be needed for
-- other databases. -- other databases.
-- To create the schema, either type the command: -- To create the schema, either type the command:
-- cqlsh -u <user> -p <password> -k <database> -f dhcpdb_create.cql -- cqlsh -u <user> -p <password> -k <database> -f dhcpdb_create.cql
-- ... at the command prompt, or log in to the DSC SQL database and at the "cqlsh>" -- ... at the command prompt, or log in to the CQL database and at the "cqlsh>"
-- prompt, issue the command: -- prompt, issue the command: