diff --git a/core/unittest/config/ConfigUpdateUnittest.cpp b/core/unittest/config/ConfigUpdateUnittest.cpp index fddd53804a..05c1d65c0b 100644 --- a/core/unittest/config/ConfigUpdateUnittest.cpp +++ b/core/unittest/config/ConfigUpdateUnittest.cpp @@ -62,6 +62,9 @@ class ConfigUpdateUnittest : public testing::Test { void SetUp() override { filesystem::create_directories(configDir); PipelineConfigWatcher::GetInstance()->AddSource(configDir.string()); +#ifdef __ENTERPRISE__ + builtinPipelineCnt = EnterpriseConfigProvider::GetInstance()->GetAllBuiltInPipelineConfigs().size(); +#endif } void TearDown() override { @@ -75,6 +78,7 @@ class ConfigUpdateUnittest : public testing::Test { void PrepareInitialSettings() const; void GenerateInitialConfigs() const; + size_t builtinPipelineCnt = 0; filesystem::path configDir = "./continuous_pipeline_config"; vector pipelineConfigPaths = {configDir / "pipeline_invalid_format.json", configDir / "pipeline_invalid_detail.json", @@ -236,10 +240,6 @@ class ConfigUpdateUnittest : public testing::Test { void ConfigUpdateUnittest::OnStartUp() const { auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - size_t builtinPipelineCnt = 0; -#ifdef __ENTERPRISE__ - builtinPipelineCnt += EnterpriseConfigProvider::GetInstance()->GetAllBuiltInPipelineConfigs().size(); -#endif APSARA_TEST_EQUAL(0U + builtinPipelineCnt, diff.first.mAdded.size()); APSARA_TEST_TRUE(diff.second.IsEmpty()); @@ -255,7 +255,7 @@ void ConfigUpdateUnittest::OnStartUp() const { APSARA_TEST_TRUE(diff.second.mRemoved.empty()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL(1U + builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); TaskPipelineManager::GetInstance()->UpdatePipelines(diff.second); APSARA_TEST_EQUAL(1U, TaskPipelineManager::GetInstance()->GetAllPipelineNames().size()); auto& ptr = TaskPipelineManager::GetInstance()->FindPipelineByName("task_enabled_valid"); @@ -266,7 +266,7 @@ void ConfigUpdateUnittest::OnStartUp() const { void ConfigUpdateUnittest::OnConfigDelete() const { PrepareInitialSettings(); - APSARA_TEST_EQUAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL(1U + builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); APSARA_TEST_EQUAL(1U, TaskPipelineManager::GetInstance()->GetAllPipelineNames().size()); filesystem::remove_all(configDir); @@ -281,14 +281,14 @@ void ConfigUpdateUnittest::OnConfigDelete() const { APSARA_TEST_EQUAL(1U, diff.second.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_TRUE(PipelineManagerMock::GetInstance()->GetAllConfigNames().empty()); + APSARA_TEST_EQUAL(builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); TaskPipelineManager::GetInstance()->UpdatePipelines(diff.second); APSARA_TEST_TRUE(TaskPipelineManager::GetInstance()->GetAllPipelineNames().empty()); } void ConfigUpdateUnittest::OnConfigToInvalidFormat() const { PrepareInitialSettings(); - APSARA_TEST_EQUAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL(1U + builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); APSARA_TEST_EQUAL(1U, TaskPipelineManager::GetInstance()->GetAllPipelineNames().size()); for (const auto& path : pipelineConfigPaths) { @@ -306,7 +306,7 @@ void ConfigUpdateUnittest::OnConfigToInvalidFormat() const { void ConfigUpdateUnittest::OnConfigToInvalidDetail() const { PrepareInitialSettings(); - APSARA_TEST_EQUAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL(1U + builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); APSARA_TEST_EQUAL(1U, TaskPipelineManager::GetInstance()->GetAllPipelineNames().size()); for (const auto& path : pipelineConfigPaths) { @@ -328,7 +328,7 @@ void ConfigUpdateUnittest::OnConfigToInvalidDetail() const { APSARA_TEST_TRUE(diff.second.mRemoved.empty()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL(1U + builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); auto& ptr = TaskPipelineManager::GetInstance()->FindPipelineByName("task_enabled_valid"); TaskPipelineManager::GetInstance()->UpdatePipelines(diff.second); APSARA_TEST_EQUAL(1U, TaskPipelineManager::GetInstance()->GetAllPipelineNames().size()); @@ -340,7 +340,7 @@ void ConfigUpdateUnittest::OnConfigToInvalidDetail() const { void ConfigUpdateUnittest::OnConfigToEnabledValid() const { PrepareInitialSettings(); - APSARA_TEST_EQUAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL(1U + builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); APSARA_TEST_EQUAL(1U, TaskPipelineManager::GetInstance()->GetAllPipelineNames().size()); for (const auto& path : pipelineConfigPaths) { @@ -362,7 +362,7 @@ void ConfigUpdateUnittest::OnConfigToEnabledValid() const { APSARA_TEST_TRUE(diff.second.mRemoved.empty()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL(4U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL(4U + builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); TaskPipelineManager::GetInstance()->UpdatePipelines(diff.second); APSARA_TEST_EQUAL(4U, TaskPipelineManager::GetInstance()->GetAllPipelineNames().size()); { @@ -393,7 +393,7 @@ void ConfigUpdateUnittest::OnConfigToEnabledValid() const { void ConfigUpdateUnittest::OnConfigToDisabledValid() const { PrepareInitialSettings(); - APSARA_TEST_EQUAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL(1U + builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); APSARA_TEST_EQUAL(1U, TaskPipelineManager::GetInstance()->GetAllPipelineNames().size()); for (const auto& path : pipelineConfigPaths) { @@ -411,14 +411,14 @@ void ConfigUpdateUnittest::OnConfigToDisabledValid() const { APSARA_TEST_EQUAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_TRUE(PipelineManagerMock::GetInstance()->GetAllConfigNames().empty()); + APSARA_TEST_EQUAL(builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); TaskPipelineManager::GetInstance()->UpdatePipelines(diff.second); APSARA_TEST_TRUE(TaskPipelineManager::GetInstance()->GetAllPipelineNames().empty()); } void ConfigUpdateUnittest::OnConfigUnchanged() const { PrepareInitialSettings(); - APSARA_TEST_EQUAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL(1U + builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); APSARA_TEST_EQUAL(1U, TaskPipelineManager::GetInstance()->GetAllPipelineNames().size()); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); @@ -446,7 +446,7 @@ void ConfigUpdateUnittest::OnConfigUnchanged() const { APSARA_TEST_TRUE(diff.second.mRemoved.empty()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL(1U + builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); auto& ptr = TaskPipelineManager::GetInstance()->FindPipelineByName("task_enabled_valid"); TaskPipelineManager::GetInstance()->UpdatePipelines(diff.second); APSARA_TEST_EQUAL(1U, TaskPipelineManager::GetInstance()->GetAllPipelineNames().size()); @@ -458,7 +458,7 @@ void ConfigUpdateUnittest::OnConfigUnchanged() const { void ConfigUpdateUnittest::OnConfigAdded() const { PrepareInitialSettings(); - APSARA_TEST_EQUAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL(1U + builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); APSARA_TEST_EQUAL(1U, TaskPipelineManager::GetInstance()->GetAllPipelineNames().size()); { @@ -504,7 +504,7 @@ void ConfigUpdateUnittest::OnConfigAdded() const { APSARA_TEST_TRUE(diff.second.mRemoved.empty()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL(2U + builtinPipelineCnt, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); auto& ptr = TaskPipelineManager::GetInstance()->FindPipelineByName("task_enabled_valid"); TaskPipelineManager::GetInstance()->UpdatePipelines(diff.second); APSARA_TEST_EQUAL(2U, TaskPipelineManager::GetInstance()->GetAllPipelineNames().size()); diff --git a/core/unittest/config/PipelineConfigWatcherUnittest.cpp b/core/unittest/config/PipelineConfigWatcherUnittest.cpp index 56c8c3fdd4..920aec0882 100644 --- a/core/unittest/config/PipelineConfigWatcherUnittest.cpp +++ b/core/unittest/config/PipelineConfigWatcherUnittest.cpp @@ -18,6 +18,9 @@ #include #include "common/JsonUtil.h" +#ifdef __ENTERPRISE__ +#include "config/provider/EnterpriseConfigProvider.h" +#endif #include "config/watcher/PipelineConfigWatcher.h" #include "plugin/PluginRegistry.h" #include "unittest/Unittest.h" @@ -47,6 +50,9 @@ class PipelineConfigWatcherUnittest : public testing::Test { PipelineConfigWatcher::GetInstance()->AddSource(configDir1.string()); filesystem::create_directories(configDir2); PipelineConfigWatcher::GetInstance()->AddSource(configDir2.string()); +#ifdef __ENTERPRISE__ + builtinPipelineCnt = EnterpriseConfigProvider::GetInstance()->GetAllBuiltInPipelineConfigs().size(); +#endif } void ClearConfig() { @@ -56,6 +62,7 @@ class PipelineConfigWatcherUnittest : public testing::Test { filesystem::remove_all(configDir2); } + size_t builtinPipelineCnt = 0; filesystem::path configDir1 = "./continuous_pipeline_config1"; filesystem::path configDir2 = "./continuous_pipeline_config2"; @@ -182,16 +189,16 @@ void PipelineConfigWatcherUnittest::TestLoadAddedSingletonConfig() { fout << otherConfig; fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: added -> added, first < second @@ -206,16 +213,16 @@ void PipelineConfigWatcherUnittest::TestLoadAddedSingletonConfig() { fout << otherConfig; fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: added -> added, first > second -> first < second @@ -234,7 +241,8 @@ void PipelineConfigWatcherUnittest::TestLoadAddedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test1.json", ios::trunc); @@ -247,16 +255,16 @@ void PipelineConfigWatcherUnittest::TestLoadAddedSingletonConfig() { fout << modifiedOtherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: added -> modified, first < second @@ -269,7 +277,8 @@ void PipelineConfigWatcherUnittest::TestLoadAddedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test1.json", ios::trunc); @@ -282,16 +291,16 @@ void PipelineConfigWatcherUnittest::TestLoadAddedSingletonConfig() { fout << modifiedOtherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: added -> modified, first > second -> first < second @@ -310,7 +319,8 @@ void PipelineConfigWatcherUnittest::TestLoadAddedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); fout.open(configDir1 / "test1.json", ios::trunc); fout << greaterPriorityConfig; @@ -318,13 +328,13 @@ void PipelineConfigWatcherUnittest::TestLoadAddedSingletonConfig() { filesystem::remove(configDir2 / "test2.json"); filesystem::remove(configDir2 / "test-other.json"); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(1U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(1U + builtinPipelineCnt, allConfigNames.size()); APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[0]); ClearConfig(); } @@ -338,7 +348,8 @@ void PipelineConfigWatcherUnittest::TestLoadAddedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); fout.open(configDir1 / "test1.json", ios::trunc); fout << lessPriorityConfig; @@ -346,13 +357,13 @@ void PipelineConfigWatcherUnittest::TestLoadAddedSingletonConfig() { filesystem::remove(configDir2 / "test2.json"); filesystem::remove(configDir2 / "test-other.json"); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(1U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(1U + builtinPipelineCnt, allConfigNames.size()); APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[0]); ClearConfig(); } @@ -372,22 +383,23 @@ void PipelineConfigWatcherUnittest::TestLoadAddedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); fout.open(configDir1 / "test1.json", ios::trunc); fout << greaterPriorityConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: added -> unchanged, first < second @@ -400,22 +412,23 @@ void PipelineConfigWatcherUnittest::TestLoadAddedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); fout.open(configDir1 / "test1.json", ios::trunc); fout << lessPriorityConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: added -> unchanged, first > second -> first < second @@ -434,7 +447,8 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(1U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test1.json", ios::trunc); @@ -447,16 +461,16 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout << otherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: modified -> added, first < second @@ -466,7 +480,8 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(1U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test1.json", ios::trunc); @@ -479,16 +494,16 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout << otherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: modified -> added, first > second -> first < second @@ -510,7 +525,8 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test1.json", ios::trunc); @@ -523,16 +539,16 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout << modifiedOtherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: modified -> modified, first < second @@ -548,7 +564,8 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test1.json", ios::trunc); @@ -561,16 +578,16 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout << modifiedOtherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: modified -> modified, first > second -> first < second @@ -586,7 +603,8 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test1.json", ios::trunc); @@ -599,16 +617,16 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout << modifiedOtherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: modified -> modified, first < second -> first > second @@ -624,7 +642,8 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test1.json", ios::trunc); @@ -637,16 +656,16 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout << modifiedOtherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: modified -> removed, first > second @@ -662,7 +681,8 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test1.json", ios::trunc); @@ -671,14 +691,14 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { filesystem::remove(configDir2 / "test2.json"); filesystem::remove(configDir2 / "test-other.json"); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(1U, allConfigNames.size()); - APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[0]); + APSARA_TEST_EQUAL_FATAL(1U + builtinPipelineCnt, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[builtinPipelineCnt]); ClearConfig(); } { // case: modified -> removed, first < second @@ -694,7 +714,8 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test1.json", ios::trunc); @@ -703,13 +724,13 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { filesystem::remove(configDir2 / "test2.json"); filesystem::remove(configDir2 / "test-other.json"); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(1U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(1U + builtinPipelineCnt, allConfigNames.size()); APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[0]); ClearConfig(); } @@ -732,23 +753,24 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test1.json", ios::trunc); fout << modifiedGreaterPriorityConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: modified -> unchanged, first < second @@ -764,7 +786,8 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test1.json", ios::trunc); @@ -772,16 +795,16 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout.close(); filesystem::remove(configDir2 / "test2.json"); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: modified -> unchanged, first > second -> first < second @@ -797,23 +820,24 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test1.json", ios::trunc); fout << lessPriorityConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: modified -> unchanged, first < second -> first > second @@ -829,23 +853,24 @@ void PipelineConfigWatcherUnittest::TestLoadModifiedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fout.open(configDir1 / "test3.json", ios::trunc); fout << greaterPriorityConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test3", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test3", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } } @@ -857,8 +882,13 @@ void PipelineConfigWatcherUnittest::TestLoadRemovedSingletonConfig() { fout << greaterPriorityConfig; fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); + size_t builtinPipelineCnt = 0; +#ifdef __ENTERPRISE__ + builtinPipelineCnt += EnterpriseConfigProvider::GetInstance()->GetAllBuiltInPipelineConfigs().size(); +#endif PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(1U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); filesystem::remove(configDir1 / "test1.json"); fout.open(configDir2 / "test2.json", ios::trunc); @@ -868,16 +898,16 @@ void PipelineConfigWatcherUnittest::TestLoadRemovedSingletonConfig() { fout << otherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: removed -> added, first < second @@ -887,7 +917,8 @@ void PipelineConfigWatcherUnittest::TestLoadRemovedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(1U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); filesystem::remove(configDir1 / "test1.json"); fout.open(configDir2 / "test2.json", ios::trunc); @@ -897,16 +928,16 @@ void PipelineConfigWatcherUnittest::TestLoadRemovedSingletonConfig() { fout << otherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: removed -> added, first > second -> first < second @@ -928,7 +959,8 @@ void PipelineConfigWatcherUnittest::TestLoadRemovedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); this_thread::sleep_for(chrono::milliseconds(1)); filesystem::remove(configDir1 / "test1.json"); @@ -939,16 +971,16 @@ void PipelineConfigWatcherUnittest::TestLoadRemovedSingletonConfig() { fout << modifiedOtherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: removed -> modified, first < second @@ -964,7 +996,8 @@ void PipelineConfigWatcherUnittest::TestLoadRemovedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); this_thread::sleep_for(chrono::milliseconds(1)); filesystem::remove(configDir1 / "test1.json"); @@ -975,16 +1008,16 @@ void PipelineConfigWatcherUnittest::TestLoadRemovedSingletonConfig() { fout << modifiedOtherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: removed -> modified, first > second -> first < second @@ -1006,18 +1039,20 @@ void PipelineConfigWatcherUnittest::TestLoadRemovedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); filesystem::remove(configDir1 / "test1.json"); filesystem::remove(configDir2 / "test2.json"); filesystem::remove(configDir2 / "test-other.json"); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(0U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(0U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); ClearConfig(); } { // case: removed -> removed, first < second @@ -1033,18 +1068,20 @@ void PipelineConfigWatcherUnittest::TestLoadRemovedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); filesystem::remove(configDir1 / "test1.json"); filesystem::remove(configDir2 / "test2.json"); filesystem::remove(configDir2 / "test-other.json"); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(0U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(0U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); ClearConfig(); } { // case: removed -> removed, first > second -> first < second @@ -1066,20 +1103,21 @@ void PipelineConfigWatcherUnittest::TestLoadRemovedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); filesystem::remove(configDir1 / "test1.json"); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: removed -> unchanged, first < second @@ -1095,20 +1133,21 @@ void PipelineConfigWatcherUnittest::TestLoadRemovedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); filesystem::remove(configDir1 / "test1.json"); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: removed -> unchanged, first > second -> first < second @@ -1126,8 +1165,13 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout << greaterPriorityConfig; fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); + size_t builtinPipelineCnt = 0; +#ifdef __ENTERPRISE__ + builtinPipelineCnt += EnterpriseConfigProvider::GetInstance()->GetAllBuiltInPipelineConfigs().size(); +#endif PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(1U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); fout.open(configDir2 / "test2.json", ios::trunc); fout << lessPriorityConfig; @@ -1136,16 +1180,16 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout << otherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: unchanged -> added, first < second @@ -1155,7 +1199,8 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(1U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(1U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); fout.open(configDir2 / "test2.json", ios::trunc); fout << greaterPriorityConfig; @@ -1164,16 +1209,16 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout << otherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: unchanged -> added, first > second -> first < second @@ -1195,7 +1240,8 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); fout.open(configDir2 / "test2.json", ios::trunc); fout << modifiedLessPriorityConfig; @@ -1204,16 +1250,16 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout << modifiedOtherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: unchanged -> modified, first < second @@ -1229,7 +1275,8 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); fout.open(configDir2 / "test2.json", ios::trunc); fout << modifiedGreaterPriorityConfig; @@ -1238,16 +1285,16 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout << modifiedOtherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: unchanged -> modified, first > second -> first < second @@ -1263,7 +1310,8 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); fout.open(configDir2 / "test2.json", ios::trunc); fout << greaterPriorityConfig; @@ -1272,16 +1320,16 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout << modifiedOtherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: unchanged -> modified, first < second -> first > second @@ -1297,7 +1345,8 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); fout.open(configDir2 / "test2.json", ios::trunc); fout << modifiedLessPriorityConfig; @@ -1306,16 +1355,16 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout << modifiedOtherConfig; fout.close(); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test3", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test3", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: unchanged -> removed, first > second @@ -1331,19 +1380,20 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); filesystem::remove(configDir2 / "test2.json"); filesystem::remove(configDir2 / "test-other.json"); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(1U, allConfigNames.size()); - APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[0]); + APSARA_TEST_EQUAL_FATAL(1U + builtinPipelineCnt, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[builtinPipelineCnt]); ClearConfig(); } { // case: unchanged -> removed, first < second @@ -1359,18 +1409,19 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); filesystem::remove(configDir2 / "test2.json"); filesystem::remove(configDir2 / "test-other.json"); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(1, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(2, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(1U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(2U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(1U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(1U + builtinPipelineCnt, allConfigNames.size()); APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[0]); ClearConfig(); } @@ -1393,19 +1444,20 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test1", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: unchanged -> unchanged, first < second @@ -1421,19 +1473,20 @@ void PipelineConfigWatcherUnittest::TestLoadUnchangedSingletonConfig() { fout.close(); auto diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); - APSARA_TEST_EQUAL_FATAL(2U, PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, + PipelineManagerMock::GetInstance()->GetAllConfigNames().size()); diff = PipelineConfigWatcher::GetInstance()->CheckConfigDiff(); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mAdded.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mModified.size()); - APSARA_TEST_EQUAL_FATAL(0, diff.first.mRemoved.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mAdded.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mModified.size()); + APSARA_TEST_EQUAL_FATAL(0U, diff.first.mRemoved.size()); PipelineManagerMock::GetInstance()->UpdatePipelines(diff.first); auto allConfigNames = PipelineManagerMock::GetInstance()->GetAllConfigNames(); - APSARA_TEST_EQUAL_FATAL(2U, allConfigNames.size()); + APSARA_TEST_EQUAL_FATAL(2U + builtinPipelineCnt, allConfigNames.size()); sort(allConfigNames.begin(), allConfigNames.end()); - APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[0]); - APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[1]); + APSARA_TEST_EQUAL_FATAL("test-other", allConfigNames[builtinPipelineCnt]); + APSARA_TEST_EQUAL_FATAL("test2", allConfigNames[builtinPipelineCnt + 1]); ClearConfig(); } { // case: unchanged -> unchanged, first > second -> first < second