You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by le...@apache.org on 2026/10/08 10:22:06 UTC
(cloudberry) 03/08: Fix expected CPU usage in resgroup tests
This is an automated email from the ASF dual-hosted git repository.
leborchuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit bef6eeebbd256ffb464414b29b3673b52ee41dad
Author: Dianjin Wang <wa...@gmail.com>
AuthorDate: Tue Sep 1 21:23:55 2026 +0800
Fix expected CPU usage in resgroup tests
The test already averages CPU samples, but the expected values are
still too low. The suite sets the cluster CPU limit to 100%, so expect
100% for one uncapped group and 33%/67% for groups with weights 100/200.
Keep the existing tolerance of 10 percentage points.
Assisted-by: Claude Code
Backpatch-through: REL_2_STABLE
---
.../expected/resgroup/resgroup_cpu_max_percent.out | 17 ++++++++++++-----
.../sql/resgroup/resgroup_cpu_max_percent.sql | 17 ++++++++++++-----
.../expected/resgroup/resgroup_cpu_max_percent.out | 17 ++++++++++++-----
.../sql/resgroup/resgroup_cpu_max_percent.sql | 17 ++++++++++++-----
4 files changed, 48 insertions(+), 20 deletions(-)
diff --git a/contrib/pax_storage/src/test/isolation2/expected/resgroup/resgroup_cpu_max_percent.out b/contrib/pax_storage/src/test/isolation2/expected/resgroup/resgroup_cpu_max_percent.out
index 1e011ecec22..fadb068241c 100644
--- a/contrib/pax_storage/src/test/isolation2/expected/resgroup/resgroup_cpu_max_percent.out
+++ b/contrib/pax_storage/src/test/isolation2/expected/resgroup/resgroup_cpu_max_percent.out
@@ -220,7 +220,11 @@ SELECT pg_sleep(1.7);
(1 row)
-- end_ignore
-SELECT verify_cpu_usage('rg1_cpu_test', 90, 10);
+-- rg1_cpu_test is uncapped (cpu_max_percent=-1) and it is the only busy
+-- group, so it takes essentially every core: gp_resgroup_status reports
+-- ~100, not 90. Expecting 90 put the real value on the upper edge of the
+-- +/- err_rate window, so any upward sampling jitter failed the test.
+SELECT verify_cpu_usage('rg1_cpu_test', 100, 10);
verify_cpu_usage
------------------
t
@@ -270,10 +274,11 @@ SET
-- when there are multiple groups with parallel queries,
-- they should share the cpu usage by their cpu_weight settings,
--
+-- The suite CPU limit is 100%, and both groups are uncapped.
-- rg1_cpu_test:rg2_cpu_test is 100:200 => 1:2, so:
--
--- - rg1_cpu_test gets 90% * 1/3 => 30%;
--- - rg2_cpu_test gets 90% * 2/3 => 60%;
+-- - rg1_cpu_test gets 100% * 1/3 => approximately 33%;
+-- - rg2_cpu_test gets 100% * 2/3 => approximately 67%;
--
10&: SELECT * FROM gp_dist_random('gp_id') WHERE busy() IS NULL; <waiting ...>
@@ -395,12 +400,14 @@ SELECT pg_sleep(1.7);
(1 row)
-- end_ignore
-SELECT verify_cpu_usage('rg1_cpu_test', 30, 10);
+-- Both groups are uncapped, so they share the whole machine in proportion
+-- to cpu_weight (100 and 200): ~33 and ~67, not ~30 and ~60.
+SELECT verify_cpu_usage('rg1_cpu_test', 33, 10);
verify_cpu_usage
------------------
t
(1 row)
-SELECT verify_cpu_usage('rg2_cpu_test', 60, 10);
+SELECT verify_cpu_usage('rg2_cpu_test', 67, 10);
verify_cpu_usage
------------------
t
diff --git a/contrib/pax_storage/src/test/isolation2/sql/resgroup/resgroup_cpu_max_percent.sql b/contrib/pax_storage/src/test/isolation2/sql/resgroup/resgroup_cpu_max_percent.sql
index a014108bb52..8b1e4ca2e76 100644
--- a/contrib/pax_storage/src/test/isolation2/sql/resgroup/resgroup_cpu_max_percent.sql
+++ b/contrib/pax_storage/src/test/isolation2/sql/resgroup/resgroup_cpu_max_percent.sql
@@ -141,7 +141,11 @@ SELECT fetch_sample();
SELECT pg_sleep(1.7);
-- end_ignore
-SELECT verify_cpu_usage('rg1_cpu_test', 90, 10);
+-- rg1_cpu_test is uncapped (cpu_max_percent=-1) and it is the only busy
+-- group, so it takes essentially every core: gp_resgroup_status reports
+-- ~100, not 90. Expecting 90 put the real value on the upper edge of the
+-- +/- err_rate window, so any upward sampling jitter failed the test.
+SELECT verify_cpu_usage('rg1_cpu_test', 100, 10);
-- start_ignore
SELECT * FROM cancel_all;
@@ -169,10 +173,11 @@ SELECT * FROM cancel_all;
-- when there are multiple groups with parallel queries,
-- they should share the cpu usage by their cpu_weight settings,
--
+-- The suite CPU limit is 100%, and both groups are uncapped.
-- rg1_cpu_test:rg2_cpu_test is 100:200 => 1:2, so:
--
--- - rg1_cpu_test gets 90% * 1/3 => 30%;
--- - rg2_cpu_test gets 90% * 2/3 => 60%;
+-- - rg1_cpu_test gets 100% * 1/3 => approximately 33%;
+-- - rg2_cpu_test gets 100% * 2/3 => approximately 67%;
--
10&: SELECT * FROM gp_dist_random('gp_id') WHERE busy() IS NULL;
@@ -212,8 +217,10 @@ SELECT fetch_sample();
SELECT pg_sleep(1.7);
-- end_ignore
-SELECT verify_cpu_usage('rg1_cpu_test', 30, 10);
-SELECT verify_cpu_usage('rg2_cpu_test', 60, 10);
+-- Both groups are uncapped, so they share the whole machine in proportion
+-- to cpu_weight (100 and 200): ~33 and ~67, not ~30 and ~60.
+SELECT verify_cpu_usage('rg1_cpu_test', 33, 10);
+SELECT verify_cpu_usage('rg2_cpu_test', 67, 10);
-- start_ignore
SELECT * FROM cancel_all;
diff --git a/src/test/isolation2/expected/resgroup/resgroup_cpu_max_percent.out b/src/test/isolation2/expected/resgroup/resgroup_cpu_max_percent.out
index 44969ba7eea..f5a0c1fa929 100644
--- a/src/test/isolation2/expected/resgroup/resgroup_cpu_max_percent.out
+++ b/src/test/isolation2/expected/resgroup/resgroup_cpu_max_percent.out
@@ -220,7 +220,11 @@ SELECT pg_sleep(1.7);
(1 row)
-- end_ignore
-SELECT verify_cpu_usage('rg1_cpu_test', 90, 10);
+-- rg1_cpu_test is uncapped (cpu_max_percent=-1) and it is the only busy
+-- group, so it takes essentially every core: gp_resgroup_status reports
+-- ~100, not 90. Expecting 90 put the real value on the upper edge of the
+-- +/- err_rate window, so any upward sampling jitter failed the test.
+SELECT verify_cpu_usage('rg1_cpu_test', 100, 10);
verify_cpu_usage
------------------
t
@@ -270,10 +274,11 @@ SET
-- when there are multiple groups with parallel queries,
-- they should share the cpu usage by their cpu_weight settings,
--
+-- The suite CPU limit is 100%, and both groups are uncapped.
-- rg1_cpu_test:rg2_cpu_test is 100:200 => 1:2, so:
--
--- - rg1_cpu_test gets 90% * 1/3 => 30%;
--- - rg2_cpu_test gets 90% * 2/3 => 60%;
+-- - rg1_cpu_test gets 100% * 1/3 => approximately 33%;
+-- - rg2_cpu_test gets 100% * 2/3 => approximately 67%;
--
10&: SELECT * FROM gp_dist_random('gp_id') WHERE busy() IS NULL; <waiting ...>
@@ -395,13 +400,15 @@ SELECT pg_sleep(1.7);
(1 row)
-- end_ignore
-SELECT verify_cpu_usage('rg1_cpu_test', 30, 10);
+-- Both groups are uncapped, so they share the whole machine in proportion
+-- to cpu_weight (100 and 200): ~33 and ~67, not ~30 and ~60.
+SELECT verify_cpu_usage('rg1_cpu_test', 33, 10);
verify_cpu_usage
------------------
t
(1 row)
-- start_ignore
-SELECT verify_cpu_usage('rg2_cpu_test', 60, 10);
+SELECT verify_cpu_usage('rg2_cpu_test', 67, 10);
verify_cpu_usage
------------------
t
diff --git a/src/test/isolation2/sql/resgroup/resgroup_cpu_max_percent.sql b/src/test/isolation2/sql/resgroup/resgroup_cpu_max_percent.sql
index 89fa523cc88..0d91f699e94 100644
--- a/src/test/isolation2/sql/resgroup/resgroup_cpu_max_percent.sql
+++ b/src/test/isolation2/sql/resgroup/resgroup_cpu_max_percent.sql
@@ -141,7 +141,11 @@ SELECT fetch_sample();
SELECT pg_sleep(1.7);
-- end_ignore
-SELECT verify_cpu_usage('rg1_cpu_test', 90, 10);
+-- rg1_cpu_test is uncapped (cpu_max_percent=-1) and it is the only busy
+-- group, so it takes essentially every core: gp_resgroup_status reports
+-- ~100, not 90. Expecting 90 put the real value on the upper edge of the
+-- +/- err_rate window, so any upward sampling jitter failed the test.
+SELECT verify_cpu_usage('rg1_cpu_test', 100, 10);
-- start_ignore
SELECT * FROM cancel_all;
@@ -169,10 +173,11 @@ SELECT * FROM cancel_all;
-- when there are multiple groups with parallel queries,
-- they should share the cpu usage by their cpu_weight settings,
--
+-- The suite CPU limit is 100%, and both groups are uncapped.
-- rg1_cpu_test:rg2_cpu_test is 100:200 => 1:2, so:
--
--- - rg1_cpu_test gets 90% * 1/3 => 30%;
--- - rg2_cpu_test gets 90% * 2/3 => 60%;
+-- - rg1_cpu_test gets 100% * 1/3 => approximately 33%;
+-- - rg2_cpu_test gets 100% * 2/3 => approximately 67%;
--
10&: SELECT * FROM gp_dist_random('gp_id') WHERE busy() IS NULL;
@@ -212,9 +217,11 @@ SELECT fetch_sample();
SELECT pg_sleep(1.7);
-- end_ignore
-SELECT verify_cpu_usage('rg1_cpu_test', 30, 10);
+-- Both groups are uncapped, so they share the whole machine in proportion
+-- to cpu_weight (100 and 200): ~33 and ~67, not ~30 and ~60.
+SELECT verify_cpu_usage('rg1_cpu_test', 33, 10);
-- start_ignore
-SELECT verify_cpu_usage('rg2_cpu_test', 60, 10);
+SELECT verify_cpu_usage('rg2_cpu_test', 67, 10);
SELECT * FROM cancel_all;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org