Commit df8b6739 authored by Razvan Becheriu's avatar Razvan Becheriu
Browse files

sort exported vlues and save them as csv

parent b912c5a0
......@@ -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
......
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,
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment