ruojieranyishen commented on code in PR #1511:
URL: 
https://github.com/apache/incubator-pegasus/pull/1511#discussion_r1259492268


##########
src/server/test/pegasus_server_impl_test.cpp:
##########
@@ -95,6 +97,51 @@ class pegasus_server_impl_test : public 
pegasus_server_test_base
             ASSERT_EQ(before_count + test.expect_perf_counter_incr, 
after_count);
         }
     }
+
+    void test_open_db_with_rocksdb_envs(bool is_restart)
+    {
+        struct create_test
+        {
+            std::string env_key;
+            std::string env_value;
+            std::string expect_value;
+        } tests[] = {
+            {"rocksdb.num_levels", "5", "5"}, {"rocksdb.write_buffer_size", 
"33554432", "33554432"},
+        };
+
+        std::map<std::string, std::string> all_test_envs;
+        {
+            // Make sure all rocksdb options of ROCKSDB_DYNAMIC_OPTIONS and 
ROCKSDB_STATIC_OPTIONS
+            // are tested.
+            for (auto test : tests) {
+                all_test_envs[test.env_key] = test.env_value;
+            }
+            for (const auto &option : pegasus::ROCKSDB_DYNAMIC_OPTIONS) {
+                ASSERT_TRUE(all_test_envs.find(option) != all_test_envs.end());
+            }
+            for (const auto &option : pegasus::ROCKSDB_STATIC_OPTIONS) {
+                ASSERT_TRUE(all_test_envs.find(option) != all_test_envs.end());
+            }
+        }
+
+        start(all_test_envs);
+        if (is_restart) {
+            _server->stop(false);
+            start();
+        }
+
+        std::map<std::string, std::string> query_envs;
+        _server->query_app_envs(query_envs);
+        for (auto test : tests) {
+            auto iter = query_envs.find(test.env_key);
+            if (iter != query_envs.end()) {
+                ASSERT_EQ(iter->second, test.expect_value);
+            } else {
+                ASSERT_EQ(test.env_key,
+                          fmt::format("query_app_envs not supported {}", 
test.env_key));

Review Comment:
   Thanks for your advice.
   `all_test_envs`  can ensure that all supported options are added to tests. 
   ```c++
   std::map<std::string, std::string> all_test_envs;
   ``` 
   Traverse tests can check `query_app_envs` function. This can find 
unsupported options.
   ```c++
           for (const auto &test : tests) {
   ``` 
   Line 140 ASSERT_EQ may be ambiguous, I modified the code.
   ```diff
   -                ASSERT_EQ(test.env_key, fmt::format("query_app_envs not 
supported {}", test.env_key));
   +               ASSERT_TRUE(false) << fmt::format("query_app_envs not 
supported {}", test.env_key);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to