From 263997e805f70dea637f55601e561446e5d66821 Mon Sep 17 00:00:00 2001 From: Ian Rodney Date: Sun, 29 Mar 2020 22:06:36 -0700 Subject: [PATCH] Revert "Revert "Pyarrow Segfault Regression Test (#7568)" (#7805)" This reverts commit eb61036ba212e2e2a8bb0a1630158ac41215b7da. --- python/ray/tests/BUILD | 8 ++++++ python/ray/tests/test_symbol_collisions.py | 29 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 python/ray/tests/test_symbol_collisions.py diff --git a/python/ray/tests/BUILD b/python/ray/tests/BUILD index 3cfa7a18b75df..0aa1c77ed7ffb 100644 --- a/python/ray/tests/BUILD +++ b/python/ray/tests/BUILD @@ -407,3 +407,11 @@ py_test( tags = ["exclusive"], deps = ["//:ray_lib"], ) + +py_test( + name = "test_symbol_collisions", + size = "small", + srcs = ["test_symbol_collisions.py"], + tags = ["exclusive"], + deps = ["//:ray_lib"], +) diff --git a/python/ray/tests/test_symbol_collisions.py b/python/ray/tests/test_symbol_collisions.py new file mode 100644 index 0000000000000..fdd684cc4bd0b --- /dev/null +++ b/python/ray/tests/test_symbol_collisions.py @@ -0,0 +1,29 @@ +""" +This script ensures that various libraries do not conflict with ray by +trying to import both libraries in both orders. +A specific example is that importing ray after pyarrow causes a Segfault. +""" +import subprocess + +TESTED_LIBRARIES = ["pyarrow"] + + +def test_imports(): + def try_imports(library1, library2): + return_info = subprocess.run([ + "python", "-c", "import {}; import {}".format(library1, library2) + ]) + if return_info.returncode != 0: + return "Importing {} before {} caused an error".format( + library1, library2) + return "" + + for library in TESTED_LIBRARIES: + assert try_imports("ray", library) == "" + assert try_imports(library, "ray") == "" + + +if __name__ == "__main__": + import sys + import pytest + sys.exit(pytest.main(["-v", __file__]))