@@ -500,7 +500,8 @@ TEST_F(OptionsUtilTest, LoadLatestOptions) {
500500static void WriteOptionsFile (Env* env, const std::string& path,
501501 const std::string& options_file, int major,
502502 int minor, const std::string& db_opts,
503- const std::string& cf_opts) {
503+ const std::string& cf_opts,
504+ const std::string& bbt_opts = " " ) {
504505 std::string options_file_header =
505506 " \n "
506507 " [Version]\n "
@@ -516,6 +517,8 @@ static void WriteOptionsFile(Env* env, const std::string& path,
516517 ASSERT_OK (wf->Append (
517518 " [CFOptions \" default\" ] # column family must be specified\n " +
518519 cf_opts + " \n " ));
520+ ASSERT_OK (wf->Append (" [TableOptions/BlockBasedTable \" default\" ]\n " +
521+ bbt_opts + " \n " ));
519522 ASSERT_OK (wf->Close ());
520523
521524 std::string latest_options_file;
@@ -567,9 +570,20 @@ TEST_F(OptionsUtilTest, BadLatestOptions) {
567570 s = LoadLatestOptions (ignore_opts, dbname_, &db_opts, &cf_descs);
568571 ASSERT_NOK (s);
569572 ASSERT_TRUE (s.IsInvalidArgument ());
573+ // Write an options file for a previous minor release with an unknown BBT
574+ // Option
575+ WriteOptionsFile (options.env , dbname_, " OPTIONS-0003" , ROCKSDB_MAJOR,
576+ ROCKSDB_MINOR - 1 , " " , " " , " unknown_bbt_opt=true" );
577+ s = LoadLatestOptions (config_opts, dbname_, &db_opts, &cf_descs);
578+ ASSERT_NOK (s);
579+ ASSERT_TRUE (s.IsInvalidArgument ());
580+ // Even though ignore_unknown_options=true, we still return an error...
581+ s = LoadLatestOptions (ignore_opts, dbname_, &db_opts, &cf_descs);
582+ ASSERT_NOK (s);
583+ ASSERT_TRUE (s.IsInvalidArgument ());
570584
571585 // Write an options file for the current release with an unknown DB Option
572- WriteOptionsFile (options.env , dbname_, " OPTIONS-0003 " , ROCKSDB_MAJOR,
586+ WriteOptionsFile (options.env , dbname_, " OPTIONS-0004 " , ROCKSDB_MAJOR,
573587 ROCKSDB_MINOR, " unknown_db_opt=true" , " " );
574588 s = LoadLatestOptions (config_opts, dbname_, &db_opts, &cf_descs);
575589 ASSERT_NOK (s);
@@ -580,7 +594,7 @@ TEST_F(OptionsUtilTest, BadLatestOptions) {
580594 ASSERT_TRUE (s.IsInvalidArgument ());
581595
582596 // Write an options file for the current release with an unknown CF Option
583- WriteOptionsFile (options.env , dbname_, " OPTIONS-0004 " , ROCKSDB_MAJOR,
597+ WriteOptionsFile (options.env , dbname_, " OPTIONS-0005 " , ROCKSDB_MAJOR,
584598 ROCKSDB_MINOR, " " , " unknown_cf_opt=true" );
585599 s = LoadLatestOptions (config_opts, dbname_, &db_opts, &cf_descs);
586600 ASSERT_NOK (s);
@@ -591,7 +605,7 @@ TEST_F(OptionsUtilTest, BadLatestOptions) {
591605 ASSERT_TRUE (s.IsInvalidArgument ());
592606
593607 // Write an options file for the current release with an invalid DB Option
594- WriteOptionsFile (options.env , dbname_, " OPTIONS-0005 " , ROCKSDB_MAJOR,
608+ WriteOptionsFile (options.env , dbname_, " OPTIONS-0006 " , ROCKSDB_MAJOR,
595609 ROCKSDB_MINOR, " create_if_missing=hello" , " " );
596610 s = LoadLatestOptions (config_opts, dbname_, &db_opts, &cf_descs);
597611 ASSERT_NOK (s);
@@ -602,20 +616,20 @@ TEST_F(OptionsUtilTest, BadLatestOptions) {
602616 ASSERT_TRUE (s.IsInvalidArgument ());
603617
604618 // Write an options file for the next release with an invalid DB Option
605- WriteOptionsFile (options.env , dbname_, " OPTIONS-0006 " , ROCKSDB_MAJOR,
619+ WriteOptionsFile (options.env , dbname_, " OPTIONS-0007 " , ROCKSDB_MAJOR,
606620 ROCKSDB_MINOR + 1 , " create_if_missing=hello" , " " );
607621 ASSERT_NOK (LoadLatestOptions (config_opts, dbname_, &db_opts, &cf_descs));
608622 ASSERT_OK (LoadLatestOptions (ignore_opts, dbname_, &db_opts, &cf_descs));
609623
610624 // Write an options file for the next release with an unknown DB Option
611- WriteOptionsFile (options.env , dbname_, " OPTIONS-0007 " , ROCKSDB_MAJOR,
625+ WriteOptionsFile (options.env , dbname_, " OPTIONS-0008 " , ROCKSDB_MAJOR,
612626 ROCKSDB_MINOR + 1 , " unknown_db_opt=true" , " " );
613627 ASSERT_NOK (LoadLatestOptions (config_opts, dbname_, &db_opts, &cf_descs));
614628 // Ignore the errors for future releases when ignore_unknown_options=true
615629 ASSERT_OK (LoadLatestOptions (ignore_opts, dbname_, &db_opts, &cf_descs));
616630
617631 // Write an options file for the next major release with an unknown CF Option
618- WriteOptionsFile (options.env , dbname_, " OPTIONS-0008 " , ROCKSDB_MAJOR + 1 ,
632+ WriteOptionsFile (options.env , dbname_, " OPTIONS-0009 " , ROCKSDB_MAJOR + 1 ,
619633 ROCKSDB_MINOR, " " , " unknown_cf_opt=true" );
620634 ASSERT_NOK (LoadLatestOptions (config_opts, dbname_, &db_opts, &cf_descs));
621635 // Ignore the errors for future releases when ignore_unknown_options=true
0 commit comments