mirror of
https://github.com/XRPLF/rippled.git
synced 2026-03-22 12:42:26 +00:00
Fix CI: guard MetricsRegistry GTest for telemetry=OFF only
When telemetry=ON, XRPL_ENABLE_TELEMETRY is globally defined, causing MetricsRegistry.cpp to compile its full OTel path which references xrpld symbols (LedgerMaster, TxQ, OpenLedger) that cannot be linked into the standalone GTest binary. Guard the test with #ifndef and only add MetricsRegistry.cpp as a source when telemetry is OFF. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -39,12 +39,7 @@ if(NOT WIN32)
|
||||
add_dependencies(xrpl.tests xrpl.test.net)
|
||||
endif()
|
||||
|
||||
xrpl_add_test(
|
||||
telemetry
|
||||
# MetricsRegistry lives in xrpld; compile its .cpp directly into the test
|
||||
# target so the no-op path can be tested without linking all of xrpld.
|
||||
${CMAKE_SOURCE_DIR}/src/xrpld/telemetry/MetricsRegistry.cpp
|
||||
)
|
||||
xrpl_add_test(telemetry)
|
||||
target_link_libraries(xrpl.test.telemetry PRIVATE xrpl.imports.test)
|
||||
target_include_directories(xrpl.test.telemetry PRIVATE ${CMAKE_SOURCE_DIR}/src)
|
||||
if(telemetry)
|
||||
@@ -52,5 +47,14 @@ if(telemetry)
|
||||
xrpl.test.telemetry
|
||||
PRIVATE opentelemetry-cpp::opentelemetry-cpp
|
||||
)
|
||||
else()
|
||||
# MetricsRegistry lives in xrpld; compile its .cpp directly into the test
|
||||
# target so the no-op path can be tested without linking all of xrpld.
|
||||
# When telemetry=ON, XRPL_ENABLE_TELEMETRY is globally defined and the
|
||||
# .cpp pulls in xrpld symbols we cannot satisfy here.
|
||||
target_sources(
|
||||
xrpl.test.telemetry
|
||||
PRIVATE ${CMAKE_SOURCE_DIR}/src/xrpld/telemetry/MetricsRegistry.cpp
|
||||
)
|
||||
endif()
|
||||
add_dependencies(xrpl.tests xrpl.test.telemetry)
|
||||
|
||||
@@ -7,11 +7,16 @@
|
||||
* - Double stop() is safe.
|
||||
* - Destructor handles cleanup without crash.
|
||||
*
|
||||
* NOTE: Tests that exercise the OTel SDK path require XRPL_ENABLE_TELEMETRY
|
||||
* to be defined at build time (telemetry=ON). The no-op path tests run
|
||||
* unconditionally.
|
||||
* NOTE: These tests only exercise the no-op path (telemetry disabled).
|
||||
* When XRPL_ENABLE_TELEMETRY is defined, MetricsRegistry.cpp pulls in
|
||||
* xrpld symbols that cannot be linked into this standalone test binary,
|
||||
* so the tests are compiled out.
|
||||
*/
|
||||
|
||||
// When telemetry is globally enabled, MetricsRegistry.cpp requires xrpld
|
||||
// link dependencies we cannot satisfy in a standalone GTest binary.
|
||||
#ifndef XRPL_ENABLE_TELEMETRY
|
||||
|
||||
#include <xrpld/telemetry/MetricsRegistry.h>
|
||||
|
||||
#include <xrpl/core/ServiceRegistry.h>
|
||||
@@ -337,3 +342,5 @@ TEST_F(MetricsRegistryTest, destructor_calls_stop)
|
||||
}
|
||||
// If we get here without crash, the destructor handled stop.
|
||||
}
|
||||
|
||||
#endif // !XRPL_ENABLE_TELEMETRY
|
||||
|
||||
Reference in New Issue
Block a user