You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pegasus.apache.org by "acelyc111 (via GitHub)" <gi...@apache.org> on 2023/04/16 15:51:40 UTC

[GitHub] [incubator-pegasus] acelyc111 opened a new pull request, #1442: fix(ut): fix a flaky test integration_test.write_corrupt_db

acelyc111 opened a new pull request, #1442:
URL: https://github.com/apache/incubator-pegasus/pull/1442

   https://github.com/apache/incubator-pegasus/issues/1383


-- 
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: dev-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


[GitHub] [incubator-pegasus] empiredan commented on a diff in pull request #1442: fix(ut): fix a flaky test integration_test.write_corrupt_db

Posted by "empiredan (via GitHub)" <gi...@apache.org>.
empiredan commented on code in PR #1442:
URL: https://github.com/apache/incubator-pegasus/pull/1442#discussion_r1168131577


##########
src/test/function_test/utils/test_util.cpp:
##########
@@ -88,4 +99,38 @@ void test_util::run_cmd_from_project_root(const std::string &cmd)
     ASSERT_NO_FATAL_FAILURE(run_cmd(cmd));
 }
 
+int test_util::get_alive_replica_server_count()
+{
+    std::string json_filename = fmt::format("test_json_file.{}", dsn::rand::next_u32());

Review Comment:
   ```suggestion
       const auto json_filename = fmt::format("test_json_file.{}", dsn::rand::next_u32());
   ```



##########
src/test/function_test/utils/test_util.cpp:
##########
@@ -88,4 +99,38 @@ void test_util::run_cmd_from_project_root(const std::string &cmd)
     ASSERT_NO_FATAL_FAILURE(run_cmd(cmd));
 }
 
+int test_util::get_alive_replica_server_count()
+{
+    std::string json_filename = fmt::format("test_json_file.{}", dsn::rand::next_u32());
+    auto cleanup =
+        dsn::defer([json_filename]() { dsn::utils::filesystem::remove_path(json_filename); });
+    run_cmd_from_project_root(fmt::format("echo 'nodes -djo {}' | ./run.sh shell", json_filename));
+    std::ifstream f(json_filename);
+    json data = json::parse(f);
+    int replica_server_count = 0;
+    if (!dsn::buf2int32(data["summary"]["alive_node_count"], replica_server_count)) {
+        return -1;
+    }
+    return replica_server_count;
+}
+
+int test_util::get_leader_count(const std::string &table_name, int replica_server_index)
+{
+    std::string json_filename = fmt::format("test_json_file.{}", dsn::rand::next_u32());

Review Comment:
   ```suggestion
       const auto json_filename = fmt::format("test_json_file.{}", dsn::rand::next_u32());
   ```



##########
src/test/function_test/utils/test_util.cpp:
##########
@@ -88,4 +99,38 @@ void test_util::run_cmd_from_project_root(const std::string &cmd)
     ASSERT_NO_FATAL_FAILURE(run_cmd(cmd));
 }
 
+int test_util::get_alive_replica_server_count()
+{
+    std::string json_filename = fmt::format("test_json_file.{}", dsn::rand::next_u32());
+    auto cleanup =
+        dsn::defer([json_filename]() { dsn::utils::filesystem::remove_path(json_filename); });
+    run_cmd_from_project_root(fmt::format("echo 'nodes -djo {}' | ./run.sh shell", json_filename));
+    std::ifstream f(json_filename);
+    json data = json::parse(f);
+    int replica_server_count = 0;
+    if (!dsn::buf2int32(data["summary"]["alive_node_count"], replica_server_count)) {
+        return -1;
+    }
+    return replica_server_count;
+}
+
+int test_util::get_leader_count(const std::string &table_name, int replica_server_index)
+{
+    std::string json_filename = fmt::format("test_json_file.{}", dsn::rand::next_u32());
+    auto cleanup =
+        dsn::defer([json_filename]() { dsn::utils::filesystem::remove_path(json_filename); });
+    run_cmd_from_project_root(
+        fmt::format("echo 'app {} -djo {}' | ./run.sh shell", table_name, json_filename));
+    std::ifstream f(json_filename);
+    json data = json::parse(f);

Review Comment:
   ```suggestion
       const auto data = json::parse(f);
   ```



##########
src/test/function_test/utils/test_util.cpp:
##########
@@ -88,4 +99,38 @@ void test_util::run_cmd_from_project_root(const std::string &cmd)
     ASSERT_NO_FATAL_FAILURE(run_cmd(cmd));
 }
 
+int test_util::get_alive_replica_server_count()
+{
+    std::string json_filename = fmt::format("test_json_file.{}", dsn::rand::next_u32());
+    auto cleanup =
+        dsn::defer([json_filename]() { dsn::utils::filesystem::remove_path(json_filename); });
+    run_cmd_from_project_root(fmt::format("echo 'nodes -djo {}' | ./run.sh shell", json_filename));
+    std::ifstream f(json_filename);
+    json data = json::parse(f);

Review Comment:
   ```suggestion
       const auto data = json::parse(f);
   ```



-- 
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: dev-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


[GitHub] [incubator-pegasus] acelyc111 commented on a diff in pull request #1442: fix(ut): fix a flaky test integration_test.write_corrupt_db

Posted by "acelyc111 (via GitHub)" <gi...@apache.org>.
acelyc111 commented on code in PR #1442:
URL: https://github.com/apache/incubator-pegasus/pull/1442#discussion_r1168121600


##########
src/test/function_test/utils/test_util.h:
##########
@@ -55,7 +55,14 @@ class test_util : public ::testing::Test
 
     void SetUp() override;
 
-    void run_cmd_from_project_root(const std::string &cmd);
+    static void run_cmd_from_project_root(const std::string &cmd);
+
+    // Get the count of alive replica servers.
+    static int get_replica_server_count();

Review Comment:
   Renamed to `get_alive_replica_server_count`



-- 
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: dev-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


[GitHub] [incubator-pegasus] levy5307 commented on a diff in pull request #1442: fix(ut): fix a flaky test integration_test.write_corrupt_db

Posted by "levy5307 (via GitHub)" <gi...@apache.org>.
levy5307 commented on code in PR #1442:
URL: https://github.com/apache/incubator-pegasus/pull/1442#discussion_r1168117807


##########
src/test/function_test/utils/test_util.h:
##########
@@ -55,7 +55,14 @@ class test_util : public ::testing::Test
 
     void SetUp() override;
 
-    void run_cmd_from_project_root(const std::string &cmd);
+    static void run_cmd_from_project_root(const std::string &cmd);
+
+    // Get the count of alive replica servers.
+    static int get_replica_server_count();

Review Comment:
   get_alive_replica_count



-- 
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: dev-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


[GitHub] [incubator-pegasus] acelyc111 merged pull request #1442: fix(ut): fix a flaky test integration_test.write_corrupt_db

Posted by "acelyc111 (via GitHub)" <gi...@apache.org>.
acelyc111 merged PR #1442:
URL: https://github.com/apache/incubator-pegasus/pull/1442


-- 
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: dev-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org