|
@@ -1209,6 +1209,54 @@ TEST_F(CfgMgrTest, staging) {
|
|
|
EXPECT_EQ(0, config->getLoggingInfo().size());
|
|
|
}
|
|
|
|
|
|
+// This test verifies that it is possible to revert to an old configuration.
|
|
|
+TEST_F(CfgMgrTest, revert) {
|
|
|
+ CfgMgr& cfg_mgr = CfgMgr::instance();
|
|
|
+ // Let's create 5 unique configurations: differing by a debug level in the
|
|
|
+ // range of 10 to 14.
|
|
|
+ for (int i = 0; i < 5; ++i) {
|
|
|
+ ConfigurationPtr config = cfg_mgr.getStagingCfg();
|
|
|
+ LoggingInfo logging_info;
|
|
|
+ logging_info.debuglevel_ = i + 10;
|
|
|
+ config->addLoggingInfo(logging_info);
|
|
|
+ cfg_mgr.commit();
|
|
|
+ }
|
|
|
+
|
|
|
+ // Now we have 5 configurations with:
|
|
|
+ // - debuglevel = 99 (a default one)
|
|
|
+ // - debuglevel = 10
|
|
|
+ // - debuglevel = 11
|
|
|
+ // - debuglevel = 12
|
|
|
+ // - debuglevel = 13
|
|
|
+ // - debuglevel = 14 (current)
|
|
|
+
|
|
|
+ // Hence, the maximum index of the configuration to revert is 5 (which
|
|
|
+ // points to the configuration with debuglevel = 99). For the index greater
|
|
|
+ // than 5 we should get an exception.
|
|
|
+ ASSERT_THROW(cfg_mgr.revert(6), isc::OutOfRange);
|
|
|
+ // Value of 0 also doesn't make sense.
|
|
|
+ ASSERT_THROW(cfg_mgr.revert(0), isc::OutOfRange);
|
|
|
+
|
|
|
+ // We should be able to revert to configuration with debuglevel = 10.
|
|
|
+ ASSERT_NO_THROW(cfg_mgr.revert(4));
|
|
|
+ // And this configuration should be now the current one and the debuglevel
|
|
|
+ // of this configuration is 10.
|
|
|
+ EXPECT_EQ(10, cfg_mgr.getCurrentCfg()->getLoggingInfo()[0].debuglevel_);
|
|
|
+
|
|
|
+ // The new set of configuration is now as follows:
|
|
|
+ // - debuglevel = 99
|
|
|
+ // - debuglevel = 10
|
|
|
+ // - debuglevel = 11
|
|
|
+ // - debuglevel = 12
|
|
|
+ // - debuglevel = 13
|
|
|
+ // - debuglevel = 14
|
|
|
+ // - debuglevel = 10 (current)
|
|
|
+ // So, reverting to configuration having index 3 means that the debug level
|
|
|
+ // of the current configuration will become 12.
|
|
|
+ ASSERT_NO_THROW(cfg_mgr.revert(3));
|
|
|
+ EXPECT_EQ(12, cfg_mgr.getCurrentCfg()->getLoggingInfo()[0].debuglevel_);
|
|
|
+}
|
|
|
+
|
|
|
/// @todo Add unit-tests for testing:
|
|
|
/// - addActiveIface() with invalid interface name
|
|
|
/// - addActiveIface() with the same interface twice
|