From fdf8b3a409b5856efefde7d9605584171d867c48 Mon Sep 17 00:00:00 2001 From: abingcbc Date: Thu, 26 Dec 2024 11:56:35 +0800 Subject: [PATCH] fix --- core/pipeline/PipelineManager.h | 1 + core/unittest/pipeline/PipelineUnittest.cpp | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/pipeline/PipelineManager.h b/core/pipeline/PipelineManager.h index 6c3cf5cbe0..255514c15d 100644 --- a/core/pipeline/PipelineManager.h +++ b/core/pipeline/PipelineManager.h @@ -76,6 +76,7 @@ class PipelineManager { friend class CircularProcessQueueUnittest; friend class CommonConfigProviderUnittest; friend class FlusherUnittest; + friend class PipelineUnittest; #endif }; diff --git a/core/unittest/pipeline/PipelineUnittest.cpp b/core/unittest/pipeline/PipelineUnittest.cpp index 0f9b273a37..614e6dd415 100644 --- a/core/unittest/pipeline/PipelineUnittest.cpp +++ b/core/unittest/pipeline/PipelineUnittest.cpp @@ -2702,7 +2702,8 @@ void PipelineUnittest::TestProcess() const { processor->Init(Json::Value(), ctx); pipeline.mProcessorLine.emplace_back(std::move(processor)); - WriteMetrics::GetInstance()->PrepareMetricsRecordRef(pipeline.mMetricsRecordRef, MetricCategory::METRIC_CATEGORY_UNKNOWN, {}); + WriteMetrics::GetInstance()->PrepareMetricsRecordRef( + pipeline.mMetricsRecordRef, MetricCategory::METRIC_CATEGORY_UNKNOWN, {}); pipeline.mProcessorsInEventsTotal = pipeline.mMetricsRecordRef.CreateCounter(METRIC_PIPELINE_PROCESSORS_IN_EVENTS_TOTAL); pipeline.mProcessorsInGroupsTotal @@ -2750,7 +2751,8 @@ void PipelineUnittest::TestSend() const { configs.emplace_back(1, nullptr); pipeline.mRouter.Init(configs, ctx); - WriteMetrics::GetInstance()->PrepareMetricsRecordRef(pipeline.mMetricsRecordRef, MetricCategory::METRIC_CATEGORY_UNKNOWN, {}); + WriteMetrics::GetInstance()->PrepareMetricsRecordRef( + pipeline.mMetricsRecordRef, MetricCategory::METRIC_CATEGORY_UNKNOWN, {}); pipeline.mFlushersInGroupsTotal = pipeline.mMetricsRecordRef.CreateCounter(METRIC_PIPELINE_FLUSHERS_IN_EVENT_GROUPS_TOTAL); pipeline.mFlushersInEventsTotal @@ -2816,7 +2818,8 @@ void PipelineUnittest::TestSend() const { configs.emplace_back(configJson.size(), nullptr); pipeline.mRouter.Init(configs, ctx); - WriteMetrics::GetInstance()->PrepareMetricsRecordRef(pipeline.mMetricsRecordRef, MetricCategory::METRIC_CATEGORY_UNKNOWN, {}); + WriteMetrics::GetInstance()->PrepareMetricsRecordRef( + pipeline.mMetricsRecordRef, MetricCategory::METRIC_CATEGORY_UNKNOWN, {}); pipeline.mFlushersInGroupsTotal = pipeline.mMetricsRecordRef.CreateCounter(METRIC_PIPELINE_FLUSHERS_IN_EVENT_GROUPS_TOTAL); pipeline.mFlushersInEventsTotal @@ -2893,15 +2896,19 @@ void PipelineUnittest::TestInProcessingCount() const { vector group; group.emplace_back(make_shared()); + auto pipeline2 = make_shared(); + PipelineManager::GetInstance()->mPipelineNameEntityMap[""] = pipeline2; processQueue->EnablePop(); processQueue->Push(GenerateProcessItem(pipeline)); APSARA_TEST_EQUAL(0, pipeline->mInProcessCnt.load()); + APSARA_TEST_EQUAL(0, pipeline2->mInProcessCnt.load()); unique_ptr item; APSARA_TEST_TRUE(processQueue->Pop(item)); - APSARA_TEST_EQUAL(1, pipeline->mInProcessCnt.load()); - - pipeline->SubInProcessCnt(); APSARA_TEST_EQUAL(0, pipeline->mInProcessCnt.load()); + APSARA_TEST_EQUAL(1, pipeline2->mInProcessCnt.load()); + + pipeline2->SubInProcessCnt(); + APSARA_TEST_EQUAL(0, pipeline2->mInProcessCnt.load()); } void PipelineUnittest::TestWaitAllItemsInProcessFinished() const {