github-actions[bot] commented on code in PR #62764: URL: https://github.com/apache/doris/pull/62764#discussion_r3297528577
########## be/test/cloud/cloud_warm_up_manager_test.cpp: ########## @@ -0,0 +1,298 @@ +// 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 "cloud/cloud_warm_up_manager.h" + +#include <bthread/condition_variable.h> +#include <gtest/gtest.h> + +#include <atomic> +#include <chrono> +#include <condition_variable> +#include <functional> +#include <memory> +#include <mutex> +#include <thread> + +#include "cloud/cloud_storage_engine.h" +#include "cloud/config.h" +#include "cpp/sync_point.h" +#include "storage/olap_common.h" +#include "storage/rowset/rowset_meta.h" + +namespace doris { + +using namespace std::chrono_literals; + +namespace { + +bool wait_until(const std::function<bool()>& pred, std::chrono::milliseconds timeout) { + auto deadline = std::chrono::steady_clock::now() + timeout; + while (std::chrono::steady_clock::now() < deadline) { + if (pred()) { + return true; + } + std::this_thread::sleep_for(10ms); + } + return pred(); +} + +} // namespace + +class CloudWarmUpManagerTest : public testing::Test { +public: + void SetUp() override { + _origin_thread_pool_size = config::warm_up_manager_thread_pool_size; + SyncPoint::get_instance()->clear_all_call_backs(); + SyncPoint::get_instance()->enable_processing(); + } + + void TearDown() override { + SyncPoint::get_instance()->disable_processing(); + SyncPoint::get_instance()->clear_all_call_backs(); + config::warm_up_manager_thread_pool_size = _origin_thread_pool_size; + } + + std::unique_ptr<RowsetMeta> create_rowset_meta(int64_t tablet_id) { + auto rs_meta = std::make_unique<RowsetMeta>(); + rs_meta->set_tablet_id(tablet_id); + rs_meta->set_rowset_id(_engine.next_rowset_id()); + rs_meta->set_rowset_type(BETA_ROWSET); + rs_meta->set_rowset_state(VISIBLE); + rs_meta->set_version({1, 1}); + rs_meta->set_num_segments(1); + return rs_meta; + } + +protected: + CloudStorageEngine _engine {EngineOptions {}}; + int32_t _origin_thread_pool_size = 0; +}; + +TEST_F(CloudWarmUpManagerTest, NonPositiveTimeoutQueuesBackgroundCopyAndReturns) { + config::warm_up_manager_thread_pool_size = 1; + CloudWarmUpManager manager(_engine); + + std::mutex blocker_mtx; + std::condition_variable blocker_cv; + bool blocker_started = false; + bool release_blocker = false; + + ASSERT_TRUE(manager._thread_pool_token + ->submit_func([&] { Review Comment: This test directly accesses `CloudWarmUpManager::_thread_pool_token`, but that member is private in `cloud_warm_up_manager.h` and this file does not use a `#define private public` test hack or a friend/test hook. `BE_TEST` only exposes `consumer_job()`, so the new BE unit test will fail to compile. Please expose a small test hook or drive the behavior through public/sync-point observable state instead of accessing the private token directly. -- 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]
