This is an automated email from the ASF dual-hosted git repository. maxyang pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit e5c8ebb1c5b27cf349fde0dc266840e24709f1a5 Author: RMT <[email protected]> AuthorDate: Tue Aug 1 18:04:38 2023 +0800 let resource group io limit testing can be reproduced (#16107) let resource group io limit testing can be reproduced. If we retain the objects created in the testing, we must clear those objects before we re-run the testing on local, it's not convenient for developers. --- .../expected/resgroup/resgroup_auxiliary_tools_v2.out | 8 +++++--- src/test/isolation2/input/resgroup/resgroup_io_limit.source | 4 ++++ src/test/isolation2/output/resgroup/resgroup_io_limit.source | 9 +++++++++ .../isolation2/sql/resgroup/resgroup_auxiliary_tools_v2.sql | 11 +++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/test/isolation2/expected/resgroup/resgroup_auxiliary_tools_v2.out b/src/test/isolation2/expected/resgroup/resgroup_auxiliary_tools_v2.out index 779e4dd1bcf..45bd1cb45e1 100644 --- a/src/test/isolation2/expected/resgroup/resgroup_auxiliary_tools_v2.out +++ b/src/test/isolation2/expected/resgroup/resgroup_auxiliary_tools_v2.out @@ -141,7 +141,9 @@ if os.path.exists(dirname): return True try: os.makedirs(dirname) except Exception as e: plpy.error("cannot create dir {}".format(e)) else: return True $$ LANGUAGE plpython3u; CREATE -0: CREATE OR REPLACE FUNCTION rmdir(dirname text) RETURNS BOOL AS $$ import shutil import os -if not os.path.exists(dirname): return True -try: shutil.rmtree(dirname) except Exception as e: plpy.error("cannot remove dir {}".format(e)) else: return True $$ LANGUAGE plpython3u; +0: CREATE OR REPLACE FUNCTION rmdir(dirname text) RETURNS BOOL AS $$ import shutil import fcntl import os +try: f = os.open(dirname, os.O_RDONLY) except FileNotFoundError: return True +fcntl.flock(f, fcntl.LOCK_EX) +if not os.path.exists(dirname): os.close(f) return True +try: shutil.rmtree(dirname) except Exception as e: plpy.error("cannot remove dir {}".format(e)) else: return True finally: os.close(f) $$ LANGUAGE plpython3u; CREATE diff --git a/src/test/isolation2/input/resgroup/resgroup_io_limit.source b/src/test/isolation2/input/resgroup/resgroup_io_limit.source index 935964c5163..d3a0bd485a0 100644 --- a/src/test/isolation2/input/resgroup/resgroup_io_limit.source +++ b/src/test/isolation2/input/resgroup/resgroup_io_limit.source @@ -68,3 +68,7 @@ DROP RESOURCE GROUP rg_test_group2; DROP RESOURCE GROUP rg_test_group3; DROP RESOURCE GROUP rg_test_group4; DROP RESOURCE GROUP rg_test_group5; + +DROP TABLESPACE rg_io_limit_ts_1; + +select rmdir('@testtablespace@/rg_io_limit_ts_1') from gp_dist_random('gp_id') intersect select rmdir('@testtablespace@/rg_io_limit_ts_1') from gp_id; diff --git a/src/test/isolation2/output/resgroup/resgroup_io_limit.source b/src/test/isolation2/output/resgroup/resgroup_io_limit.source index 610c5b29b13..9e40b8c34d9 100644 --- a/src/test/isolation2/output/resgroup/resgroup_io_limit.source +++ b/src/test/isolation2/output/resgroup/resgroup_io_limit.source @@ -134,3 +134,12 @@ DROP RESOURCE GROUP rg_test_group4; DROP DROP RESOURCE GROUP rg_test_group5; DROP + +DROP TABLESPACE rg_io_limit_ts_1; +DROP + +select rmdir('@testtablespace@/rg_io_limit_ts_1') from gp_dist_random('gp_id') intersect select rmdir('@testtablespace@/rg_io_limit_ts_1') from gp_id; + rmdir +------- + t +(1 row) diff --git a/src/test/isolation2/sql/resgroup/resgroup_auxiliary_tools_v2.sql b/src/test/isolation2/sql/resgroup/resgroup_auxiliary_tools_v2.sql index b791c1c31af..966d121a5dc 100644 --- a/src/test/isolation2/sql/resgroup/resgroup_auxiliary_tools_v2.sql +++ b/src/test/isolation2/sql/resgroup/resgroup_auxiliary_tools_v2.sql @@ -328,9 +328,18 @@ $$ LANGUAGE plpython3u; 0: CREATE OR REPLACE FUNCTION rmdir(dirname text) RETURNS BOOL AS $$ import shutil + import fcntl import os + try: + f = os.open(dirname, os.O_RDONLY) + except FileNotFoundError: + return True + + fcntl.flock(f, fcntl.LOCK_EX) + if not os.path.exists(dirname): + os.close(f) return True try: @@ -339,4 +348,6 @@ $$ LANGUAGE plpython3u; plpy.error("cannot remove dir {}".format(e)) else: return True + finally: + os.close(f) $$ LANGUAGE plpython3u; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
