From: Thomas Markwalder Date: Fri, 24 Jun 2016 17:22:20 +0000 (-0400) Subject: [4277] Rollback test passes X-Git-Tag: trac4551_base~12^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c22198304950758329176ba0f3c86bc77a6eb33;p=thirdparty%2Fkea.git [4277] Rollback test passes tests/pgsql_host_data_source_unittest.cc TEST_F(PgSqlHostDataSourceTest, testAddRollback) now functions and passes --- diff --git a/src/lib/dhcpsrv/pgsql_host_data_source.cc b/src/lib/dhcpsrv/pgsql_host_data_source.cc index c89a97e83f..ccf3397a5b 100644 --- a/src/lib/dhcpsrv/pgsql_host_data_source.cc +++ b/src/lib/dhcpsrv/pgsql_host_data_source.cc @@ -33,35 +33,9 @@ using namespace std; namespace { -#if 0 // TKM -/// @brief Maximum size of an IPv6 address represented as a text string. -/// -/// This is 32 hexadecimal characters written in 8 groups of four, plus seven -/// colon separators. -const size_t ADDRESS6_TEXT_MAX_LEN = 39; - -/// @brief Maximum length of classes stored in a dhcp4/6_client_classes -/// columns. -const size_t CLIENT_CLASSES_MAX_LEN = 255; - -/// @brief Maximum length of the hostname stored in DNS. -/// -/// This length is restricted by the length of the domain-name carried -/// in the Client FQDN %Option (see RFC4702 and RFC4704). -const size_t HOSTNAME_MAX_LEN = 255; -#endif - /// @brief Maximum length of option value. const size_t OPTION_VALUE_MAX_LEN = 4096; -#if 0 -/// @brief Maximum length of option value specified in textual format. -const size_t OPTION_FORMATTED_VALUE_MAX_LEN = 8192; - -/// @brief Maximum length of option space name. -const size_t OPTION_SPACE_MAX_LEN = 128; -#endif - /// @brief Numeric value representing last supported identifier. /// /// This value is used to validate whether the identifier type stored in @@ -1658,9 +1632,6 @@ PgSqlHostDataSource::add(const HostPtr& host) { uint32_t host_id = impl_->addStatement(PgSqlHostDataSourceImpl::INSERT_HOST, bind_array, true); - // @todo TKM take this out - std::cout << "id of new host: " << host_id << std::endl; - // Insert DHCPv4 options. ConstCfgOptionPtr cfg_option4 = host->getCfgOption4(); if (cfg_option4) { @@ -1889,20 +1860,5 @@ std::pair PgSqlHostDataSource::getVersion() const { return(impl_->getVersion()); } -#if 0 -// Do we really need these ? -void -PgSqlHostDataSource::commit() { - impl_->conn_.commit(); -} - - -void -PgSqlHostDataSource::rollback() { - impl_->conn_.rollback(); -} -#endif - - }; // end of isc::dhcp namespace }; // end of isc namespace diff --git a/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc b/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc index 205e2ce6d6..b58b60ee7a 100644 --- a/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc +++ b/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc @@ -231,7 +231,7 @@ TEST_F(PgSqlHostDataSourceTest, hostnameFQDN100) { testHostname("foo.example.org", 100); } -// Test verifies if a host without any hostname specified can be stored and +// Test verifies if a host without any hostname specified can be stored and // later retrieved. TEST_F(PgSqlHostDataSourceTest, noHostname) { testHostname("", 1); @@ -423,7 +423,6 @@ TEST_F(PgSqlHostDataSourceTest, formattedOptionsReservations46) { testOptionsReservations46(true); } -#if 0 // This test checks transactional insertion of the host information // into the database. The failure to insert host information at // any stage should cause the whole transaction to be rolled back. @@ -443,9 +442,10 @@ TEST_F(PgSqlHostDataSourceTest, testAddRollback) { params["password"] = "keatest"; PgSqlConnection conn(params); ASSERT_NO_THROW(conn.openDatabase()); - int status = mysql_query(conn.mysql_, - "DROP TABLE IF EXISTS ipv6_reservations"); - ASSERT_EQ(0, status) << mysql_error(conn.mysql_); + + PgSqlResult r(PQexec(conn, "DROP TABLE IF EXISTS ipv6_reservations")); + ASSERT_TRUE (PQresultStatus(r) == PGRES_COMMAND_OK) + << " drop command failed :" << PQerrorMessage(conn); // Create a host with a reservation. HostPtr host = initializeHost6("2001:db8:1::1", Host::IDENT_HWADDR, false); @@ -470,6 +470,5 @@ TEST_F(PgSqlHostDataSourceTest, testAddRollback) { host->getIdentifier().size()); EXPECT_FALSE(from_hds); } -#endif }; // Of anonymous namespace