90 lines
3.0 KiB
C++
90 lines
3.0 KiB
C++
// 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 "olap/storage_engine.h"
|
|
|
|
#include <gmock/gmock-actions.h>
|
|
#include <gmock/gmock-matchers.h>
|
|
#include <gtest/gtest-message.h>
|
|
#include <gtest/gtest-test-part.h>
|
|
|
|
#include <filesystem>
|
|
|
|
#include "common/status.h"
|
|
#include "gtest/gtest_pred_impl.h"
|
|
#include "testutil/test_util.h"
|
|
|
|
using ::testing::_;
|
|
using ::testing::Return;
|
|
using ::testing::SetArgPointee;
|
|
using std::string;
|
|
|
|
namespace doris {
|
|
using namespace config;
|
|
|
|
class StorageEngineTest : public testing::Test {
|
|
public:
|
|
virtual void SetUp() {
|
|
EngineOptions options;
|
|
|
|
_storage_engine.reset(new StorageEngine(options));
|
|
}
|
|
|
|
virtual void TearDown() {}
|
|
|
|
std::unique_ptr<StorageEngine> _storage_engine;
|
|
};
|
|
|
|
TEST_F(StorageEngineTest, TestBrokenDisk) {
|
|
DEFINE_mString(broken_storage_path, "");
|
|
std::string path = config::custom_config_dir + "/be_custom.conf";
|
|
|
|
std::error_code ec;
|
|
{
|
|
_storage_engine->add_broken_path("broken_path1");
|
|
EXPECT_EQ(std::filesystem::exists(path, ec), true);
|
|
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path1"), 1);
|
|
EXPECT_EQ(broken_storage_path, "broken_path1;");
|
|
}
|
|
|
|
{
|
|
_storage_engine->add_broken_path("broken_path2");
|
|
EXPECT_EQ(std::filesystem::exists(path, ec), true);
|
|
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path1"), 1);
|
|
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path2"), 1);
|
|
EXPECT_EQ(broken_storage_path, "broken_path1;broken_path2;");
|
|
}
|
|
|
|
{
|
|
_storage_engine->add_broken_path("broken_path2");
|
|
EXPECT_EQ(std::filesystem::exists(path, ec), true);
|
|
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path1"), 1);
|
|
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path2"), 1);
|
|
EXPECT_EQ(broken_storage_path, "broken_path1;broken_path2;");
|
|
}
|
|
|
|
{
|
|
_storage_engine->remove_broken_path("broken_path2");
|
|
EXPECT_EQ(std::filesystem::exists(path, ec), true);
|
|
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path1"), 1);
|
|
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path2"), 0);
|
|
EXPECT_EQ(broken_storage_path, "broken_path1;");
|
|
}
|
|
}
|
|
|
|
} // namespace doris
|