Browse Source

[3966] Fixed failing lease dump unit tests.

Marcin Siodelski 9 years ago
parent
commit
fce2324898

+ 38 - 0
src/bin/admin/scripts/mysql/lease_dump_4.0.sh

@@ -0,0 +1,38 @@
+#!/bin/sh
+# Copyright (C) 2015  Internet Systems Consortium.
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
+# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+# Specifies the MySQL sql for schema-version 4.0 required to produce 
+# lease output that includes a header row containing column names,
+# followed by the lease data. The text is used in a single call 
+# to the mysql command line tool.
+
+# SQL for DHCPv4 leases
+lease4_dump_sql="\
+SELECT 'address', 'hwaddr', 'client_id', 'valid_lifetime', 'expire',\
+'subnet_id', 'fqdn_fwd', 'fqdn_rev', 'hostname', 'state';\
+SELECT INET_NTOA(address), IFNULL(HEX(hwaddr), ''), IFNULL(HEX(client_id), ''),\
+valid_lifetime, expire, subnet_id, fqdn_fwd, fqdn_rev, hostname, state from lease4"
+
+# SQL for DHCPv6 leases
+lease6_dump_sql="\
+SELECT 'address', 'duid', 'valid_lifetime', 'expire',\
+'subnet_id', 'pref_lifetime', 'lease_type', 'iaid', 'prefix_len', 'fqdn_fwd',\
+'fqdn_rev', 'hostname', 'hwaddr', 'hwtype', 'hwaddr_source', 'state';\
+SELECT a.address, IFNULL(HEX(a.duid), ''), a.valid_lifetime,\
+a.expire, a.subnet_id, a.pref_lifetime, IFNULL(b.name, ''), a.iaid, a.prefix_len,\
+a.fqdn_fwd, a.fqdn_rev, hostname, IFNULL(HEX(hwaddr), ''), IFNULL(hwtype, ''),\
+IFNULL(hwaddr_source, ''), state \
+FROM lease6 a left outer join lease6_types b on (a.lease_type = b.lease_type)"

+ 4 - 4
src/bin/admin/tests/data/mysql.lease4_dump_test.reference.csv

@@ -1,4 +1,4 @@
-address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname
-0.0.0.10,3230,3330,40,2015-01-01 01:15:30,50,1,1,one.example.com
-0.0.0.11,,313233,40,2015-02-02 02:30:45,50,1,1,
-0.0.0.12,3232,,40,2015-03-03 11:01:07,50,1,1,three.example.com
+address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state
+0.0.0.10,3230,3330,40,2015-01-01 01:15:30,50,1,1,one.example.com,0
+0.0.0.11,,313233,40,2015-02-02 02:30:45,50,1,1,,0
+0.0.0.12,3232,,40,2015-03-03 11:01:07,50,1,1,three.example.com,0

+ 4 - 4
src/bin/admin/tests/data/mysql.lease6_dump_test.reference.csv

@@ -1,4 +1,4 @@
-address,duid,valid_lifetime,expire,subnet_id,pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname,hwaddr,hwtype,hwaddr_source
-10,3230,30,2015-04-04 01:15:30,40,50,IA_TA,60,70,1,1,one.example.com,3830,90,100
-11,,30,2015-05-05 02:30:45,40,50,IA_TA,60,70,1,1,,3830,90,100
-12,3231,30,2015-06-06 11:01:07,40,50,IA_TA,60,70,1,1,three.example.com,3830,90,100
+address,duid,valid_lifetime,expire,subnet_id,pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname,hwaddr,hwtype,hwaddr_source,state
+10,3230,30,2015-04-04 01:15:30,40,50,IA_TA,60,70,1,1,one.example.com,3830,90,100,0
+11,,30,2015-05-05 02:30:45,40,50,IA_TA,60,70,1,1,,3830,90,100,0
+12,3231,30,2015-06-06 11:01:07,40,50,IA_TA,60,70,1,1,three.example.com,3830,90,100,0

+ 6 - 6
src/bin/admin/tests/mysql_tests.sh.in

@@ -302,9 +302,9 @@ mysql_lease4_dump_test() {
 
     # Insert the reference record
     insert_sql="\
-insert into lease4 values(10,20,30,40,\"2015-01-01 01:15:30\",50,1,1,\"one.example.com\");\
-insert into lease4 values(11,NULL,123,40,\"2015-02-02 02:30:45\",50,1,1,\"\");\
-insert into lease4 values(12,22,NULL,40,\"2015-03-03 11:01:07\",50,1,1,\"three.example.com\");"
+insert into lease4 values(10,20,30,40,\"2015-01-01 01:15:30\",50,1,1,\"one.example.com\", 0);\
+insert into lease4 values(11,NULL,123,40,\"2015-02-02 02:30:45\",50,1,1,\"\", 0);\
+insert into lease4 values(12,22,NULL,40,\"2015-03-03 11:01:07\",50,1,1,\"three.example.com\", 0);"
 
     mysql_execute "$insert_sql"
     ERRCODE=$?
@@ -362,9 +362,9 @@ mysql_lease6_dump_test() {
 
     # Insert the reference record
     insert_sql="\
-insert into lease6 values(10,20,30,\"2015-04-04 01:15:30\",40,50,1,60,70,1,1,\"one.example.com\",80,90,100);\
-insert into lease6 values(11,NULL,30,\"2015-05-05 02:30:45\",40,50,1,60,70,1,1,\"\",80,90,100);\
-insert into lease6 values(12,21,30,\"2015-06-06 11:01:07\",40,50,1,60,70,1,1,\"three.example.com\",80,90,100);"
+insert into lease6 values(10,20,30,\"2015-04-04 01:15:30\",40,50,1,60,70,1,1,\"one.example.com\",80,90,100, 0);\
+insert into lease6 values(11,NULL,30,\"2015-05-05 02:30:45\",40,50,1,60,70,1,1,\"\",80,90,100, 0);\
+insert into lease6 values(12,21,30,\"2015-06-06 11:01:07\",40,50,1,60,70,1,1,\"three.example.com\",80,90,100, 0);"
 
     mysql_execute "$insert_sql"
     ERRCODE=$?