Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
Takuka0311 committed Nov 27, 2024
1 parent 66eafb3 commit e43f5e7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
15 changes: 9 additions & 6 deletions core/unittest/config/CommonConfigProviderUnittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,17 +435,20 @@ void CommonConfigProviderUnittest::TestGetConfigUpdateAndConfigWatcher() {
auto pipelineConfigDiff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff();
PipelineManager::GetInstance()->UpdatePipelines(pipelineConfigDiff.first);
APSARA_TEST_TRUE(!pipelineConfigDiff.first.IsEmpty());
APSARA_TEST_EQUAL(1U, pipelineConfigDiff.first.mAdded.size());
APSARA_TEST_EQUAL(pipelineConfigDiff.first.mAdded[0].mName, "config1");
APSARA_TEST_EQUAL(PipelineManager::GetInstance()->GetAllConfigNames().size(), 1);
APSARA_TEST_EQUAL(2U, pipelineConfigDiff.first.mAdded.size());
APSARA_TEST_EQUAL(pipelineConfigDiff.first.mAdded[0].mName, LoongCollectorMonitor::GetInnerSelfMonitorMetricPipelineName());
APSARA_TEST_EQUAL(pipelineConfigDiff.first.mAdded[1].mName, "config1");
APSARA_TEST_EQUAL(PipelineManager::GetInstance()->GetAllConfigNames().size(), 2);
APSARA_TEST_EQUAL(PipelineManager::GetInstance()->GetAllConfigNames()[0], "config1");
APSARA_TEST_EQUAL(PipelineManager::GetInstance()->GetAllConfigNames()[1], LoongCollectorMonitor::GetInnerSelfMonitorMetricPipelineName());
// 再次处理 pipelineconfig
pipelineConfigDiff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff();
PipelineManager::GetInstance()->UpdatePipelines(pipelineConfigDiff.first);
APSARA_TEST_TRUE(pipelineConfigDiff.first.IsEmpty());
APSARA_TEST_TRUE(pipelineConfigDiff.first.mAdded.empty());
APSARA_TEST_EQUAL(PipelineManager::GetInstance()->GetAllConfigNames().size(), 1);
APSARA_TEST_EQUAL(PipelineManager::GetInstance()->GetAllConfigNames().size(), 2);
APSARA_TEST_EQUAL(PipelineManager::GetInstance()->GetAllConfigNames()[0], "config1");
APSARA_TEST_EQUAL(PipelineManager::GetInstance()->GetAllConfigNames()[1], LoongCollectorMonitor::GetInnerSelfMonitorMetricPipelineName());


APSARA_TEST_EQUAL(provider.mInstanceConfigInfoMap.size(), 2);
Expand Down Expand Up @@ -653,13 +656,13 @@ void CommonConfigProviderUnittest::TestGetConfigUpdateAndConfigWatcher() {
APSARA_TEST_TRUE(!pipelineConfigDiff.first.IsEmpty());
APSARA_TEST_EQUAL(1U, pipelineConfigDiff.first.mRemoved.size());
APSARA_TEST_EQUAL(pipelineConfigDiff.first.mRemoved[0], "config1");
APSARA_TEST_TRUE(PipelineManager::GetInstance()->GetAllConfigNames().empty());
APSARA_TEST_EQUAL(1U, PipelineManager::GetInstance()->GetAllConfigNames().size());
// 再次处理pipelineConfigDiff
pipelineConfigDiff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff();
PipelineManager::GetInstance()->UpdatePipelines(pipelineConfigDiff.first);
APSARA_TEST_TRUE(pipelineConfigDiff.first.IsEmpty());
APSARA_TEST_TRUE(pipelineConfigDiff.first.mRemoved.empty());
APSARA_TEST_TRUE(PipelineManager::GetInstance()->GetAllConfigNames().empty());
APSARA_TEST_EQUAL(1U, PipelineManager::GetInstance()->GetAllConfigNames().size());

APSARA_TEST_TRUE(provider.mInstanceConfigInfoMap.empty());
// 处理instanceConfigDiff
Expand Down
2 changes: 1 addition & 1 deletion core/unittest/config/ConfigUpdateUnittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class ConfigUpdateUnittest : public testing::Test {

void ConfigUpdateUnittest::OnStartUp() const {
auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff();
APSARA_TEST_TRUE(diff.first.IsEmpty());
APSARA_TEST_EQUAL(1U, diff.first.mAdded.size());
APSARA_TEST_TRUE(diff.second.IsEmpty());

GenerateInitialConfigs();
Expand Down
6 changes: 3 additions & 3 deletions core/unittest/config/ConfigWatcherUnittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const filesystem::path ConfigWatcherUnittest::instanceConfigDir = "./instance_co
void ConfigWatcherUnittest::InvalidConfigDirFound() const {
{
auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff();
APSARA_TEST_TRUE(diff.first.IsEmpty());
APSARA_TEST_EQUAL(1U, diff.first.mAdded.size());
APSARA_TEST_TRUE(diff.second.IsEmpty());

{ ofstream fout("continuous_pipeline_config"); }
Expand Down Expand Up @@ -82,7 +82,7 @@ void ConfigWatcherUnittest::InvalidConfigFileFound() const {
fout << "[}";
}
auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff();
APSARA_TEST_TRUE(diff.first.IsEmpty());
APSARA_TEST_EQUAL(1U, diff.first.mAdded.size());
APSARA_TEST_TRUE(diff.second.IsEmpty());
filesystem::remove_all(configDir);
}
Expand Down Expand Up @@ -132,7 +132,7 @@ void ConfigWatcherUnittest::DuplicateConfigs() const {
{ ofstream fout("dir2/config.json"); }
auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff();
APSARA_TEST_FALSE(diff.first.IsEmpty());
APSARA_TEST_EQUAL(1U, diff.first.mAdded.size());
APSARA_TEST_EQUAL(2U, diff.first.mAdded.size());

filesystem::remove_all("dir1");
filesystem::remove_all("dir2");
Expand Down

0 comments on commit e43f5e7

Please sign in to comment.