Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions be/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ file(GLOB_RECURSE UT_FILES CONFIGURE_DEPENDS
gutil/*.cpp
io/*.cpp
load/*.cpp
olap/*.cpp
runtime/*.cpp
service/*.cpp
storage/*.cpp
testutil/*.cpp
udf/*.cpp
tools/*.cpp
util/*.cpp
vec/*.cpp
Expand Down
21 changes: 19 additions & 2 deletions be/test/udf/python/python_server_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,23 @@ class PythonServerTest : public ::testing::Test {
bp::child child(sleep_path, "60", bp::std_out > output_stream, bp::std_err > bp::null);
return std::make_shared<PythonUDFProcess>(std::move(child), std::move(output_stream));
}

template <typename VersionedPoolPtr>
Status get_process_with_retry(
PythonServerManager& mgr, const PythonVersion& version,
const VersionedPoolPtr& versioned_pool, ProcessPtr* process,
std::chrono::milliseconds timeout = std::chrono::milliseconds(5000)) {
Status last_status;
auto deadline = std::chrono::steady_clock::now() + timeout;
while (std::chrono::steady_clock::now() < deadline) {
last_status = mgr._get_process(version, versioned_pool, process);
if (last_status.ok()) {
return last_status;
}
std::this_thread::sleep_for(std::chrono::milliseconds(50));
Comment thread
linrrzqqq marked this conversation as resolved.
}
return last_status;
}
};

// ============================================================================
Expand All @@ -221,7 +238,7 @@ TEST_F(PythonServerTest, EnsurePoolInitializedCanInitializeEmptyPoolForTest) {
PythonVersion version("3.9.16", test_dir_, python_path);
config::max_python_process_num = 1;

mgr.set_process_pool_for_test(version, {});
mgr.set_process_pool_for_test(version, {}, false);
auto pool_result = mgr._ensure_pool_initialized(version);
ASSERT_TRUE(pool_result.has_value()) << pool_result.error().to_string();

Expand Down Expand Up @@ -746,7 +763,7 @@ TEST_F(PythonServerTest, GetProcessRecreatesDeadProcessWhenNoAliveProcess) {
ASSERT_FALSE(first_process->is_alive());

ProcessPtr replacement;
Status status = mgr._get_process(version, pool_result.value(), &replacement);
Status status = get_process_with_retry(mgr, version, pool_result.value(), &replacement);

EXPECT_TRUE(status.ok()) << status.to_string();
ASSERT_NE(replacement, nullptr);
Expand Down
9 changes: 6 additions & 3 deletions be/test/udf/python/python_udf_runtime_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,12 @@ TEST_F(PythonUDFRuntimeTest, WaitChildExitReturnsExitedForExitedChild) {
&exit_status);
child.detach();

EXPECT_EQ(result, PythonUDFProcess::ChildExitWaitResult::EXITED);
EXPECT_TRUE(WIFEXITED(exit_status));
EXPECT_EQ(WEXITSTATUS(exit_status), 7);
EXPECT_TRUE(result == PythonUDFProcess::ChildExitWaitResult::EXITED ||
result == PythonUDFProcess::ChildExitWaitResult::ALREADY_REAPED);
if (result == PythonUDFProcess::ChildExitWaitResult::EXITED) {
EXPECT_TRUE(WIFEXITED(exit_status));
EXPECT_EQ(WEXITSTATUS(exit_status), 7);
}
}

TEST_F(PythonUDFRuntimeTest, WaitChildExitReturnsTimeoutForRunningChild) {
Expand Down
Loading