]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5494] Fixed Cassandra support for macOS
authorFrancis Dupont <fdupont@isc.org>
Sun, 31 Dec 2017 16:48:28 +0000 (17:48 +0100)
committerFrancis Dupont <fdupont@isc.org>
Sun, 31 Dec 2017 16:48:28 +0000 (17:48 +0100)
doc/devel/unit-tests.dox
src/bin/admin/admin-utils.sh
src/bin/admin/kea-admin.in
src/lib/dhcpsrv/cql_lease_mgr.h
tools/Makefile.am
tools/cql_config
tools/cql_config_defines.sh.sample [moved from tools/cql_config_defines.sh with 100% similarity]

index ecaa04ffb4b7fa91f3aaee60a29d102270abc9e1..c91d2849e74ffebb23579a93c8409a509830a6ef 100644 (file)
@@ -263,7 +263,24 @@ local   all             postgres                                trust
 
  @subsection cqlUnitTestsPrerequisites Cassandra database
 
- @todo: Describe steps necessary to set up Cassandra database suitable for running
- unittests.
-
+ @todo: Describe steps necessary to set up Cassandra database suitable
+ for running unittests.
+
+ It seems this was enough:
+
+ -# Launch cassandra if not running (-f for foreground)
+ @verbatim
+ % cassandra -f
+ @endverbatim
+
+ The tool is cqlsh:
+
+ -# Run the tool
+ @verbatim
+ % cqlsh
+ Connected to Test Cluster at 127.0.0.1:9042.
+ [cqlsh 5.0.1 | Cassandra 3.11.1 | CQL spec 3.4.4 | Native protocol v4]
+ Use HELP for help.
+ cqlsh> @endverbatim\n
  */
index 80f5410306bacb208bcf063387afc3f7127be4d3..464cc22ab7d6f9bbb4349001e1f038e5fee81b44 100755 (executable)
@@ -128,7 +128,7 @@ cql_execute_script() {
 cql_version() {
   version=$(cql_execute "SELECT version, minor FROM schema_version" "$@")
   error=$?
-  version=$(echo "$version" | grep -A 1 "+" | grep -v "+" | tr -d ' ' | cut -d "|" -f 1-2 --output-delimiter=".")
+  version=$(echo "$version" | grep -A 1 "+" | grep -v "+" | tr -d ' ' | cut -d "|" -f 1-2 | tr "|" ".")
   echo "$version"
   return $error
 }
index 7613dfafa686b46255ae349303f6ec9afec76947..d28697de0ce1c414a044faa4394c02cbc44c2245 100644 (file)
@@ -518,11 +518,11 @@ cql_dump() {
     fi
 
     # Parse and display header.
-    echo "$result" | head -n 2 | tail -n 1 | sed -e 's/\s*//g' | sed -e 's/|/,/g' > $dump_file
+    echo "$result" | head -n 2 | tail -n 1 | sed -e 's/[[:space:]]*//g' | sed -e 's/|/,/g' > $dump_file
 
     # Parse and display contents - done separately from header to allow sorting
-    # by address.
-    echo "$result" | tail -n +4 | head -n -2 | sed -e 's/\s*//g' | sed -e 's/|/,/g' | sort -r >> $dump_file
+    # by address. awk script replaces head -n -2 which is not portable.
+    echo "$result" | tail -n +4 | awk 'n>=2 { print a[n%2] } { a[n%2]=$0; n=n+1 }' | sed -e 's/[[:space:]]*//g' | sed -e 's/|/,/g' | sort -r >> $dump_file
 
     echo lease$dump_type successfully dumped to $dump_file
     exit 0
index 878f2093937d1352b600eaaca8520bd4f7d4fa50..abb34dd1f4b44d0e97caeb7eb5d072521e571132 100644 (file)
@@ -318,7 +318,7 @@ public:
     ///
     /// @throw isc::dhcp::DbOperationError An operation on the open database has
     ///        failed.
-    virtual bool deleteLease(const isc::asiolink::IOAddress& addr);
+    virtual bool deleteLease(const isc::asiolink::IOAddress& addr) override;
 
     /// @brief Deletes all expired and reclaimed DHCPv4 leases.
     ///
@@ -349,7 +349,7 @@ public:
     ///
     /// @param subnet_id identifier of the subnet
     /// @return number of leases removed.
-    virtual size_t wipeLeases4(const SubnetID& subnet_id);
+    virtual size_t wipeLeases4(const SubnetID& subnet_id) override;
 
     /// @brief Removed specified IPv6 leases.
     ///
@@ -360,7 +360,7 @@ public:
     ///
     /// @param subnet_id identifier of the subnet
     /// @return number of leases removed.
-    virtual size_t wipeLeases6(const SubnetID& subnet_id);
+    virtual size_t wipeLeases6(const SubnetID& subnet_id) override;
 
     /// @brief Return backend type
     ///
index 4be133f4a1cddff9968337b5495f0e088d31697a..b18bd4facd72e81bb5812e4915fe92660c6980e3 100644 (file)
@@ -20,6 +20,6 @@ EXTRA_DIST = system_messages
 # Scripts for Cassandra support. Ultimately those scripts will have to be
 # incorporated in DataStax cpp-driver source tree, but until that happens,
 # let's keep them in Kea rpo
-EXTRA_DIST += cql_config cql_config_defines.sh
+EXTRA_DIST += cql_config cql_config_defines.sh.sample
 
 endif
index 19a426a46ee9b7c3b363ed8f0eaeba88a203d6ef..fba61640aaf14d7f34bfbb55c75ecdcac915fdba 100755 (executable)
@@ -1,8 +1,14 @@
 #!/bin/bash
-DIR=$(readlink -f $0 | xargs dirname)
+
+if test `uname -s` = "Darwin"; then
+       DIR=$(stat -f %N $0 | xargs dirname)
+else
+       DIR=$(readlink -f $0 | xargs dirname)
+fi
+
 if ! [ -f ${DIR}/cql_config_defines.sh ] || ! [ -x ${DIR}/cql_config_defines.sh ]
 then
-       echo "missing path configuration file for DataStax Cassandra (cql_config_defines.h)"
+       echo "missing path configuration file for DataStax Cassandra (cql_config_defines.sh)"
        exit 0
 fi
 source ${DIR}/cql_config_defines.sh