From adfe22bffbacbe05e41505dfa0c0acd6e0461dea Mon Sep 17 00:00:00 2001 From: yuzelin Date: Wed, 27 Nov 2024 20:31:22 +0800 Subject: [PATCH] try fix? --- pypaimon/py4j/tests/test_data_types.py | 24 +++++++++++++++++----- pypaimon/py4j/tests/test_preicates.py | 22 ++++++++++++++++---- pypaimon/py4j/tests/test_write_and_read.py | 22 +++++++++++++++----- 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/pypaimon/py4j/tests/test_data_types.py b/pypaimon/py4j/tests/test_data_types.py index 66241c3..aa95adc 100644 --- a/pypaimon/py4j/tests/test_data_types.py +++ b/pypaimon/py4j/tests/test_data_types.py @@ -15,22 +15,35 @@ # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ - +import os import random +import shutil import string +import tempfile + import pyarrow as pa import unittest from pypaimon import Schema -from pypaimon.py4j.tests import utils -from pypaimon.py4j.util import java_utils +from pypaimon.py4j import Catalog +from pypaimon.py4j.tests.utils import _setup_hadoop_bundle_jar, _setup_bridge_jar +from pypaimon.py4j.util import java_utils, constants class DataTypesTest(unittest.TestCase): @classmethod def setUpClass(cls): - cls.tempdir, cls.warehouse, cls.catalog = utils.setup_class() + os.environ[constants.PYPAIMON4J_TEST_MODE] = 'true' + cls.tempdir = tempfile.mkdtemp() + + _setup_hadoop_bundle_jar(cls.tempdir) + _setup_bridge_jar(cls.tempdir) + + cls.warehouse = os.path.join(cls.tempdir, 'warehouse') + cls.catalog = Catalog.create({'warehouse': cls.warehouse}) + cls.catalog.create_database('default', False) + cls.simple_pa_schema = pa.schema([ ('f0', pa.int32()), ('f1', pa.string()) @@ -38,7 +51,8 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - utils.teardown_class(cls.tempdir) + shutil.rmtree(cls.tempdir, ignore_errors=True) + del os.environ[constants.PYPAIMON4J_TEST_MODE] def test_int(self): pa_schema = pa.schema([ diff --git a/pypaimon/py4j/tests/test_preicates.py b/pypaimon/py4j/tests/test_preicates.py index e32bd95..faf9cb6 100644 --- a/pypaimon/py4j/tests/test_preicates.py +++ b/pypaimon/py4j/tests/test_preicates.py @@ -15,14 +15,18 @@ # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ - +import os +import shutil +import tempfile import unittest import random import pandas as pd import pyarrow as pa from pypaimon import Schema -from pypaimon.py4j.tests import utils +from pypaimon.py4j import Catalog +from pypaimon.py4j.tests.utils import _setup_hadoop_bundle_jar, _setup_bridge_jar +from pypaimon.py4j.util import constants def _check_filtered_result(read_builder, expected_df): @@ -42,7 +46,16 @@ class PredicateTest(unittest.TestCase): @classmethod def setUpClass(cls): - cls.tempdir, cls.warehouse, cls.catalog = utils.setup_class() + os.environ[constants.PYPAIMON4J_TEST_MODE] = 'true' + cls.tempdir = tempfile.mkdtemp() + + _setup_hadoop_bundle_jar(cls.tempdir) + _setup_bridge_jar(cls.tempdir) + + cls.warehouse = os.path.join(cls.tempdir, 'warehouse') + cls.catalog = Catalog.create({'warehouse': cls.warehouse}) + cls.catalog.create_database('default', False) + pa_schema = pa.schema([ ('f0', pa.int64()), ('f1', pa.string()), @@ -82,7 +95,8 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - utils.teardown_class(cls.tempdir) + shutil.rmtree(cls.tempdir, ignore_errors=True) + del os.environ[constants.PYPAIMON4J_TEST_MODE] def testWrongFieldName(self): table = self.catalog.get_table('default.test_append') diff --git a/pypaimon/py4j/tests/test_write_and_read.py b/pypaimon/py4j/tests/test_write_and_read.py index 2565702..de4bcf3 100644 --- a/pypaimon/py4j/tests/test_write_and_read.py +++ b/pypaimon/py4j/tests/test_write_and_read.py @@ -15,7 +15,9 @@ # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ - +import os +import shutil +import tempfile import unittest import pandas as pd import pyarrow as pa @@ -24,15 +26,24 @@ from pypaimon import Schema from pypaimon.py4j import Catalog from pypaimon.py4j.java_gateway import get_gateway -from pypaimon.py4j.tests import utils -from pypaimon.py4j.util import java_utils +from pypaimon.py4j.tests.utils import _setup_hadoop_bundle_jar, _setup_bridge_jar +from pypaimon.py4j.util import java_utils, constants class TableWriteReadTest(unittest.TestCase): @classmethod def setUpClass(cls): - cls.tempdir, cls.warehouse, cls.catalog = utils.setup_class() + os.environ[constants.PYPAIMON4J_TEST_MODE] = 'true' + cls.tempdir = tempfile.mkdtemp() + + _setup_hadoop_bundle_jar(cls.tempdir) + _setup_bridge_jar(cls.tempdir) + + cls.warehouse = os.path.join(cls.tempdir, 'warehouse') + cls.catalog = Catalog.create({'warehouse': cls.warehouse}) + cls.catalog.create_database('default', False) + cls.simple_pa_schema = pa.schema([ ('f0', pa.int32()), ('f1', pa.string()) @@ -40,7 +51,8 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - utils.teardown_class(cls.tempdir) + shutil.rmtree(cls.tempdir, ignore_errors=True) + del os.environ[constants.PYPAIMON4J_TEST_MODE] def testReadEmptyAppendTable(self): schema = Schema(self.simple_pa_schema)