|
4 | 4 | #include <vector> |
5 | 5 | #include <gtest/gtest.h> |
6 | 6 |
|
7 | | -TEST(Config, Profiling) { |
| 7 | +TEST(Config, GetAndSet) { |
8 | 8 | const char *path = "test.conf"; |
9 | 9 | Config config; |
10 | | - Server srv(nullptr, &config); |
11 | 10 |
|
12 | 11 | config.Load(path); |
13 | | - std::map<std::string, std::string> cases = { |
| 12 | + std::map<std::string, std::string> mutable_cases = { |
| 13 | + {"timeout" , "1000"}, |
| 14 | + {"maxclients" , "2000"}, |
| 15 | + {"max-backup-to-keep" , "32"}, |
| 16 | + {"max-backup-keep-hours" , "4000"}, |
| 17 | + {"requirepass" , "mytest_requirepass"}, |
| 18 | + {"masterauth" , "mytest_masterauth"}, |
| 19 | + {"compact-cron" , "1 2 3 4 5"}, |
| 20 | + {"bgsave-cron" , "5 4 3 2 1"}, |
| 21 | + {"max-io-mb" , "5000"}, |
| 22 | + {"max-db-size" , "6000"}, |
| 23 | + {"max-replication-mb" , "7000"}, |
| 24 | + {"slave-serve-stale-data" , "no"}, |
| 25 | + {"slave-read-only" , "no"}, |
| 26 | + {"slave-priority" , "101"}, |
| 27 | + {"slowlog-log-slower-than" , "1234"}, |
| 28 | + {"slowlog-max-len" , "123"}, |
14 | 29 | {"profiling-sample-ratio" , "50"}, |
15 | 30 | {"profiling-sample-record-max-len" , "1"}, |
16 | 31 | {"profiling-sample-record-threshold-ms" , "50"}, |
17 | 32 | {"profiling-sample-commands" , "get,set"}, |
| 33 | + |
| 34 | + {"rocksdb.compression" , "no"}, |
| 35 | + {"rocksdb.max_open_files" , "1234"}, |
| 36 | + {"rocksdb.write_buffer_size" , "1234"}, |
| 37 | + {"rocksdb.max_write_buffer_number" , "1"}, |
| 38 | + {"rocksdb.max_background_compactions" , "2"}, |
| 39 | + {"rocksdb.max_sub_compactions" , "3"}, |
| 40 | + {"rocksdb.delayed_write_rate" , "1234"}, |
| 41 | + {"rocksdb.stats_dump_period_sec" , "600"}, |
| 42 | + {"rocksdb.compaction_readahead_size" , "1024"}, |
| 43 | + {"rocksdb.level0_slowdown_writes_trigger" , "50"}, |
18 | 44 | }; |
19 | 45 | std::vector<std::string> values; |
20 | | - for (const auto &iter : cases) { |
21 | | - config.Set(&srv, iter.first, iter.second); |
| 46 | + for (const auto &iter : mutable_cases) { |
| 47 | + auto s = config.Set(nullptr, iter.first, iter.second); |
| 48 | + ASSERT_TRUE(s.IsOK()); |
22 | 49 | config.Get(iter.first, &values); |
| 50 | + ASSERT_TRUE(s.IsOK()); |
23 | 51 | ASSERT_EQ(values.size(), 2); |
24 | 52 | EXPECT_EQ(values[0], iter.first); |
25 | 53 | EXPECT_EQ(values[1], iter.second); |
26 | 54 | } |
27 | 55 | ASSERT_TRUE(config.Rewrite().IsOK()); |
28 | 56 | config.Load(path); |
29 | | - for (const auto &iter : cases) { |
30 | | - config.Set(&srv, iter.first, iter.second); |
| 57 | + for (const auto &iter : mutable_cases) { |
| 58 | + auto s = config.Set(nullptr, iter.first, iter.second); |
| 59 | + ASSERT_TRUE(s.IsOK()); |
31 | 60 | config.Get(iter.first, &values); |
32 | 61 | ASSERT_EQ(values.size(), 2); |
33 | 62 | EXPECT_EQ(values[0], iter.first); |
34 | 63 | EXPECT_EQ(values[1], iter.second); |
35 | 64 | } |
36 | 65 | unlink(path); |
| 66 | + |
| 67 | + std::map<std::string, std::string> immutable_cases = { |
| 68 | + {"daemonize", "yes"}, |
| 69 | + {"bind", "0.0.0.0"}, |
| 70 | + {"repl-bind", "0.0.0.0"}, |
| 71 | + {"workers", "8"}, |
| 72 | + {"repl-workers", "8"}, |
| 73 | + {"tcp-backlog", "500"}, |
| 74 | + {"codis-enabled", "yes"}, |
| 75 | + {"slaveof", "no one"}, |
| 76 | + {"db-name", "test_dbname"}, |
| 77 | + {"dir", "test_dir"}, |
| 78 | + {"backup-dir", "test_dir/backup"}, |
| 79 | + {"pidfile", "test.pid"}, |
| 80 | + {"supervised", "no"}, |
| 81 | + {"rocksdb.block_size", "1234"}, |
| 82 | + {"rocksdb.target_file_size_base", "100"}, |
| 83 | + {"rocksdb.max_background_flushes", "16"}, |
| 84 | + {"rocksdb.wal_ttl_seconds", "10000"}, |
| 85 | + {"rocksdb.wal_size_limit_mb", "16"}, |
| 86 | + {"rocksdb.enable_pipelined_write", "no"}, |
| 87 | + {"rocksdb.cache_index_and_filter_blocks", "no"}, |
| 88 | + {"rocksdb.metadata_block_cache_size", "100"}, |
| 89 | + {"rocksdb.subkey_block_cache_size", "100"}, |
| 90 | + }; |
| 91 | + for (const auto &iter : immutable_cases) { |
| 92 | + auto s = config.Set(nullptr, iter.first, iter.second); |
| 93 | + ASSERT_FALSE(s.IsOK()); |
| 94 | + } |
37 | 95 | } |
38 | 96 |
|
39 | 97 | TEST(Namespace, Add) { |
|
0 commit comments