mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-02 23:15:20 +00:00
[#2353] log exceptions in MySQL unit tests
This commit is contained in:
@@ -197,7 +197,7 @@ anything e.g. `DEBUG=true`. `unset DEBUG` to remove this behavior.
|
|||||||
%@endverbatim
|
%@endverbatim
|
||||||
|
|
||||||
The unit tests are run automatically when "make check" is executed (providing
|
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
|
section in the <a href="https://kea.readthedocs.io/">Kea Administrator
|
||||||
Reference Manual</a>).
|
Reference Manual</a>).
|
||||||
|
|
||||||
@@ -392,12 +392,12 @@ local all postgres trust
|
|||||||
@section unitTestsKerberos Kerberos Configuration for Unit Tests
|
@section unitTestsKerberos Kerberos Configuration for Unit Tests
|
||||||
|
|
||||||
The GSS-TSIG hook library uses the GSS-API with Kerberos. While there are
|
The GSS-TSIG hook library uses the GSS-API with Kerberos. While there are
|
||||||
no doubts that the hook can be safely used with a valid Kerberos configuration
|
no doubts that the hook can be safely used with a valid Kerberos configuration
|
||||||
in production, unit tests reported problems on some systems.
|
in production, unit tests reported problems on some systems.
|
||||||
|
|
||||||
GSS-TSIG hook unit tests use a setup inherited from bind9 with old crypto
|
GSS-TSIG hook unit tests use a setup inherited from bind9 with old crypto
|
||||||
settings which are not allowed by default Kerberos system configuration.
|
settings which are not allowed by default Kerberos system configuration.
|
||||||
A simple workaround is to set the KRB5_CONFIG environment variable to
|
A simple workaround is to set the KRB5_CONFIG environment variable to
|
||||||
a random value that doesn't match a file (e.g. KRB5_CONFIG=).
|
a random value that doesn't match a file (e.g. KRB5_CONFIG=).
|
||||||
|
|
||||||
@section writingShellScriptsAndTests Writing shell scripts and tests
|
@section writingShellScriptsAndTests Writing shell scripts and tests
|
||||||
|
@@ -9,10 +9,14 @@
|
|||||||
#include <exceptions/exceptions.h>
|
#include <exceptions/exceptions.h>
|
||||||
#include <mysql/mysql_connection.h>
|
#include <mysql/mysql_connection.h>
|
||||||
#include <mysql/testutils/mysql_schema.h>
|
#include <mysql/testutils/mysql_schema.h>
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
#include <testutils/gtest_utils.h>
|
||||||
#include <gtest/gtest.h>
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
|
||||||
using namespace isc::db;
|
using namespace isc::db;
|
||||||
using namespace isc::db::test;
|
using namespace isc::db::test;
|
||||||
|
|
||||||
@@ -185,8 +189,8 @@ public:
|
|||||||
ASSERT_FALSE(in_bindings[1]->amNull());
|
ASSERT_FALSE(in_bindings[1]->amNull());
|
||||||
|
|
||||||
// Store data in the database.
|
// Store data in the database.
|
||||||
ASSERT_NO_THROW(conn_.insertQuery(MySqlConnectionTest::INSERT_VALUE,
|
ASSERT_NO_THROW_LOG(conn_.insertQuery(MySqlConnectionTest::INSERT_VALUE,
|
||||||
in_bindings));
|
in_bindings));
|
||||||
|
|
||||||
// Create input binding for select query.
|
// Create input binding for select query.
|
||||||
MySqlBindingCollection bindings =
|
MySqlBindingCollection bindings =
|
||||||
@@ -204,9 +208,9 @@ public:
|
|||||||
|
|
||||||
// Execute select statement. We expect one row to be returned. For this
|
// Execute select statement. We expect one row to be returned. For this
|
||||||
// returned row the lambda provided as 4th argument should be executed.
|
// 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,
|
bindings, out_bindings,
|
||||||
[&](MySqlBindingCollection& out_bindings) {
|
[&](MySqlBindingCollection& out_bindings) {
|
||||||
|
|
||||||
// Compare received data with input data assuming they are both non-null.
|
// Compare received data with input data assuming they are both non-null.
|
||||||
|
|
||||||
@@ -436,7 +440,7 @@ public:
|
|||||||
MySqlBinding::createNull(),
|
MySqlBinding::createNull(),
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT_NO_THROW(
|
ASSERT_NO_THROW_LOG(
|
||||||
conn_.insertQuery(MySqlConnectionTest::INSERT_VALUE, in_bindings));
|
conn_.insertQuery(MySqlConnectionTest::INSERT_VALUE, in_bindings));
|
||||||
|
|
||||||
// This variable will be checked to see if the row has been deleted
|
// 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.
|
// Execute delete query but use int_value of non existing row.
|
||||||
// The row should not be deleted.
|
// The row should not be deleted.
|
||||||
in_bindings = {MySqlBinding::createInteger<uint32_t>(1)};
|
in_bindings = {MySqlBinding::createInteger<uint32_t>(1)};
|
||||||
ASSERT_NO_THROW(
|
ASSERT_NO_THROW_LOG(
|
||||||
deleted = conn_.updateDeleteQuery(
|
deleted = conn_.updateDeleteQuery(
|
||||||
MySqlConnectionTest::DELETE_BY_INT_VALUE, in_bindings));
|
MySqlConnectionTest::DELETE_BY_INT_VALUE, in_bindings));
|
||||||
ASSERT_FALSE(deleted);
|
ASSERT_FALSE(deleted);
|
||||||
|
|
||||||
// This time use the correct value.
|
// This time use the correct value.
|
||||||
in_bindings = {MySqlBinding::createInteger<uint32_t>(1024)};
|
in_bindings = {MySqlBinding::createInteger<uint32_t>(1024)};
|
||||||
ASSERT_NO_THROW(
|
ASSERT_NO_THROW_LOG(
|
||||||
deleted = conn_.updateDeleteQuery(
|
deleted = conn_.updateDeleteQuery(
|
||||||
MySqlConnectionTest::DELETE_BY_INT_VALUE, in_bindings));
|
MySqlConnectionTest::DELETE_BY_INT_VALUE, in_bindings));
|
||||||
// The row should have been deleted.
|
// The row should have been deleted.
|
||||||
@@ -469,15 +473,15 @@ public:
|
|||||||
MySqlBinding::createTimestamp(),
|
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,
|
in_bindings, out_bindings,
|
||||||
[&deleted](MySqlBindingCollection&) {
|
[&deleted](MySqlBindingCollection&) {
|
||||||
// This will be executed if the
|
// This will be executed if the
|
||||||
// row is returned as a result of
|
// row is returned as a result of
|
||||||
// select query. We expect that
|
// select query. We expect that
|
||||||
// this is not executed.
|
// this is not executed.
|
||||||
deleted = false;
|
deleted = false;
|
||||||
}));
|
}));
|
||||||
// Make sure that select query returned nothing.
|
// Make sure that select query returned nothing.
|
||||||
EXPECT_TRUE(deleted);
|
EXPECT_TRUE(deleted);
|
||||||
}
|
}
|
||||||
@@ -653,7 +657,7 @@ TEST_F(MySqlSchemaTest, checkVersion) {
|
|||||||
// Check version
|
// Check version
|
||||||
auto parameters = DatabaseConnection::parse(validMySQLConnectionString());
|
auto parameters = DatabaseConnection::parse(validMySQLConnectionString());
|
||||||
std::pair<uint32_t, uint32_t> version;
|
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_MAJOR, version.first);
|
||||||
EXPECT_EQ(MYSQL_SCHEMA_VERSION_MINOR, version.second);
|
EXPECT_EQ(MYSQL_SCHEMA_VERSION_MINOR, version.second);
|
||||||
}
|
}
|
||||||
@@ -697,7 +701,7 @@ TEST_F(MySqlSecureConnectionTest, Tcp) {
|
|||||||
VALID_HOST_TCP, VALID_USER,
|
VALID_HOST_TCP, VALID_USER,
|
||||||
VALID_PASSWORD);
|
VALID_PASSWORD);
|
||||||
MySqlConnection conn(DatabaseConnection::parse(conn_str));
|
MySqlConnection conn(DatabaseConnection::parse(conn_str));
|
||||||
ASSERT_NO_THROW(conn.openDatabase());
|
ASSERT_NO_THROW_LOG(conn.openDatabase());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Check the SSL/TLS protected connection.
|
/// @brief Check the SSL/TLS protected connection.
|
||||||
@@ -713,7 +717,7 @@ TEST_F(MySqlSecureConnectionTest, Tls) {
|
|||||||
VALID_CERT, VALID_KEY, VALID_CA,
|
VALID_CERT, VALID_KEY, VALID_CA,
|
||||||
VALID_CIPHER);
|
VALID_CIPHER);
|
||||||
MySqlConnection conn(DatabaseConnection::parse(conn_str));
|
MySqlConnection conn(DatabaseConnection::parse(conn_str));
|
||||||
ASSERT_NO_THROW(conn.openDatabase());
|
ASSERT_NO_THROW_LOG(conn.openDatabase());
|
||||||
EXPECT_TRUE(conn.getTls());
|
EXPECT_TRUE(conn.getTls());
|
||||||
std::string cipher = conn.getTlsCipher();
|
std::string cipher = conn.getTlsCipher();
|
||||||
EXPECT_FALSE(cipher.empty());
|
EXPECT_FALSE(cipher.empty());
|
||||||
|
Reference in New Issue
Block a user