Search in sources :

Example 1 with LabelledMetric

use of org.hyperledger.besu.plugin.services.metrics.LabelledMetric in project besu by hyperledger.

the class AbstractEthTaskTest method shouldHaveSpecificMetricsLabels.

@Test
public void shouldHaveSpecificMetricsLabels() {
    // seed with a failing value so that a no-op also trips the failure.
    final String[] lastLabelNames = { "AbstractEthTask" };
    final MetricsSystem instrumentedLabeler = new NoOpMetricsSystem() {

        @Override
        public LabelledMetric<OperationTimer> createLabelledTimer(final MetricCategory category, final String name, final String help, final String... labelNames) {
            return names -> {
                lastLabelNames[0] = names[0];
                return null;
            };
        }
    };
    new AbstractEthTask<>(instrumentedLabeler) {

        @Override
        protected void executeTask() {
        // no-op
        }
    };
    assertThat(lastLabelNames[0]).isNotEqualTo("AbstractEthTask");
}
Also used : MockExecutorService(org.hyperledger.besu.testutil.MockExecutorService) Arrays(java.util.Arrays) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CompletableFuture(java.util.concurrent.CompletableFuture) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) LabelledMetric(org.hyperledger.besu.plugin.services.metrics.LabelledMetric) Mockito.verify(org.mockito.Mockito.verify) List(java.util.List) Lists(com.google.common.collect.Lists) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MetricsSystem(org.hyperledger.besu.plugin.services.MetricsSystem) MetricCategory(org.hyperledger.besu.plugin.services.metrics.MetricCategory) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) OperationTimer(org.hyperledger.besu.plugin.services.metrics.OperationTimer) OperationTimer(org.hyperledger.besu.plugin.services.metrics.OperationTimer) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) MetricsSystem(org.hyperledger.besu.plugin.services.MetricsSystem) MetricCategory(org.hyperledger.besu.plugin.services.metrics.MetricCategory) Test(org.junit.Test)

Aggregations

Lists (com.google.common.collect.Lists)1 Arrays (java.util.Arrays)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 NoOpMetricsSystem (org.hyperledger.besu.metrics.noop.NoOpMetricsSystem)1 MetricsSystem (org.hyperledger.besu.plugin.services.MetricsSystem)1 LabelledMetric (org.hyperledger.besu.plugin.services.metrics.LabelledMetric)1 MetricCategory (org.hyperledger.besu.plugin.services.metrics.MetricCategory)1 OperationTimer (org.hyperledger.besu.plugin.services.metrics.OperationTimer)1 MockExecutorService (org.hyperledger.besu.testutil.MockExecutorService)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1 Mock (org.mockito.Mock)1 Mockito.verify (org.mockito.Mockito.verify)1 Mockito.when (org.mockito.Mockito.when)1 MockitoJUnitRunner (org.mockito.junit.MockitoJUnitRunner)1