Armeria: Tests related to metric export fail when changing to Spring Boot 2.4

Created on 30 Oct 2020  路  3Comments  路  Source: line/armeria

In Spring Boot 2.4 there are changes to the Metrics export in integration test.

We use the in-memory MeterRegistry unless @AutoConfigureMetrics is specified when writing tests. But we can't use it because we can't use it for boot1-autoconfigure.

Therefore, I think you need to register the MeterRegistry as a bean when writing a test related to metric export. What do you think?

dependencies

Most helpful comment

Sloved with

@SpringBootTest(classes = NoMeterTestConfiguration.class, properties =
        "management.metrics.export.defaults.enabled=true") // @AutoConfigureMetrics is not allowed for boot1.

All 3 comments

Sounds good to me. Does this relate to #3101 ? (I guess not)

Sounds good to me. Does this relate to #3101 ? (I guess not)

Not relevant. This is simply a problem when changed to 2.4. The reason I mentioned this in #3101 is that I thought it would be more efficient to work after #3101.

Here's the situation I'm thinking of:
After finding and disabling all metric related auto configurations, I need to create the metricRegistry I want in my test. And after #3101, this code is unnecessary and should be deleted.

@SpringBootApplication(exclude = {
        PrometheusMetricsExportAutoConfiguration.class,
        SimpleMetricsExportAutoConfiguration.class,
        CompositeMeterRegistryAutoConfiguration.class,
        MetricsAutoConfiguration.class,
        HttpClientMetricsAutoConfiguration.class
})

If I work after #3101, I just need to write a test by injecting the metricRegistry bean.

Sloved with

@SpringBootTest(classes = NoMeterTestConfiguration.class, properties =
        "management.metrics.export.defaults.enabled=true") // @AutoConfigureMetrics is not allowed for boot1.

Was this page helpful?
0 / 5 - 0 ratings