Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/common/stats/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,17 @@ envoy_benchmark_test(
benchmark_binary = "tag_extractor_impl_benchmark",
)

envoy_cc_test(
name = "tag_utility_test",
srcs = ["tag_utility_test.cc"],
rbe_pool = "6gig",
deps = [
":stat_test_utility_lib",
"//source/common/stats:symbol_table_lib",
"//source/common/stats:tag_utility_lib",
],
)

envoy_cc_test(
name = "thread_local_store_test",
srcs = ["thread_local_store_test.cc"],
Expand Down
43 changes: 43 additions & 0 deletions test/common/stats/tag_utility_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "source/common/stats/tag_utility.h"

#include "source/common/stats/symbol_table.h"

#include "gtest/gtest.h"

namespace Envoy {
namespace Stats {
namespace TagUtility {

namespace {

class TagUtilityTest : public ::testing::Test {
protected:
SymbolTable symbol_table_;
StatNamePool symbolic_pool_{symbol_table_};
StatNamePool dynamic_pool_{symbol_table_};;
};

TEST_F(TagUtilityTest, Symbolic) {
StatNameTagVector tags;
tags.push_back(StatNameTag(symbolic_pool_.add("tag_name"), symbolic_pool_.add("tag_value")));
TagStatNameJoiner joiner(symbolic_pool_.add("prefix"),
symbolic_pool_.add("name"),
tags, symbol_table_);
EXPECT_EQ("prefix.name.tag_name.tag_value", symbol_table_.toString(joiner.nameWithTags()));
EXPECT_EQ("prefix.name", symbol_table_.toString(joiner.tagExtractedName()));
}

TEST_F(TagUtilityTest, Dynamic) {
StatNameTagVector tags;
tags.push_back(StatNameTag(dynamic_pool_.add("tag_name"), dynamic_pool_.add("tag_value")));
TagStatNameJoiner joiner(dynamic_pool_.add("prefix"),
dynamic_pool_.add("name"),
tags, symbol_table_);
EXPECT_EQ("prefix.name.tag_name.tag_value", symbol_table_.toString(joiner.nameWithTags()));
EXPECT_EQ("prefix.name", symbol_table_.toString(joiner.tagExtractedName()));
}

} // namespace
} // namespace TagUtility
} // namespace Stats
} // namespace Envoy
Loading