Commit 4c07c122 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[4489] Added unit test for read only mode in PgSQL backend.

parent 65d3817d
...@@ -1787,8 +1787,6 @@ public: ...@@ -1787,8 +1787,6 @@ public:
/// @brief Indicates if the database is opened in read only mode. /// @brief Indicates if the database is opened in read only mode.
bool is_readonly_; bool is_readonly_;
namespace {
}; };
...@@ -1948,8 +1946,6 @@ TaggedStatementArray tagged_statements = { { ...@@ -1948,8 +1946,6 @@ TaggedStatementArray tagged_statements = { {
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 3)"}} " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 3)"}}
}; };
}; // end anonymouse namespace
MySqlHostDataSourceImpl:: MySqlHostDataSourceImpl::
MySqlHostDataSourceImpl(const MySqlConnection::ParameterMap& parameters) MySqlHostDataSourceImpl(const MySqlConnection::ParameterMap& parameters)
: host_exchange_(new MySqlHostWithOptionsExchange(MySqlHostWithOptionsExchange::DHCP4_ONLY)), : host_exchange_(new MySqlHostWithOptionsExchange(MySqlHostWithOptionsExchange::DHCP4_ONLY)),
......
...@@ -64,8 +64,13 @@ public: ...@@ -64,8 +64,13 @@ public:
/// close the database. Then reopen it and delete everything created by /// close the database. Then reopen it and delete everything created by
/// the test. /// the test.
virtual ~PgSqlHostDataSourceTest() { virtual ~PgSqlHostDataSourceTest() {
hdsptr_->rollback(); try {
hdsptr_->rollback();
} catch (...) {
// Rollback may fail if backend is in read only mode. That's ok.
}
HostDataSourceFactory::destroy(); HostDataSourceFactory::destroy();
hdsptr_.reset();
destroyPgSQLSchema(); destroyPgSQLSchema();
} }
...@@ -168,6 +173,12 @@ TEST(PgSqlHostDataSource, OpenDatabase) { ...@@ -168,6 +173,12 @@ TEST(PgSqlHostDataSource, OpenDatabase) {
destroyPgSQLSchema(); destroyPgSQLSchema();
} }
// This test verifies that database backend can operate in Read-Only mode.
TEST_F(PgSqlHostDataSourceTest, testReadOnlyDatabase) {
testReadOnlyDatabase(PGSQL_VALID_TYPE);
}
// Test verifies if a host reservation can be added and later retrieved by IPv4 // Test verifies if a host reservation can be added and later retrieved by IPv4
// address. Host uses hw address as identifier. // address. Host uses hw address as identifier.
TEST_F(PgSqlHostDataSourceTest, basic4HWAddr) { TEST_F(PgSqlHostDataSourceTest, basic4HWAddr) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment