Skip to content

Commit

Permalink
[BUILD] move client::nosend under test_common (#1811)
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo committed Nov 28, 2022
1 parent 6a99fee commit ec90007
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 29 deletions.
1 change: 1 addition & 0 deletions .github/.codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ignore:
- "cmake/**/*"
- "buildscripts/**/*"
- "third_party/**/*"
- "test_common/**/*"
- "tools/**/*"
- ".vscode/**/*"
- ".github/**/*"
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ if(NOT WITH_API_ONLY)
add_subdirectory(sdk)
add_subdirectory(ext)
add_subdirectory(exporters)
if(BUILD_TESTING)
add_subdirectory(test_common)
endif()
if(WITH_EXAMPLES)
add_subdirectory(examples)
endif()
Expand Down
12 changes: 6 additions & 6 deletions exporters/otlp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ cc_test(
deps = [
":otlp_http_exporter",
"//api",
"//ext/src/http/client/nosend:http_client_nosend",
"//test_common/src/http/client/nosend:http_client_nosend",
"@com_google_googletest//:gtest_main",
],
)
Expand All @@ -386,7 +386,7 @@ cc_test(
deps = [
":otlp_http_exporter",
"//api",
"//ext/src/http/client/nosend:http_client_nosend",
"//test_common/src/http/client/nosend:http_client_nosend",
"@com_google_googletest//:gtest_main",
],
)
Expand All @@ -402,7 +402,7 @@ cc_test(
deps = [
":otlp_http_log_record_exporter",
"//api",
"//ext/src/http/client/nosend:http_client_nosend",
"//test_common/src/http/client/nosend:http_client_nosend",
"@com_google_googletest//:gtest_main",
],
)
Expand All @@ -418,7 +418,7 @@ cc_test(
deps = [
":otlp_http_log_record_exporter",
"//api",
"//ext/src/http/client/nosend:http_client_nosend",
"//test_common/src/http/client/nosend:http_client_nosend",
"@com_google_googletest//:gtest_main",
],
)
Expand Down Expand Up @@ -481,7 +481,7 @@ cc_test(
deps = [
":otlp_http_metric_exporter",
"//api",
"//ext/src/http/client/nosend:http_client_nosend",
"//test_common/src/http/client/nosend:http_client_nosend",
"@com_google_googletest//:gtest_main",
],
)
Expand All @@ -497,7 +497,7 @@ cc_test(
deps = [
":otlp_http_metric_exporter",
"//api",
"//ext/src/http/client/nosend:http_client_nosend",
"//test_common/src/http/client/nosend:http_client_nosend",
"@com_google_googletest//:gtest_main",
],
)
Expand Down
7 changes: 4 additions & 3 deletions exporters/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ if(BUILD_TESTING)
add_executable(otlp_http_exporter_test test/otlp_http_exporter_test.cc)
target_link_libraries(
otlp_http_exporter_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
${GMOCK_LIB} opentelemetry_exporter_otlp_http http_client_nosend)
${GMOCK_LIB} opentelemetry_exporter_otlp_http
opentelemetry_http_client_nosend)
gtest_add_tests(
TARGET otlp_http_exporter_test
TEST_PREFIX exporter.otlp.
Expand All @@ -306,7 +307,7 @@ if(BUILD_TESTING)
${GMOCK_LIB}
opentelemetry_exporter_otlp_http_log
opentelemetry_logs
http_client_nosend)
opentelemetry_http_client_nosend)
gtest_add_tests(
TARGET otlp_http_log_record_exporter_test
TEST_PREFIX exporter.otlp.
Expand All @@ -333,7 +334,7 @@ if(BUILD_TESTING)
${GMOCK_LIB}
opentelemetry_exporter_otlp_http_metric
opentelemetry_metrics
http_client_nosend)
opentelemetry_http_client_nosend)
gtest_add_tests(
TARGET otlp_http_metric_exporter_test
TEST_PREFIX exporter.otlp.
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/test/otlp_http_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
# include "opentelemetry/exporters/otlp/protobuf_include_suffix.h"

# include "opentelemetry/ext/http/client/http_client_factory.h"
# include "opentelemetry/ext/http/client/nosend/http_client_nosend.h"
# include "opentelemetry/ext/http/server/http_server.h"
# include "opentelemetry/sdk/trace/batch_span_processor.h"
# include "opentelemetry/sdk/trace/tracer_provider.h"
# include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h"
# include "opentelemetry/trace/provider.h"

# include <google/protobuf/message_lite.h>
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/test/otlp_http_log_record_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

# include "opentelemetry/common/key_value_iterable_view.h"
# include "opentelemetry/ext/http/client/http_client_factory.h"
# include "opentelemetry/ext/http/client/nosend/http_client_nosend.h"
# include "opentelemetry/ext/http/server/http_server.h"
# include "opentelemetry/logs/provider.h"
# include "opentelemetry/sdk/logs/batch_log_record_processor.h"
# include "opentelemetry/sdk/logs/exporter.h"
# include "opentelemetry/sdk/logs/log_record.h"
# include "opentelemetry/sdk/logs/logger_provider.h"
# include "opentelemetry/sdk/resource/resource.h"
# include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h"

# include <google/protobuf/message_lite.h>
# include <gtest/gtest.h>
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/test/otlp_http_metric_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

#include "opentelemetry/common/key_value_iterable_view.h"
#include "opentelemetry/ext/http/client/http_client_factory.h"
#include "opentelemetry/ext/http/client/nosend/http_client_nosend.h"
#include "opentelemetry/ext/http/server/http_server.h"
#include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h"
#include "opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h"
#include "opentelemetry/sdk/metrics/data/metric_data.h"
#include "opentelemetry/sdk/metrics/instruments.h"
#include "opentelemetry/sdk/resource/resource.h"
#include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h"

#include <google/protobuf/message_lite.h>
#include <gtest/gtest.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class HttpClientFactory

static std::shared_ptr<HttpClient> Create();

#ifdef ENABLE_TEST
static std::shared_ptr<HttpClient> CreateNoSend();
#endif
};
} // namespace client
} // namespace http
Expand Down
3 changes: 0 additions & 3 deletions ext/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ if(WITH_ZPAGES)
endif()

