Verify statsd mock client interaction in unit test (#14939)

This commit is contained in:
Abhishek Radhakrishnan 2023-09-05 07:34:22 -07:00 committed by GitHub
parent 289ee1e011
commit 9d6ca61ac1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 11 deletions

View File

@ -47,12 +47,12 @@ public class StatsDEmitterTest
new ObjectMapper(),
client
);
client.gauge("broker.query.cache.total.hitRate", 54);
emitter.emit(new ServiceMetricEvent.Builder()
.setDimension("dataSource", "data-source")
.setMetric("query/cache/total/hitRate", 0.54)
.build("broker", "brokerHost1")
);
verify(client).gauge("broker.query.cache.total.hitRate", 54);
}
@Test
@ -64,12 +64,12 @@ public class StatsDEmitterTest
new ObjectMapper(),
client
);
client.gauge("broker.query.cache.total.hitRate", 0.54);
emitter.emit(new ServiceMetricEvent.Builder()
.setDimension("dataSource", "data-source")
.setMetric("query/cache/total/hitRate", 0.54)
.build("broker", "brokerHost1")
);
verify(client).gauge("broker.query.cache.total.hitRate", 0.54);
}
@Test
@ -81,7 +81,6 @@ public class StatsDEmitterTest
new ObjectMapper(),
client
);
client.time("broker.query.time.data-source.groupBy", 10);
emitter.emit(new ServiceMetricEvent.Builder()
.setDimension("dataSource", "data-source")
.setDimension("type", "groupBy")
@ -96,6 +95,7 @@ public class StatsDEmitterTest
.setMetric("query/time", 10)
.build("broker", "brokerHost1")
);
verify(client).time("broker.query.time.data-source.groupBy", 10);
}
@Test
@ -107,7 +107,6 @@ public class StatsDEmitterTest
new ObjectMapper(),
client
);
client.time("brokerHost1#broker#query#time#data-source#groupBy", 10);
emitter.emit(new ServiceMetricEvent.Builder()
.setDimension("dataSource", "data-source")
.setDimension("type", "groupBy")
@ -122,6 +121,7 @@ public class StatsDEmitterTest
.setMetric("query/time", 10)
.build("broker", "brokerHost1")
);
verify(client).time("brokerHost1#broker#query#time#data-source#groupBy", 10);
}
@Test
@ -133,9 +133,6 @@ public class StatsDEmitterTest
new ObjectMapper(),
client
);
client.time("broker#query#time", 10,
"dataSource:data-source", "type:groupBy", "hostname:brokerHost1"
);
emitter.emit(new ServiceMetricEvent.Builder()
.setDimension("dataSource", "data-source")
.setDimension("type", "groupBy")
@ -150,6 +147,8 @@ public class StatsDEmitterTest
.setMetric("query/time", 10)
.build("broker", "brokerHost1")
);
verify(client).time("broker#query#time", 10,
"dataSource:data-source", "type:groupBy", "hostname:brokerHost1");
}
@Test
@ -161,12 +160,12 @@ public class StatsDEmitterTest
new ObjectMapper(),
client
);
client.count("brokerHost1.broker.jvm.gc.count.G1-GC", 1);
emitter.emit(new ServiceMetricEvent.Builder()
.setDimension("gcName", "G1 GC")
.setMetric("jvm/gc/count", 1)
.build("broker", "brokerHost1")
);
verify(client).count("brokerHost1.broker.jvm.gc.count.G1-GC", 1);
}
@Test
@ -178,15 +177,14 @@ public class StatsDEmitterTest
new ObjectMapper(),
client
);
client.time("druid.query.time", 10,
"druid_service:druid/broker", "dataSource:data-source", "type:groupBy", "hostname:brokerHost1"
);
emitter.emit(new ServiceMetricEvent.Builder()
.setDimension("dataSource", "data-source")
.setDimension("type", "groupBy")
.setMetric("query/time", 10)
.build("druid/broker", "brokerHost1")
);
verify(client).time("druid.query.time", 10,
"druid_service:druid/broker", "dataSource:data-source", "type:groupBy", "hostname:brokerHost1");
}
@Test