From: JINMEI Tatuya Date: Tue, 23 Oct 2012 06:03:02 +0000 (-0700) Subject: [2212] ported command test's loadBrokenZone test. X-Git-Tag: trac2487_base~23^2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ff2ddee910f9a53bd1dd47c432c99a280a6d076;p=thirdparty%2Fkea.git [2212] ported command test's loadBrokenZone test. now catch exceptions from reload(). --- diff --git a/src/bin/auth/datasrc_clients_mgr.h b/src/bin/auth/datasrc_clients_mgr.h index 667ec32f40..aef7f02a91 100644 --- a/src/bin/auth/datasrc_clients_mgr.h +++ b/src/bin/auth/datasrc_clients_mgr.h @@ -490,9 +490,16 @@ DataSrcClientsBuilderBase::doLoadZone( assert(client_list); datasrc::ConfigurableClientList::ReloadResult result; - { + try { typename MutexType::Locker locker(*map_mutex_); result = client_list->reload(origin); + } catch (const isc::Exception& ex) { + // We catch our internal exceptions (which will be just ignored) and + // propagated others (which should generally be considered fatal and + // will make the thread terminate) + isc_throw(InternalCommandError, "failed to load a zone " << origin << + "/" << rrclass << ": error occurred in reload: " << + ex.what()); } switch (result) { case datasrc::ConfigurableClientList::ZONE_RELOADED: diff --git a/src/bin/auth/tests/datasrc_clients_builder_unittest.cc b/src/bin/auth/tests/datasrc_clients_builder_unittest.cc index 27918b622e..df1ca8cae1 100644 --- a/src/bin/auth/tests/datasrc_clients_builder_unittest.cc +++ b/src/bin/auth/tests/datasrc_clients_builder_unittest.cc @@ -372,4 +372,20 @@ TEST_F(DataSrcClientsBuilderTest, find(Name("example.org"), RRType::SOA())->code); } +TEST_F(DataSrcClientsBuilderTest, loadBrokenZone) { + configureZones(); + + ASSERT_EQ(0, std::system(INSTALL_PROG " -c " TEST_DATA_DIR + "/test1-broken.zone.in " + TEST_DATA_BUILDDIR "/test1.zone.copied")); + // there's an error in the new zone file. reload will be rejected. + const Command loadzone_cmd(LOADZONE, isc::data::Element::fromJSON( + "{\"class\": \"IN\"," + " \"origin\": \"test1.example\"}")); + EXPECT_THROW(builder.handleCommand(loadzone_cmd), + TestDataSrcClientsBuilder::InternalCommandError); + zoneChecks(clients_map, rrclass); // zone shouldn't be replaced +} + + } // unnamed namespace