|
@@ -641,4 +641,68 @@ TEST_F(DataSrcClientsBuilderTest,
|
|
TestDataSrcClientsBuilder::InternalCommandError);
|
|
TestDataSrcClientsBuilder::InternalCommandError);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Test the SEGMENT_INFO_UPDATE command. This test is little bit
|
|
|
|
+// indirect. It doesn't seem possible to fake the client list inside
|
|
|
|
+// easily. So we create a real image to load and load it. Then we check
|
|
|
|
+// the segment is used.
|
|
|
|
+TEST_F(DataSrcClientsBuilderTest,
|
|
|
|
+#ifdef USE_SHARED_MEMORY
|
|
|
|
+ segmentInfoUpdate
|
|
|
|
+#else
|
|
|
|
+ DISABLED_segmentInfoUpdate
|
|
|
|
+#endif
|
|
|
|
+ )
|
|
|
|
+{
|
|
|
|
+ // First, prepare the file image to be mapped
|
|
|
|
+ const ConstElementPtr config = Element::fromJSON(
|
|
|
|
+ "{"
|
|
|
|
+ "\"IN\": [{"
|
|
|
|
+ " \"type\": \"MasterFiles\","
|
|
|
|
+ " \"params\": {"
|
|
|
|
+ " \"test1.example\": \""
|
|
|
|
+ TEST_DATA_BUILDDIR "/test1.zone.copied\"},"
|
|
|
|
+ " \"cache-enable\": true,"
|
|
|
|
+ " \"cache-type\": \"mapped\""
|
|
|
|
+ "}]}");
|
|
|
|
+ const ConstElementPtr segment_config = Element::fromJSON(
|
|
|
|
+ "{"
|
|
|
|
+ " \"mapped-file\": \""
|
|
|
|
+ TEST_DATA_BUILDDIR "/test1.zone.image" "\"}");
|
|
|
|
+ clients_map = configureDataSource(config);
|
|
|
|
+ {
|
|
|
|
+ const boost::shared_ptr<ConfigurableClientList> list =
|
|
|
|
+ (*clients_map)[RRClass::IN()];
|
|
|
|
+ list->resetMemorySegment("MasterFiles",
|
|
|
|
+ memory::ZoneTableSegment::CREATE,
|
|
|
|
+ segment_config);
|
|
|
|
+ const ConfigurableClientList::ZoneWriterPair result =
|
|
|
|
+ list->getCachedZoneWriter(isc::dns::Name("test1.example"), false,
|
|
|
|
+ "MasterFiles");
|
|
|
|
+ ASSERT_EQ(ConfigurableClientList::ZONE_SUCCESS, result.first);
|
|
|
|
+ result.second->load();
|
|
|
|
+ result.second->install();
|
|
|
|
+ // not absolutely necessary, but just in case
|
|
|
|
+ result.second->cleanup();
|
|
|
|
+ } // Release this list. That will release the file with the image too,
|
|
|
|
+ // so we can map it read only from somewhere else.
|
|
|
|
+
|
|
|
|
+ // Create a new map, with the same configuration, but without the segments
|
|
|
|
+ // set
|
|
|
|
+ clients_map = configureDataSource(config);
|
|
|
|
+ const boost::shared_ptr<ConfigurableClientList> list =
|
|
|
|
+ (*clients_map)[RRClass::IN()];
|
|
|
|
+ EXPECT_EQ(SEGMENT_WAITING, list->getStatus()[0].getSegmentState());
|
|
|
|
+ // Send the command
|
|
|
|
+ const ElementPtr command_args = Element::fromJSON(
|
|
|
|
+ "{"
|
|
|
|
+ " \"data-source-name\": \"MasterFiles\","
|
|
|
|
+ " \"data-source-class\": \"IN\""
|
|
|
|
+ "}");
|
|
|
|
+ command_args->set("segment-params", segment_config);
|
|
|
|
+ builder.handleCommand(Command(SEGMENT_INFO_UPDATE, command_args,
|
|
|
|
+ FinishedCallback()));
|
|
|
|
+ // The segment is now used.
|
|
|
|
+ EXPECT_EQ(SEGMENT_INUSE, list->getStatus()[0].getSegmentState());
|
|
|
|
+}
|
|
|
|
+
|
|
} // unnamed namespace
|
|
} // unnamed namespace
|