MCPcopy
hub / github.com/IBM/sarama / validateBrokerMetrics

Function validateBrokerMetrics

broker_test.go:1542–1571  ·  view source on GitHub ↗
(t *testing.T, broker *Broker, mockBrokerMetrics brokerMetrics)

Source from the content-addressed store, hash-verified

1540}
1541
1542func validateBrokerMetrics(t *testing.T, broker *Broker, mockBrokerMetrics brokerMetrics) {
1543 metricValidators := newMetricValidators()
1544 mockBrokerBytesRead := mockBrokerMetrics.bytesRead
1545 mockBrokerBytesWritten := mockBrokerMetrics.bytesWritten
1546
1547 // Check that the number of bytes sent corresponds to what the mock broker received
1548 metricValidators.registerForAllBrokers(broker, countMeterValidator("incoming-byte-rate", mockBrokerBytesWritten))
1549 if mockBrokerBytesWritten == 0 {
1550 // This a ProduceRequest with NoResponse
1551 metricValidators.registerForAllBrokers(broker, countMeterValidator("response-rate", 0))
1552 metricValidators.registerForAllBrokers(broker, countHistogramValidator("response-size", 0))
1553 metricValidators.registerForAllBrokers(broker, minMaxHistogramValidator("response-size", 0, 0))
1554 } else {
1555 metricValidators.registerForAllBrokers(broker, countMeterValidator("response-rate", 1))
1556 metricValidators.registerForAllBrokers(broker, countHistogramValidator("response-size", 1))
1557 metricValidators.registerForAllBrokers(broker, minMaxHistogramValidator("response-size", mockBrokerBytesWritten, mockBrokerBytesWritten))
1558 }
1559
1560 // Check that the number of bytes received corresponds to what the mock broker sent
1561 metricValidators.registerForAllBrokers(broker, countMeterValidator("outgoing-byte-rate", mockBrokerBytesRead))
1562 metricValidators.registerForAllBrokers(broker, countMeterValidator("request-rate", 1))
1563 metricValidators.registerForAllBrokers(broker, countHistogramValidator("request-size", 1))
1564 metricValidators.registerForAllBrokers(broker, minMaxHistogramValidator("request-size", mockBrokerBytesRead, mockBrokerBytesRead))
1565
1566 // Check that there is no more requests in flight
1567 metricValidators.registerForAllBrokers(broker, counterValidator("requests-in-flight", 0))
1568
1569 // Run the validators
1570 metricValidators.run(t, broker.conf.MetricRegistry)
1571}
1572
1573func BenchmarkBroker_Open(b *testing.B) {
1574 mb := NewMockBroker(nil, 0)

Callers 1

Calls 7

newMetricValidatorsFunction · 0.85
countMeterValidatorFunction · 0.85
countHistogramValidatorFunction · 0.85
minMaxHistogramValidatorFunction · 0.85
counterValidatorFunction · 0.85
registerForAllBrokersMethod · 0.80
runMethod · 0.65

Tested by

no test coverage detected