% DATASRC_UNEXPECTED_QUERY_STATE unexpected query state
This indicates a programming error. An internal task of unknown type was
generated.
+
+% DATASRC_VALIDATE_ERROR validation of zone %1/%2 failed: %3
+The zone was loaded into the data source successfully, but the content fails
+basic sanity checks. See the message if you want to know what exactly is wrong
+with the data. The data can not be used and previous version, if any, will be
+preserved.
+
+% DATASRC_VALIDATE_WARNING %1/%2: %3
+The zone was loaded, but there's some problem with the content. The problem
+is not serious enough to make the zone unusable, but it should still be checked
+and fixed. See the message to know what exactly is wrong with the data.
// and this way, it is much simpler.
class Updater : public ZoneUpdater {
public:
- Updater(MockClient* client) :
+ Updater(MockClient* client, const Name& name) :
client_(client),
- finder_(client_->rrclass_)
+ finder_(client_->rrclass_, name)
{}
virtual ZoneFinder& getFinder() {
return (finder_);
MockClient* client_;
class Finder : public ZoneFinder {
public:
- Finder(const RRClass& rrclass) :
- class_(rrclass)
+ Finder(const RRClass& rrclass, const Name& name) :
+ class_(rrclass),
+ name_(name)
{}
virtual RRClass getClass() const {
return (class_);
}
virtual Name getOrigin() const {
- isc_throw(isc::NotImplemented, "Method not used in tests");
+ return (name_);
}
virtual shared_ptr<Context> find(const Name&, const RRType&,
const FindOptions)
}
private:
const RRClass class_;
+ const Name name_;
} finder_;
};
// const_cast is bad. But the const on getUpdater seems wrong in the first
// place, since updater will be modifying the data there. And the updater
// wants to store data into the client so we can examine it later.
- return (ZoneUpdaterPtr(new Updater(const_cast<MockClient*>(this))));
+ return (ZoneUpdaterPtr(new Updater(const_cast<MockClient*>(this), name)));
}
class ZoneLoaderTest : public ::testing::Test {
#include <datasrc/data_source.h>
#include <datasrc/iterator.h>
#include <datasrc/zone.h>
+#include <datasrc/logger.h>
+#include <datasrc/rrset_collection.h>
#include <dns/rrset.h>
+#include <dns/zone_checker.h>
+
+#include <boost/bind.hpp>
using isc::dns::Name;
using isc::dns::ConstRRsetPtr;
return (false); // Not yet, there may be more
}
+void
+logWarning(const dns::Name* zone_name, const dns::RRClass* rrclass,
+ const std::string& reason)
+{
+ LOG_WARN(logger, DATASRC_VALIDATE_WARNING).arg(*zone_name).arg(*rrclass).
+ arg(reason);
+}
+
+void
+logError(const dns::Name* zone_name, const dns::RRClass* rrclass,
+ const std::string& reason)
+{
+ LOG_ERROR(logger, DATASRC_VALIDATE_ERROR).arg(*zone_name).arg(*rrclass).
+ arg(reason);
+}
+
} // end unnamed namespace
bool
}
if (complete_) {
+ // Everything is loaded. Perform some basic sanity checks on the zone.
+ RRsetCollection collection(updater_);
+ dns::Name zone_name(updater_->getFinder().getOrigin());
+ dns::RRClass zone_class(updater_->getFinder().getClass());
+ dns::ZoneCheckerCallbacks
+ callbacks(boost::bind(&logError, &zone_name, &zone_class, _1),
+ boost::bind(&logWarning, &zone_name, &zone_class, _1));
+ if (!dns::checkZone(zone_name, zone_class, collection, callbacks)) {
+ // Validation failed.
+ loaded_ok_ = false;
+ isc_throw(ZoneContentError, "Errors found when validating zone " <<
+ zone_name << "/" << zone_class);
+ }
updater_->commit();
}
return (complete_);