address,duid,valid_lifetime,expire,subnet_id,pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname,hwaddr,state,user_context,hwtype,hwaddr_source,pool_id
::10,32:30:33,30,1642000000,40,50,0,60,128,1,1,one.example.com,38:30,0,,90,16,0
::11,32:31:33,30,1643210000,40,50,0,60,128,1,1,,38:30,1,{ },90,1,0
-::12,32:32:33,30,1643212345,40,50,0,60,128,1,1,threeˎxampleˌom,38:30,2,{ "a": 1, "b": "c" },90,4,0
+::12,32:32:33,30,1643212345,40,50,0,60,128,1,1,threeˎxampleˌom,38:30,2,{ "a": 1, "b": "c" },0,0,0
+::13,32:33:33,30,1700000000,40,50,0,60,128,1,1,no.hwaddr.only.duid,,2,,0,0,0
# Insert the reference record
insert_sql="\
-insert into lease6 values(inet6_aton('::10'),203,30,(SELECT FROM_UNIXTIME(1642000000)),40,50,0,60,128,1,1,'one.example.com',80,90,16,0,NULL,0);\
-insert into lease6 values(inet6_aton('::11'),213,30,(SELECT FROM_UNIXTIME(1643210000)),40,50,0,60,128,1,1,'',80,90,1,1,'{ }',0);\
-insert into lease6 values(inet6_aton('::12'),223,30,(SELECT FROM_UNIXTIME(1643212345)),40,50,0,60,128,1,1,'three,example,com',80,90,4,2,'{ \"a\": 1, \"b\": \"c\" }',0)"
+insert into lease6 values(inet6_aton('::10'),203,30,(SELECT FROM_UNIXTIME(1642000000)),40,50,0,60,128,1,1,'one.example.com',80,90,16,0,NULL,0); \
+insert into lease6 values(inet6_aton('::11'),213,30,(SELECT FROM_UNIXTIME(1643210000)),40,50,0,60,128,1,1,'',80,90,1,1,'{ }',0); \
+insert into lease6 values(inet6_aton('::12'),223,30,(SELECT FROM_UNIXTIME(1643212345)),40,50,0,60,128,1,1,'three,example,com',80,0,0,2,'{ \"a\": 1, \"b\": \"c\" }',0); \
+insert into lease6 values(inet6_aton('::13'),233,30,(SELECT FROM_UNIXTIME(1700000000)),40,50,0,60,128,1,1,'no.hwaddr.only.duid',NULL,0,0,2,'',0); \
+"
run_command \
mysql_execute "$insert_sql"
insert_sql="\
insert into lease6 values(cast('::10' as inet),E'\\\\x323033',30,TO_TIMESTAMP(1642000000),40,50,0,60,128,'t','t','one.example.com',0,decode(encode('80','hex'),'hex'),90,16,'',0); \
insert into lease6 values(cast('::11' as inet),E'\\\\x323133',30,TO_TIMESTAMP(1643210000),40,50,0,60,128,'t','t','',1,decode(encode('80','hex'),'hex'),90,1,'{ }',0); \
-insert into lease6 values(cast('::12' as inet),E'\\\\x323233',30,TO_TIMESTAMP(1643212345),40,50,0,60,128,'t','t','three,example,com',2,decode(encode('80','hex'),'hex'),90,4,'{ \"a\": 1, \"b\": \"c\" }',0)"
+insert into lease6 values(cast('::12' as inet),E'\\\\x323233',30,TO_TIMESTAMP(1643212345),40,50,0,60,128,'t','t','three,example,com',2,decode(encode('80','hex'),'hex'),0,0,'{ \"a\": 1, \"b\": \"c\" }',0); \
+insert into lease6 values(cast('::13' as inet),E'\\\\x323333',30,TO_TIMESTAMP(1700000000),40,50,0,60,128,'t','t','no.hwaddr.only.duid',2,NULL,0,0,'',0); \
+"
run_command \
pgsql_execute "$insert_sql"
// We have several entries for different leases, the naming is:
// <lease letter>_<version#>.
string a_1 = "2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
- "200,200,8,100,0,7,0,1,1,host.example.com,,1,,,,0\n";
+ "200,200,8,100,0,7,0,1,1,host.example.com,,1,,0,0,0\n";
string a_2 = "2001:db8:1::1,,200,200,8,100,0,7,0,1,1,"
- "host.example.com,,1,,,,0\n";
+ "host.example.com,,1,,0,0,0\n";
string a_3 = "2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
- "200,400,8,100,0,7,0,1,1,host.example.com,,1,,,,0\n";
+ "200,400,8,100,0,7,0,1,1,host.example.com,,1,,0,0,0\n";
string a_4 = "2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
"0,200,8,100,0,7,0,1,1,host.example.com,,1,"
- "{ \"foo\": true },,,0\n";
+ "{ \"foo\": true },0,0,0\n";
string b_1 = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
- "300,300,6,150,0,8,0,0,0,,,1,{ \"bar\": false },,,0\n";
+ "300,300,6,150,0,8,0,0,0,,,1,{ \"bar\": false },0,0,0\n";
string b_2 = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
- "300,800,6,150,0,8,0,0,0,,,1,,,,0\n";
+ "300,800,6,150,0,8,0,0,0,,,1,,0,0,0\n";
string b_3 = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
- "300,1000,6,150,0,8,0,0,0,,,1,,,,0\n";
+ "300,1000,6,150,0,8,0,0,0,,,1,,0,0,0\n";
string c_1 = "3000:1::,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
- "100,200,8,0,2,16,64,0,0,,,1,,,,0\n";
+ "100,200,8,0,2,16,64,0,0,,,1,,0,0,0\n";
string c_2 = "3000:1::,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
- "100,400,8,0,2,16,64,0,0,,,1,,,,0\n";
+ "100,400,8,0,2,16,64,0,0,,,1,,0,0,0\n";
string d_1 = "2001:db8:1::3,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
- "200,600,8,100,0,7,0,1,1,host.example.com,,1,,,,0\n";
+ "200,600,8,100,0,7,0,1,1,host.example.com,,1,,0,0,0\n";
// new files have 128 prefixlen for non PD type
string a_3_n = "2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
- "200,400,8,100,0,7,128,1,1,host.example.com,,1,,,,0\n";
+ "200,400,8,100,0,7,128,1,1,host.example.com,,1,,0,0,0\n";
string b_2_n = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
- "300,800,6,150,0,8,128,0,0,,,1,,,,0\n";
+ "300,800,6,150,0,8,128,0,0,,,1,,0,0,0\n";
string b_3_n = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
- "300,1000,6,150,0,8,128,0,0,,,1,,,,0\n";
+ "300,1000,6,150,0,8,128,0,0,,,1,,0,0,0\n";
string d_1_n = "2001:db8:1::3,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
- "200,600,8,100,0,7,128,1,1,host.example.com,,1,,,,0\n";
+ "200,600,8,100,0,7,128,1,1,host.example.com,,1,,0,0,0\n";
// Subtest 1: both previous and copy available
// Create the test previous file
"lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname,hwaddr,"
"state,user_context,hwtype,hwaddr_source,pool_id\n"
"2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
- "200,200,8,100,0,7,128,1,1,host.example.com,,0,,,,0\n"
+ "200,200,8,100,0,7,128,1,1,host.example.com,,0,,0,0,0\n"
"2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05"
- ",300,300,6,150,0,8,128,0,0,,,0,,,,0\n"
+ ",300,300,6,150,0,8,128,0,0,,,0,,0,0,0\n"
"3000:1:1::,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
- "300,300,10,150,2,7,64,0,0,,,0,{ \"foobar\": true },,,0\n"
- "2001:db8:2::10,00:00:00,300,300,6,150,0,8,128,0,0,,,1,,,,0\n",
+ "300,300,10,150,2,7,64,0,0,,,0,{ \"foobar\": true },0,0,0\n"
+ "2001:db8:2::10,00:00:00,300,300,6,150,0,8,128,0,0,,,1,,0,0,0\n",
io_.readFile());
}
"{ \"foobar\": true },,,0\n";
std::string b_1 = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
- "300,300,6,150,0,8,0,0,0,,,1,,,,0\n";
+ "300,300,6,150,0,8,0,0,0,,,1,,0,0,0\n";
std::string b_2 = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
- "300,800,6,150,0,8,0,0,0,,,1,,,,0\n";
+ "300,800,6,150,0,8,0,0,0,,,1,,0,0,0\n";
std::string c_1 = "3000:1::,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
- "100,200,8,0,2,16,64,0,0,,,1,,,,0\n";
+ "100,200,8,0,2,16,64,0,0,,,1,,0,0,0\n";
// new files have 128 prefixlen for non PD type
std::string a_3_n = "2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
"200,400,8,100,0,7,128,1,1,host.example.com,,1,"
- "{ \"foobar\": true },,,0\n";
+ "{ \"foobar\": true },0,0,0\n";
std::string b_2_n = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
- "300,800,6,150,0,8,128,0,0,,,1,,,,0\n";
+ "300,800,6,150,0,8,128,0,0,,,1,,0,0,0\n";
// Create a lease file with three valid leases: 2001:db8:1::1,
// 3000:1:: and 2001:db8:2::10.
// new files have 128 prefixlen for non PD type
std::string b_2_n = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
- "300,800,6,150,0,8,128,0,0,,,1,,,,0\n";
+ "300,800,6,150,0,8,128,0,0,,,1,,0,0,0\n";
// Create lease file in which one of the entries for the 2001:db8:1::1
// has valid lifetime set to 0, in which case the lease should be
std::string update_file_contents = new_file_contents +
"3000::1,00:00:00:00:00:00:00:00:00:00:00:00:00,400,"
- "400,2,300,0,123,128,0,0,,,0,,,,0\n";
+ "400,2,300,0,123,128,0,0,,,0,,0,0,0\n";
EXPECT_EQ(update_file_contents, current_file.readFile());
// This string contains the contents of the lease file we
// entry each.
std::string result_file_contents = new_file_contents +
"2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,200,800,"
- "8,100,0,7,128,1,1,,,1,{ \"foo\": true },,,0\n"
+ "8,100,0,7,128,1,1,,,1,{ \"foo\": true },0,0,0\n"
"2001:db8:1::2,01:01:01:01:01:01:01:01:01:01:01:01:01,200,800,"
- "8,100,0,7,128,1,1,,,1,,,,0\n";
+ "8,100,0,7,128,1,1,,,1,,0,0,0\n";
// The LFC should have created a file with the two leases and moved it
// to leasefile6_0.csv.2
// the same.
std::string input_file_contents = new_file_contents +
"2001:db8:1::2,01:01:01:01:01:01:01:01:01:01:01:01:01,200,800,"
- "8,100,0,7,128,1,1,,,1,{ \"foo\": true },,,0\n";
+ "8,100,0,7,128,1,1,,,1,{ \"foo\": true },0,0,0\n";
LeaseFileIO input_file(getLeaseFilePath("leasefile6_0.csv.1"));
input_file.writeFile(input_file_contents);
// Verify cleaned, converted contents
std::string result_file_contents = header_5_0 +
"2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,200,800,"
- "8,100,0,7,128,1,1,,,0,,,,0\n"
+ "8,100,0,7,128,1,1,,,0,,0,0,0\n"
"2001:db8:1::2,01:01:01:01:01:01:01:01:01:01:01:01:01,200,800,"
"8,100,0,7,128,1,1,,11:22:33:44:55,0,,1,0,0\n";
EXPECT_EQ(result_file_contents, input_file.readFile());