diff --git a/tests/test_delta_lake.py b/tests/test_delta_lake.py index 1776ea64407..6561a87ae43 100644 --- a/tests/test_delta_lake.py +++ b/tests/test_delta_lake.py @@ -6,21 +6,8 @@ import subprocess import chdb from chdb import session +from utils import is_musl_linux -def is_musl_linux(): - """Check if running on musl Linux""" - if platform.system() != "Linux": - return False - try: - result = subprocess.run(['ldd', '--version'], capture_output=True, text=True) - print(f"stdout: {result.stdout.lower()}") - print(f"stderr: {result.stderr.lower()}") - # Check both stdout and stderr for musl - output_text = (result.stdout + result.stderr).lower() - return 'musl' in output_text - except Exception as e: - print(f"Exception in is_musl_linux: {e}") - return False @unittest.skipUnless(sys.platform.startswith("linux") and not is_musl_linux(), "Runs only on Linux platforms") class TestDeltaLake(unittest.TestCase): @@ -44,5 +31,6 @@ def test_delta_lake(self): ''') self.assertEqual(ret.rows_read(), 0) + if __name__ == "__main__": unittest.main() diff --git a/tests/test_issue60.py b/tests/test_issue60.py index c3d32af330b..f1d4c976e47 100644 --- a/tests/test_issue60.py +++ b/tests/test_issue60.py @@ -2,9 +2,10 @@ import time import unittest import chdb +from utils import is_musl_linux + data = """url('https://datasets-documentation.s3.eu-west-3.amazonaws.com/house_parquet/house_0.parquet')""" -# data = """file('/home/Clickhouse/server/chdb-server/house_0.parquet', Parquet)""" query_str = f''' SELECT @@ -54,11 +55,13 @@ def print_chdb(threadName, delay): class TestQueryInThread(unittest.TestCase): + @unittest.skipIf(is_musl_linux(), "Skipping test on musl Linux") def test_query_in_thread(self): thread1 = myThread(1, "Thread-1", 1) thread1.start() thread1.join() self.assertEqual(str(result), expected_result) + if __name__ == '__main__': unittest.main() diff --git a/tests/test_session_concurrency.py b/tests/test_session_concurrency.py index c4541737fdf..2957e9632c8 100644 --- a/tests/test_session_concurrency.py +++ b/tests/test_session_concurrency.py @@ -7,26 +7,12 @@ import platform import subprocess from chdb import session +from utils import is_musl_linux test_concurrent_dir = ".tmp_test_session_concurrency" -def is_musl_linux(): - if platform.system() != "Linux": - return False - try: - result = subprocess.run(['ldd', '--version'], capture_output=True, text=True) - print(f"stdout: {result.stdout.lower()}") - print(f"stderr: {result.stderr.lower()}") - # Check both stdout and stderr for musl - output_text = (result.stdout + result.stderr).lower() - return 'musl' in output_text - except Exception as e: - print(f"Exception in is_musl_linux: {e}") - return False - - class TestSessionConcurrency(unittest.TestCase): def setUp(self) -> None: shutil.rmtree(test_concurrent_dir, ignore_errors=True) diff --git a/tests/test_unsupported_arrow_types.py b/tests/test_unsupported_arrow_types.py index df783ebe388..7d7a0d0280a 100644 --- a/tests/test_unsupported_arrow_types.py +++ b/tests/test_unsupported_arrow_types.py @@ -7,22 +7,7 @@ import pyarrow.compute as pc import chdb from chdb import ChdbError - - -def is_musl_linux(): - """Check if running on musl Linux""" - if platform.system() != "Linux": - return False - try: - result = subprocess.run(['ldd', '--version'], capture_output=True, text=True) - print(f"stdout: {result.stdout.lower()}") - print(f"stderr: {result.stderr.lower()}") - # Check both stdout and stderr for musl - output_text = (result.stdout + result.stderr).lower() - return 'musl' in output_text - except Exception as e: - print(f"Exception in is_musl_linux: {e}") - return False +from utils import is_musl_linux class TestUnsupportedArrowTypes(unittest.TestCase): diff --git a/tests/utils.py b/tests/utils.py index af14d4614f6..539749938b5 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,14 +1,13 @@ import re import os +import platform +import subprocess current_dir = os.path.dirname(os.path.abspath(__file__)) -data_file = os.path.join( - current_dir, "../tests/data/alltypes_dictionary.parquet") +data_file = os.path.join(current_dir, "../tests/data/alltypes_dictionary.parquet") # reset elapsed time to 0.0 from output, since it will be different each time # eg: "elapsed": 0.001015, - - def reset_elapsed(input): try: if not isinstance(input, str): @@ -20,3 +19,19 @@ def reset_elapsed(input): except UnicodeDecodeError: pass return input + + +def is_musl_linux(): + """Check if running on musl Linux""" + if platform.system() != "Linux": + return False + try: + result = subprocess.run(['ldd', '--version'], capture_output=True, text=True) + print(f"stdout: {result.stdout.lower()}") + print(f"stderr: {result.stderr.lower()}") + # Check both stdout and stderr for musl + output_text = (result.stdout + result.stderr).lower() + return 'musl' in output_text + except Exception as e: + print(f"Exception in is_musl_linux: {e}") + return False