# ... and at the shell level, so Makefile.am can take action depending on this.
AM_CONDITIONAL(HAVE_PGSQL, test "$PG_CONFIG" != "")
-dsc_config="no"
-AC_ARG_WITH([dhcp-dscsql],
- AC_HELP_STRING([--with-dhcp-dscsql=PATH],
- [path to the DataStaxCassandraSQL 'dsc_config' script]),
- [dsc_config="$withval"])
-
-if test "${dsc_config}" = "yes" ; then
- DSC_CONFIG="/usr/bin/dsc_config"
-elif test "${dsc_config}" != "no" ; then
- DSC_CONFIG="${withval}"
+cql_config="no"
+AC_ARG_WITH([cql],
+ AC_HELP_STRING([--with-cql=PATH],
+ [path to the Cassandra CQL 'cql_config' script]),
+ [cql_config="$withval"])
+
+if test "${cql_config}" = "yes" ; then
+ cql_config="/usr/bin/cql_config"
+elif test "${cql_config}" != "no" ; then
+ CQL_CONFIG="${withval}"
fi
-if test "$DSC_CONFIG" != "" ; then
- if test -d "$DSC_CONFIG" -o ! -x "$DSC_CONFIG" ; then
- AC_MSG_ERROR([--with-dhcp-dscsql should point to a dsc_config program])
+if test "$CQL_CONFIG" != "" ; then
+ if test -d "$CQL_CONFIG" -o ! -x "$CQL_CONFIG" ; then
+ AC_MSG_ERROR([--with-cql should point to a cql_config program])
fi
- DSCSQL_CPPFLAGS=`$DSC_CONFIG --cppflags`
- DSCSQL_INCLUDEDIR=`$DSC_CONFIG --includedir`
- DSCSQL_CPPFLAGS="$DSCSQL_CPPFLAGS -I$DSCSQL_INCLUDEDIR"
- DSCSQL_LIBS=`$DSC_CONFIG --libdir`
- DSCSQL_LIBS="-L$DSCSQL_LIBS -lcassandra_static -luv"
- DSCSQL_VERSION=`$DSC_CONFIG --version`
+ CQL_CPPFLAGS=`$CQL_CONFIG --cppflags`
+ CQL_INCLUDEDIR=`$CQL_CONFIG --includedir`
+ CQL_CPPFLAGS="$CQL_CPPFLAGS -I$CQL_INCLUDEDIR"
+ CQL_LIBS=`$CQL_CONFIG --libdir`
+ CQL_LIBS="-L$CQL_LIBS -lcassandra_static -luv"
+ CQL_VERSION=`$CQL_CONFIG --version`
- AC_SUBST(DSCSQL_CPPFLAGS)
- AC_SUBST(DSCSQL_LIBS)
+ AC_SUBST(CQL_CPPFLAGS)
+ 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"
LIBS_SAVED="$LIBS"
- CPPFLAGS="$DSCSQL_CPPFLAGS $CPPFLAGS"
- LIBS="$DSCSQL_LIBS $LIBS"
+ CPPFLAGS="$CQL_CPPFLAGS $CPPFLAGS"
+ LIBS="$CQL_LIBS $LIBS"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <cassandra.h>],
[CassCluster* cluster = cass_cluster_new();
cass_cluster_free(cluster);])],
- [AC_MSG_RESULT([checking for DataStax Cassandra SQL headers and library... yes])],
- [AC_MSG_RESULT([checking for DataStax Cassandra SQL headers and library... no])
- AC_MSG_ERROR([Needs DataStax Cassandra SQL library])]
+ [AC_MSG_RESULT([checking for Cassandra CQL headers and library... yes])],
+ [AC_MSG_RESULT([checking for Cassandra CQL headers and library... no])
+ AC_MSG_ERROR([Needs Cassandra CQL library])]
)
CPPFLAGS=$CPPFLAGS_SAVED
LIBS=$LIBS_SAVED
- # Note that DSCSQL is present in the config.h file
- AC_DEFINE([HAVE_DSCSQL], [1], [DSCSQL is present])
+ # Note that CQL is present in the config.h file
+ AC_DEFINE([HAVE_CQL], [1], [CQL is present])
fi
# ... 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
log4cplus_path="yes"
src/bin/admin/tests/memfile_tests.sh
src/bin/admin/tests/mysql_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/dhcp/Makefile
src/hooks/dhcp/user_chk/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_2.0_to_3.0.sh
- src/share/database/scripts/dscsql/Makefile
+ src/share/database/scripts/cql/Makefile
tools/Makefile
tools/path_replacer.sh
])
END
fi
-if test "$DSCSQL_CPPFLAGS" != "" ; then
+if test "$CQL_CPPFLAGS" != "" ; then
cat >> config.report << END
-DataStax Cassandra SQL:
- DSCSQL_VERSION: ${DSCSQL_VERSION}
- DSCSQL_CPPFLAGS: ${DSCSQL_CPPFLAGS}
- DSCSQL_LIBS: ${DSCSQL_LIBS}
+Cassandra CQL:
+ CQL_VERSION: ${CQL_VERSION}
+ CQL_CPPFLAGS: ${CQL_CPPFLAGS}
+ CQL_LIBS: ${CQL_LIBS}
END
else
cat >> config.report << END
-DataStax Cassandra SQL:
+Cassandra CQL:
no
END
fi
return $?
}
-dscsql_execute() {
+cql_execute() {
QUERY=$1
shift
if [ $# -gt 1 ]; then
return $retcode
}
-dscsql_version() {
- version=`dscsql_execute "SELECT version, minor FROM schema_version" "$@"`
+cql_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="."`
echo $version
return $?
printf " - lease-upgrade: Upgrades your lease database scheme\n"
printf " - lease-dump: Dump current leases to a CSV file\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 "PARAMETERS: Parameters are optional in general, but may be required\n"
printf " for specific operation.\n"
exit 0
}
-dscsql_init() {
+cql_init() {
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
# 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
# his setup.
#
ERRCODE=$?
if [ $ERRCODE -ne 0 ]
then
- log_error "dscsql_init table query failed, cqlsh status = $ERRCODE"
+ log_error "cql_init table query failed, cqlsh status = $ERRCODE"
exit 1
fi
exit 1
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 -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=$?
printf "cqlsh returned status code $ERRCODE\n"
if [ "$ERRCODE" -eq 0 ]; then
printf "Lease DB version reported after initialization: "
- dscsql_version
+ cql_version
printf "\n"
fi
exit 0
}
-dscsql_upgrade() {
- version=`dscsql_version`
+cql_upgrade() {
+ version=`cql_version`
printf "Lease DB version reported before upgrade: $version\n"
# Check if the scripts directory exists at all.
- if [ ! -d ${scripts_dir}/dscsql ]; then
- log_error "Invalid scripts directory: ${scripts_dir}/dscsql"
+ if [ ! -d ${scripts_dir}/cql ]; then
+ log_error "Invalid scripts directory: ${scripts_dir}/cql"
exit 1
fi
# 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
- 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
fi
- for script in ${scripts_dir}/dscsql/upgrade*.sh
+ for script in ${scripts_dir}/cql/upgrade*.sh
do
echo "Processing $script file..."
sh ${script} -u ${db_user} -p ${db_password} -k ${db_name}
done
- version=`dscsql_version`
+ version=`cql_version`
printf "Lease DB version reported after upgrade: $version\n"
exit 0
}
pgsql)
invoke="select * from"
;;
- dscsql)
+ cql)
invoke="select * from"
;;
*)
exit 0
}
-dscsql_dump() {
+cql_dump() {
# get the correct dump query
- version=`dscsql_version`
+ version=`cql_version`
retcode=$?
if [ $retcode -ne 0 ]
then
- log_error "lease-dump: dscsql_version failed, exit code $retcode"
+ log_error "lease-dump: cql_version failed, exit code $retcode"
exit 1;
fi
# 'tr' to translate tabs to commas. We do not use MySQL's output
# to file as that requires linux superuser privileges to execute
# the select.
- dscsql_execute "${dump_qry}" > $tmp_file
+ cql_execute "${dump_qry}" > $tmp_file
retcode=$?
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
fi
usage
exit 1
fi
-is_in_list "${backend}" "memfile mysql pgsql dscsql"
+is_in_list "${backend}" "memfile mysql pgsql cql"
if [ ${_inlist} -eq 0 ]; then
log_error "invalid backend: ${backend}"
exit 1
pgsql)
pgsql_init
;;
- dscsql)
- dscsql_init
+ cql)
+ cql_init
;;
esac
;;
pgsql)
pgsql_version
;;
- dscsql)
- dscsql_version
+ cql)
+ cql_version
;;
esac
;;
pgsql)
pgsql_upgrade
;;
- dscsql)
- dscsql_upgrade
+ cql)
+ cql_upgrade
;;
esac
;;
pgsql)
pgsql_dump
;;
- dscsql)
- dscsql_dump
+ cql)
+ cql_dump
;;
esac
;;
SHTESTS += pgsql_tests.sh
endif
-if HAVE_DSCSQL
-SHTESTS += dscsql_tests.sh
+if HAVE_CQL
+SHTESTS += cql_tests.sh
endif
noinst_SCRIPTS = $(SHTESTS)
EXTRA_DIST += dhcpdb_create_1.0.cql
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.
check-local:
--- /dev/null
+#!/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
# Include common test library.
. @abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh
-dscsql_init_test() {
- test_start "dscsql.init"
+cql_init_test() {
+ test_start "cql.init"
# @todo: Implement this
test_finish 0
}
-dscsql_version_test() {
- test_start "dscsql.version"
+cql_version_test() {
+ test_start "cql.version"
# @todo: Implement this
test_finish 0
}
-dscsql_upgrade_test() {
- test_start "dscsql.upgrade"
+cql_upgrade_test() {
+ test_start "cql.upgrade"
# @todo: Implement this
test_finish 0
}
-dscsql_init_test
-dscsql_version_test
-dscsql_upgrade_test
+cql_init_test
+cql_version_test
+cql_upgrade_test
mysql.lease6_dump_test.reference.csv \
pgsql.lease4_dump_test.reference.csv \
pgsql.lease6_dump_test.reference.csv \
- dscsql.lease4_dump_test.reference.csv \
- dscsql.lease6_dump_test.reference.csv
+ cql.lease4_dump_test.reference.csv \
+ cql.lease6_dump_test.reference.csv
-- See the License for the specific language governing permissions and
-- 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
-- process. Do not update this file to 2.0 or any later.
-- 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.
-- To create the schema, either type the command:
-- 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:
-- SOURCE dhcpdb_create.cql
--- This script is also called from kea-admin, see kea-admin init dscsql
+-- This script is also called from kea-admin, see kea-admin init cql
-- Over time, Kea database schema will evolve. Each version is marked with
-- major.minor version. This file is organized sequentially, i.e. database
if HAVE_PGSQL
AM_CPPFLAGS += $(PGSQL_CPPFLAGS)
endif
-if HAVE_DSCSQL
-AM_CPPFLAGS += $(DSCSQL_CPPFLAGS)
+if HAVE_CQL
+AM_CPPFLAGS += $(CQL_CPPFLAGS)
endif
AM_CXXFLAGS = $(KEA_CXXFLAGS)
if HAVE_PGSQL
kea_dhcp_ddns_LDFLAGS += $(PGSQL_LIBS)
endif
-if HAVE_DSCSQL
-kea_dhcp_ddns_LDFLAGS += $(DSCSQL_LIBS)
+if HAVE_CQL
+kea_dhcp_ddns_LDFLAGS += $(CQL_LIBS)
endif
kea_dhcp_ddnsdir = $(pkgdatadir)
#ifdef HAVE_PGSQL
#include <dhcpsrv/pgsql_lease_mgr.h>
#endif
-#ifdef HAVE_DSCSQL
-#include <dhcpsrv/dscsql_lease_mgr.h>
+#ifdef HAVE_CQL
+#include <dhcpsrv/cql_lease_mgr.h>
#endif
#include <dhcpsrv/memfile_lease_mgr.h>
#ifdef HAVE_PGSQL
tmp << isc::dhcp::PgSqlLeaseMgr::getDBVersion() << std::endl;
#endif
-#ifdef HAVE_DSCSQL
- tmp << isc::dhcp::DSCSqlLeaseMgr::getDBVersion() << std::endl;
+#ifdef HAVE_CQL
+ tmp << isc::dhcp::CqlLeaseMgr::getDBVersion() << std::endl;
#endif
tmp << isc::dhcp::Memfile_LeaseMgr::getDBVersion();
if HAVE_PGSQL
d2_unittests_LDFLAGS += $(PGSQL_LIBS)
endif
-if HAVE_DSCSQL
-d2_unittests_LDFLAGS += $(DSCSQL_LIBS)
+if HAVE_CQL
+d2_unittests_LDFLAGS += $(CQL_LIBS)
endif
d2_unittests_LDFLAGS += $(GTEST_LDFLAGS)
if HAVE_PGSQL
AM_CPPFLAGS += $(PGSQL_CPPFLAGS)
endif
-if HAVE_DSCSQL
-AM_CPPFLAGS += $(DSCSQL_CPPFLAGS)
+if HAVE_CQL
+AM_CPPFLAGS += $(CQL_CPPFLAGS)
endif
AM_CXXFLAGS = $(KEA_CXXFLAGS)
if HAVE_PGSQL
kea_dhcp4_LDFLAGS += $(PGSQL_LIBS)
endif
-if HAVE_DSCSQL
-kea_dhcp4_LDFLAGS += $(DSCSQL_LIBS)
+if HAVE_CQL
+kea_dhcp4_LDFLAGS += $(CQL_LIBS)
endif
kea_dhcp4dir = $(pkgdatadir)
#ifdef HAVE_PGSQL
#include <dhcpsrv/pgsql_lease_mgr.h>
#endif
-#ifdef HAVE_DSCSQL
-#include <dhcpsrv/dscsql_lease_mgr.h>
+#ifdef HAVE_CQL
+#include <dhcpsrv/cql_lease_mgr.h>
#endif
#include <dhcpsrv/memfile_lease_mgr.h>
#ifdef HAVE_PGSQL
tmp << PgSqlLeaseMgr::getDBVersion() << endl;
#endif
-#ifdef HAVE_DSCSQL
- tmp << DSCSqlLeaseMgr::getDBVersion() << endl;
+#ifdef HAVE_CQL
+ tmp << CqlLeaseMgr::getDBVersion() << endl;
#endif
tmp << Memfile_LeaseMgr::getDBVersion();
if HAVE_PGSQL
dhcp4_unittests_LDFLAGS += $(PGSQL_LIBS)
endif
-if HAVE_DSCSQL
-dhcp4_unittests_LDFLAGS += $(DSCSQL_LIBS)
+if HAVE_CQL
+dhcp4_unittests_LDFLAGS += $(CQL_LIBS)
endif
dhcp4_unittests_LDFLAGS += $(GTEST_LDFLAGS)
if HAVE_PGSQL
AM_CPPFLAGS += $(PGSQL_CPPFLAGS)
endif
-if HAVE_DSCSQL
-AM_CPPFLAGS += $(DSCSQL_CPPFLAGS)
+if HAVE_CQL
+AM_CPPFLAGS += $(CQL_CPPFLAGS)
endif
AM_CXXFLAGS = $(KEA_CXXFLAGS)
if HAVE_PGSQL
kea_dhcp6_LDFLAGS += $(PGSQL_LIBS)
endif
-if HAVE_DSCSQL
-kea_dhcp6_LDFLAGS += $(DSCSQL_LIBS)
+if HAVE_CQL
+kea_dhcp6_LDFLAGS += $(CQL_LIBS)
endif
kea_dhcp6dir = $(pkgdatadir)
#ifdef HAVE_PGSQL
#include <dhcpsrv/pgsql_lease_mgr.h>
#endif
-#ifdef HAVE_DSCSQL
-#include <dhcpsrv/dscsql_lease_mgr.h>
+#ifdef HAVE_CQL
+#include <dhcpsrv/cql_lease_mgr.h>
#endif
#include <dhcpsrv/memfile_lease_mgr.h>
#ifdef HAVE_PGSQL
tmp << PgSqlLeaseMgr::getDBVersion() << endl;
#endif
-#ifdef HAVE_DSCSQL
- tmp << DSCSqlLeaseMgr::getDBVersion() << endl;
+#ifdef HAVE_CQL
+ tmp << CqlLeaseMgr::getDBVersion() << endl;
#endif
tmp << Memfile_LeaseMgr::getDBVersion();
if HAVE_PGSQL
dhcp6_unittests_LDFLAGS += $(PGSQL_LIBS)
endif
-if HAVE_DSCSQL
-dhcp6_unittests_LDFLAGS += $(DSCSQL_LIBS)
+if HAVE_CQL
+dhcp6_unittests_LDFLAGS += $(CQL_LIBS)
endif
dhcp6_unittests_LDFLAGS += $(GTEST_LDFLAGS)
if HAVE_PGSQL
kea_lfc_LDFLAGS += $(PGSQL_LIBS)
endif
-if HAVE_DSCSQL
-kea_lfc_LDFLAGS += $(DSCSQL_LIBS)
+if HAVE_CQL
+kea_lfc_LDFLAGS += $(CQL_LIBS)
endif
kea_lfcdir = $(pkgdatadir)
if HAVE_PGSQL
lfc_unittests_LDFLAGS += $(PGSQL_LIBS)
endif
-if HAVE_DSCSQL
-lfc_unittests_LDFLAGS += $(DSCSQL_LIBS)
+if HAVE_CQL
+lfc_unittests_LDFLAGS += $(CQL_LIBS)
endif
lfc_unittests_LDFLAGS += $(GTEST_LDFLAGS)
if HAVE_PGSQL
AM_CPPFLAGS += $(PGSQL_CPPFLAGS)
endif
-if HAVE_DSCSQL
-AM_CPPFLAGS += $(DSCSQL_CPPFLAGS)
+if HAVE_CQL
+AM_CPPFLAGS += $(CQL_CPPFLAGS)
endif
AM_CXXFLAGS = $(KEA_CXXFLAGS)
libkea_dhcpsrv_la_SOURCES += pgsql_exchange.cc pgsql_exchange.h
libkea_dhcpsrv_la_SOURCES += pgsql_lease_mgr.cc pgsql_lease_mgr.h
endif
-if HAVE_DSCSQL
-libkea_dhcpsrv_la_SOURCES += dscsql_lease_mgr.cc dscsql_lease_mgr.h
-libkea_dhcpsrv_la_SOURCES += dscsql_connection.cc dscsql_connection.h
+if HAVE_CQL
+libkea_dhcpsrv_la_SOURCES += cql_lease_mgr.cc cql_lease_mgr.h
+libkea_dhcpsrv_la_SOURCES += cql_connection.cc cql_connection.h
endif
libkea_dhcpsrv_la_SOURCES += pool.cc pool.h
libkea_dhcpsrv_la_SOURCES += srv_config.cc srv_config.h
if HAVE_PGSQL
libkea_dhcpsrv_la_LDFLAGS += $(PGSQL_LIBS)
endif
-if HAVE_DSCSQL
-libkea_dhcpsrv_la_LDFLAGS += $(DSCSQL_LIBS)
+if HAVE_CQL
+libkea_dhcpsrv_la_LDFLAGS += $(CQL_LIBS)
endif
if USE_CLANGPP
// See the License for the specific language governing permissions and
// limitations under the License.
-#include <dhcpsrv/dscsql_connection.h>
+#include <dhcpsrv/cql_connection.h>
#include <string>
using namespace std;
namespace isc {
namespace dhcp {
-DSCSqlConnection::DSCSqlConnection(const ParameterMap& parameters) : DatabaseConnection(parameters),
+CqlConnection::CqlConnection(const ParameterMap& parameters) : DatabaseConnection(parameters),
cluster_(NULL), session_(NULL), tagged_statements_(NULL) {
}
-DSCSqlConnection::~DSCSqlConnection() {
+CqlConnection::~CqlConnection() {
CassError rc;
for (int i = 0; i < statements_.size(); i++)
{
}
void
-DSCSqlConnection::openDatabase() {
+CqlConnection::openDatabase() {
CassError rc;
// Set up the values of the parameters
const char* contact_points = "127.0.0.1";
}
void
-DSCSqlConnection::prepareStatements(DSCSqlTaggedStatement *statements) {
+CqlConnection::prepareStatements(CqlTaggedStatement *statements) {
CassError rc = CASS_OK;
CassFuture* future = NULL;
uint32_t size = 0;
}
string
-DSCSqlConnection::getName() const {
+CqlConnection::getName() const {
string name = "";
try {
name = getParameter("name");
}
string
-DSCSqlConnection::getDescription() const {
- return (string("DataStax Cassandra Database"));
+CqlConnection::getDescription() const {
+ return (string("Cassandra Database"));
}
pair<uint32_t, uint32_t>
-DSCSqlConnection::getVersion() const {
+CqlConnection::getVersion() const {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
- DHCPSRV_DSCSQL_GET_VERSION);
+ DHCPSRV_CQL_GET_VERSION);
uint32_t version = CASS_VERSION_MAJOR;
uint32_t minor = CASS_VERSION_MINOR;
}
void
-DSCSqlConnection::commit() {
- LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_DSCSQL_COMMIT);
+CqlConnection::commit() {
+ LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_COMMIT);
}
void
-DSCSqlConnection::rollback() {
- LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_DSCSQL_ROLLBACK);
+CqlConnection::rollback() {
+ LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_ROLLBACK);
}
void
-DSCSqlConnection::checkStatementError(std::string& error, CassFuture* future, uint32_t stindex, const char* what) const
+CqlConnection::checkStatementError(std::string& error, CassFuture* future, uint32_t stindex, const char* what) const
{
CassError rc;
const char* errorMessage;
}
void
-DSCSqlConnection::checkStatementError(std::string& error, CassFuture* future, const char* what) const
+CqlConnection::checkStatementError(std::string& error, CassFuture* future, const char* what) const
{
CassError rc;
const char* errorMessage;
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef DSCSQL_CONNECTION_H
-#define DSCSQL_CONNECTION_H
+#ifndef CQL_CONNECTION_H
+#define CQL_CONNECTION_H
#include <dhcpsrv/database_connection.h>
#include <dhcpsrv/dhcpsrv_log.h>
namespace dhcp {
/// @brief Defines a single query
-struct DSCSqlTaggedStatement {
+struct CqlTaggedStatement {
/// Param name.
const char** params_;
const char* text_;
};
-/// Defines DSC SQL backend version: 1.0
-const uint32_t DSCSQL_CURRENT_VERSION = 1;
-const uint32_t DSCSQL_CURRENT_MINOR = 0;
+/// Defines CQL backend version: 1.0
+const uint32_t CQL_CURRENT_VERSION = 1;
+const uint32_t CQL_CURRENT_MINOR = 0;
-class DSCSqlConnection : public DatabaseConnection {
+class CqlConnection : public DatabaseConnection {
public:
/// @brief Constructor
///
- /// Initialize DSCSqlConnection object with parameters needed for connection.
- DSCSqlConnection(const ParameterMap& parameters);
+ /// Initialize CqlConnection object with parameters needed for connection.
+ CqlConnection(const ParameterMap& parameters);
/// @brief Destructor
- virtual ~DSCSqlConnection();
+ virtual ~CqlConnection();
/// @brief Prepare statements
///
/// Creates the prepared statements for all of the SQL statements used
- /// by the PostgreSQL backend.
+ /// by the CQL backend.
///
/// @throw isc::dhcp::DbOperationError An operation on the open database has
/// failed.
/// @throw isc::InvalidParameter 'index' is not valid for the vector. This
/// represents an internal error within the code.
- void prepareStatements(DSCSqlTaggedStatement *statements);
+ void prepareStatements(CqlTaggedStatement *statements);
/// @brief Open Database
///
///
/// Commits all pending database operations.
///
- /// @throw DbOperationError Iif the commit failed.
+ /// @throw DbOperationError If the commit failed.
virtual void commit();
/// @brief Rollback Transactions
/// @brief Check Error
///
/// Chech error for current database operation.
- void checkStatementError(std::string& error, CassFuture* future, uint32_t stindex, const char* what) const;
+ void checkStatementError(std::string& error, CassFuture* future,
+ uint32_t stindex, const char* what) const;
/// @brief Check Error
///
/// Chech error for current database operation.
- void checkStatementError(std::string& error, CassFuture* future, const char* what) const;
+ void checkStatementError(std::string& error, CassFuture* future,
+ const char* what) const;
- /// DSC SQL connection handle
+ /// CQL connection handle
CassCluster* cluster_;
CassSession* session_;
std::vector<const CassPrepared*> statements_; ///< Prepared statements
- DSCSqlTaggedStatement *tagged_statements_;
+ CqlTaggedStatement *tagged_statements_;
};
}; // end of isc::dhcp namespace
}; // end of isc namespace
-#endif // DSCSQL_CONNECTION_H
+#endif // CQL_CONNECTION_H
The database access string specified a database type (given in the
message) that is unknown to the software. This is a configuration error.
-% DHCPSRV_DSCSQL_ADD_ADDR4 adding IPv4 lease with address %1
+% DHCPSRV_CQL_ADD_ADDR4 adding IPv4 lease with address %1
A debug message issued when the server is about to add an IPv4 lease
-with the specified address to the DataStax Cassandra backend database.
+with the specified address to the Cassandra backend database.
-% DHCPSRV_DSCSQL_ADD_ADDR6 adding IPv6 lease with address %1
+% DHCPSRV_CQL_ADD_ADDR6 adding IPv6 lease with address %1
A debug message issued when the server is about to add an IPv6 lease
-with the specified address to the DataStax Cassandra backend database.
+with the specified address to the Cassandra backend database.
-% DHCPSRV_DSCSQL_COMMIT committing to DataStax Cassandra database
+% DHCPSRV_CQL_COMMIT committing to Cassandra database
The code has issued a commit call.
-% DHCPSRV_DSCSQL_DB opening DataStax Cassandra lease database: %1
+% DHCPSRV_CQL_DB opening Cassandra lease database: %1
This informational message is logged when a DHCP server (either V4 or
-V6) is about to open a DataStax Cassandra lease database. The parameters of
+V6) is about to open a Cassandra lease database. The parameters of
the connection including database name and username needed to access it
(but not the password if any) are logged.
-% DHCPSRV_DSCSQL_DELETE_ADDR deleting lease for address %1
+% DHCPSRV_CQL_DELETE_ADDR deleting lease for address %1
A debug message issued when the server is attempting to delete a lease
-for the specified address from the DataStax Cassandra database for the specified
+for the specified address from the Cassandra database for the specified
address.
-% DHCPSRV_DSCSQL_DELETE_EXPIRED_RECLAIMED4 deleting reclaimed IPv4 leases that expired more than %1 seconds ago
+% DHCPSRV_CQL_DELETE_EXPIRED_RECLAIMED4 deleting reclaimed IPv4 leases that expired more than %1 seconds ago
A debug message issued when the server is removing reclaimed DHCPv4
leases which have expired longer than a specified period of time.
The argument is the amount of time Kea waits after a reclaimed
lease expires before considering its removal.
-% DHCPSRV_DSCSQL_DELETE_EXPIRED_RECLAIMED6 deleting reclaimed IPv6 leases that expired more than %1 seconds ago
+% DHCPSRV_CQL_DELETE_EXPIRED_RECLAIMED6 deleting reclaimed IPv6 leases that expired more than %1 seconds ago
A debug message issued when the server is removing reclaimed DHCPv6
leases which have expired longer than a specified period of time.
The argument is the amount of time Kea waits after a reclaimed
lease expires before considering its removal.
-% DHCPSRV_DSCSQL_GET_ADDR4 obtaining IPv4 lease for address %1
+% DHCPSRV_CQL_GET_ADDR4 obtaining IPv4 lease for address %1
A debug message issued when the server is attempting to obtain an IPv4
-lease from the DataStax Cassandra database for the specified address.
+lease from the Cassandra database for the specified address.
-% DHCPSRV_DSCSQL_GET_ADDR6 obtaining IPv6 lease for address %1 and lease type %2
+% DHCPSRV_CQL_GET_ADDR6 obtaining IPv6 lease for address %1 and lease type %2
A debug message issued when the server is attempting to obtain an IPv6
-lease from the DataStax Cassandra database for the specified address.
+lease from the Cassandra database for the specified address.
-% DHCPSRV_DSCSQL_GET_CLIENTID obtaining IPv4 leases for client ID %1
+% DHCPSRV_CQL_GET_CLIENTID obtaining IPv4 leases for client ID %1
A debug message issued when the server is attempting to obtain a set of
-IPv4 leases from the DataStax Cassandra database for a client with the specified
+IPv4 leases from the Cassandra database for a client with the specified
client identification.
-% DHCPSRV_DSCSQL_GET_CLIENTID_HWADDR_SUBID obtaining IPv4 lease for client ID %1, hardware address %2 and subnet ID %3
+% DHCPSRV_CQL_GET_CLIENTID_HWADDR_SUBID obtaining IPv4 lease for client ID %1, hardware address %2 and subnet ID %3
A debug message issued when the server is attempting to obtain an IPv4
-lease from the DataStax Cassandra database for a client with the specified
+lease from the Cassandra database for a client with the specified
client ID, hardware address and subnet ID.
-% DHCPSRV_DSCSQL_GET_EXPIRED4 obtaining maximum %1 of expired IPv4 leases
+% DHCPSRV_CQL_GET_EXPIRED4 obtaining maximum %1 of expired IPv4 leases
A debug message issued when the server is attempting to obtain expired
IPv4 leases to reclaim them. The maximum number of leases to be retrieved
is logged in the message.
-% DHCPSRV_DSCSQL_GET_EXPIRED6 obtaining maximum %1 of expired IPv6 leases
+% DHCPSRV_CQL_GET_EXPIRED6 obtaining maximum %1 of expired IPv6 leases
A debug message issued when the server is attempting to obtain expired
IPv6 leases to reclaim them. The maximum number of leases to be retrieved
is logged in the message.
-% DHCPSRV_DSCSQL_GET_HWADDR obtaining IPv4 leases for hardware address %1
+% DHCPSRV_CQL_GET_HWADDR obtaining IPv4 leases for hardware address %1
A debug message issued when the server is attempting to obtain a set of
-IPv4 leases from the DataStax Cassandra database for a client with the specified
+IPv4 leases from the Cassandra database for a client with the specified
hardware address.
-% DHCPSRV_DSCSQL_GET_IAID_DUID obtaining IPv6 leases for IAID %1 and DUID %2 and lease type %3
+% DHCPSRV_CQL_GET_IAID_DUID obtaining IPv6 leases for IAID %1 and DUID %2 and lease type %3
A debug message issued when the server is attempting to obtain a set of
-IPv6 lease from the DataStax Cassandra database for a client with the specified
+IPv6 lease from the Cassandra database for a client with the specified
IAID (Identity Association ID) and DUID (DHCP Unique Identifier).
-% DHCPSRV_DSCSQL_GET_IAID_SUBID_DUID obtaining IPv6 leases for IAID %1, Subnet ID %2, DUID %3 and lease type %4
+% DHCPSRV_CQL_GET_IAID_SUBID_DUID obtaining IPv6 leases for IAID %1, Subnet ID %2, DUID %3 and lease type %4
A debug message issued when the server is attempting to obtain an IPv6
-lease from the DataStax Cassandra database for a client with the specified IAID
+lease from the Cassandra database for a client with the specified IAID
(Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
-% DHCPSRV_DSCSQL_GET_SUBID_CLIENTID obtaining IPv4 lease for subnet ID %1 and client ID %2
+% DHCPSRV_CQL_GET_SUBID_CLIENTID obtaining IPv4 lease for subnet ID %1 and client ID %2
A debug message issued when the server is attempting to obtain an IPv4
-lease from the DataStax Cassandra database for a client with the specified
+lease from the Cassandra database for a client with the specified
subnet ID and client ID.
-% DHCPSRV_DSCSQL_GET_SUBID_HWADDR obtaining IPv4 lease for subnet ID %1 and hardware address %2
+% DHCPSRV_CQL_GET_SUBID_HWADDR obtaining IPv4 lease for subnet ID %1 and hardware address %2
A debug message issued when the server is attempting to obtain an IPv4
-lease from the DataStax Cassandra database for a client with the specified
+lease from the Cassandra database for a client with the specified
subnet ID and hardware address.
-% DHCPSRV_DSCSQL_GET_VERSION obtaining schema version information
+% DHCPSRV_CQL_GET_VERSION obtaining schema version information
A debug message issued when the server is about to obtain schema version
-information from the DataStax Cassandra database.
+information from the Cassandra database.
-% DHCPSRV_DSCSQL_ROLLBACK rolling back DataStax Cassandra database
+% DHCPSRV_CQL_ROLLBACK rolling back Cassandra database
The code has issued a rollback call.
-% DHCPSRV_DSCSQL_UPDATE_ADDR4 updating IPv4 lease for address %1
+% DHCPSRV_CQL_UPDATE_ADDR4 updating IPv4 lease for address %1
A debug message issued when the server is attempting to update IPv4
-lease from the DataStax Cassandra database for the specified address.
+lease from the Cassandra database for the specified address.
-% DHCPSRV_DSCSQL_UPDATE_ADDR6 updating IPv6 lease for address %1
+% DHCPSRV_CQL_UPDATE_ADDR6 updating IPv6 lease for address %1
A debug message issued when the server is attempting to update IPv6
-lease from the DataStax Cassandra database for the specified address.
+lease from the Cassandra database for the specified address.
}
#endif
-#ifdef HAVE_DSCSQL
- if (db_type == "dscsql") {
- isc_throw(NotImplemented, "Sorry, DSCSQL backend for host reservations "
+#ifdef HAVE_CQL
+ if (db_type == "cql") {
+ isc_throw(NotImplemented, "Sorry, CQL backend for host reservations "
"is not implemented yet.");
}
#endif
#ifdef HAVE_PGSQL
#include <dhcpsrv/pgsql_lease_mgr.h>
#endif
-#ifdef HAVE_DSCSQL
-#include <dhcpsrv/dscsql_lease_mgr.h>
+#ifdef HAVE_CQL
+#include <dhcpsrv/cql_lease_mgr.h>
#endif
#include <boost/algorithm/string.hpp>
return;
}
#endif
-#ifdef HAVE_DSCSQL
- if (parameters[type] == string("dscsql")) {
- LOG_INFO(dhcpsrv_logger, DHCPSRV_DSCSQL_DB).arg(redacted);
- getLeaseMgrPtr().reset(new DSCSqlLeaseMgr(parameters));
+#ifdef HAVE_CQL
+ if (parameters[type] == string("cql")) {
+ LOG_INFO(dhcpsrv_logger, DHCPSRV_CQL_DB).arg(redacted);
+ getLeaseMgrPtr().reset(new CQLLeaseMgr(parameters));
return;
}
#endif
// b. Check if the 'type' keyword known and throw an exception if not.
string dbtype = type_ptr->second;
- if ((dbtype != "memfile") && (dbtype != "mysql") && (dbtype != "postgresql") && (dbtype != "dscsql")) {
+ if ((dbtype != "memfile") && (dbtype != "mysql") && (dbtype != "postgresql") && (dbtype != "cql")) {
isc_throw(BadValue, "unknown backend database type: " << dbtype
<< " (" << config_value->getPosition() << ")");
}
libdhcpsrv_unittests_SOURCES += pgsql_exchange_unittest.cc
libdhcpsrv_unittests_SOURCES += pgsql_lease_mgr_unittest.cc
endif
-if HAVE_DSCSQL
-libdhcpsrv_unittests_SOURCES += dscsql_lease_mgr_unittest.cc
+if HAVE_CQL
+libdhcpsrv_unittests_SOURCES += cql_lease_mgr_unittest.cc
endif
libdhcpsrv_unittests_SOURCES += pool_unittest.cc
libdhcpsrv_unittests_SOURCES += srv_config_unittest.cc
if HAVE_PGSQL
libdhcpsrv_unittests_CPPFLAGS += $(PGSQL_CPPFLAGS)
endif
-if HAVE_DSCSQL
-libdhcpsrv_unittests_CPPFLAGS += $(DSCSQL_CPPFLAGS)
+if HAVE_CQL
+libdhcpsrv_unittests_CPPFLAGS += $(CQL_CPPFLAGS)
endif
libdhcpsrv_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
if HAVE_PGSQL
libdhcpsrv_unittests_LDFLAGS += $(PGSQL_LIBS)
endif
-if HAVE_DSCSQL
-libdhcpsrv_unittests_LDFLAGS += $(DSCSQL_LIBS)
+if HAVE_CQL
+libdhcpsrv_unittests_LDFLAGS += $(CQL_LIBS)
endif
libdhcpsrv_unittests_CXXFLAGS = $(AM_CXXFLAGS)
#include <asiolink/io_address.h>
#include <dhcpsrv/lease_mgr_factory.h>
-#include <dhcpsrv/dscsql_connection.h>
-#include <dhcpsrv/dscsql_lease_mgr.h>
+#include <dhcpsrv/cql_connection.h>
+#include <dhcpsrv/cql_lease_mgr.h>
#include <dhcpsrv/tests/test_utils.h>
#include <dhcpsrv/tests/generic_lease_mgr_unittest.h>
-#include <dhcpsrv/testutils/dscsql_schema.h>
+#include <dhcpsrv/testutils/cql_schema.h>
#include <exceptions/exceptions.h>
#include <gtest/gtest.h>
namespace {
-/// @brief Test fixture class for testing DataStax Cassandra Lease Manager
+/// @brief Test fixture class for testing Cassandra Lease Manager
///
/// Opens the database prior to each test and closes it afterwards.
/// All pending transactions are deleted prior to closure.
-class DSCSqlLeaseMgrTest : public GenericLeaseMgrTest {
+class CqlLeaseMgrTest : public GenericLeaseMgrTest {
public:
/// @brief Constructor
///
/// Deletes everything from the database and opens it.
- DSCSqlLeaseMgrTest() {
+ CqlLeaseMgrTest() {
// Ensure schema is the correct one.
- destroyDSCSQLSchema();
- createDSCSQLSchema();
+ destroyCqlSchema();
+ createCqlSchema();
// Connect to the database
try {
- LeaseMgrFactory::create(validDSCSQLConnectionString());
+ LeaseMgrFactory::create(validCqlConnectionString());
} catch (...) {
std::cerr << "*** ERROR: unable to open database. The test\n"
"*** environment is broken and must be fixed before\n"
- "*** the DSC SQL tests will run correctly.\n"
+ "*** the CQL tests will run correctly.\n"
"*** The reason for the problem is described in the\n"
"*** accompanying exception output.\n";
throw;
///
/// Rolls back all pending transactions. The deletion of lmptr_ will close
/// the database. Then reopen it and delete everything created by the test.
- virtual ~DSCSqlLeaseMgrTest() {
+ virtual ~CqlLeaseMgrTest() {
lmptr_->rollback();
LeaseMgrFactory::destroy();
- destroyDSCSQLSchema();
+ destroyCqlSchema();
}
/// @brief Reopen the database
/// Closes the database and re-open it. Anything committed should be
/// visible.
///
- /// Parameter is ignored for DSC SQL backend as the v4 and v6 leases share
+ /// Parameter is ignored for CQL backend as the v4 and v6 leases share
/// the same database.
void reopen(Universe) {
LeaseMgrFactory::destroy();
- LeaseMgrFactory::create(validConnectionString());
+ LeaseMgrFactory::create(validCqlConnectionString());
lmptr_ = &(LeaseMgrFactory::instance());
}
/// @brief Check that database can be opened
///
-/// This test checks if the DSCSqlLeaseMgr can be instantiated. This happens
+/// This test checks if the CqlLeaseMgr can be instantiated. This happens
/// only if the database can be opened. Note that this is not part of the
-/// DSCSqlLeaseMgr test fixure set. This test checks that the database can be
+/// CqlLeaseMgr test fixure set. This test checks that the database can be
/// opened: the fixtures assume that and check basic operations.
-TEST(DSCSqlOpenTest, OpenDatabase) {
+TEST(CQLOpenTest, OpenDatabase) {
// Schema needs to be created for the test to work.
- destroyDSCSQLSchema();
- createDSCSQLSchema();
+ destroyCqlSchema();
+ createCqlSchema();
// Check that lease manager open the database opens correctly and tidy up.
// If it fails, print the error message.
try {
- LeaseMgrFactory::create(validDSCSQLConnectionString());
+ LeaseMgrFactory::create(validCqlConnectionString());
EXPECT_NO_THROW((void) LeaseMgrFactory::instance());
LeaseMgrFactory::destroy();
} catch (const isc::Exception& ex) {
FAIL() << "*** ERROR: unable to open database, reason:\n"
<< " " << ex.what() << "\n"
<< "*** The test environment is broken and must be fixed\n"
- << "*** before the DSC SQL tests will run correctly.\n";
+ << "*** before the CQL tests will run correctly.\n";
}
// Check that attempting to get an instance of the lease manager when
// Check that invalid login data causes an exception.
EXPECT_THROW(LeaseMgrFactory::create(connectionString(
- DSCSQL_VALID_TYPE, INVALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD)),
+ CQL_VALID_TYPE, INVALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD)),
DbOpenError);
EXPECT_THROW(LeaseMgrFactory::create(connectionString(
- DSCSQL_VALID_TYPE, VALID_NAME, INVALID_HOST, VALID_USER, VALID_PASSWORD)),
+ CQL_VALID_TYPE, VALID_NAME, INVALID_HOST, VALID_USER, VALID_PASSWORD)),
DbOpenError);
EXPECT_THROW(LeaseMgrFactory::create(connectionString(
- DSCSQL_VALID_TYPE, VALID_NAME, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
+ CQL_VALID_TYPE, VALID_NAME, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
DbOpenError);
EXPECT_THROW(LeaseMgrFactory::create(connectionString(
- DSCSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, INVALID_PASSWORD)),
+ CQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, INVALID_PASSWORD)),
DbOpenError);
// Check for missing parameters
EXPECT_THROW(LeaseMgrFactory::create(connectionString(
- DSCSQL_VALID_TYPE, NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
+ CQL_VALID_TYPE, NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
NoDatabaseName);
// Tidy up after the test
- destroyDSCSQLSchema();
+ destroyCqlSchema();
}
/// @brief Check the getType() method
///
/// getType() returns a string giving the type of the backend, which should
/// always be "cassandra".
-TEST_F(DSCSqlLeaseMgrTest, getType) {
+TEST_F(CqlLeaseMgrTest, getType) {
EXPECT_EQ(std::string("cassandra"), lmptr_->getType());
}
/// expire_time = cltt + valid_lifetime
///
/// This test checks that the conversion is correct.
-TEST_F(DSCSqlLeaseMgrTest, checkTimeConversion) {
+TEST_F(CqlLeaseMgrTest, checkTimeConversion) {
const time_t cltt = time(NULL);
time_t converted_cltt = 0;
/// @brief Check getName() returns correct database name
-TEST_F(DSCSqlLeaseMgrTest, getName) {
+TEST_F(CqlLeaseMgrTest, getName) {
EXPECT_EQ(std::string("keatest"), lmptr_->getName());
}
/// @brief Check that getVersion() returns the expected version
-TEST_F(DSCSqlLeaseMgrTest, checkVersion) {
+TEST_F(CqlLeaseMgrTest, checkVersion) {
// Check version
pair<uint32_t, uint32_t> version;
ASSERT_NO_THROW(version = lmptr_->getVersion());
- EXPECT_EQ(CURRENT_VERSION_VERSION, version.first);
- EXPECT_EQ(CURRENT_VERSION_MINOR, version.second);
+ EXPECT_EQ(CQL_CURRENT_VERSION, version.first);
+ EXPECT_EQ(CQL_CURRENT_MINOR, version.second);
}
////////////////////////////////////////////////////////////////////////////////
///
/// Checks that the addLease, getLease4 (by address) and deleteLease (with an
/// IPv4 address) works.
-TEST_F(DSCSqlLeaseMgrTest, basicLease4) {
+TEST_F(CqlLeaseMgrTest, basicLease4) {
testBasicLease4();
}
/// @brief Check that Lease4 code safely handles invalid dates.
-TEST_F(DSCSqlLeaseMgrTest, maxDate4) {
+TEST_F(CqlLeaseMgrTest, maxDate4) {
testMaxDate4();
}
/// @brief Lease4 update tests
///
/// Checks that we are able to update a lease in the database.
-TEST_F(DSCSqlLeaseMgrTest, updateLease4) {
+TEST_F(CqlLeaseMgrTest, updateLease4) {
testUpdateLease4();
}
/// @brief Check GetLease4 methods - access by Hardware Address
-TEST_F(DSCSqlLeaseMgrTest, getLease4HWAddr1) {
+TEST_F(CqlLeaseMgrTest, getLease4HWAddr1) {
testGetLease4HWAddr1();
}
/// @brief Check GetLease4 methods - access by Hardware Address
-TEST_F(DSCSqlLeaseMgrTest, getLease4HWAddr2) {
+TEST_F(CqlLeaseMgrTest, getLease4HWAddr2) {
testGetLease4HWAddr2();
}
//
// Check that the system can cope with getting a hardware address of
// any size.
-TEST_F(DSCSqlLeaseMgrTest, getLease4HWAddrSize) {
+TEST_F(CqlLeaseMgrTest, getLease4HWAddrSize) {
testGetLease4HWAddrSize();
}
///
/// Adds leases to the database and checks that they can be accessed via
/// a combination of hardware address and subnet ID
-TEST_F(DSCSqlLeaseMgrTest, getLease4HwaddrSubnetId) {
+TEST_F(CqlLeaseMgrTest, getLease4HwaddrSubnetId) {
testGetLease4HWAddrSubnetId();
}
//
// Check that the system can cope with getting a hardware address of
// any size.
-TEST_F(DSCSqlLeaseMgrTest, getLease4HWAddrSubnetIdSize) {
+TEST_F(CqlLeaseMgrTest, getLease4HWAddrSubnetIdSize) {
testGetLease4HWAddrSubnetIdSize();
}
// This test was derived from memfile.
-TEST_F(DSCSqlLeaseMgrTest, getLease4ClientId) {
+TEST_F(CqlLeaseMgrTest, getLease4ClientId) {
testGetLease4ClientId();
}
///
/// Adds leases to the database and checks that they can be accessed via
/// the Client ID.
-TEST_F(DSCSqlLeaseMgrTest, getLease4ClientId2) {
+TEST_F(CqlLeaseMgrTest, getLease4ClientId2) {
testGetLease4ClientId2();
}
// @brief Get Lease4 by client ID (2)
//
// Check that the system can cope with a client ID of any size.
-TEST_F(DSCSqlLeaseMgrTest, getLease4ClientIdSize) {
+TEST_F(CqlLeaseMgrTest, getLease4ClientIdSize) {
testGetLease4ClientIdSize();
}
///
/// Adds leases to the database and checks that they can be accessed via
/// a combination of client and subnet IDs.
-TEST_F(DSCSqlLeaseMgrTest, getLease4ClientIdSubnetId) {
+TEST_F(CqlLeaseMgrTest, getLease4ClientIdSubnetId) {
testGetLease4ClientIdSubnetId();
}
/// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id),
/// updateLease4() and deleteLease (IPv4 address) can handle NULL client-id.
/// (client-id is optional and may not be present)
-TEST_F(DSCSqlLeaseMgrTest, lease4NullClientId) {
+TEST_F(CqlLeaseMgrTest, lease4NullClientId) {
testLease4NullClientId();
}
///
/// Checks that the it is not possible to create a lease when the hostname
/// length exceeds 255 characters.
-TEST_F(DSCSqlLeaseMgrTest, lease4InvalidHostname) {
+TEST_F(CqlLeaseMgrTest, lease4InvalidHostname) {
testLease4InvalidHostname();
}
// Test checks whether simple add, get and delete operations are possible
// on Lease6
-TEST_F(DSCSqlLeaseMgrTest, testAddGetDelete6) {
+TEST_F(CqlLeaseMgrTest, testAddGetDelete6) {
testAddGetDelete6(false);
}
///
/// Checks that the addLease, getLease6 (by address) and deleteLease (with an
/// IPv6 address) works.
-TEST_F(DSCSqlLeaseMgrTest, basicLease6) {
+TEST_F(CqlLeaseMgrTest, basicLease6) {
testBasicLease6();
}
/// @brief Check that Lease6 code safely handles invalid dates.
-TEST_F(DSCSqlLeaseMgrTest, maxDate6) {
+TEST_F(CqlLeaseMgrTest, maxDate6) {
testMaxDate6();
}
///
/// Checks that the it is not possible to create a lease when the hostname
/// length exceeds 255 characters.
-TEST_F(DSCSqlLeaseMgrTest, lease6InvalidHostname) {
+TEST_F(CqlLeaseMgrTest, lease6InvalidHostname) {
testLease6InvalidHostname();
}
///
/// Adds leases to the database and checks that they can be accessed via
/// a combination of DUID and IAID.
-TEST_F(DSCSqlLeaseMgrTest, getLeases6DuidIaid) {
+TEST_F(CqlLeaseMgrTest, getLeases6DuidIaid) {
testGetLeases6DuidIaid();
}
// Check that the system can cope with a DUID of allowed size.
-TEST_F(DSCSqlLeaseMgrTest, getLeases6DuidSize) {
+TEST_F(CqlLeaseMgrTest, getLeases6DuidSize) {
testGetLeases6DuidSize();
}
/// with alternating subnet_ids.
/// It then verifies that all of getLeases6() method variants correctly
/// discriminate between the leases based on lease type alone.
-TEST_F(DSCSqlLeaseMgrTest, lease6LeaseTypeCheck) {
+TEST_F(CqlLeaseMgrTest, lease6LeaseTypeCheck) {
testLease6LeaseTypeCheck();
}
///
/// Adds leases to the database and checks that they can be accessed via
/// a combination of DIUID and IAID.
-TEST_F(DSCSqlLeaseMgrTest, getLease6DuidIaidSubnetId) {
+TEST_F(CqlLeaseMgrTest, getLease6DuidIaidSubnetId) {
testGetLease6DuidIaidSubnetId();
}
// Test checks that getLease6() works with different DUID sizes
-TEST_F(DSCSqlLeaseMgrTest, getLease6DuidIaidSubnetIdSize) {
+TEST_F(CqlLeaseMgrTest, getLease6DuidIaidSubnetIdSize) {
testGetLease6DuidIaidSubnetIdSize();
}
/// @brief Lease6 update tests
///
/// Checks that we are able to update a lease in the database.
-TEST_F(DSCSqlLeaseMgrTest, updateLease6) {
+TEST_F(CqlLeaseMgrTest, updateLease6) {
testUpdateLease6();
}
/// Checks that the lease can be created, deleted and recreated with
/// different parameters. It also checks that the re-created lease is
/// correctly stored in the lease database.
-TEST_F(DSCSqlLeaseMgrTest, testRecreateLease4) {
+TEST_F(CqlLeaseMgrTest, testRecreateLease4) {
testRecreateLease4();
}
/// Checks that the lease can be created, deleted and recreated with
/// different parameters. It also checks that the re-created lease is
/// correctly stored in the lease database.
-TEST_F(DSCSqlLeaseMgrTest, testRecreateLease6) {
+TEST_F(CqlLeaseMgrTest, testRecreateLease6) {
testRecreateLease6();
}
/// @brief Checks that null DUID is not allowed.
-TEST_F(DSCSqlLeaseMgrTest, nullDuid) {
+TEST_F(CqlLeaseMgrTest, nullDuid) {
testNullDuid();
}
/// @brief Tests whether memfile can store and retrieve hardware addresses
-TEST_F(DSCSqlLeaseMgrTest, testLease6Mac) {
+TEST_F(CqlLeaseMgrTest, testLease6Mac) {
testLease6MAC();
}
/// @brief Tests whether memfile can store and retrieve hardware addresses
-TEST_F(DSCSqlLeaseMgrTest, testLease6HWTypeAndSource) {
+TEST_F(CqlLeaseMgrTest, testLease6HWTypeAndSource) {
testLease6HWTypeAndSource();
}
/// whether only expired leases are returned, and that they are returned in
/// the order from most to least expired. It also checks that the lease
/// which is marked as 'reclaimed' is not returned.
-TEST_F(DSCSqlLeaseMgrTest, getExpiredLeases4) {
+TEST_F(CqlLeaseMgrTest, getExpiredLeases4) {
testGetExpiredLeases4();
}
/// whether only expired leases are returned, and that they are returned in
/// the order from most to least expired. It also checks that the lease
/// which is marked as 'reclaimed' is not returned.
-TEST_F(DSCSqlLeaseMgrTest, getExpiredLeases6) {
+TEST_F(CqlLeaseMgrTest, getExpiredLeases6) {
testGetExpiredLeases6();
}
/// @brief Check that expired reclaimed DHCPv6 leases are removed.
-TEST_F(DSCSqlLeaseMgrTest, deleteExpiredReclaimedLeases6) {
+TEST_F(CqlLeaseMgrTest, deleteExpiredReclaimedLeases6) {
testDeleteExpiredReclaimedLeases6();
}
/// @brief Check that expired reclaimed DHCPv4 leases are removed.
-TEST_F(DSCSqlLeaseMgrTest, deleteExpiredReclaimedLeases4) {
+TEST_F(CqlLeaseMgrTest, deleteExpiredReclaimedLeases4) {
testDeleteExpiredReclaimedLeases4();
}
#include <config.h>
#include <string>
#include <cassandra.h>
-#include <dhcpsrv/dscsql_connection.h>
-#include <dhcpsrv/testutils/dscsql_schema.h>
+#include <dhcpsrv/cql_connection.h>
+#include <dhcpsrv/testutils/cql_schema.h>
#include <gtest/gtest.h>
#include <fstream>
namespace dhcp {
namespace test {
-const char* DSCSQL_VALID_TYPE = "type=cassandra";
+const char* CQL_VALID_TYPE = "type=cassandra";
string
-validDSCSQLConnectionString() {
- return (connectionString(DSCSQL_VALID_TYPE, VALID_NAME, VALID_HOST,
+validCqlConnectionString() {
+ return (connectionString(CQL_VALID_TYPE, VALID_NAME, VALID_HOST,
VALID_USER, VALID_PASSWORD));
}
-void destroyDSCSQLSchema(bool show_err) {
- runDSCSQLScript(DATABASE_SCRIPTS_DIR, "dscsql/dhcpdb_drop.cql", show_err);
+void destroyCqlSchema(bool show_err) {
+ runCqlScript(DATABASE_SCRIPTS_DIR, "cql/dhcpdb_drop.cql", show_err);
}
-void createDSCSQLSchema(bool show_err) {
- runDSCSQLScript(DATABASE_SCRIPTS_DIR, "dscsql/dhcpdb_create.cql",
+void createCqlSchema(bool show_err) {
+ runCqlScript(DATABASE_SCRIPTS_DIR, "cql/dhcpdb_create.cql",
show_err);
}
-void runDSCSQLScript(const std::string& path, const std::string& script_name,
+void runCqlScript(const std::string& path, const std::string& script_name,
bool show_err) {
std::ostringstream cmd;
cmd << "cqlsh -u keatest -p keatest -k keatest -f";
cmd << script_name;
int retval = ::system(cmd.str().c_str());
- ASSERT_EQ(0, retval) << "runDSCSQLSchema failed:" << cmd.str();
+ ASSERT_EQ(0, retval) << "runCqlSchema failed:" << cmd.str();
}
// 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/.
-#ifndef TEST_DSCSQL_SCHEMA_H
-#define TEST_DSCSQL_SCHEMA_H
+#ifndef TEST_CQL_SCHEMA_H
+#define TEST_CQL_SCHEMA_H
#include <config.h>
#include <dhcpsrv/testutils/schema.h>
namespace dhcp {
namespace test {
-extern const char* DSCSQL_VALID_TYPE;
+extern const char* CQL_VALID_TYPE;
/// Return valid connection string
///
-/// @return valid DSCSQL connection string.
-std::string validDSCSQLConnectionString();
+/// @return valid CQL connection string.
+std::string validCqlConnectionString();
/// @brief Clear everything from the database
///
/// Submits the current schema drop script:
///
-/// <TEST_ADMIN_SCRIPTS_DIR>/dscsql/dhcpdb_drop.cql
+/// <TEST_ADMIN_SCRIPTS_DIR>/cql/dhcpdb_drop.cql
///
-/// to the unit test DSCSQL database. If the script fails, the invoking test
+/// to the unit test CQL database. If the script fails, the invoking test
/// will fail. The output of stderr is suppressed unless the parameter,
/// show_err is true.
///
/// @param show_err flag which governs whether or not stderr is suppressed.
-void destroyDSCSQLSchema(bool show_err = false);
+void destroyCqlSchema(bool show_err = false);
-/// @brief Create the DSCSQL Schema
+/// @brief Create the CQL Schema
///
/// Submits the current schema creation script:
///
-/// <TEST_ADMIN_SCRIPTS_DIR>/dscsql/dhcpdb_create.cql
+/// <TEST_ADMIN_SCRIPTS_DIR>/cql/dhcpdb_create.cql
///
-/// to the unit test DSCSQL database. If the script fails, the invoking test
+/// to the unit test CQL database. If the script fails, the invoking test
/// will fail. The output of stderr is suppressed unless the parameter,
/// show_err is true.
///
/// @param show_err flag which governs whether or not stderr is suppressed.
-void createDSCSQLSchema(bool show_err = false);
+void createCqlSchema(bool show_err = false);
-/// @brief Run a DSCSQL SQL script against the DSCSQL unit test database
+/// @brief Run a CQL SQL script against the CQL unit test database
///
-/// Submits the given SQL script to DSCSQL via cqlsh CLI. The output of
+/// Submits the given SQL script to CQL via cqlsh CLI. The output of
/// stderr is suppressed unless the parameter, show_err is true. The is done
/// to suppress warnings that might otherwise make test output needlessly
/// noisy. A gtest assertion occurs if the script fails to execute.
/// @param path - path (if not blank) of the script to execute
/// @param script_name - file name of the path to execute
/// @param show_err flag which governs whether or not stderr is suppressed.
-void runDSCSQLScript(const std::string& path, const std::string& script_name,
+void runCqlScript(const std::string& path, const std::string& script_name,
bool show_err);
};
-SUBDIRS = mysql pgsql dscsql
+SUBDIRS = mysql pgsql cql
SUBDIRS = .
-sqlscriptsdir = ${datarootdir}/${PACKAGE_NAME}/scripts/dscsql
+sqlscriptsdir = ${datarootdir}/${PACKAGE_NAME}/scripts/cql
sqlscripts_DATA = dhcpdb_create.cql
sqlscripts_DATA += dhcpdb_drop.cql
-- See the License for the specific language governing permissions and
-- limitations under the License.
--- This is the Kea schema specification for DataStax Cassandra SQL.
+-- This is the Kea schema specification for Cassandra CQL.
-- 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.
-- To create the schema, either type the command:
-- 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:
-- SOURCE dhcpdb_create.cql
--- This script is also called from kea-admin, see kea-admin init dscsql
+-- This script is also called from kea-admin, see kea-admin init cql
-- Over time, Kea database schema will evolve. Each version is marked with
-- major.minor version. This file is organized sequentially, i.e. database