add_subdirectory(http/client/curl)
if(BUILD_TESTING)
add_subdirectory(http/client/nosend)
endif()
7 changes: 7 additions & 0 deletions test_common/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "headers",
hdrs = glob(["include/**/*.h"]),
strip_include_prefix = "include",
)
13 changes: 13 additions & 0 deletions test_common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if(BUILD_TESTING)
add_library(opentelemetry_test_common INTERFACE)
target_include_directories(
opentelemetry_test_common
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

set_target_properties(opentelemetry_test_common PROPERTIES EXPORT_NAME
"teset_common")
target_link_libraries(opentelemetry_test_common INTERFACE opentelemetry_api)

add_subdirectory(src)
endif()
3 changes: 3 additions & 0 deletions test_common/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if(BUILD_TESTING)
add_subdirectory(http/client/nosend)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ cc_library(
"//api",
"//ext:headers",
"//sdk:headers",
"//test_common:headers",
"@com_google_googletest//:gtest_main",
],
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
if(${BUILD_TESTING})
add_library(http_client_nosend http_client_factory_nosend.cc
http_client_nosend.cc)
add_library(opentelemetry_http_client_nosend http_client_factory_nosend.cc
http_client_nosend.cc)

set_target_properties(http_client_nosend PROPERTIES EXPORT_NAME
http_client_nosend)
set_target_properties(opentelemetry_http_client_nosend
PROPERTIES EXPORT_NAME opentelemetry_http_client_nosend)

if(MSVC)
# Explicitly specify that we consume GTest from shared library. The rest of
Expand All @@ -24,13 +24,8 @@ if(${BUILD_TESTING})
find_library(GMOCK_LIB gmock PATH_SUFFIXES lib)
endif()

target_link_libraries(http_client_nosend ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIB}
opentelemetry_ext)
target_link_libraries(
opentelemetry_http_client_nosend ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIB}
opentelemetry_ext opentelemetry_test_common)

install(
TARGETS http_client_nosend
EXPORT "${PROJECT_NAME}-target"
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "opentelemetry/ext/http/client/http_client.h"
#include "opentelemetry/ext/http/client/http_client_factory.h"
#include "opentelemetry/ext/http/client/nosend/http_client_nosend.h"
#include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h"

namespace http_client = opentelemetry::ext::http::client;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

#ifdef ENABLE_TEST
# include "opentelemetry/ext/http/client/nosend/http_client_nosend.h"
# include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace ext
Expand Down

0 comments on commit ec90007

Please sign in to comment.