yiguolei commented on code in PR #45284: URL: https://github.com/apache/doris/pull/45284#discussion_r1881305428
########## be/test/util/cgroup_util_test.cpp: ########## @@ -87,4 +87,35 @@ TEST_F(CGroupUtilTest, memlimit) { } } +TEST_F(CGroupUtilTest, readcpu) { + std::string dir_path = GetCurrentRunningDir(); + + std::string cpuset_1_path(dir_path + "/util/test_data/cgroup_cpu_data/cpuset1"); + std::string cpuset_1_str = ""; + Status ret1 = CGroupUtil::read_string_line_from_cgroup_file(cpuset_1_path, &cpuset_1_str); + EXPECT_TRUE(ret1.ok()); + int cpu_count1 = 0; + static_cast<void>(CGroupUtil::parse_cpuset_line(cpuset_1_str, &cpu_count1)); + EXPECT_TRUE(cpu_count1 == 3); + + std::string cpuset_2_path(dir_path + "/util/test_data/cgroup_cpu_data/cpuset2"); + std::string cpuset_2_str = ""; + Status ret2 = CGroupUtil::read_string_line_from_cgroup_file(cpuset_2_path, &cpuset_2_str); + EXPECT_TRUE(ret2.ok()); + int cpu_count2 = 0; + static_cast<void>(CGroupUtil::parse_cpuset_line(cpuset_2_str, &cpu_count2)); + EXPECT_TRUE(cpu_count2 == 11); + + std::string cpuset_3_path(dir_path + "/util/test_data/cgroup_cpu_data/cpuset3"); + std::string cpuset_3_str = ""; + Status ret3 = CGroupUtil::read_string_line_from_cgroup_file(cpuset_3_path, &cpuset_3_str); + EXPECT_TRUE(ret3.ok()); + int cpu_count3 = 0; + static_cast<void>(CGroupUtil::parse_cpuset_line(cpuset_3_str, &cpu_count3)); + EXPECT_TRUE(cpu_count3 == 10); + + int ret = CGroupUtil::get_cgroup_limited_cpu_number(16); Review Comment: 把这个get_cgroup_limited_cpu_number 方法里的函数拆分一下,分别然后我们提供一个cpu.quota 或者cpu.max 这些文件,把cgroup cpu 相关文件的解析,都通过一些我们提供的测试文件都测试到。 不要依赖当前系统的,比如你这里写的>0,我感觉没啥用。 -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org