UTs fail when kea-admin is installed
The following tests fail:
[ FAILED ] 6 tests, listed below:
[ FAILED ] MySqlOpenTest.OpenDatabase
[ FAILED ] MySqlHostDataSource.OpenDatabase
[ FAILED ] MySqlHostDataSource.OpenDatabaseMultiThreading
[ FAILED ] PgSqlOpenTest.OpenDatabase
[ FAILED ] PgSqlHostDataSource.OpenDatabase
[ FAILED ] PgSqlHostDataSource.OpenDatabaseMultiThreading
When kea is built and installed to a non-standard prefix. If you hide or delete the installed kea-admin, the UTs pass.
The following is UT output with logging visible for failed test MySqlOpenTest.OpenDatabase;
2024-05-20 11:27:32.450 INFO [kea.dhcpsrv/237474.140363241547648] DHCPSRV_MYSQL_DB opening MySQL lease database: connect-timeout=foo host=localhost name=keatest password=***** type=mysql user=keatest
2024-05-20 11:27:32.450 INFO [kea.database/237474.140363241547648] DATABASE_MYSQL_INITIALIZE_SCHEMA Initializing the MySQL schema with command: /home/tmark/labs/var/kea/3223/sbin/kea-admin db-init mysql --extra --connect_timeout foo --host localhost --name keatest --password keatest --user keatest.
Checking if there is a database initialized already...
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [ERROR] Unknown suffix 'f' used for variable 'connect_timeout' (value 'foo').
mysql: [ERROR] mysql: Error while setting value 'foo' to 'connect_timeout'.
ERROR/kea-admin: mysql_init table query failed, mysql status = 9
mysql_lease_mgr_unittest.cc:191: Failure
Expected: LeaseMgrFactory::create(connectionString( MYSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD, INVALID_TIMEOUT_1)) throws an exception of type DbInvalidTimeout.
Actual: it throws a different type.
2024-05-20 11:27:32.499 INFO [kea.dhcpsrv/237474.140363241547648] DHCPSRV_MYSQL_DB opening MySQL lease database: connect-timeout=-17 host=localhost name=keatest password=***** type=mysql user=keatest
2024-05-20 11:27:32.499 INFO [kea.database/237474.140363241547648] DATABASE_MYSQL_INITIALIZE_SCHEMA Initializing the MySQL schema with command: /home/tmark/labs/var/kea/3223/sbin/kea-admin db-init mysql --extra --connect_timeout -17 --host localhost --name keatest --password keatest --user keatest.
Checking if there is a database initialized already...
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] option 'connect_timeout': value -17 adjusted to 0.
ERROR/kea-admin: Expected empty database keatest. Aborting, the following tables are present:
dhcp4_audit....
Here is the same test passing once installed kea-admin is deleted:
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
2024-05-20 11:35:52.938 INFO [kea.dhcpsrv/237692.140404974946176] DHCPSRV_MYSQL_DB opening MySQL lease database: host=localhost name=keatest password=***** type=mysql user=keatest
2024-05-20 11:35:52.946 DEBUG [kea.dhcpsrv/237692.140404974946176] DHCPSRV_CLOSE_DB closing currently open mysql database
2024-05-20 11:35:52.947 INFO [kea.dhcpsrv/237692.140404974946176] DHCPSRV_MYSQL_DB opening MySQL lease database: connect-timeout=10 host=localhost name=keatest password=***** type=mysql user=keatest
2024-05-20 11:35:52.953 DEBUG [kea.dhcpsrv/237692.140404974946176] DHCPSRV_CLOSE_DB closing currently open mysql database
2024-05-20 11:35:52.953 ERROR [kea.dhcpsrv/237692.140404974946176] DHCPSRV_NOTYPE_DB no 'type' keyword to determine database backend: name=keatest host=localhost user=invaliduser password=keatest
2024-05-20 11:35:52.953 ERROR [kea.dhcpsrv/237692.140404974946176] DHCPSRV_UNKNOWN_DB unknown database type: unknown
2024-05-20 11:35:52.953 INFO [kea.dhcpsrv/237692.140404974946176] DHCPSRV_MYSQL_DB opening MySQL lease database: host=localhost name=invalidname password=***** type=mysql user=keatest
2024-05-20 11:35:52.954 INFO [kea.dhcpsrv/237692.140404974946176] DHCPSRV_MYSQL_DB opening MySQL lease database: host=invalidhost name=keatest password=***** type=mysql user=keatest
2024-05-20 11:35:53.064 INFO [kea.dhcpsrv/237692.140404974946176] DHCPSRV_MYSQL_DB opening MySQL lease database: host=localhost name=keatest password=***** type=mysql user=invaliduser
2024-05-20 11:35:53.066 INFO [kea.dhcpsrv/237692.140404974946176] DHCPSRV_MYSQL_DB opening MySQL lease database: host=localhost name=keatest password=***** type=mysql user=keatest
2024-05-20 11:35:53.067 INFO [kea.dhcpsrv/237692.140404974946176] DHCPSRV_MYSQL_DB opening MySQL lease database: connect-timeout=foo host=localhost name=keatest password=***** type=mysql user=keatest
2024-05-20 11:35:53.068 INFO [kea.dhcpsrv/237692.140404974946176] DHCPSRV_MYSQL_DB opening MySQL lease database: connect-timeout=-17 host=localhost name=keatest password=***** type=mysql user=keatest
2024-05-20 11:35:53.068 INFO [kea.dhcpsrv/237692.140404974946176] DHCPSRV_MYSQL_DB opening MySQL lease database: host=localhost password=***** type=mysql user=keatest
2024-05-20 11:35:53.069 INFO [kea.dhcpsrv/237692.140404974946176] DHCPSRV_MYSQL_DB opening MySQL lease database: extended-info-tables=true host=localhost name=keatest password=***** type=mysql user=keatest
2024-05-20 11:35:53.096 DEBUG [kea.dhcpsrv/237692.140404974946176] DHCPSRV_CLOSE_DB closing currently open mysql database
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
[ OK ] MySqlOpenTest.OpenDatabase (220 ms)
[ RUN ] MySqlOpenTest.OpenDatabaseMultiThreading
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
2024-05-20 11:35:53.162 INFO [kea.dhcpsrv/237692.140404974946176] DHCPSRV_MYSQL_DB opening MySQL lease database: host=localhost name=keatest password=***** type=mysql user=keatest
2024-05-20 11:35:53.167 DEBUG [kea.dhcpsrv/237692.140404974946176] DHCPSRV_CLOSE_DB closing currently open mysql database
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
The test that fails is passing an invalid connection timeout "foo", which does not throw a DbOpenError* exception, it throws a DbInvalidTimeout exception (I think) which we then mistakenly decide is a missing schema. When we attempt to run kea-admin that fails though I do not know if it fails because of the bad parameters or something path-related. Not sure why it makes difference where kea-admin is found but it does.
At the very least we should avoid attempting to update the schema when we know the error is a bad parameter.
I've attached config.report: