diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 1c556aae0..0a0f39814 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -23,30 +23,6 @@ jobs: fail-fast: false matrix: include: - # Java 11 tests - - name: "Unit tests - Java 11" - java_version: 11 - test_suite: 'test jacoco:report' - - name: "Style check - Java 11" - java_version: 11 - test_suite: 'compile com.mycila:license-maven-plugin:check pmd:pmd pmd:cpd pmd:check pmd:cpd-check javadoc:jar' - - name: "Standalone integration 4.0 - Java 11" - java_version: 11 - test_suite: 'verify -P docker-integration-test,standalone-integration-tests -DskipUTs' - artifacts_dir: "standalone-integration/target" - - name: "Standalone integration 4.1 - Java 11" - java_version: 11 - test_suite: 'verify -P docker-integration-test,standalone-integration-tests -Dit.cassandra.version=4.1 -DskipUTs' - artifacts_dir: "standalone-integration/target" - - name: "Standalone integration 5.0- - Java 11" - java_version: 11 - test_suite: 'verify -P docker-integration-test,standalone-integration-tests -Dit.cassandra.version=5.0 -DskipUTs' - artifacts_dir: "standalone-integration/target" - - name: "Python integration - Java 11" - java_version: 11 - test_suite: 'verify -P docker-integration-test,python-integration-tests -DskipUTs' - artifacts_dir: "ecchronos-binary/target" - # Java 17 tests - name: "Unit tests - Java 17" java_version: 17 @@ -56,7 +32,7 @@ jobs: test_suite: 'compile -Djava.version=17 com.mycila:license-maven-plugin:check pmd:pmd pmd:cpd pmd:check pmd:cpd-check javadoc:jar' - name: "Standalone integration 4.0 - Java 17" java_version: 17 - test_suite: 'verify -P docker-integration-test,standalone-integration-tests -Djava.version=17 -DskipUTs' + test_suite: 'verify -P docker-integration-test,standalone-integration-tests -Dit.cassandra.version=4.0 -Djava.version=17 -DskipUTs' artifacts_dir: "standalone-integration/target" - name: "Standalone integration 4.1 - Java 17" java_version: 17 @@ -68,7 +44,7 @@ jobs: artifacts_dir: "standalone-integration/target" - name: "Python integration - Java 17" java_version: 17 - test_suite: 'verify -P docker-integration-test,python-integration-tests -DskipUTs -Djava.version=17' + test_suite: 'verify -P docker-integration-test,python-integration-tests -Dit.cassandra.version=5.0 -Djava.version=17 -DskipUTs' artifacts_dir: "ecchronos-binary/target" # Java 21 tests @@ -80,7 +56,7 @@ jobs: test_suite: 'compile -Djava.version=21 com.mycila:license-maven-plugin:check pmd:pmd pmd:cpd pmd:check pmd:cpd-check javadoc:jar' - name: "Standalone integration 4.0 - Java 21" java_version: 21 - test_suite: 'verify -P docker-integration-test,standalone-integration-tests -DskipUTs -Djava.version=21' + test_suite: 'verify -P docker-integration-test,standalone-integration-tests -Dit.cassandra.version=4.0 -Djava.version=21 -DskipUTs' artifacts_dir: "standalone-integration/target" - name: "Standalone integration 4.1 - Java 21" java_version: 21 @@ -92,7 +68,7 @@ jobs: artifacts_dir: "standalone-integration/target" - name: "Python integration - Java 21" java_version: 21 - test_suite: 'verify -P docker-integration-test,python-integration-tests -Djava.version=21 -DskipUTs' + test_suite: 'verify -P docker-integration-test,python-integration-tests -Dit.cassandra.version=5.0 -Djava.version=21 -DskipUTs' artifacts_dir: "ecchronos-binary/target" steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 diff --git a/CHANGES.md b/CHANGES.md index 6e4ec2560..3b3024f0f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,8 @@ ## Version 6.0.0 +* Bump Spring, Tomcat, Java, SnakeYaml, Jackson and various other dependencies - Issues #704, #754 + ## Version 5.0.5 * Update dependencies to C* 5.0 - Issue #734 diff --git a/README.md b/README.md index c336d9db0..576445e7b 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ More information on the REST interface of ecChronos is described in [REST.md](do ## Prerequisites -* JDK 11 -* Python 3.8 +* Java 17 / 21 +* Python 3 ### Installation diff --git a/application/pom.xml b/application/pom.xml index 86600aeed..dfa48c151 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -16,11 +16,13 @@ --> + com.ericsson.bss.cassandra.ecchronos parent 6.0.0-SNAPSHOT + 4.0.0 application @@ -28,6 +30,7 @@ EcChronos Application + com.ericsson.bss.cassandra.ecchronos @@ -67,7 +70,7 @@ - com.datastax.oss + org.apache.cassandra java-driver-core @@ -105,14 +108,25 @@ org.springdoc - springdoc-openapi-ui + springdoc-openapi-starter-webmvc-ui + + + + jakarta.servlet + jakarta.servlet-api + + + + org.apache.httpcomponents.client5 + httpclient5 - + io.micrometer micrometer-registry-prometheus + io.micrometer micrometer-registry-jmx @@ -171,23 +185,21 @@ spring-test test + org.springframework.boot spring-boot-test test - - org.apache.httpcomponents - httpclient - test - + org.bouncycastle - bcpkix-jdk15on - 1.64 + bcpkix-jdk18on test + + diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/ReloadingCertificateHandler.java b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/ReloadingCertificateHandler.java index a13e18f50..fce80d57e 100644 --- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/ReloadingCertificateHandler.java +++ b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/ReloadingCertificateHandler.java @@ -27,7 +27,7 @@ import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLParameters; import javax.net.ssl.TrustManagerFactory; -import javax.xml.bind.DatatypeConverter; +import jakarta.xml.bind.DatatypeConverter; import java.io.File; import java.io.FileInputStream; import java.io.IOException; diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/MetricBeans.java b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/MetricBeans.java index feb4db12a..2a410c402 100644 --- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/MetricBeans.java +++ b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/MetricBeans.java @@ -26,19 +26,19 @@ import io.micrometer.core.instrument.simple.SimpleMeterRegistry; import io.micrometer.jmx.JmxConfig; import io.micrometer.jmx.JmxMeterRegistry; -import io.micrometer.prometheus.PrometheusConfig; -import io.micrometer.prometheus.PrometheusMeterRegistry; +import io.micrometer.prometheusmetrics.PrometheusConfig; +import io.micrometer.prometheusmetrics.PrometheusMeterRegistry; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpStatus; import org.springframework.web.filter.OncePerRequestFilter; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; @Configuration diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/RepairHistoryBean.java b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/RepairHistoryBean.java index 54a4b2cf6..7bccf1dac 100644 --- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/RepairHistoryBean.java +++ b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/RepairHistoryBean.java @@ -29,6 +29,7 @@ import com.ericsson.bss.cassandra.ecchronos.core.utils.NodeResolver; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import java.util.concurrent.TimeUnit; @@ -92,6 +93,7 @@ public RepairHistory repairHistory() } @Bean + @Primary public RepairHistoryProvider repairHistoryProvider() { return repairHistoryProvider; diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TomcatWebServerCustomizer.java b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TomcatWebServerCustomizer.java index 9e2dfdca8..70a76b8a2 100644 --- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TomcatWebServerCustomizer.java +++ b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TomcatWebServerCustomizer.java @@ -17,6 +17,7 @@ import org.apache.catalina.connector.Connector; import org.apache.coyote.http11.Http11NioProtocol; import org.apache.tomcat.util.net.SSLHostConfig; +import org.apache.tomcat.util.net.SSLHostConfigCertificate; import org.apache.tomcat.util.net.jsse.PEMFile; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -126,18 +127,21 @@ private SSLHostConfig getSslHostConfig(final Ssl ssl) private void setCertificates(final SSLHostConfig sslHostConfig, final Ssl ssl) { + SSLHostConfigCertificate sslHostConfigCertificate = + new SSLHostConfigCertificate(sslHostConfig, SSLHostConfigCertificate.Type.UNDEFINED); + sslHostConfig.addCertificate(sslHostConfigCertificate); if (ssl.getCertificate() != null && ssl.getCertificatePrivateKey() != null) { - sslHostConfig.setCertificateFile(getFilePath(ssl.getCertificate())); - sslHostConfig.setCertificateKeyFile(getFilePath(ssl.getCertificatePrivateKey())); + sslHostConfigCertificate.setCertificateFile(getFilePath(ssl.getCertificate())); + sslHostConfigCertificate.setCertificateKeyFile(getFilePath(ssl.getCertificatePrivateKey())); } else if (ssl.getKeyStore() != null) { - sslHostConfig.setCertificateKeystoreFile(getFilePath(ssl.getKeyStore())); - sslHostConfig.setCertificateKeystorePassword(ssl.getKeyStorePassword()); - sslHostConfig.setCertificateKeystoreType(ssl.getKeyStoreType()); - sslHostConfig.setCertificateKeyAlias(ssl.getKeyAlias()); - sslHostConfig.setCertificateKeyPassword(ssl.getKeyPassword()); + sslHostConfigCertificate.setCertificateKeystoreFile(getFilePath(ssl.getKeyStore())); + sslHostConfigCertificate.setCertificateKeystorePassword(ssl.getKeyStorePassword()); + sslHostConfigCertificate.setCertificateKeystoreType(ssl.getKeyStoreType()); + sslHostConfigCertificate.setCertificateKeyAlias(ssl.getKeyAlias()); + sslHostConfigCertificate.setCertificateKeyPassword(ssl.getKeyPassword()); } else { diff --git a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/TestNoopStatementDecorator.java b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/TestNoopStatementDecorator.java index 5a8d93606..702f94c92 100644 --- a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/TestNoopStatementDecorator.java +++ b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/TestNoopStatementDecorator.java @@ -19,6 +19,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.mockito.MockMakers; +import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import static org.assertj.core.api.Assertions.assertThat; @@ -26,8 +28,8 @@ @RunWith(MockitoJUnitRunner.class) public class TestNoopStatementDecorator { - @Mock - private Statement mockStatement; + @Mock(mockMaker = MockMakers.SUBCLASS) + private Statement mockStatement = Mockito.mock(Statement.class, Mockito.withSettings().mockMaker(MockMakers.SUBCLASS)); @Test public void testApplyPreservesStatement() diff --git a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/config/TestRetryPolicy.java b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/config/TestRetryPolicy.java index bdbf59f75..f6bbc20e0 100644 --- a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/config/TestRetryPolicy.java +++ b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/config/TestRetryPolicy.java @@ -21,10 +21,13 @@ import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; +import org.mockito.Mock; +import org.mockito.MockMakers; public class TestRetryPolicy { - RetryPolicy retryPolicy = Mockito.mock(RetryPolicy.class); + @Mock(mockMaker = MockMakers.SUBCLASS) + RetryPolicy retryPolicy = Mockito.mock(RetryPolicy.class, Mockito.withSettings().mockMaker(MockMakers.SUBCLASS)); @Before public void setup() diff --git a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TestTomcatWebServerCustomizer.java b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TestTomcatWebServerCustomizer.java index d3b3fb1b1..143b636cc 100644 --- a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TestTomcatWebServerCustomizer.java +++ b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TestTomcatWebServerCustomizer.java @@ -19,13 +19,14 @@ import com.ericsson.bss.cassandra.ecchronos.connection.NativeConnectionProvider; import com.ericsson.bss.cassandra.ecchronos.core.repair.state.ReplicationState; import com.ericsson.bss.cassandra.ecchronos.core.utils.NodeResolver; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.ssl.SSLContextBuilder; -import org.awaitility.Duration; +import org.apache.hc.client5.http.classic.HttpClient; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.ssl.*; +import org.apache.hc.core5.http.HttpResponse; +import org.apache.hc.core5.ssl.SSLContextBuilder; +import org.awaitility.Durations; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; @@ -43,8 +44,8 @@ import java.nio.file.Paths; import java.security.GeneralSecurityException; import java.time.Instant; +import java.time.Duration; import java.util.Date; -import java.util.concurrent.TimeUnit; import static java.net.HttpURLConnection.HTTP_OK; import static org.assertj.core.api.Assertions.assertThat; @@ -68,13 +69,13 @@ public abstract class TestTomcatWebServerCustomizer protected static final String EXPIRED_METRICS_CLIENT_COMMON_NAME = "expiredMetricsClient"; protected static final String KEYSTORE_PASSWORD = "ecctest"; - protected static final int REFRESH_RATE = 100; - protected static final int METRICS_REFRESH_RATE = 50; + protected static final int REFRESH_RATE_IN_MS = 100; + protected static final int METRICS_REFRESH_RATE_IN_MS = 50; protected static final int INVOCATION_COUNT = 1; - private static final Duration RELOAD_TIMEOUT = Duration.TEN_SECONDS; + private static final Duration RELOAD_TIMEOUT = Durations.TEN_SECONDS; - //These must be set in @BeforeClass + // These must be set in @BeforeClass protected static String serverCaCert; protected static String serverCaCertKey; protected static String serverCert; @@ -186,7 +187,7 @@ public static void createCerts(String algorithm, boolean isServerUsingKeyStores) Date notBefore = Date.from(Instant.now()); Date notAfter = Date.from(Instant.now().plus(java.time.Duration.ofHours(1))); - //Server + // Server certUtils.createSelfSignedCACertificate(SERVER_CA_COMMON_NAME, notBefore, notAfter, algorithm, serverCaCert, serverCaCertKey); certUtils.createCertificate(SERVER_COMMON_NAME, notBefore, notAfter, serverCaCert, serverCaCertKey, serverCert, serverCertKey); @@ -200,7 +201,7 @@ public static void createCerts(String algorithm, boolean isServerUsingKeyStores) expiredClientKeyStore); certUtils.createTrustStore(serverCaCert, "PKCS12", KEYSTORE_PASSWORD, clientTrustStore); - //Metrics server + // Metrics server certUtils.createSelfSignedCACertificate(METRICS_SERVER_CA_COMMON_NAME, notBefore, notAfter, algorithm, metricsServerCaCert, metricsServerCaCertKey); certUtils.createCertificate(METRICS_SERVER_COMMON_NAME, notBefore, notAfter, metricsServerCaCert, metricsServerCaCertKey, metricsServerCert, metricsServerCertKey); @@ -249,10 +250,10 @@ public void testSuccessfulCertificateReloading() public void testSuccessfulResponseWhenValidCertificate() throws IOException, GeneralSecurityException { HttpResponse response = configureHttpClient(clientKeyStore, clientTrustStore, KEYSTORE_PASSWORD).execute(new HttpGet(httpsUrl)); - assertThat(response.getStatusLine().getStatusCode()).isEqualTo(HTTP_OK); + assertThat(response.getCode()).isEqualTo(HTTP_OK); HttpResponse metricsResponse = configureHttpClient(metricsClientKeyStore, metricsClientTrustStore, KEYSTORE_PASSWORD).execute(new HttpGet(metricsServerHttpsUrl)); - assertThat(metricsResponse.getStatusLine().getStatusCode()).isEqualTo(HTTP_OK); + assertThat(metricsResponse.getCode()).isEqualTo(HTTP_OK); } @Test @@ -287,8 +288,13 @@ private HttpClient configureHttpClient(String keyStore, String trustStore, Strin .build(); return HttpClients.custom() - .setSSLContext(sslContext) - .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) + .setConnectionManager( + PoolingHttpClientConnectionManagerBuilder.create() + .setSSLSocketFactory(SSLConnectionSocketFactoryBuilder.create() + .setSslContext(sslContext).setHostnameVerifier(NoopHostnameVerifier.INSTANCE) + .build() + ).build() + ) .build(); } @@ -309,12 +315,12 @@ public void initialize(ConfigurableApplicationContext configurableApplicationCon addInlinedPropertiesToEnvironment(configurableApplicationContext, "server.ssl.enabled=true", "server.ssl.client-auth=need", - "server.ssl.refresh-rate-in-ms=" + REFRESH_RATE, + "server.ssl.refresh-rate-in-ms=" + REFRESH_RATE_IN_MS, "metricsServer.enabled=true", "metricsServer.port=0", "metricsServer.ssl.enabled=true", "metricsServer.ssl.client-auth=need", - "metricsServer.ssl.refresh-rate-in-ms=" + METRICS_REFRESH_RATE); + "metricsServer.ssl.refresh-rate-in-ms=" + METRICS_REFRESH_RATE_IN_MS); } } } \ No newline at end of file diff --git a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TestTomcatWebServerCustomizerPEMEC.java b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TestTomcatWebServerCustomizerPEMEC.java index 674c93fd6..ce0fc92df 100644 --- a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TestTomcatWebServerCustomizerPEMEC.java +++ b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TestTomcatWebServerCustomizerPEMEC.java @@ -16,7 +16,7 @@ package com.ericsson.bss.cassandra.ecchronos.application.spring; import com.ericsson.bss.cassandra.ecchronos.application.utils.CertUtils; -import org.awaitility.Duration; +import java.time.Duration; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,7 +26,6 @@ import org.springframework.test.context.junit4.SpringRunner; import java.io.IOException; -import java.util.concurrent.TimeUnit; import static org.awaitility.Awaitility.await; import static org.mockito.Mockito.atLeast; @@ -47,11 +46,16 @@ public static void setup() @Test public void testSuccessfulCertificateReloadingWithTrustCertificate() { - await().atMost(new Duration(REFRESH_RATE * (INVOCATION_COUNT + 10), TimeUnit.MILLISECONDS)).untilAsserted( - () -> verify(tomcatWebServerCustomizer, atLeast(INVOCATION_COUNT)).reloadDefaultTrustStore()); - await().atMost(new Duration(METRICS_REFRESH_RATE * (INVOCATION_COUNT + 10), TimeUnit.MILLISECONDS)) - .untilAsserted( - () -> verify(tomcatWebServerCustomizer, atLeast(INVOCATION_COUNT)).reloadMetricsTrustStore()); + await().atMost( + Duration.ofMillis(REFRESH_RATE_IN_MS * (INVOCATION_COUNT + 10))) + .untilAsserted(() -> verify(tomcatWebServerCustomizer, atLeast(INVOCATION_COUNT)) + .reloadDefaultTrustStore() + ); + await().atMost( + Duration.ofMillis(METRICS_REFRESH_RATE_IN_MS * (INVOCATION_COUNT + 10))) + .untilAsserted(() -> verify(tomcatWebServerCustomizer, atLeast(INVOCATION_COUNT)) + .reloadMetricsTrustStore() + ); } static class PropertyOverrideContextInitializer diff --git a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TestTomcatWebServerCustomizerPEMRSA.java b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TestTomcatWebServerCustomizerPEMRSA.java index 399a36dbb..9850f4f13 100644 --- a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TestTomcatWebServerCustomizerPEMRSA.java +++ b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/TestTomcatWebServerCustomizerPEMRSA.java @@ -15,7 +15,7 @@ package com.ericsson.bss.cassandra.ecchronos.application.spring; import com.ericsson.bss.cassandra.ecchronos.application.utils.CertUtils; -import org.awaitility.Duration; +import java.time.Duration; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -25,7 +25,6 @@ import org.springframework.test.context.junit4.SpringRunner; import java.io.IOException; -import java.util.concurrent.TimeUnit; import static org.awaitility.Awaitility.await; import static org.mockito.Mockito.atLeast; @@ -46,11 +45,16 @@ public static void setup() @Test public void testSuccessfulCertificateReloadingWithTrustCertificate() { - await().atMost(new Duration(REFRESH_RATE * (INVOCATION_COUNT + 10), TimeUnit.MILLISECONDS)).untilAsserted( - () -> verify(tomcatWebServerCustomizer, atLeast(INVOCATION_COUNT)).reloadDefaultTrustStore()); - await().atMost(new Duration(METRICS_REFRESH_RATE * (INVOCATION_COUNT + 10), TimeUnit.MILLISECONDS)) - .untilAsserted( - () -> verify(tomcatWebServerCustomizer, atLeast(INVOCATION_COUNT)).reloadMetricsTrustStore()); + await().atMost( + Duration.ofMillis(REFRESH_RATE_IN_MS * (INVOCATION_COUNT + 10))) + .untilAsserted(() -> verify(tomcatWebServerCustomizer, atLeast(INVOCATION_COUNT)) + .reloadDefaultTrustStore() + ); + await().atMost( + Duration.ofMillis(METRICS_REFRESH_RATE_IN_MS * (INVOCATION_COUNT + 10))) + .untilAsserted(() -> verify(tomcatWebServerCustomizer, atLeast(INVOCATION_COUNT)) + .reloadMetricsTrustStore() + ); } static class PropertyOverrideContextInitializer diff --git a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/utils/CertUtils.java b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/utils/CertUtils.java index dba87ff99..45b19b9ab 100644 --- a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/utils/CertUtils.java +++ b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/utils/CertUtils.java @@ -71,9 +71,9 @@ public class CertUtils { public static final String RSA_ALGORITHM_NAME = "RSA"; public static final String EC_ALGORITHM_NAME = "ECDSA"; - //When changing keysize make sure you know what you are doing. - //Too big keysize will slow keypair generation by ALOT. - //2048 for RSA is not secure enough in real world, but since this is only for tests it's perfectly fine. + // When changing key sizes, make sure you know what you are doing. + // Too big key sizes will slow down key pair generation by A LOT. + // 2048 for RSA is not secure enough in the real world, but since this is only for tests it's perfectly fine. private static final int RSA_KEY_SIZE = 2048; private static final int EC_KEY_SIZE = 384; private static final int PEM_ENCODED_LINE_LENGTH = 64; @@ -117,8 +117,8 @@ public void createCertificate(String commonName, Date notBefore, Date notAfter, X509Certificate caCertificate = getCertificate(Paths.get(caCertificateFile).toFile()); PublicKey caPublicKey = caCertificate.getPublicKey(); X509Certificate certificate = generate(getHashAlgorithm(caAlgorithm), keyPair.getPublic(), caPrivateKey, - caPublicKey, commonName, caCertificate.getSubjectDN().getName().replace("CN=", ""), notBefore, - notAfter, false); + caPublicKey, commonName, caCertificate.getSubjectDN().getName().replace("CN=", ""), + notBefore, notAfter, false); storeCertificate(certificate, Paths.get(certificateOutputFile)); storePrivateKey(keyPair.getPrivate(), Paths.get(privateKeyOutputFile)); diff --git a/connection.impl/pom.xml b/connection.impl/pom.xml index 2d979c999..a681361a9 100644 --- a/connection.impl/pom.xml +++ b/connection.impl/pom.xml @@ -28,6 +28,7 @@ EcChronos Connection Implementation + com.ericsson.bss.cassandra.ecchronos @@ -37,17 +38,16 @@ - com.datastax.oss + org.apache.cassandra java-driver-core - com.datastax.oss + org.apache.cassandra java-driver-metrics-micrometer - org.osgi org.osgi.service.component.annotations @@ -77,30 +77,12 @@ assertj-core test + - - - org.apache.maven.plugins - maven-shade-plugin - - - package - - shade - - - - - com.datastax.oss:java-driver-metrics-micrometer - - - - - - + org.apache.felix maven-bundle-plugin @@ -115,7 +97,7 @@ com.ericsson.bss.cassandra.ecchronos.connection.impl.*, - com.datastax.oss.driver.internal.metrics.micrometer.* + org.apache.cassandra.driver.internal.metrics.micrometer.* diff --git a/connection/pom.xml b/connection/pom.xml index 1140f03aa..979b3ca6d 100644 --- a/connection/pom.xml +++ b/connection/pom.xml @@ -30,7 +30,7 @@ - com.datastax.oss + org.apache.cassandra java-driver-core diff --git a/core/pom.xml b/core/pom.xml index 2225bf17e..8c2cf40e8 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -54,12 +54,12 @@ - com.datastax.oss + org.apache.cassandra java-driver-core - com.datastax.oss + org.apache.cassandra java-driver-query-builder diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/OnDemandRepair.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/OnDemandRepair.java index 667a933a9..f7c153522 100644 --- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/OnDemandRepair.java +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/OnDemandRepair.java @@ -18,9 +18,9 @@ import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairOptions; import com.google.common.annotations.VisibleForTesting; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; import java.util.Objects; import java.util.UUID; diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/RepairInfo.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/RepairInfo.java index abd4589e1..07efa731a 100644 --- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/RepairInfo.java +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/RepairInfo.java @@ -15,8 +15,8 @@ package com.ericsson.bss.cassandra.ecchronos.core.repair.types; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; import java.util.List; import java.util.Objects; diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/RepairStats.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/RepairStats.java index 23f529f8e..1fd048f37 100644 --- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/RepairStats.java +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/RepairStats.java @@ -15,9 +15,9 @@ package com.ericsson.bss.cassandra.ecchronos.core.repair.types; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; import java.util.Objects; @SuppressWarnings("VisibilityModifier") diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/Schedule.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/Schedule.java index 8926a17f1..4b9608fdd 100644 --- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/Schedule.java +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/Schedule.java @@ -19,9 +19,9 @@ import com.ericsson.bss.cassandra.ecchronos.core.repair.state.VnodeRepairStates; import com.google.common.annotations.VisibleForTesting; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; import java.util.Collections; import java.util.List; import java.util.Objects; diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/ScheduleConfig.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/ScheduleConfig.java index 0222e2300..dcb1cdc33 100644 --- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/ScheduleConfig.java +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/ScheduleConfig.java @@ -18,8 +18,8 @@ import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairOptions.RepairParallelism; import com.ericsson.bss.cassandra.ecchronos.core.repair.ScheduledRepairJobView; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; import java.util.Objects; /** diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/VirtualNodeState.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/VirtualNodeState.java index 80f327b7b..1443ce127 100644 --- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/VirtualNodeState.java +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/types/VirtualNodeState.java @@ -17,9 +17,9 @@ import com.ericsson.bss.cassandra.ecchronos.core.repair.state.VnodeRepairState; import com.ericsson.bss.cassandra.ecchronos.core.utils.DriverNode; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; import java.net.InetAddress; import java.util.Objects; import java.util.Set; diff --git a/docs/COMPATIBILITY.md b/docs/COMPATIBILITY.md index b2332b750..9b648521c 100644 --- a/docs/COMPATIBILITY.md +++ b/docs/COMPATIBILITY.md @@ -3,7 +3,7 @@ The table below shows what versions of Cassandra have been verified with ecChronos releases. -| ecChronos \ C* | 3.0.x | 3.11.x | 4.0.x | 4.1.x | 5.0.x | -|:--------------:|:-----:|:------:|:-----:|:-----:|:-----:| -| 4.x.x | X | X | X | - | - | -| 5.x.x | - | - | X | X | X | +| ecChronos \ C* | 4.0.x | 4.1.x | 5.0.x | +|:--------------:|:-----:|:-----:|:-----:| +| 5.x.x | X | X | X | +| 6.x.x | X | X | X | diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 8220bad3f..6b22ceb30 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -9,9 +9,9 @@ For keeping track of the history it is recommended that most communication is pe ### Prerequisites * Maven -* JDK11 +* Java 17 / 21 * Docker (for test setup) -* Python +* Python 3 ### Branches @@ -75,8 +75,9 @@ The following table state what versions of ecChronos is still under active maint | 1.x.x | 2019-Jan-25 | - | | 2.x.x | 2021-Feb-25 | - | | 3.x.x | 2022-Jun-30 | - | -| 4.x.x | 2022-Dec-15 | X | +| 4.x.x | 2022-Dec-15 | - | | 5.x.x | 2023-Dec-06 | X | +| 6.x.x | 2024-???-?? | X | ### REST API diff --git a/docs/autogenerated/openapi.yaml b/docs/autogenerated/openapi.yaml index 4aa73dc18..91e1f5da9 100644 --- a/docs/autogenerated/openapi.yaml +++ b/docs/autogenerated/openapi.yaml @@ -54,7 +54,7 @@ paths: schema: type: array items: - $ref: '#/components/schemas/OnDemandRepair' + $ref: "#/components/schemas/OnDemandRepair" post: tags: - Repair-Management @@ -100,7 +100,7 @@ paths: schema: type: array items: - $ref: '#/components/schemas/OnDemandRepair' + $ref: "#/components/schemas/OnDemandRepair" /repair-management/v2/schedules: get: tags: @@ -130,7 +130,7 @@ paths: schema: type: array items: - $ref: '#/components/schemas/Schedule' + $ref: "#/components/schemas/Schedule" /repair-management/v2/schedules/{id}: get: tags: @@ -157,7 +157,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Schedule' + $ref: "#/components/schemas/Schedule" /repair-management/v2/running-job: get: tags: @@ -198,7 +198,7 @@ paths: schema: type: array items: - $ref: '#/components/schemas/OnDemandRepair' + $ref: "#/components/schemas/OnDemandRepair" /repair-management/v2/repairInfo: get: tags: @@ -251,7 +251,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/RepairInfo' + $ref: "#/components/schemas/RepairInfo" /metrics: get: tags: @@ -283,9 +283,15 @@ paths: text/plain;version=0.0.4;charset=utf-8: schema: type: string + application/openmetrics-text; version=1.0.0; charset=utf-8: + schema: + type: string application/openmetrics-text;version=1.0.0;charset=utf-8: schema: type: string + text/plain; version=0.0.4; charset=utf-8: + schema: + type: string /actuator: get: tags: @@ -302,21 +308,21 @@ paths: additionalProperties: type: object additionalProperties: - $ref: '#/components/schemas/Link' - application/vnd.spring-boot.actuator.v2+json: + $ref: "#/components/schemas/Link" + application/json: schema: type: object additionalProperties: type: object additionalProperties: - $ref: '#/components/schemas/Link' - application/json: + $ref: "#/components/schemas/Link" + application/vnd.spring-boot.actuator.v2+json: schema: type: object additionalProperties: type: object additionalProperties: - $ref: '#/components/schemas/Link' + $ref: "#/components/schemas/Link" /actuator/health: get: tags: @@ -330,10 +336,10 @@ paths: application/vnd.spring-boot.actuator.v3+json: schema: type: object - application/vnd.spring-boot.actuator.v2+json: + application/json: schema: type: object - application/json: + application/vnd.spring-boot.actuator.v2+json: schema: type: object /actuator/health/**: @@ -349,10 +355,10 @@ paths: application/vnd.spring-boot.actuator.v3+json: schema: type: object - application/vnd.spring-boot.actuator.v2+json: + application/json: schema: type: object - application/json: + application/vnd.spring-boot.actuator.v2+json: schema: type: object components: @@ -442,7 +448,7 @@ components: type: integer format: int64 config: - $ref: '#/components/schemas/ScheduleConfig' + $ref: "#/components/schemas/ScheduleConfig" repairType: type: string enum: @@ -452,7 +458,7 @@ components: virtualNodeStates: type: array items: - $ref: '#/components/schemas/VirtualNodeState' + $ref: "#/components/schemas/VirtualNodeState" ScheduleConfig: required: - errorTimeInMs @@ -528,7 +534,7 @@ components: repairStats: type: array items: - $ref: '#/components/schemas/RepairStats' + $ref: "#/components/schemas/RepairStats" RepairStats: required: - keyspace diff --git a/pom.xml b/pom.xml index f2cc0f122..48c589e2c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - 4.1.94.Final - 1.9.16 - 4.2.21 - 4.17.0 - 32.0.1-jre + 3.26.3 + 4.2.2 3.1.8 - 1.0.1 - 1.5.0 - 25.1-jre - 1.4.2 - 2.1.12 - 1.7.30 - 1.2.13 - 1.3.0 - 4.5.1 - 3.16.1 - 5.8.2 - 2.17.0 - 2.15.2 - 2.15.2 - 1.33 - - 4.13.4 - 1.8.4 - 2.1.14 - 2.4.7 - 1 - 3.0.0 + 4.18.1 + 1.5.1 + 2.18.1 + 2.18.1 + 1.4.3 + 3.17.1 + 1.0.2 + 33.3.1-jre + 4.2.28 + 1.13.6 + 4.1.114.Final + 0.16.0 + 1.3.2 + 6.1.0 + 3.1.0 + 2.0.1 1.0 + 5.11.3 1.1.1 - 3.16.1 - 9.0.90 - 2.7.18 - 1.7.0 - 0.16.0 - 2.0.2 - 2.2.11 - 5.3.39 - 1.18.3 + 1.5.12 + 5.14.2 + 2.17.0 + 2.2.12 + 5.3.1 + 1.78.1 + 2.2.2 + 3.3.5 + 6.1.14 + 2.3 + 1.5.1 + 1.4.1 + 4.13.5 + 2.0.16 + 2.6.0 + 2.2.25 + 1.20.3 + 10.1.31 - 3.11.0 - 2.5.2 - 3.3.1 - 2.22.1 - 3.6.0 - 3.2.0 + 4.6 + 0.45.1 + 5.1.9 + 3.6.0 + 3.7.1 + 3.6.0 + 3.13.0 + 3.8.1 + 3.1.3 + 3.5.1 + 3.2.7 + 3.1.3 + 3.4.2 + 3.10.1 3.14.0 - 3.0.0 - 3.1.0 - 3.5.0 - 3.3.0 - 3.4.1 - 5.1.8 - 3.0 - 0.43.0 - 1.2 - 0.8.9 - 3.0.0 - 1.19 - - 2.5.3 - 2.8.2 - 3.0.1 - 3.0.1 - 1.6 - - UTF-8 - + 3.1.1 + 3.3.1 + 3.6.0 + 3.3.1 + 3.5.1 + 1.5.0 + 3.5.0 + 2.4.0 + 0.8.12 + + false ${skipTests} - 1073741824 256M + 1073741824 latest + + io.netty @@ -222,16 +223,25 @@ micrometer-core ${io.micrometer.version} + io.micrometer micrometer-registry-prometheus ${io.micrometer.version} + io.micrometer micrometer-registry-jmx ${io.micrometer.version} + + + io.prometheus + simpleclient + ${io.prometheus.simpleclient.version} + + io.dropwizard.metrics metrics-core @@ -240,7 +250,7 @@ - com.datastax.oss + org.apache.cassandra java-driver-core ${cassandra.driver.core.version} @@ -270,13 +280,15 @@ + - com.datastax.oss + org.apache.cassandra java-driver-metrics-micrometer ${cassandra.driver.core.version} + - com.datastax.oss + org.apache.cassandra java-driver-query-builder ${cassandra.driver.core.version} @@ -296,30 +308,25 @@ caffeine ${caffeine.version} + com.google.guava guava ${guava.version} + com.google.guava failureaccess ${failureaccess.version} - com.datastax.oss native-protocol ${cassandra.driver.protocol.version} - - com.datastax.oss - java-driver-shaded-guava - ${cassandra.driver.shaded.guava.version} - - com.typesafe config @@ -385,8 +392,8 @@ org.springdoc - springdoc-openapi-ui - ${org.springdoc.openapi-ui.version} + springdoc-openapi-starter-webmvc-ui + ${springdoc.openapi-starter-webmvc-ui.version} @@ -395,12 +402,25 @@ ${org.springframework.web.version} + + jakarta.servlet + jakarta.servlet-api + ${jakarta.servlet-api.version} + + + + org.apache.httpcomponents.client5 + httpclient5 + ${org.apache.httpcomponents.client.version} + + jakarta.validation jakarta.validation-api ${jakarta.validation-api.version} + io.swagger.core.v3 swagger-annotations @@ -409,26 +429,26 @@ io.prometheus - simpleclient - ${io.prometheus.simpleclient} + prometheus-metrics-exposition-formats + ${io.prometheus.client-java.version} org.osgi org.osgi.service.component.annotations - ${osgi.version} + ${osgi.component.version} provided org.osgi org.osgi.service.metatype.annotations - ${osgi.version} + ${osgi.metatype.version} provided - + org.mockito mockito-all @@ -472,6 +492,13 @@ test + + org.bouncycastle + bcpkix-jdk18on + ${org.bouncycastle.bcpkix-jdk18on.version} + test + + org.ops4j.pax.exam @@ -496,8 +523,8 @@ javax.inject - javax.inject - ${javax.inject.version} + javax.inject-api + ${javax.inject-api.version} test @@ -598,6 +625,9 @@ maven-compiler-plugin ${org.apache.maven.plugins.maven-compiler-plugin.version} + + -parameters + ${java.version} ${java.version} @@ -668,7 +698,7 @@ limitations under the License. YEAR - 2019 + 2024 [0-9-]+ @@ -1082,30 +1112,49 @@ limitations under the License. + - Marcus Olsson - marcus.olsson@ericsson.com + Tommy Stendahl + tommy.stendahl@ericsson.com Ericsson AB http://www.ericsson.com + + + Johan W Andersson + johan.w.andersson@ericsson.com + Ericsson AB + http://www.ericsson.com + + + + Christian Andersson + christian.a.andersson@ericsson.com + Ericsson AB + http://www.ericsson.com + + - Per Otterström - per.otterstrom@ericsson.com + Sajid Riaz + sajid.riaz@ericsson.com Ericsson AB http://www.ericsson.com + - Jan Karlsson - jan.karlsson@ericsson.com + Victor Cavichioli + victor.cavichioli@ericsson.com Ericsson AB http://www.ericsson.com + https://github.com/ericsson/ecchronos scm:git:git@github.com:ericsson/ecchronos.git scm:git:git@github.com:ericsson/ecchronos.git - HEAD - + HEAD + + diff --git a/rest/pom.xml b/rest/pom.xml index 0b580688b..073230d3d 100644 --- a/rest/pom.xml +++ b/rest/pom.xml @@ -46,6 +46,10 @@ + + io.prometheus + prometheus-metrics-exposition-formats + io.prometheus simpleclient diff --git a/rest/src/main/java/com/ericsson/bss/cassandra/ecchronos/rest/MetricsREST.java b/rest/src/main/java/com/ericsson/bss/cassandra/ecchronos/rest/MetricsREST.java index 490e4f856..0225cb276 100644 --- a/rest/src/main/java/com/ericsson/bss/cassandra/ecchronos/rest/MetricsREST.java +++ b/rest/src/main/java/com/ericsson/bss/cassandra/ecchronos/rest/MetricsREST.java @@ -14,8 +14,9 @@ */ package com.ericsson.bss.cassandra.ecchronos.rest; -import io.micrometer.prometheus.PrometheusMeterRegistry; -import io.prometheus.client.exporter.common.TextFormat; +import io.micrometer.prometheusmetrics.PrometheusMeterRegistry; +import io.prometheus.metrics.expositionformats.PrometheusTextFormatWriter; +import io.prometheus.metrics.expositionformats.OpenMetricsTextFormatWriter; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -45,10 +46,11 @@ public MetricsREST(final PrometheusMeterRegistry prometheusMeterRegistry) myPrometheusMeterRegistry = prometheusMeterRegistry; } - @GetMapping(value = "/metrics", produces = { TextFormat.CONTENT_TYPE_004, TextFormat.CONTENT_TYPE_OPENMETRICS_100 }) + @GetMapping(value = "/metrics", produces = { PrometheusTextFormatWriter.CONTENT_TYPE, + OpenMetricsTextFormatWriter.CONTENT_TYPE }) @Operation(operationId = "metrics", description = "Get metrics in the specified format", summary = "Get metrics") public final ResponseEntity getMetrics(@RequestHeader(value = HttpHeaders.ACCEPT, required = false, - defaultValue = TextFormat.CONTENT_TYPE_004) + defaultValue = PrometheusTextFormatWriter.CONTENT_TYPE) final String acceptHeader, @RequestParam(value = "name[]", required = false, defaultValue = "") @Parameter(description = "Filter metrics based on these names.") @@ -58,7 +60,14 @@ public final ResponseEntity getMetrics(@RequestHeader(value = HttpHeader { throw new ResponseStatusException(NOT_FOUND); } - String contentType = TextFormat.chooseContentType(acceptHeader); + + // Check the content type, but default to PrometheusTextFormat + String contentType = PrometheusTextFormatWriter.CONTENT_TYPE; + if (acceptHeader != null && acceptHeader.contains("application/openmetrics-text")) + { + contentType = OpenMetricsTextFormatWriter.CONTENT_TYPE; + } + return ResponseEntity.ok() .header(CONTENT_TYPE, contentType) .body(myPrometheusMeterRegistry.scrape(contentType, includedMetrics)); diff --git a/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestMetricsREST.java b/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestMetricsREST.java index b438b5070..215952bac 100644 --- a/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestMetricsREST.java +++ b/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestMetricsREST.java @@ -14,8 +14,9 @@ */ package com.ericsson.bss.cassandra.ecchronos.rest; -import io.micrometer.prometheus.PrometheusMeterRegistry; -import io.prometheus.client.exporter.common.TextFormat; +import io.micrometer.prometheusmetrics.PrometheusMeterRegistry; +import io.prometheus.metrics.expositionformats.OpenMetricsTextFormatWriter; +import io.prometheus.metrics.expositionformats.PrometheusTextFormatWriter; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -62,7 +63,7 @@ public void testGetMetricsMeterRegistryNull() } catch (ResponseStatusException e) { - assertThat(e.getRawStatusCode()).isEqualTo(NOT_FOUND.value()); + assertThat(e.getStatusCode().value()).isEqualTo(NOT_FOUND.value()); } assertThat(response).isNull(); verify(myPrometheusMeterRegistryMock, never()).scrape(any(String.class), any(Set.class)); @@ -76,8 +77,8 @@ public void testGetMetricsNoParams() assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); List contentTypeHeaders = response.getHeaders().get(HttpHeaders.CONTENT_TYPE); assertThat(contentTypeHeaders).hasSize(1); - assertThat(contentTypeHeaders.get(0)).isEqualTo(TextFormat.CONTENT_TYPE_004); - verify(myPrometheusMeterRegistryMock).scrape(TextFormat.CONTENT_TYPE_004, Collections.emptySet()); + assertThat(contentTypeHeaders.get(0)).isEqualTo(PrometheusTextFormatWriter.CONTENT_TYPE); + verify(myPrometheusMeterRegistryMock).scrape(PrometheusTextFormatWriter.CONTENT_TYPE, Collections.emptySet()); } @Test @@ -88,8 +89,8 @@ public void testGetMetricsAcceptHeader() assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); List contentTypeHeaders = response.getHeaders().get(HttpHeaders.CONTENT_TYPE); assertThat(contentTypeHeaders).hasSize(1); - assertThat(contentTypeHeaders.get(0)).isEqualTo(TextFormat.CONTENT_TYPE_OPENMETRICS_100); - verify(myPrometheusMeterRegistryMock).scrape(TextFormat.CONTENT_TYPE_OPENMETRICS_100, Collections.emptySet()); + assertThat(contentTypeHeaders.get(0)).isEqualTo(OpenMetricsTextFormatWriter.CONTENT_TYPE); + verify(myPrometheusMeterRegistryMock).scrape(OpenMetricsTextFormatWriter.CONTENT_TYPE, Collections.emptySet()); } @Test @@ -100,7 +101,7 @@ public void testGetMetricsIncludedNames() assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); List contentTypeHeaders = response.getHeaders().get(HttpHeaders.CONTENT_TYPE); assertThat(contentTypeHeaders).hasSize(1); - assertThat(contentTypeHeaders.get(0)).isEqualTo(TextFormat.CONTENT_TYPE_004); - verify(myPrometheusMeterRegistryMock).scrape(TextFormat.CONTENT_TYPE_004, Collections.singleton("fooMetrics")); + assertThat(contentTypeHeaders.get(0)).isEqualTo(PrometheusTextFormatWriter.CONTENT_TYPE); + verify(myPrometheusMeterRegistryMock).scrape(PrometheusTextFormatWriter.CONTENT_TYPE, Collections.singleton("fooMetrics")); } } diff --git a/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestOnDemandRepairManagementRESTImpl.java b/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestOnDemandRepairManagementRESTImpl.java index 5191052e4..77fb10097 100644 --- a/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestOnDemandRepairManagementRESTImpl.java +++ b/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestOnDemandRepairManagementRESTImpl.java @@ -184,7 +184,7 @@ public void testGetRepairWithId() } catch (ResponseStatusException e) { - assertThat(e.getRawStatusCode()).isEqualTo(NOT_FOUND.value()); + assertThat(e.getStatusCode().value()).isEqualTo(NOT_FOUND.value()); } assertThat(response).isNull(); response = OnDemandRest.getRepairs(expectedId.toString(), expectedHostId.toString()); @@ -198,7 +198,7 @@ public void testGetRepairWithId() } catch (ResponseStatusException e) { - assertThat(e.getRawStatusCode()).isEqualTo(NOT_FOUND.value()); + assertThat(e.getStatusCode().value()).isEqualTo(NOT_FOUND.value()); } assertThat(response).isNull(); response = OnDemandRest.getRepairs(expectedId.toString(), null); @@ -460,7 +460,7 @@ public void testRunRepairNoKeyspaceWithTable() } catch (ResponseStatusException e) { - assertThat(e.getRawStatusCode()).isEqualTo(BAD_REQUEST.value()); + assertThat(e.getStatusCode().value()).isEqualTo(BAD_REQUEST.value()); } assertThat(response).isNull(); } diff --git a/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestRepairManagementRESTImpl.java b/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestRepairManagementRESTImpl.java index 4ae3c387d..84e7ca962 100644 --- a/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestRepairManagementRESTImpl.java +++ b/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestRepairManagementRESTImpl.java @@ -282,7 +282,7 @@ public void testGetRepairInfoOnlyTable() } catch (ResponseStatusException e) { - assertThat(e.getRawStatusCode()).isEqualTo(BAD_REQUEST.value()); + assertThat(e.getStatusCode().value()).isEqualTo(BAD_REQUEST.value()); } assertThat(response).isNull(); } @@ -317,7 +317,7 @@ public void testGetRepairInfoNoKeyspaceNoTableNoSinceOrDuration() } catch (ResponseStatusException e) { - assertThat(e.getRawStatusCode()).isEqualTo(BAD_REQUEST.value()); + assertThat(e.getStatusCode().value()).isEqualTo(BAD_REQUEST.value()); } assertThat(response).isNull(); } @@ -333,7 +333,7 @@ public void testGetRepairInfoSinceBiggerThanSincePlusDuration() } catch (ResponseStatusException e) { - assertThat(e.getRawStatusCode()).isEqualTo(BAD_REQUEST.value()); + assertThat(e.getStatusCode().value()).isEqualTo(BAD_REQUEST.value()); } assertThat(response).isNull(); } diff --git a/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestScheduleRepairManagementRESTImpl.java b/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestScheduleRepairManagementRESTImpl.java index f3199dd96..1b433be4b 100644 --- a/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestScheduleRepairManagementRESTImpl.java +++ b/rest/src/test/java/com/ericsson/bss/cassandra/ecchronos/rest/TestScheduleRepairManagementRESTImpl.java @@ -176,7 +176,7 @@ public void testGetScheduleWithId() throws UnknownHostException } catch (ResponseStatusException e) { - assertThat(e.getRawStatusCode()).isEqualTo(NOT_FOUND.value()); + assertThat(e.getStatusCode().value()).isEqualTo(NOT_FOUND.value()); } assertThat(response).isNull(); @@ -196,7 +196,7 @@ public void testGetScheduleWithId() throws UnknownHostException } catch (ResponseStatusException e) { - assertThat(e.getRawStatusCode()).isEqualTo(NOT_FOUND.value()); + assertThat(e.getStatusCode().value()).isEqualTo(NOT_FOUND.value()); } assertThat(response).isNull();