From: Razvan Becheriu Date: Tue, 7 Jun 2016 15:15:38 +0000 (+0300) Subject: minor changes X-Git-Tag: trac4283_base~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74b0e9173729ea628e5201914990627d3ea6c4a0;p=thirdparty%2Fkea.git minor changes --- diff --git a/src/bin/admin/admin-utils.sh b/src/bin/admin/admin-utils.sh index 03ec7dc5ff..d6f33a4d30 100755 --- a/src/bin/admin/admin-utils.sh +++ b/src/bin/admin/admin-utils.sh @@ -76,7 +76,7 @@ pgsql_execute_script() { retcode=$? else export PGPASSWORD=$db_password - psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -U $db_user -d $db_name -h localhost -f $file + psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -U $db_user -d $db_name -f $file retcode=$? fi return $retcode diff --git a/src/bin/admin/kea-admin.in b/src/bin/admin/kea-admin.in index 1cd45475b4..5fa3d70b76 100644 --- a/src/bin/admin/kea-admin.in +++ b/src/bin/admin/kea-admin.in @@ -203,17 +203,6 @@ pgsql_init() { cql_init() { printf "Checking if there is a database initialized already... Please ignore errors.\n" - result=`cql_execute "DESCRIBE KEYSPACES;"` - if [ "$result" != "" ]; then - result=`echo "$result" | sed -n "/$db_name/ p"` - if [ "$result" = "" ]; then - printf "Creating keyspace $db_name...\n" - cql_execute "CREATE KEYSPACE $db_name WITH replication = {'class' : 'SimpleStrategy','replication_factor' : 1};" - else - printf "Keyspace $db_name already exists.\n" - fi - fi - result=`cql_execute "USE $db_name; DESCRIBE tables;"` if [ "$result"="" ]; then printf "Creating and initializing tables using script %s...\n" $scripts_dir/cql/dhcpdb_create.cql @@ -225,7 +214,7 @@ cql_init() { version=`cql_version` printf "Lease DB version reported after initialization: $version\n" - return 0 + exit 0 } ### Functions that implement database version checking commands @@ -340,7 +329,7 @@ cql_upgrade() { version=`cql_version` printf "Lease DB version reported after upgrade: $version\n" - return 0 + exit 0 } # Utility function which tests if the given file exists and @@ -535,7 +524,7 @@ cql_dump() { # delete the tmp file on success rm $tmp_file echo lease$dump_type successfully dumped to $dump_file - return 0 + exit 0 } ### Script starts here ### diff --git a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc index 616b64f518..b3af9a2c1b 100644 --- a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc @@ -94,7 +94,7 @@ public: /// CqlLeaseMgr test fixure set. This test checks that the database can be /// opened: the fixtures assume that and check basic operations. -TEST(CQLOpenTest, OpenDatabase) { +TEST(CqlOpenTest, OpenDatabase) { // Schema needs to be created for the test to work. destroyCqlSchema(false, true); diff --git a/src/lib/dhcpsrv/testutils/cql_schema.cc b/src/lib/dhcpsrv/testutils/cql_schema.cc index 20110da2a3..b03c8a4814 100644 --- a/src/lib/dhcpsrv/testutils/cql_schema.cc +++ b/src/lib/dhcpsrv/testutils/cql_schema.cc @@ -38,15 +38,15 @@ bool softWipeEnabled() { return (false); } -void destroyCqlSchema(bool , bool show_err) { -// if (force_wipe || !softWipeEnabled()) { +void destroyCqlSchema(bool force_wipe, bool show_err) { + if (force_wipe || !softWipeEnabled()) { // Do full wipe runCqlScript(DATABASE_SCRIPTS_DIR, "cql/dhcpdb_drop.cql", show_err); -// } else { + } else { // do soft wipe (just remove the data, not the structures) -// runCqlScript(DATABASE_SCRIPTS_DIR, "cql/soft_wipe.cql", show_err); -// } + runCqlScript(DATABASE_SCRIPTS_DIR, "cql/soft_wipe.cql", show_err); + } } void createCqlSchema(bool force_wipe, bool show_err) { diff --git a/src/share/database/scripts/cql/dhcpdb_create.cql b/src/share/database/scripts/cql/dhcpdb_create.cql index bf0a95d715..6cad321bfc 100644 --- a/src/share/database/scripts/cql/dhcpdb_create.cql +++ b/src/share/database/scripts/cql/dhcpdb_create.cql @@ -29,7 +29,7 @@ -- 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 -- major.minor version. This file is organized sequentially, i.e. database