]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
sort exported vlues and save them as csv
authorRazvan Becheriu <razvan@isc.org>
Tue, 14 May 2019 14:30:08 +0000 (17:30 +0300)
committerRazvan Becheriu <razvan@isc.org>
Wed, 22 May 2019 16:53:22 +0000 (19:53 +0300)
src/bin/admin/tests/cql_tests.sh.in
src/bin/admin/tests/data/cql.lease6_dump_test.reference.csv
src/bin/admin/tests/data/cql.subnet_id_test.reference.csv

index 44a6888753f122b1ae4fb51ddc80ca26b84fcf86..02a06ab6a45dba88ab3a40754c4b05259be5d01b 100644 (file)
@@ -120,8 +120,7 @@ cql_lease4_dump_test() {
     script_dir="@abs_top_srcdir@/src/bin/admin/scripts"
 
     output_file="$output_dir/data/cql.lease4_dump_test.output.csv"
-    tmp_file="$output_file.tmp"
-
+    sorted_file="$output_dir/data/cql.lease4_dump_test.output.sorted.csv"
     ref_file="$test_dir/data/cql.lease4_dump_test.reference.csv"
 
     # Wipe out any residuals from prior failed runs.
@@ -130,9 +129,9 @@ cql_lease4_dump_test() {
         rm $output_file
     fi
 
-    if [ -e $tmp_file ]
+    if [ -e $sorted_file ]
     then
-        rm $tmp_file
+        rm $sorted_file
     fi
 
     # Wipe the database.
@@ -167,13 +166,19 @@ cql_lease4_dump_test() {
     $keaadmin lease-dump cql -4 -u $db_user -p $db_password -n $db_name -d $db_scripts_dir -o $output_file
     assert_eq 0 $? "kea-admin lease-dump -4 failed, expected exit code %d, actual %d"
 
+    # sort data so we can compare
+    cat $output_file | sort -g > $sorted_file
+
     # Compare the dump output to reference file, they should be identical.
-    cmp -s $output_file  $ref_file
+    cmp -s $sorted_file $ref_file
     assert_eq 0 $? "dump file does not match reference file, expected exit code %d, actual %d"
 
     # remove the output file.
     rm $output_file
 
+    # remove the sorted file.
+    rm $sorted_file
+
     # Wipe the database.
     cql_wipe
 
@@ -188,8 +193,7 @@ cql_lease6_dump_test() {
     script_dir="@abs_top_srcdir@/src/bin/admin/scripts"
 
     output_file="$output_dir/data/cql.lease6_dump_test.output.csv"
-    tmp_file="$output_file.tmp"
-
+    sorted_file="$output_dir/data/cql.lease6_dump_test.output.sorted.csv"
     ref_file="$test_dir/data/cql.lease6_dump_test.reference.csv"
 
     # Wipe out any residuals from prior failed runs.
@@ -198,9 +202,9 @@ cql_lease6_dump_test() {
         rm $output_file
     fi
 
-    if [ -e $tmp_file ]
+    if [ -e $sorted_file ]
     then
-        rm $tmp_file
+        rm $sorted_file
     fi
 
     # Wipe the database.
@@ -238,13 +242,19 @@ cql_lease6_dump_test() {
     $keaadmin lease-dump cql -6 -u $db_user -p $db_password -n $db_name -d $db_scripts_dir -o $output_file
     assert_eq 0 $? "kea-admin lease-dump -6 failed, status code %d"
 
+    # sort data so we can compare
+    cat $output_file | sort -g > $sorted_file
+
     # Compare the dump output to reference file, they should be identical.
-    cmp -s $output_file  $ref_file
+    cmp -s $sorted_file $ref_file
     assert_eq 0 $? "dump file does not match reference file, expected exit code %d, actual %d"
 
     # remove the output file.
     rm $output_file
 
+    # remove the sorted file.
+    rm $sorted_file
+
     # Wipe the database.
     cql_wipe
 
@@ -331,6 +341,7 @@ cql_unused_subnet_id_test() {
 
     output_dir="@abs_top_builddir@/src/bin/admin/tests"
     export_file="$output_dir/data/cql.subnet_id_test.csv"
+    sorted_file="$output_dir/data/cql.subnet_id_test.sorted.csv"
 
     # Fetch host_reservation data for comparison
     echo "Exporting host_reservation data to $export_file ..."
@@ -341,13 +352,20 @@ cql_unused_subnet_id_test() {
 
     cql_execute "$qry" > $export_file
     assert_eq 0 $? "insert hosts failed, expected exit code: %d, actual: %d"
+
+    # sort data so we can compare
+    cat $export_file | grep "|" | sort -V > $sorted_file
+
     # Compare the dump output to reference file, they should be identical.
-    cmp -s $export_file $ref_file
+    cmp -s $sorted_file $ref_file
     assert_eq 0 $? "export file does not match reference file, expected exit code %d, actual %d"
 
     # remove the output file.
     rm $export_file
 
+    # remove the sorted file.
+    rm $sorted_file
+
     # Wipe the database.
     cql_wipe
 
index 5763429f4ca15f8cb79b01d730caae8c48664bec..6e531db529ba192c77f53a6958a140bb13300200 100644 (file)
@@ -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,state,user_context
-2001:db8::12,0x3231,30,1436173267,40,50,1,60,70,True,True,three.example.com,0x3830,90,4,2,
-2001:db8::11,null,30,1433464245,40,50,1,60,70,True,True,,0x3830,90,1,1,
 2001:db8::10,0x3230,30,1430694930,40,50,1,60,70,True,True,one.example.com,0x3830,90,16,0,
+2001:db8::11,null,30,1433464245,40,50,1,60,70,True,True,,0x3830,90,1,1,
+2001:db8::12,0x3231,30,1436173267,40,50,1,60,70,True,True,three.example.com,0x3830,90,4,2,
index a593be56727d82ed150e6a0c8cf24c9650fe2437..724264ad211793a7e55016b8f68e00ab4fce37ea 100644 (file)
@@ -1,10 +1,6 @@
-
- id | host_ipv4_subnet_id | host_ipv6_subnet_id | option_subnet_id
-----+---------------------+---------------------+------------------
-  2 |                   4 |                  -1 |                4
-  4 |                   4 |                   6 |               -1
-  3 |                  -1 |                   6 |                6
-  5 |                  -1 |                   6 |                6
-  1 |                  -1 |                  -1 |               -1
-
-(5 rows)
+id,host_ipv4_subnet_id,host_ipv6_subnet_id,option_subnet_id
+1,-1,-1,-1
+2,4,-1,4
+3,-1,6,6
+4,4,6,-1
+5,-1,6,6