From 00dc4a695368855f00df708398cd2777c74ebf8a Mon Sep 17 00:00:00 2001 From: JoukoVirtanen Date: Wed, 15 Jan 2025 20:52:03 -0800 Subject: [PATCH 1/2] X-Smart-Branch-Parent: master From b9de71476a0ff69853b1aed1a4cf681fc637aa51 Mon Sep 17 00:00:00 2001 From: JoukoVirtanen Date: Fri, 17 Jan 2025 12:00:02 -0800 Subject: [PATCH 2/2] The configuration is logged whenever it is updated. All collector logs are written during integration tests --- collector/lib/CollectorConfig.h | 2 ++ collector/lib/ConfigLoader.cpp | 4 ++-- integration-tests/pkg/collector/collector.go | 1 + integration-tests/pkg/collector/collector_docker.go | 4 ++++ integration-tests/suites/base.go | 3 +++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/collector/lib/CollectorConfig.h b/collector/lib/CollectorConfig.h index 3ebfdc8beb..454ac07019 100644 --- a/collector/lib/CollectorConfig.h +++ b/collector/lib/CollectorConfig.h @@ -16,6 +16,7 @@ #include "CollectionMethod.h" #include "HostConfig.h" +#include "Logging.h" #include "NetworkConnection.h" #include "TlsConfig.h" #include "json/value.h" @@ -146,6 +147,7 @@ class CollectorConfig { void ResetRuntimeConfig() { auto lock = WriteLock(); + CLOG(INFO) << "Resetting runtime configuration"; runtime_config_.reset(); } diff --git a/collector/lib/ConfigLoader.cpp b/collector/lib/ConfigLoader.cpp index d94b308f2c..797fa2a8a8 100644 --- a/collector/lib/ConfigLoader.cpp +++ b/collector/lib/ConfigLoader.cpp @@ -96,8 +96,8 @@ bool ConfigLoader::LoadConfiguration(CollectorConfig& config, const YAML::Node& config.SetRuntimeConfig(std::move(runtime_config)); - CLOG(DEBUG) << "Runtime configuration:\n" - << config.GetRuntimeConfigStr(); + CLOG(INFO) << "Runtime configuration:\n" + << config.GetRuntimeConfigStr(); return true; } diff --git a/integration-tests/pkg/collector/collector.go b/integration-tests/pkg/collector/collector.go index 676baee07f..acced1dc22 100644 --- a/integration-tests/pkg/collector/collector.go +++ b/integration-tests/pkg/collector/collector.go @@ -18,6 +18,7 @@ type Manager interface { IsRunning() (bool, error) ContainerID() string TestName() string + SetTestName(string) } func New(e executor.Executor, name string) Manager { diff --git a/integration-tests/pkg/collector/collector_docker.go b/integration-tests/pkg/collector/collector_docker.go index b0d3df86ab..babe634a96 100644 --- a/integration-tests/pkg/collector/collector_docker.go +++ b/integration-tests/pkg/collector/collector_docker.go @@ -188,3 +188,7 @@ func (c *DockerCollectorManager) ContainerID() string { func (c *DockerCollectorManager) TestName() string { return c.testName } + +func (c *DockerCollectorManager) SetTestName(testName string) { + c.testName = testName +} diff --git a/integration-tests/suites/base.go b/integration-tests/suites/base.go index 32e5afa1ac..5d74cc93cf 100644 --- a/integration-tests/suites/base.go +++ b/integration-tests/suites/base.go @@ -128,6 +128,9 @@ func (s *IntegrationTestSuiteBase) StopCollector() { func (s *IntegrationTestSuiteBase) Collector() collector.Manager { if s.collector == nil { s.collector = collector.New(s.Executor(), s.T().Name()) + } else { + // Otherwise the test name does not get set when subsequent tests are run + s.collector.SetTestName(s.T().Name()) } return s.collector }