[Stats] add nodeaddress tag for stats test (#8423)

This commit is contained in:
Lingxuan Zuo
2020-05-21 01:30:01 +08:00
committed by GitHub
parent c9898eff24
commit cd706f40c4
+7 -4
View File
@@ -41,11 +41,12 @@ class MockExporter : public opencensus::stats::StatsExporter::Handler {
ASSERT_EQ("current_worker", descriptor.name());
ASSERT_EQ(opencensus::stats::ViewData::Type::kDouble, view_data.type());
for (const auto row : view_data.double_data()) {
for (size_t i = 0; i < descriptor.columns().size(); ++i) {
if (descriptor.columns()[i].name() == "NodeAddress") {
ASSERT_EQ("Localhost", row.first[i]);
if (descriptor.columns()[i].name() == "WorkerPidKey") {
ASSERT_EQ("1000", row.first[i]);
} else if (descriptor.columns()[i].name() == "LanguageKey") {
ASSERT_EQ("CPP", row.first[i]);
}
}
// row.second store the data of this metric.
@@ -58,7 +59,9 @@ class MockExporter : public opencensus::stats::StatsExporter::Handler {
class StatsTest : public ::testing::Test {
public:
void SetUp() {
ray::stats::Init("127.0.0.1:8888", {{stats::NodeAddressKey, "Localhost"}}, false);
const stats::TagsType global_tags = {{stats::LanguageKey, "CPP"},
{stats::WorkerPidKey, "1000"}};
ray::stats::Init("127.0.0.1:8888", global_tags, false);
MockExporter::Register();
}