mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 14:05:33 +00:00
renamed classes and files, fixed issues, added comments
# Conflicts: # ChangeLog # src/lib/dhcpsrv/cfg_hosts.cc
This commit is contained in:
@@ -1012,11 +1012,9 @@ if test "$CQL_CONFIG" != "" ; then
|
|||||||
AC_MSG_ERROR([--with-cql should point to a cql_config program])
|
AC_MSG_ERROR([--with-cql should point to a cql_config program])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CQL_CPPFLAGS=`$CQL_CONFIG --cppflags`
|
|
||||||
CQL_INCLUDEDIR=`$CQL_CONFIG --includedir`
|
CQL_INCLUDEDIR=`$CQL_CONFIG --includedir`
|
||||||
CQL_CPPFLAGS="$CQL_CPPFLAGS -I$CQL_INCLUDEDIR"
|
CQL_CPPFLAGS="`$CQL_CONFIG --cppflags` -I$CQL_INCLUDEDIR"
|
||||||
CQL_LIBS=`$CQL_CONFIG --libdir`
|
CQL_LIBS="-L`$CQL_CONFIG --libdir` -lcassandra_static -luv"
|
||||||
CQL_LIBS="-L$CQL_LIBS -lcassandra_static -luv"
|
|
||||||
CQL_VERSION=`$CQL_CONFIG --version`
|
CQL_VERSION=`$CQL_CONFIG --version`
|
||||||
|
|
||||||
AC_SUBST(CQL_CPPFLAGS)
|
AC_SUBST(CQL_CPPFLAGS)
|
||||||
|
21
src/bin/admin/admin-utils.sh
Normal file → Executable file
21
src/bin/admin/admin-utils.sh
Normal file → Executable file
@@ -48,11 +48,11 @@ pgsql_execute() {
|
|||||||
QUERY=$1
|
QUERY=$1
|
||||||
shift
|
shift
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
echo $QUERY | psql --set ON_ERROR_STOP=1 -A -t -q $*
|
echo $QUERY | psql --set ON_ERROR_STOP=1 -A -t -h localhost -q $*
|
||||||
retcode=$?
|
retcode=$?
|
||||||
else
|
else
|
||||||
export PGPASSWORD=$db_password
|
export PGPASSWORD=$db_password
|
||||||
echo $QUERY | psql --set ON_ERROR_STOP=1 -A -t -q -U $db_user -d $db_name
|
echo $QUERY | psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -U $db_user -d $db_name
|
||||||
retcode=$?
|
retcode=$?
|
||||||
fi
|
fi
|
||||||
return $retcode
|
return $retcode
|
||||||
@@ -72,11 +72,11 @@ pgsql_execute_script() {
|
|||||||
file=$1
|
file=$1
|
||||||
shift
|
shift
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
psql --set ON_ERROR_STOP=1 -A -t -q -f $file $*
|
psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -f $file $*
|
||||||
retcode=$?
|
retcode=$?
|
||||||
else
|
else
|
||||||
export PGPASSWORD=$db_password
|
export PGPASSWORD=$db_password
|
||||||
psql --set ON_ERROR_STOP=1 -A -t -q -U $db_user -d $db_name -f $file
|
psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -U $db_user -d $db_name -h localhost -f $file
|
||||||
retcode=$?
|
retcode=$?
|
||||||
fi
|
fi
|
||||||
return $retcode
|
return $retcode
|
||||||
@@ -88,14 +88,19 @@ pgsql_version() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cql_execute() {
|
cql_execute() {
|
||||||
QUERY=$1
|
query=$1
|
||||||
shift
|
shift
|
||||||
if [ $# -gt 1 ]; then
|
if [ $# -gt 1 ]; then
|
||||||
cqlsh $* -e "${QUERY}"
|
cqlsh $* -e "$query"
|
||||||
retcode=$?
|
retcode=$?
|
||||||
else
|
else
|
||||||
cqlsh -u $db_user -p $db_password -e "${QUERY}" -k $db_name
|
cqlsh -u $db_user -p $db_password -k $db_name -e "$query"
|
||||||
retcode="$?"
|
retcode=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $retcode -ne 0 ]; then
|
||||||
|
printf "cqlsh returned with exit status $retcode\n"
|
||||||
|
exit $retcode
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return $retcode
|
return $retcode
|
||||||
|
@@ -201,44 +201,31 @@ pgsql_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cql_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
|
result=`cql_execute "DESCRIBE KEYSPACES;"`
|
||||||
# is some database in place. If there is anything, we abort. Note that
|
if [ "$result" != "" ]; then
|
||||||
# cql may spit out connection or access errors to stderr, we ignore those.
|
result=`echo "$result" | sed -n "/$db_name/ p"`
|
||||||
# We should not hide them as they may give hints to user what is wrong with
|
if [ "$result" = "" ]; then
|
||||||
# his setup.
|
printf "Creating keyspace $db_name...\n"
|
||||||
#
|
cql_execute "CREATE KEYSPACE $db_name WITH replication = {'class' : 'SimpleStrategy','replication_factor' : 1};"
|
||||||
RESULT=`echo "DESCRIBE keyspaces;" | cqlsh`
|
else
|
||||||
ERRCODE=$?
|
printf "Keyspace $db_name already exists.\n"
|
||||||
if [ $ERRCODE -ne 0 ]
|
fi
|
||||||
then
|
|
||||||
log_error "cql_init table query failed, cqlsh status = $ERRCODE"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COUNT=`echo $RESULT | tr " " "\n" | grep $db_name | wc -w`
|
result=`cql_execute "USE $db_name; DESCRIBE tables;"`
|
||||||
if [ $COUNT -gt 0 ]; then
|
if [ "$result"="<empty>" ]; then
|
||||||
# Let't start with a new line. cqlsh could have printed something out.
|
printf "Creating and initializing tables using script %s...\n" $scripts_dir/cql/dhcpdb_create.cql
|
||||||
printf "\n"
|
cql_execute_script $scripts_dir/cql/dhcpdb_create.cql
|
||||||
log_error "Expected no database $db_name, but there are $COUNT databases: \n$RESULT. Aborting."
|
else
|
||||||
exit 1
|
printf "Tables are already created.\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "Initializing database using script %s\n" $scripts_dir/cql/dhcpdb_create.cql
|
version=`cql_version`
|
||||||
cqlsh -u $db_user -p $db_password -e "CREATE KEYSPACE $db_name WITH replication = {'class' : 'SimpleStrategy','replication_factor' : 1};"
|
printf "Lease DB version reported after initialization: $version\n"
|
||||||
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"
|
return 0
|
||||||
|
|
||||||
if [ "$ERRCODE" -eq 0 ]; then
|
|
||||||
printf "Lease DB version reported after initialization: "
|
|
||||||
cql_version
|
|
||||||
printf "\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit $ERRCODE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
### Functions that implement database version checking commands
|
### Functions that implement database version checking commands
|
||||||
@@ -333,22 +320,27 @@ cql_upgrade() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if there are any files in it
|
# Check if directory is readable.
|
||||||
num_files=$(find ${scripts_dir}/cql/upgrade*.sh -type f | wc -l)
|
if [ ! -r ${scripts_dir}/cql ]; then
|
||||||
if [ $num_files -eq 0 ]; then
|
log_error "Directory is not readable: ${scripts_dir}/cql"
|
||||||
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}/cql/upgrade*.sh
|
# Check if there are upgrade scripts.
|
||||||
do
|
files=$(find ${scripts_dir}/cql/upgrade*.sh -type f)
|
||||||
echo "Processing $script file..."
|
if [ $? -eq 0 ]; then # Upgrade scripts are present.
|
||||||
sh ${script} -u ${db_user} -p ${db_password} -k ${db_name}
|
for script in ${scripts_dir}/cql/upgrade*.sh
|
||||||
done
|
do
|
||||||
|
echo "Processing $script file..."
|
||||||
|
sh ${script} -u ${db_user} -p ${db_password} -k ${db_name}
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "No upgrade script available."
|
||||||
|
fi
|
||||||
|
|
||||||
version=`cql_version`
|
version=`cql_version`
|
||||||
printf "Lease DB version reported after upgrade: $version\n"
|
printf "Lease DB version reported after upgrade: $version\n"
|
||||||
exit 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Utility function which tests if the given file exists and
|
# Utility function which tests if the given file exists and
|
||||||
@@ -543,7 +535,7 @@ cql_dump() {
|
|||||||
# delete the tmp file on success
|
# delete the tmp file on success
|
||||||
rm $tmp_file
|
rm $tmp_file
|
||||||
echo lease$dump_type successfully dumped to $dump_file
|
echo lease$dump_type successfully dumped to $dump_file
|
||||||
exit 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
### Script starts here ###
|
### Script starts here ###
|
||||||
|
@@ -1,38 +0,0 @@
|
|||||||
#!/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,26 +9,106 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
# Include admin utilities
|
||||||
|
. @abs_top_srcdir@/src/bin/admin/admin-utils.sh
|
||||||
|
|
||||||
|
# Set path to the production schema scripts
|
||||||
|
db_scripts_dir=@abs_top_srcdir@/src/share/database/scripts
|
||||||
|
|
||||||
|
db_user="keatest"
|
||||||
|
db_password="keatest"
|
||||||
|
db_name="keatest"
|
||||||
|
|
||||||
|
# Set location of the kea-admin.
|
||||||
|
keaadmin=@abs_top_builddir@/src/bin/admin/kea-admin
|
||||||
|
|
||||||
cql_init_test() {
|
cql_init_test() {
|
||||||
test_start "cql.init"
|
test_start "cql.init"
|
||||||
|
|
||||||
# @todo: Implement this
|
# Wipe the database.
|
||||||
|
cql_execute_script $db_scripts_dir/cql/dhcpdb_drop.cql
|
||||||
|
assert_eq 0 $? "drop table query failed, exit code %d, expected %d"
|
||||||
|
|
||||||
|
# Create the database
|
||||||
|
$keaadmin lease-init cql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir
|
||||||
|
assert_eq 0 $? "kea-admin lease-init cql failed, expected exit code: %d, actual: %d"
|
||||||
|
|
||||||
|
# Verify that all the expected tables exist
|
||||||
|
|
||||||
|
# Check schema_version table
|
||||||
|
cql_execute "SELECT version, minor FROM schema_version;"
|
||||||
|
assert_eq 0 $? "schema_version table check failed, expected exit code: %d, actual: %d"
|
||||||
|
|
||||||
|
# Check lease4 table
|
||||||
|
cql_execute "SELECT address, hwaddr, client_id, valid_lifetime, expire, subnet_id, fqdn_fwd, fqdn_rev, hostname, state FROM lease4;"
|
||||||
|
assert_eq 0 $? "lease4 table check failed, expected exit code: %d, actual: %d"
|
||||||
|
|
||||||
|
# Check lease6 table
|
||||||
|
cql_execute "SELECT address, duid, valid_lifetime, expire, subnet_id, pref_lifetime, lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname,\
|
||||||
|
state FROM lease6;"
|
||||||
|
assert_eq 0 $? "lease6 table check failed, expected exit code: %d, actual: %d"
|
||||||
|
|
||||||
|
# Check lease6_types table
|
||||||
|
cql_execute "SELECT lease_type, name FROM lease6_types;"
|
||||||
|
assert_eq 0 $? "lease6_types table check failed, expected exit code: %d, actual: %d"
|
||||||
|
|
||||||
|
# Check lease_state table
|
||||||
|
cql_execute "SELECT state, name FROM lease_state;"
|
||||||
|
assert_eq 0 $? "lease_state table check failed, expected exit code: %d, actual: %d"
|
||||||
|
|
||||||
|
# Trying to create it again should fail. This verifies the db present
|
||||||
|
# check
|
||||||
|
echo ""
|
||||||
|
echo "Making sure keyspace creation fails the second time..."
|
||||||
|
$keaadmin lease-init cql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir
|
||||||
|
assert_eq 2 $? "kea-admin failed to deny lease-init, expected exit code: %d, actual: %d"
|
||||||
|
|
||||||
|
# Wipe the database.
|
||||||
|
cql_execute_script $db_scripts_dir/cql/dhcpdb_drop.cql
|
||||||
|
assert_eq 0 $? "drop table query failed, exit code %d, expected %d"
|
||||||
|
|
||||||
test_finish 0
|
test_finish 0
|
||||||
}
|
}
|
||||||
|
|
||||||
cql_version_test() {
|
cql_version_test() {
|
||||||
test_start "cql.version"
|
test_start "cql.version"
|
||||||
|
|
||||||
# @todo: Implement this
|
# Wipe the database.
|
||||||
|
cql_execute_script $db_scripts_dir/cql/dhcpdb_drop.cql
|
||||||
|
assert_eq 0 $? "drop table query failed, exit code %d, expected %d"
|
||||||
|
|
||||||
|
# Create the database
|
||||||
|
$keaadmin lease-init cql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir
|
||||||
|
assert_eq 0 $? "kea-admin lease-init cql failed, expected exit code: %d, actual: %d"
|
||||||
|
|
||||||
|
# Verfiy that kea-admin lease-version returns the correct version
|
||||||
|
version=$($keaadmin lease-version cql -u $db_user -p $db_password -n $db_name)
|
||||||
|
assert_str_eq "1.0" $version "Expected kea-admin to return %s, returned value was %s"
|
||||||
|
|
||||||
|
# Wipe the database.
|
||||||
|
cql_execute_script $db_scripts_dir/cql/dhcpdb_drop.cql
|
||||||
|
assert_eq 0 $? "drop table query failed, exit code %d, expected %d"
|
||||||
|
|
||||||
test_finish 0
|
test_finish 0
|
||||||
}
|
}
|
||||||
|
|
||||||
cql_upgrade_test() {
|
cql_upgrade_test() {
|
||||||
test_start "cql.upgrade"
|
test_start "cql.upgrade"
|
||||||
|
|
||||||
# @todo: Implement this
|
# Wipe the database.
|
||||||
|
cql_execute_script $db_scripts_dir/cql/dhcpdb_drop.cql
|
||||||
|
assert_eq 0 $? "drop table query failed, exit code %d, expected %d"
|
||||||
|
|
||||||
|
# Initialize database to schema 1.0.
|
||||||
|
cql_execute_script @abs_top_srcdir@/src/bin/admin/tests/dhcpdb_create_1.0.cql
|
||||||
|
assert_eq 0 $? "cannot initialize the database, expected exit code: %d, actual: %d"
|
||||||
|
|
||||||
|
$keaadmin lease-upgrade cql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir
|
||||||
|
assert_eq 0 $? "lease-upgrade failed, expected exit code: %d, actual: %d"
|
||||||
|
|
||||||
|
# Wipe the database.
|
||||||
|
cql_execute_script $db_scripts_dir/cql/dhcpdb_drop.cql
|
||||||
|
assert_eq 0 $? "drop table query failed, exit code %d, expected %d"
|
||||||
|
|
||||||
test_finish 0
|
test_finish 0
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
-- SOURCE dhcpdb_create.cql
|
-- SOURCE dhcpdb_create.cql
|
||||||
|
|
||||||
-- This script is also called from kea-admin, see kea-admin init cql
|
-- This script is also called from kea-admin, see kea-admin lease-init cql
|
||||||
|
|
||||||
-- Over time, Kea database schema will evolve. Each version is marked with
|
-- Over time, Kea database schema will evolve. Each version is marked with
|
||||||
-- major.minor version. This file is organized sequentially, i.e. database
|
-- major.minor version. This file is organized sequentially, i.e. database
|
||||||
@@ -103,11 +103,10 @@ CREATE TABLE lease6_types (
|
|||||||
name varchar, -- Name of the lease type
|
name varchar, -- Name of the lease type
|
||||||
PRIMARY KEY (lease_type)
|
PRIMARY KEY (lease_type)
|
||||||
);
|
);
|
||||||
--START TRANSACTION;
|
|
||||||
INSERT INTO lease6_types (lease_type, name) VALUES (0, 'IA_NA'); -- Non-temporary v6 addresses
|
INSERT INTO lease6_types (lease_type, name) VALUES (0, 'IA_NA'); -- Non-temporary v6 addresses
|
||||||
INSERT INTO lease6_types (lease_type, name) VALUES (1, 'IA_TA'); -- Temporary v6 addresses
|
INSERT INTO lease6_types (lease_type, name) VALUES (1, 'IA_TA'); -- Temporary v6 addresses
|
||||||
INSERT INTO lease6_types (lease_type, name) VALUES (2, 'IA_PD'); -- Prefix delegations
|
INSERT INTO lease6_types (lease_type, name) VALUES (2, 'IA_PD'); -- Prefix delegations
|
||||||
--COMMIT;
|
|
||||||
|
|
||||||
-- Kea keeps track of the hardware/MAC address source, i.e. how the address
|
-- Kea keeps track of the hardware/MAC address source, i.e. how the address
|
||||||
-- was obtained. Depending on the technique and your network topology, it may
|
-- was obtained. Depending on the technique and your network topology, it may
|
||||||
@@ -199,15 +198,9 @@ INSERT INTO lease_state (state, name) VALUES (2, 'expired-reclaimed');
|
|||||||
-- (related to the names of the columns in the BIND 10 DNS database file), the
|
-- (related to the names of the columns in the BIND 10 DNS database file), the
|
||||||
-- first column is called "version" and not "major".
|
-- first column is called "version" and not "major".
|
||||||
|
|
||||||
-- NOTE: this MUST be kept in step with src/lib/dhcpsrv/tests/schema_copy.h,
|
|
||||||
-- which defines the schema for the unit tests. If you are updating
|
|
||||||
-- the version number, the schema has changed: please ensure that
|
|
||||||
-- schema_copy.h has been updated as well.
|
|
||||||
CREATE TABLE schema_version (
|
CREATE TABLE schema_version (
|
||||||
version int,
|
version int,
|
||||||
minor int,
|
minor int,
|
||||||
PRIMARY KEY (version)
|
PRIMARY KEY (version)
|
||||||
);
|
);
|
||||||
--START TRANSACTION;
|
|
||||||
INSERT INTO schema_version (version, minor) VALUES (1, 0);
|
INSERT INTO schema_version (version, minor) VALUES (1, 0);
|
||||||
--COMMIT;
|
|
||||||
|
@@ -119,7 +119,8 @@ CqlConnection::openDatabase() {
|
|||||||
|
|
||||||
session_ = cass_session_new();
|
session_ = cass_session_new();
|
||||||
|
|
||||||
CassFuture* connect_future = cass_session_connect_keyspace(session_, cluster_, keyspace);
|
CassFuture* connect_future = cass_session_connect_keyspace(session_,
|
||||||
|
cluster_, keyspace);
|
||||||
cass_future_wait(connect_future);
|
cass_future_wait(connect_future);
|
||||||
std::string error;
|
std::string error;
|
||||||
checkStatementError(error, connect_future, "could not connect to DB");
|
checkStatementError(error, connect_future, "could not connect to DB");
|
||||||
@@ -199,9 +200,9 @@ CqlConnection::rollback() {
|
|||||||
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_ROLLBACK);
|
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_ROLLBACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CqlConnection::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;
|
CassError rc;
|
||||||
const char* errorMessage;
|
const char* errorMessage;
|
||||||
|
@@ -79,7 +79,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// @return Type of the backend.
|
/// @return Type of the backend.
|
||||||
virtual std::string getType() const {
|
virtual std::string getType() const {
|
||||||
return (std::string("cassandra"));
|
return (std::string("cql"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Returns name of the database.
|
/// @brief Returns name of the database.
|
||||||
@@ -133,7 +133,7 @@ public:
|
|||||||
CassCluster* cluster_;
|
CassCluster* cluster_;
|
||||||
CassSession* session_;
|
CassSession* session_;
|
||||||
std::vector<const CassPrepared*> statements_; ///< Prepared statements
|
std::vector<const CassPrepared*> statements_; ///< Prepared statements
|
||||||
CqlTaggedStatement *tagged_statements_;
|
CqlTaggedStatement* tagged_statements_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // end of isc::dhcp namespace
|
}; // end of isc::dhcp namespace
|
||||||
|
@@ -326,9 +326,9 @@ IPv4 leases from the memory file database for a client with the specified
|
|||||||
hardware address.
|
hardware address.
|
||||||
|
|
||||||
% DHCPSRV_MEMFILE_GET_IAID_DUID obtaining IPv6 leases for IAID %1 and DUID %2 and lease type %3
|
% DHCPSRV_MEMFILE_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
|
A debug message issued when the server is attempting to obtain a set of IPv6
|
||||||
IPv6 lease from the memory file database for a client with the specified
|
leases from the memory file database for a client with the specified IAID
|
||||||
IAID (Identity Association ID) and DUID (DHCP Unique Identifier).
|
(Identity Association ID) and DUID (DHCP Unique Identifier).
|
||||||
|
|
||||||
% DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID obtaining IPv6 leases for IAID %1, Subnet ID %2, DUID %3 and lease type %4
|
% DHCPSRV_MEMFILE_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
|
A debug message issued when the server is attempting to obtain an IPv6
|
||||||
@@ -518,9 +518,9 @@ of IPv4 leases from the MySQL database for a client with the specified
|
|||||||
hardware address.
|
hardware address.
|
||||||
|
|
||||||
% DHCPSRV_MYSQL_GET_IAID_DUID obtaining IPv6 leases for IAID %1, DUID %2, lease type %3
|
% DHCPSRV_MYSQL_GET_IAID_DUID obtaining IPv6 leases for IAID %1, DUID %2, lease type %3
|
||||||
A debug message issued when the server is attempting to obtain a set of
|
A debug message issued when the server is attempting to obtain a set of IPv6
|
||||||
IPv6 lease from the MySQL database for a client with the specified IAID
|
leases from the MySQL database for a client with the specified IAID (Identity
|
||||||
(Identity Association ID) and DUID (DHCP Unique Identifier).
|
Association ID) and DUID (DHCP Unique Identifier).
|
||||||
|
|
||||||
% DHCPSRV_MYSQL_GET_IAID_SUBID_DUID obtaining IPv6 leases for IAID %1, Subnet ID %2, DUID %3, lease type %4
|
% DHCPSRV_MYSQL_GET_IAID_SUBID_DUID obtaining IPv6 leases for IAID %1, Subnet ID %2, DUID %3, lease type %4
|
||||||
A debug message issued when the server is attempting to obtain an IPv6
|
A debug message issued when the server is attempting to obtain an IPv6
|
||||||
@@ -663,8 +663,8 @@ of IPv4 leases from the PostgreSQL database for a client with the specified
|
|||||||
hardware address.
|
hardware address.
|
||||||
|
|
||||||
% DHCPSRV_PGSQL_GET_IAID_DUID obtaining IPv4 leases for IAID %1 and DUID %2, lease type %3
|
% DHCPSRV_PGSQL_GET_IAID_DUID obtaining IPv4 leases for IAID %1 and DUID %2, lease type %3
|
||||||
A debug message issued when the server is attempting to obtain a set of
|
A debug message issued when the server is attempting to obtain a set of IPv6
|
||||||
IPv6 lease from the PostgreSQL database for a client with the specified IAID
|
leases from the PostgreSQL database for a client with the specified IAID
|
||||||
(Identity Association ID) and DUID (DHCP Unique Identifier).
|
(Identity Association ID) and DUID (DHCP Unique Identifier).
|
||||||
|
|
||||||
% DHCPSRV_PGSQL_GET_IAID_SUBID_DUID obtaining IPv4 leases for IAID %1, Subnet ID %2, DUID %3, and lease type %4
|
% DHCPSRV_PGSQL_GET_IAID_SUBID_DUID obtaining IPv4 leases for IAID %1, Subnet ID %2, DUID %3, and lease type %4
|
||||||
@@ -818,7 +818,7 @@ A debug message issued when the server is about to add an IPv6 lease
|
|||||||
with the specified address to the Cassandra backend database.
|
with the specified address to the Cassandra backend database.
|
||||||
|
|
||||||
% DHCPSRV_CQL_COMMIT committing to Cassandra database
|
% DHCPSRV_CQL_COMMIT committing to Cassandra database
|
||||||
The code has issued a commit call.
|
A commit call been issued on the server. For Cassandra, this is a no-op.
|
||||||
|
|
||||||
% DHCPSRV_CQL_DB opening Cassandra lease database: %1
|
% DHCPSRV_CQL_DB opening Cassandra lease database: %1
|
||||||
This informational message is logged when a DHCP server (either V4 or
|
This informational message is logged when a DHCP server (either V4 or
|
||||||
@@ -827,9 +827,8 @@ the connection including database name and username needed to access it
|
|||||||
(but not the password if any) are logged.
|
(but not the password if any) are logged.
|
||||||
|
|
||||||
% DHCPSRV_CQL_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
|
A debug message issued when the server is attempting to delete a lease from the
|
||||||
for the specified address from the Cassandra database for the specified
|
Cassandra database for the specified address.
|
||||||
address.
|
|
||||||
|
|
||||||
% DHCPSRV_CQL_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
|
A debug message issued when the server is removing reclaimed DHCPv4
|
||||||
@@ -877,9 +876,9 @@ IPv4 leases from the Cassandra database for a client with the specified
|
|||||||
hardware address.
|
hardware address.
|
||||||
|
|
||||||
% DHCPSRV_CQL_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
|
A debug message issued when the server is attempting to obtain a set of IPv6
|
||||||
IPv6 lease from the Cassandra database for a client with the specified
|
leases from the Cassandra database for a client with the specified IAID
|
||||||
IAID (Identity Association ID) and DUID (DHCP Unique Identifier).
|
(Identity Association ID) and DUID (DHCP Unique Identifier).
|
||||||
|
|
||||||
% DHCPSRV_CQL_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
|
A debug message issued when the server is attempting to obtain an IPv6
|
||||||
@@ -901,7 +900,8 @@ A debug message issued when the server is about to obtain schema version
|
|||||||
information from the Cassandra database.
|
information from the Cassandra database.
|
||||||
|
|
||||||
% DHCPSRV_CQL_ROLLBACK rolling back Cassandra database
|
% DHCPSRV_CQL_ROLLBACK rolling back Cassandra database
|
||||||
The code has issued a rollback call.
|
The code has issued a rollback call. For Cassandra, this is
|
||||||
|
a no-op.
|
||||||
|
|
||||||
% DHCPSRV_CQL_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
|
A debug message issued when the server is attempting to update IPv4
|
||||||
@@ -910,4 +910,3 @@ lease from the Cassandra database for the specified address.
|
|||||||
% DHCPSRV_CQL_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
|
A debug message issued when the server is attempting to update IPv6
|
||||||
lease from the Cassandra database for the specified address.
|
lease from the Cassandra database for the specified address.
|
||||||
|
|
||||||
|
@@ -74,7 +74,7 @@ LeaseMgrFactory::create(const std::string& dbaccess) {
|
|||||||
#ifdef HAVE_CQL
|
#ifdef HAVE_CQL
|
||||||
if (parameters[type] == string("cql")) {
|
if (parameters[type] == string("cql")) {
|
||||||
LOG_INFO(dhcpsrv_logger, DHCPSRV_CQL_DB).arg(redacted);
|
LOG_INFO(dhcpsrv_logger, DHCPSRV_CQL_DB).arg(redacted);
|
||||||
getLeaseMgrPtr().reset(new CQLLeaseMgr(parameters));
|
getLeaseMgrPtr().reset(new CqlLeaseMgr(parameters));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -87,7 +87,7 @@ LeaseMgrFactory::create(const std::string& dbaccess) {
|
|||||||
// Get here on no match
|
// Get here on no match
|
||||||
LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_DB).arg(parameters[type]);
|
LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_DB).arg(parameters[type]);
|
||||||
isc_throw(InvalidType, "Database access parameter 'type' does "
|
isc_throw(InvalidType, "Database access parameter 'type' does "
|
||||||
"not specify a supported database backend");
|
"not specify a supported database backend:" << parameters[type]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -376,7 +376,7 @@ public:
|
|||||||
/// Commits all pending database operations. On databases that don't
|
/// Commits all pending database operations. On databases that don't
|
||||||
/// support transactions, this is a no-op.
|
/// support transactions, this is a no-op.
|
||||||
///
|
///
|
||||||
/// @throw DbOperationError Iif the commit failed.
|
/// @throw DbOperationError If the commit failed.
|
||||||
virtual void commit();
|
virtual void commit();
|
||||||
|
|
||||||
/// @brief Rollback Transactions
|
/// @brief Rollback Transactions
|
||||||
|
@@ -159,7 +159,7 @@ PgSqlTaggedStatement tagged_statements[] = {
|
|||||||
|
|
||||||
// INSERT_LEASE4
|
// INSERT_LEASE4
|
||||||
{ 10, { OID_INT8, OID_BYTEA, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8,
|
{ 10, { OID_INT8, OID_BYTEA, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8,
|
||||||
OID_BOOL, OID_BOOL, OID_VARCHAR, OID_INT8, OID_INT8 },
|
OID_BOOL, OID_BOOL, OID_VARCHAR, OID_INT8 },
|
||||||
"insert_lease4",
|
"insert_lease4",
|
||||||
"INSERT INTO lease4(address, hwaddr, client_id, "
|
"INSERT INTO lease4(address, hwaddr, client_id, "
|
||||||
"valid_lifetime, expire, subnet_id, fqdn_fwd, fqdn_rev, hostname, "
|
"valid_lifetime, expire, subnet_id, fqdn_fwd, fqdn_rev, hostname, "
|
||||||
|
@@ -351,7 +351,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// Commits all pending database operations.
|
/// Commits all pending database operations.
|
||||||
///
|
///
|
||||||
/// @throw DbOperationError Iif the commit failed.
|
/// @throw DbOperationError If the commit failed.
|
||||||
virtual void commit();
|
virtual void commit();
|
||||||
|
|
||||||
/// @brief Rollback Transactions
|
/// @brief Rollback Transactions
|
||||||
|
@@ -45,8 +45,8 @@ public:
|
|||||||
CqlLeaseMgrTest() {
|
CqlLeaseMgrTest() {
|
||||||
|
|
||||||
// Ensure schema is the correct one.
|
// Ensure schema is the correct one.
|
||||||
destroyCqlSchema();
|
destroyCqlSchema(false, true);
|
||||||
createCqlSchema();
|
createCqlSchema(false, true);
|
||||||
|
|
||||||
// Connect to the database
|
// Connect to the database
|
||||||
try {
|
try {
|
||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
virtual ~CqlLeaseMgrTest() {
|
virtual ~CqlLeaseMgrTest() {
|
||||||
lmptr_->rollback();
|
lmptr_->rollback();
|
||||||
LeaseMgrFactory::destroy();
|
LeaseMgrFactory::destroy();
|
||||||
destroyCqlSchema();
|
destroyCqlSchema(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Reopen the database
|
/// @brief Reopen the database
|
||||||
@@ -97,8 +97,8 @@ public:
|
|||||||
TEST(CQLOpenTest, OpenDatabase) {
|
TEST(CQLOpenTest, OpenDatabase) {
|
||||||
|
|
||||||
// Schema needs to be created for the test to work.
|
// Schema needs to be created for the test to work.
|
||||||
destroyCqlSchema();
|
destroyCqlSchema(false, true);
|
||||||
createCqlSchema();
|
createCqlSchema(false, true);
|
||||||
|
|
||||||
// Check that lease manager open the database opens correctly and tidy up.
|
// Check that lease manager open the database opens correctly and tidy up.
|
||||||
// If it fails, print the error message.
|
// If it fails, print the error message.
|
||||||
@@ -147,15 +147,15 @@ TEST(CQLOpenTest, OpenDatabase) {
|
|||||||
NoDatabaseName);
|
NoDatabaseName);
|
||||||
|
|
||||||
// Tidy up after the test
|
// Tidy up after the test
|
||||||
destroyCqlSchema();
|
destroyCqlSchema(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Check the getType() method
|
/// @brief Check the getType() method
|
||||||
///
|
///
|
||||||
/// getType() returns a string giving the type of the backend, which should
|
/// getType() returns a string giving the type of the backend, which should
|
||||||
/// always be "cassandra".
|
/// always be "cql".
|
||||||
TEST_F(CqlLeaseMgrTest, getType) {
|
TEST_F(CqlLeaseMgrTest, getType) {
|
||||||
EXPECT_EQ(std::string("cassandra"), lmptr_->getType());
|
EXPECT_EQ(std::string("cql"), lmptr_->getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Check conversion functions
|
/// @brief Check conversion functions
|
||||||
|
@@ -20,6 +20,10 @@ libdhcpsrvtest_la_SOURCES += schema.cc schema.h
|
|||||||
else
|
else
|
||||||
if HAVE_PGSQL
|
if HAVE_PGSQL
|
||||||
libdhcpsrvtest_la_SOURCES += schema.cc schema.h
|
libdhcpsrvtest_la_SOURCES += schema.cc schema.h
|
||||||
|
else
|
||||||
|
if HAVE_CQL
|
||||||
|
libdhcpsrvtest_la_SOURCES += schema.cc schema.h
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -29,6 +33,9 @@ endif
|
|||||||
if HAVE_PGSQL
|
if HAVE_PGSQL
|
||||||
libdhcpsrvtest_la_SOURCES += pgsql_schema.cc pgsql_schema.h
|
libdhcpsrvtest_la_SOURCES += pgsql_schema.cc pgsql_schema.h
|
||||||
endif
|
endif
|
||||||
|
if HAVE_CQL
|
||||||
|
libdhcpsrvtest_la_SOURCES += cql_schema.cc cql_schema.h
|
||||||
|
endif
|
||||||
|
|
||||||
libdhcpsrvtest_la_CXXFLAGS = $(AM_CXXFLAGS)
|
libdhcpsrvtest_la_CXXFLAGS = $(AM_CXXFLAGS)
|
||||||
libdhcpsrvtest_la_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
|
libdhcpsrvtest_la_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
|
||||||
@@ -38,6 +45,9 @@ endif
|
|||||||
if HAVE_PGSQL
|
if HAVE_PGSQL
|
||||||
libdhcpsrvtest_la_CPPFLAGS += $(PGSQL_CPPFLAGS)
|
libdhcpsrvtest_la_CPPFLAGS += $(PGSQL_CPPFLAGS)
|
||||||
endif
|
endif
|
||||||
|
if HAVE_CQL
|
||||||
|
libdhcpsrvtest_la_CPPFLAGS += $(CQL_CPPFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
libdhcpsrvtest_la_LDFLAGS = $(AM_LDFLAGS)
|
libdhcpsrvtest_la_LDFLAGS = $(AM_LDFLAGS)
|
||||||
if HAVE_MYSQL
|
if HAVE_MYSQL
|
||||||
@@ -46,6 +56,9 @@ endif
|
|||||||
if HAVE_PGSQL
|
if HAVE_PGSQL
|
||||||
libdhcpsrvtest_la_LDFLAGS += $(PGSQL_LIBS)
|
libdhcpsrvtest_la_LDFLAGS += $(PGSQL_LIBS)
|
||||||
endif
|
endif
|
||||||
|
if HAVE_CQL
|
||||||
|
libdhcpsrvtest_la_LDFLAGS += $(CQL_LIBS)
|
||||||
|
endif
|
||||||
|
|
||||||
libdhcpsrvtest_la_LIBADD = $(top_builddir)/src/lib/cc/libkea-cc.la
|
libdhcpsrvtest_la_LIBADD = $(top_builddir)/src/lib/cc/libkea-cc.la
|
||||||
libdhcpsrvtest_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la
|
libdhcpsrvtest_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la
|
||||||
|
@@ -21,7 +21,7 @@ namespace isc {
|
|||||||
namespace dhcp {
|
namespace dhcp {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
const char* CQL_VALID_TYPE = "type=cassandra";
|
const char* CQL_VALID_TYPE = "type=cql";
|
||||||
|
|
||||||
string
|
string
|
||||||
validCqlConnectionString() {
|
validCqlConnectionString() {
|
||||||
@@ -29,25 +29,45 @@ validCqlConnectionString() {
|
|||||||
VALID_USER, VALID_PASSWORD));
|
VALID_USER, VALID_PASSWORD));
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyCqlSchema(bool show_err) {
|
bool softWipeEnabled() {
|
||||||
runCqlScript(DATABASE_SCRIPTS_DIR, "cql/dhcpdb_drop.cql", show_err);
|
const char* const env = getenv("KEA_TEST_CASSANDRA_WIPE");
|
||||||
|
if (env && (string(env) == string("soft"))) {
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createCqlSchema(bool show_err) {
|
void destroyCqlSchema(bool , bool show_err) {
|
||||||
runCqlScript(DATABASE_SCRIPTS_DIR, "cql/dhcpdb_create.cql",
|
// if (force_wipe || !softWipeEnabled()) {
|
||||||
show_err);
|
// Do full wipe
|
||||||
|
runCqlScript(DATABASE_SCRIPTS_DIR, "cql/dhcpdb_drop.cql", show_err);
|
||||||
|
// } else {
|
||||||
|
|
||||||
|
// do soft wipe (just remove the data, not the structures)
|
||||||
|
// runCqlScript(DATABASE_SCRIPTS_DIR, "cql/soft_wipe.cql", show_err);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
void createCqlSchema(bool force_wipe, bool show_err) {
|
||||||
|
if (force_wipe || !softWipeEnabled()) {
|
||||||
|
runCqlScript(DATABASE_SCRIPTS_DIR, "cql/dhcpdb_create.cql",
|
||||||
|
show_err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void runCqlScript(const std::string& path, const std::string& script_name,
|
void runCqlScript(const std::string& path, const std::string& script_name,
|
||||||
bool show_err) {
|
bool show_err) {
|
||||||
std::ostringstream cmd;
|
std::ostringstream cmd;
|
||||||
cmd << "cqlsh -u keatest -p keatest -k keatest -f";
|
cmd << "cqlsh -u keatest -p keatest -k keatest";
|
||||||
if (!show_err) {
|
if (!show_err) {
|
||||||
cmd << " 2>/dev/null ";
|
cmd << " 2>/dev/null ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd << " -f";
|
||||||
|
|
||||||
if (!path.empty()) {
|
if (!path.empty()) {
|
||||||
cmd << " < " << path << "/";
|
cmd << path << "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd << script_name;
|
cmd << script_name;
|
||||||
|
@@ -32,8 +32,10 @@ std::string validCqlConnectionString();
|
|||||||
/// will fail. The output of stderr is suppressed unless the parameter,
|
/// will fail. The output of stderr is suppressed unless the parameter,
|
||||||
/// show_err is true.
|
/// show_err is true.
|
||||||
///
|
///
|
||||||
|
/// @param force_wipe forces wipe of the database, even if KEA_TEST_CASSANDRA_WIPE
|
||||||
|
/// is set.
|
||||||
/// @param show_err flag which governs whether or not stderr is suppressed.
|
/// @param show_err flag which governs whether or not stderr is suppressed.
|
||||||
void destroyCqlSchema(bool show_err = false);
|
void destroyCqlSchema(bool force_wipe, bool show_err = false);
|
||||||
|
|
||||||
/// @brief Create the CQL Schema
|
/// @brief Create the CQL Schema
|
||||||
///
|
///
|
||||||
@@ -45,10 +47,12 @@ void destroyCqlSchema(bool show_err = false);
|
|||||||
/// will fail. The output of stderr is suppressed unless the parameter,
|
/// will fail. The output of stderr is suppressed unless the parameter,
|
||||||
/// show_err is true.
|
/// show_err is true.
|
||||||
///
|
///
|
||||||
|
/// @param force_wipe forces wipe of the database, even if KEA_TEST_CASSANDRA_WIPE
|
||||||
|
/// is set.
|
||||||
/// @param show_err flag which governs whether or not stderr is suppressed.
|
/// @param show_err flag which governs whether or not stderr is suppressed.
|
||||||
void createCqlSchema(bool show_err = false);
|
void createCqlSchema(bool force_wipe, bool show_err = false);
|
||||||
|
|
||||||
/// @brief Run a CQL SQL script against the CQL unit test database
|
/// @brief Run a CQL script against the CQL unit test database
|
||||||
///
|
///
|
||||||
/// Submits the given SQL script to CQL 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
|
/// stderr is suppressed unless the parameter, show_err is true. The is done
|
||||||
@@ -61,6 +65,29 @@ void createCqlSchema(bool show_err = false);
|
|||||||
void runCqlScript(const std::string& path, const std::string& script_name,
|
void runCqlScript(const std::string& path, const std::string& script_name,
|
||||||
bool show_err);
|
bool show_err);
|
||||||
|
|
||||||
|
/// @brief Returns status if the soft-wipe is enabled or not.
|
||||||
|
///
|
||||||
|
/// In some deployments (In case of Tomek's dev system) Cassandra tests take
|
||||||
|
/// a very long time to execute. This was traced back to slow table/indexes
|
||||||
|
/// creation/deletion. With full wipe and recreation of all structures, it
|
||||||
|
/// took over 60 seconds for each test to execute. To avoid this problem, a
|
||||||
|
/// feature called soft-wipe has been implemented. If enabled, it does not
|
||||||
|
/// remove the structures, just the data from essential tables. To enable
|
||||||
|
/// it set KEA_TEST_CASSANDRA_WIPE environment variable to 'soft'. Make sure
|
||||||
|
/// that the database schema is set up properly before running in soft-wipe
|
||||||
|
/// mode.
|
||||||
|
///
|
||||||
|
/// For example to use soft-wipe mode, you can:
|
||||||
|
///
|
||||||
|
/// $ cqlsh -u keatest -p keatest -k keatest
|
||||||
|
/// -f src/share/database/scripts/cql/dhcpdb_create.cql
|
||||||
|
/// $ export KEA_TEST_CASSANDRA_WIPE=soft
|
||||||
|
/// $ cd src/lib/dhcpsrv
|
||||||
|
/// $ make -j9
|
||||||
|
/// $ tests/libdhcpsrv_unittests --gtest_filter=CqlLeaseMgrTest.*
|
||||||
|
///
|
||||||
|
/// @return true if soft-wipe is enabled, false otherwise
|
||||||
|
bool softWipeEnabled();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@@ -49,7 +49,7 @@ void runPgSQLScript(const std::string& path, const std::string& script_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd << script_name
|
cmd << script_name
|
||||||
<< " | psql --set ON_ERROR_STOP=1 -A -t -q -U keatest -d keatest";
|
<< " | psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -U keatest -d keatest";
|
||||||
|
|
||||||
if (!show_err) {
|
if (!show_err) {
|
||||||
cmd << " 2>/dev/null ";
|
cmd << " 2>/dev/null ";
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
SUBDIRS = .
|
SUBDIRS = .
|
||||||
|
|
||||||
sqlscriptsdir = ${datarootdir}/${PACKAGE_NAME}/scripts/cql
|
sqlscriptsdir = ${datarootdir}/${PACKAGE_NAME}/scripts/cql
|
||||||
sqlscripts_DATA = dhcpdb_create.cql
|
sqlscripts_DATA = dhcpdb_create.cql dhcpdb_drop.cql
|
||||||
sqlscripts_DATA += dhcpdb_drop.cql
|
|
||||||
|
|
||||||
EXTRA_DIST = ${sqlscripts_DATA}
|
EXTRA_DIST = ${sqlscripts_DATA}
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
#
|
#
|
||||||
# source dhcpdb_create.mysql
|
# source dhcpdb_create.mysql
|
||||||
#
|
#
|
||||||
# This script is also called from kea-admin, see kea-admin init mysql
|
# This script is also called from kea-admin, see kea-admin lease-init mysql
|
||||||
#
|
#
|
||||||
# Over time, Kea database schema will evolve. Each version is marked with
|
# Over time, Kea database schema will evolve. Each version is marked with
|
||||||
# major.minor version. This file is organized sequentially, i.e. database
|
# major.minor version. This file is organized sequentially, i.e. database
|
||||||
|
Reference in New Issue
Block a user