github-actions[bot] commented on code in PR #69945: URL: https://github.com/apache/doris/pull/69945#discussion_r4438874982
########## be/test/service/arrow_flight/arrow_flight_cancel_test.cpp: ########## @@ -0,0 +1,410 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include <arrow/flight/client.h> +#include <arrow/flight/sql/server.h> +#include <brpc/server.h> +#include <gtest/gtest.h> + +#include <future> +#include <thread> + +#include "exec/pipeline/dependency.h" +#include "load/channel/load_stream_mgr.h" +#include "runtime/result_buffer_mgr.h" +#include "service/arrow_flight/arrow_flight_batch_reader.h" +#include "service/arrow_flight/flight_sql_service.h" +#include "service/backend_options.h" +#include "service/internal_service.h" +#include "testutil/column_helper.h" +#include "testutil/mock/mock_runtime_state.h" +#include "util/brpc_client_cache.h" +#include "util/debug/leakcheck_disabler.h" +#include "util/dns_cache.h" + +namespace doris::flight { + +class ArrowFlightCancelTest : public testing::Test { +protected: + void SetUp() override { + _previous_mgr = std::exchange(ExecEnv::GetInstance()->_result_mgr, &_mgr); + _state._batch_size = 1; + _id.hi = 1; + _id.lo = 2; + auto schema = arrow::schema({arrow::field("value", arrow::int64())}); + std::shared_ptr<ResultBlockBufferBase> buffer; + ASSERT_TRUE(_mgr.create_sender(_id, 16, &buffer, &_state, true, schema).ok()); + _buffer = std::dynamic_pointer_cast<ArrowFlightResultBlockBuffer>(buffer); + _dep = Dependency::create_shared(0, 0, "Result", true); + _buffer->set_dependency(_state.fragment_instance_id(), _dep); + TNetworkAddress address; + address.hostname = BackendOptions::get_localhost(); + address.port = config::brpc_port; + _statement = std::make_shared<QueryStatement>(_id, address, "select value"); + } + void TearDown() override { ExecEnv::GetInstance()->_result_mgr = _previous_mgr; } + void fill_buffer() { + auto block = std::make_shared<Block>(ColumnHelper::create_block<DataTypeInt64>({1, 2})); + ASSERT_TRUE(_buffer->add_batch(&_state, block).ok()); + ASSERT_FALSE(_dep->ready()); + } + bool registered() { + std::shared_ptr<ArrowFlightResultBlockBuffer> found; + return _mgr.find_buffer(_id, found).ok(); + } + MockRuntimeState _state; + ResultBufferMgr _mgr; Review Comment: [P2] Unregister the result-buffer metric hook before this fixture's manager is destroyed. `ResultBufferMgr` registers a global `result_buffer_block_count` callback that captures `this`, while `TearDown()` restores only `ExecEnv::_result_mgr`; the `_mgr` member is then destroyed, leaving metric scrapes with a dangling callback. Subsequent fixtures also cannot replace the hook because registration uses `emplace`. Scope cleanup to the hook owned by this fixture (preserving any prior hook) or avoid constructing an unregistered manager per test. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
