Parcourir la source

[2377] Make incremental loading work

Michal 'vorner' Vaner il y a 12 ans
Parent
commit
24c515276e
2 fichiers modifiés avec 27 ajouts et 0 suppressions
  1. 1 0
      src/lib/dns/master_loader.cc
  2. 26 0
      src/lib/dns/tests/master_loader_unittest.cc

+ 1 - 0
src/lib/dns/master_loader.cc

@@ -60,6 +60,7 @@ public:
     bool loadIncremental(size_t count_limit) {
         if (!initialized_) {
             pushSource(master_file_);
+            initialized_ = true;
         }
         size_t count = 0;
         while (ok_ && count < count_limit) {

+ 26 - 0
src/lib/dns/tests/master_loader_unittest.cc

@@ -111,6 +111,32 @@ TEST_F(MasterLoaderTest, basicLoad) {
     checkRR("www.example.org", RRType::A(), "192.0.2.1");
 }
 
+// Try loading data incrementally.
+TEST_F(MasterLoaderTest, incrementalLoad) {
+    setLoader("example.org", Name("example.org."), RRClass::IN(),
+              MasterLoader::MANY_ERRORS);
+
+    EXPECT_FALSE(loader_->loadIncremental(2));
+
+    EXPECT_TRUE(errors_.empty());
+    EXPECT_TRUE(warnings_.empty());
+
+    checkRR("example.org", RRType::SOA(), "ns1.example.org. admin.example.org. "
+            "1234 3600 1800 2419200 7200");
+    checkRR("example.org", RRType::NS(), "ns1.example.org.");
+
+    // The third one is not loaded yet
+    EXPECT_TRUE(rrsets_.empty());
+
+    // Load the rest.
+    EXPECT_TRUE(loader_->loadIncremental(20));
+
+    EXPECT_TRUE(errors_.empty());
+    EXPECT_TRUE(warnings_.empty());
+
+    checkRR("www.example.org", RRType::A(), "192.0.2.1");
+}
+
 // Try loading from file that doesn't exist. There should be single error
 // saying so.
 TEST_F(MasterLoaderTest, invalidFile) {