2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-03 23:45:27 +00:00

[#2353] log exceptions in MySQL unit tests

This commit is contained in:
Andrei Pavel
2022-03-11 11:00:00 +02:00
parent e94ea10fbf
commit 7fb02feefc
2 changed files with 29 additions and 25 deletions

View File

@@ -197,7 +197,7 @@ anything e.g. `DEBUG=true`. `unset DEBUG` to remove this behavior.
%@endverbatim
The unit tests are run automatically when "make check" is executed (providing
that Kea has been build with the \c --with-mysql switch (see the installation
that Kea has been built with the \c --with-mysql switch (see the installation
section in the <a href="https://kea.readthedocs.io/">Kea Administrator
Reference Manual</a>).

View File

@@ -9,10 +9,14 @@
#include <exceptions/exceptions.h>
#include <mysql/mysql_connection.h>
#include <mysql/testutils/mysql_schema.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <gtest/gtest.h>
#include <testutils/gtest_utils.h>
#include <array>
#include <gtest/gtest.h>
#include <boost/date_time/posix_time/posix_time.hpp>
using namespace isc::db;
using namespace isc::db::test;
@@ -185,7 +189,7 @@ public:
ASSERT_FALSE(in_bindings[1]->amNull());
// Store data in the database.
ASSERT_NO_THROW(conn_.insertQuery(MySqlConnectionTest::INSERT_VALUE,
ASSERT_NO_THROW_LOG(conn_.insertQuery(MySqlConnectionTest::INSERT_VALUE,
in_bindings));
// Create input binding for select query.
@@ -204,7 +208,7 @@ public:
// Execute select statement. We expect one row to be returned. For this
// returned row the lambda provided as 4th argument should be executed.
ASSERT_NO_THROW(conn_.selectQuery(MySqlConnectionTest::GET_BY_INT_VALUE,
ASSERT_NO_THROW_LOG(conn_.selectQuery(MySqlConnectionTest::GET_BY_INT_VALUE,
bindings, out_bindings,
[&](MySqlBindingCollection& out_bindings) {
@@ -436,7 +440,7 @@ public:
MySqlBinding::createNull(),
};
ASSERT_NO_THROW(
ASSERT_NO_THROW_LOG(
conn_.insertQuery(MySqlConnectionTest::INSERT_VALUE, in_bindings));
// This variable will be checked to see if the row has been deleted
@@ -446,14 +450,14 @@ public:
// Execute delete query but use int_value of non existing row.
// The row should not be deleted.
in_bindings = {MySqlBinding::createInteger<uint32_t>(1)};
ASSERT_NO_THROW(
ASSERT_NO_THROW_LOG(
deleted = conn_.updateDeleteQuery(
MySqlConnectionTest::DELETE_BY_INT_VALUE, in_bindings));
ASSERT_FALSE(deleted);
// This time use the correct value.
in_bindings = {MySqlBinding::createInteger<uint32_t>(1024)};
ASSERT_NO_THROW(
ASSERT_NO_THROW_LOG(
deleted = conn_.updateDeleteQuery(
MySqlConnectionTest::DELETE_BY_INT_VALUE, in_bindings));
// The row should have been deleted.
@@ -469,7 +473,7 @@ public:
MySqlBinding::createTimestamp(),
};
ASSERT_NO_THROW(conn_.selectQuery(MySqlConnectionTest::GET_BY_INT_VALUE,
ASSERT_NO_THROW_LOG(conn_.selectQuery(MySqlConnectionTest::GET_BY_INT_VALUE,
in_bindings, out_bindings,
[&deleted](MySqlBindingCollection&) {
// This will be executed if the
@@ -653,7 +657,7 @@ TEST_F(MySqlSchemaTest, checkVersion) {
// Check version
auto parameters = DatabaseConnection::parse(validMySQLConnectionString());
std::pair<uint32_t, uint32_t> version;
ASSERT_NO_THROW(version = MySqlConnection::getVersion(parameters));
ASSERT_NO_THROW_LOG(version = MySqlConnection::getVersion(parameters));
EXPECT_EQ(MYSQL_SCHEMA_VERSION_MAJOR, version.first);
EXPECT_EQ(MYSQL_SCHEMA_VERSION_MINOR, version.second);
}
@@ -697,7 +701,7 @@ TEST_F(MySqlSecureConnectionTest, Tcp) {
VALID_HOST_TCP, VALID_USER,
VALID_PASSWORD);
MySqlConnection conn(DatabaseConnection::parse(conn_str));
ASSERT_NO_THROW(conn.openDatabase());
ASSERT_NO_THROW_LOG(conn.openDatabase());
}
/// @brief Check the SSL/TLS protected connection.
@@ -713,7 +717,7 @@ TEST_F(MySqlSecureConnectionTest, Tls) {
VALID_CERT, VALID_KEY, VALID_CA,
VALID_CIPHER);
MySqlConnection conn(DatabaseConnection::parse(conn_str));
ASSERT_NO_THROW(conn.openDatabase());
ASSERT_NO_THROW_LOG(conn.openDatabase());
EXPECT_TRUE(conn.getTls());
std::string cipher = conn.getTlsCipher();
EXPECT_FALSE(cipher.empty());