From 0def93644d7a6c64504fa7fb240079cf9f431629 Mon Sep 17 00:00:00 2001 From: Punya Biswal Date: Sun, 1 Sep 2024 13:01:58 -0400 Subject: [PATCH] Add missing tests to Bazel build by globbing test files Previously, we were missing * instrument_metadata_validator_test * observable_registry_test * cardinality_limit_test * periodic_exporting_metric_reader_test And there were no checks in place to prevent things from getting worse. --- sdk/test/metrics/BUILD | 293 +-------------------- sdk/test/metrics/async_instruments_test.cc | 3 + sdk/test/metrics/meter_test.cc | 2 +- 3 files changed, 11 insertions(+), 287 deletions(-) diff --git a/sdk/test/metrics/BUILD b/sdk/test/metrics/BUILD index 3cf379494d..dac8e7263b 100644 --- a/sdk/test/metrics/BUILD +++ b/sdk/test/metrics/BUILD @@ -19,232 +19,13 @@ cc_library( ) cc_test( - name = "meter_test", - srcs = [ - "meter_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "meter_provider_sdk_test", - srcs = [ - "meter_provider_sdk_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "metric_reader_test", - srcs = [ - "metric_reader_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "histogram_test", - srcs = [ - "histogram_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "view_registry_test", - srcs = [ - "view_registry_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "aggregation_test", - srcs = [ - "aggregation_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sync_metric_storage_counter_test", - srcs = [ - "sync_metric_storage_counter_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sync_metric_storage_up_down_counter_test", - srcs = [ - "sync_metric_storage_up_down_counter_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sync_metric_storage_histogram_test", - srcs = [ - "sync_metric_storage_histogram_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sync_instruments_test", - srcs = [ - "sync_instruments_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "async_instruments_test", - srcs = [ - "async_instruments_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "async_metric_storage_test", - srcs = [ - "async_metric_storage_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "observer_result_test", - srcs = [ - "observer_result_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "multi_metric_storage_test", - srcs = [ - "multi_metric_storage_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "attributes_processor_test", - srcs = [ - "attributes_processor_test.cc", - ], + name = "other_tests", + srcs = glob( + ["*_test.cc"], + exclude = [ + "attributes_hashmap_test.cc", + ], + ), tags = [ "metrics", "test", @@ -270,66 +51,6 @@ cc_test( ], ) -cc_test( - name = "circular_buffer_counter_test", - srcs = [ - "circular_buffer_counter_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "//sdk/src/metrics", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "base2_exponential_histogram_indexer_test", - srcs = [ - "base2_exponential_histogram_indexer_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "histogram_aggregation_test", - srcs = [ - "histogram_aggregation_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sum_aggregation_test", - srcs = [ - "sum_aggregation_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - otel_cc_benchmark( name = "attributes_processor_benchmark", srcs = [ diff --git a/sdk/test/metrics/async_instruments_test.cc b/sdk/test/metrics/async_instruments_test.cc index b7ad885bbd..01a421e046 100644 --- a/sdk/test/metrics/async_instruments_test.cc +++ b/sdk/test/metrics/async_instruments_test.cc @@ -12,10 +12,13 @@ using namespace opentelemetry::sdk::metrics; using M = std::map; +namespace +{ // NOLINTNEXTLINE void asyc_generate_measurements(opentelemetry::metrics::ObserverResult /* observer */, void * /* state */) {} +} // namespace TEST(AsyncInstruments, ObservableInstrument) { diff --git a/sdk/test/metrics/meter_test.cc b/sdk/test/metrics/meter_test.cc index b5ed86f55a..cd66737465 100644 --- a/sdk/test/metrics/meter_test.cc +++ b/sdk/test/metrics/meter_test.cc @@ -28,7 +28,6 @@ nostd::shared_ptr InitMeter(MetricReader **metricReaderPtr, auto meter = provider->GetMeter(meter_name); return meter; } -} // namespace void asyc_generate_measurements(opentelemetry::metrics::ObserverResult observer, void * /* state */) { @@ -36,6 +35,7 @@ void asyc_generate_measurements(opentelemetry::metrics::ObserverResult observer, nostd::get>>(observer); observer_long->Observe(10); } +} // namespace TEST(MeterTest, BasicAsyncTests) {