|
@@ -131,6 +131,20 @@ pgsql_upgrade_test() {
|
|
|
test_finish 0
|
|
|
}
|
|
|
|
|
|
+# Given a valid timestamp string, returns a timestamp with timezone string
|
|
|
+# for the give time localized by the PostgreSQL server.
|
|
|
+get_local_time() {
|
|
|
+ timestamp="$1"
|
|
|
+
|
|
|
+ # Expiration field is a "timestamp with timezone" so we need a reference
|
|
|
+ # time for the machine/DB this test is running upon.
|
|
|
+ ref_timestamp=`pgsql_execute "SELECT timestamptz '$1';"`
|
|
|
+ ERRCODE=$?
|
|
|
+ assert_eq 0 $ERRCODE "reference time query failed for [$timestamp], expected exit code %d, actual %d"
|
|
|
+ echo $ref_timestamp
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
# Test verifies the ability to dump lease4 data to CSV file
|
|
|
# The dump output file is compared against a reference file.
|
|
|
# If the dump is successful, the file contents will be the
|
|
@@ -172,11 +186,15 @@ pgsql_lease4_dump_test() {
|
|
|
ERRCODE=$?
|
|
|
assert_eq 0 $ERRCODE "could not create database, expected exit code %d, actual %d"
|
|
|
|
|
|
+ timestamp1="2015-01-01 01:15:30"
|
|
|
+ timestamp2="2015-02-02 02:30:45"
|
|
|
+ timestamp3="2015-03-03 11:01:07"
|
|
|
+
|
|
|
# Insert the reference records
|
|
|
insert_sql="\
|
|
|
-insert into lease4 values(10,E'\\x20',E'\\x30',40,'2001-01-01 00:00:00',50,'t','t','one.example.com');\
|
|
|
-insert into lease4 values(11,'',E'\\x0123',40,'2001-01-01 00:00:00',50,'t','t','');\
|
|
|
-insert into lease4 values(12,E'\\x22','',40,'2001-01-01 00:00:00',50,'t','t','three.example.com');"
|
|
|
+insert into lease4 values(10,E'\\x20',E'\\x30',40,'$timestamp1',50,'t','t','one.example.com');\
|
|
|
+insert into lease4 values(11,'',E'\\x0123',40,'$timestamp2',50,'t','t','');\
|
|
|
+insert into lease4 values(12,E'\\x22','',40,'$timestamp3',50,'t','t','three.example.com');"
|
|
|
|
|
|
pgsql_execute "$insert_sql"
|
|
|
ERRCODE=$?
|
|
@@ -187,17 +205,20 @@ insert into lease4 values(12,E'\\x22','',40,'2001-01-01 00:00:00',50,'t','t','th
|
|
|
ERRCODE=$?
|
|
|
assert_eq 0 $ERRCODE "kea-admin lease-dump -4 failed, status code %d"
|
|
|
|
|
|
- # Expiration field is a "timestamp with timezone" so we need a reference
|
|
|
- # time for the machine/DB this test is running upon.
|
|
|
- ref_timestamp=`pgsql_execute "SELECT timestamptz '2001-01-01 00:00:00';"`
|
|
|
- ERRCODE=$?
|
|
|
- assert_eq 0 $ERRCODE "reference time query failed, expected exit code %d, actual %d"
|
|
|
- printf "reference timestamp is [$ref_timestamp]\n"
|
|
|
+ # Expiration field is a "timestamp with timezone" so we need a localized reference
|
|
|
+ # times for the machine/DB this test is running upon.
|
|
|
+ local_timestamp1=`get_local_time "$timestamp1"`
|
|
|
+ local_timestamp2=`get_local_time "$timestamp2"`
|
|
|
+ local_timestamp3=`get_local_time "$timestamp3"`
|
|
|
|
|
|
# Create the comparison file by replacing the <timestamp> tags
|
|
|
# with the local reference timestamp
|
|
|
- sedstr="'s/<timestamp>/$ref_timestamp/g'"
|
|
|
- eval sed $sedstr $ref_file >$ref_file_tmp
|
|
|
+ sedstr="\
|
|
|
+sed 's/<timestamp1>/$local_timestamp1/g' $ref_file | \
|
|
|
+sed 's/<timestamp2>/$local_timestamp2/g' | \
|
|
|
+sed 's/<timestamp3>/$local_timestamp3/g' "
|
|
|
+
|
|
|
+ eval $sedstr >$ref_file_tmp
|
|
|
ERRCODE=$?
|
|
|
assert_eq 0 $ERRCODE "timestamp replacement failed, expected exit code %d, actual %d"
|
|
|
|
|
@@ -257,11 +278,15 @@ pgsql_lease6_dump_test() {
|
|
|
ERRCODE=$?
|
|
|
assert_eq 0 $ERRCODE "could not create database, status code %d"
|
|
|
|
|
|
+ timestamp1="2015-04-04 01:15:30"
|
|
|
+ timestamp2="2015-02-02 02:30:45"
|
|
|
+ timestamp3="2015-06-06 11:01:07"
|
|
|
+
|
|
|
# Insert the reference records
|
|
|
insert_sql="\
|
|
|
-insert into lease6 values(10,E'\\x20',30,'2001-01-01 00:00:00',40,50,1,60,70,'t','t','one.example.com');\
|
|
|
-insert into lease6 values(11,'',30,'2001-01-01 00:00:00',40,50,1,60,70,'t','t','');\
|
|
|
-insert into lease6 values(12,E'\\x21',30,'2001-01-01 00:00:00',40,50,1,60,70,'t','t','three.example.com');"
|
|
|
+insert into lease6 values(10,E'\\x20',30,'$timestamp1',40,50,1,60,70,'t','t','one.example.com');\
|
|
|
+insert into lease6 values(11,'',30,'$timestamp2',40,50,1,60,70,'t','t','');\
|
|
|
+insert into lease6 values(12,E'\\x21',30,'$timestamp3',40,50,1,60,70,'t','t','three.example.com');"
|
|
|
|
|
|
pgsql_execute "$insert_sql"
|
|
|
ERRCODE=$?
|
|
@@ -272,17 +297,20 @@ insert into lease6 values(12,E'\\x21',30,'2001-01-01 00:00:00',40,50,1,60,70,'t'
|
|
|
ERRCODE=$?
|
|
|
assert_eq 0 $ERRCODE "kea-admin lease-dump -6 failed, status code %d"
|
|
|
|
|
|
- # Expiration field is a "timestamp with timezone" so we need a reference
|
|
|
- # time for the machine/DB this test is running upon.
|
|
|
- ref_timestamp=`pgsql_execute "SELECT timestamptz '2001-01-01 00:00:00';"`
|
|
|
- ERRCODE=$?
|
|
|
- assert_eq 0 $ERRCODE "reference time query failed, expected exit code %d, actual %d"
|
|
|
- printf "reference timestamp is [$ref_timestamp]\n"
|
|
|
+ # Expiration field is a "timestamp with timezone" so we need a localized reference
|
|
|
+ # times for the machine/DB this test is running upon.
|
|
|
+ local_timestamp1=`get_local_time "$timestamp1"`
|
|
|
+ local_timestamp2=`get_local_time "$timestamp2"`
|
|
|
+ local_timestamp3=`get_local_time "$timestamp3"`
|
|
|
|
|
|
# Create the comparison file by replacing the <timestamp> tags
|
|
|
# with the local reference timestamp
|
|
|
- sedstr="'s/<timestamp>/$ref_timestamp/g'"
|
|
|
- eval sed $sedstr $ref_file >$ref_file_tmp
|
|
|
+ sedstr="\
|
|
|
+sed 's/<timestamp1>/$local_timestamp1/g' $ref_file | \
|
|
|
+sed 's/<timestamp2>/$local_timestamp2/g' | \
|
|
|
+sed 's/<timestamp3>/$local_timestamp3/g' "
|
|
|
+
|
|
|
+ eval $sedstr >$ref_file_tmp
|
|
|
ERRCODE=$?
|
|
|
assert_eq 0 $ERRCODE "timestamp replacement failed, expected exit code %d, actual %d"
|
|
|
|