diff --git a/.github/workflows/build-check.yml b/.github/workflows/build-check.yml index a0987fee..e8866bc6 100644 --- a/.github/workflows/build-check.yml +++ b/.github/workflows/build-check.yml @@ -15,11 +15,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - cache: maven - - name: Build with Maven - run: mvn -B clean package --file pom.xml + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: 17 + cache: maven + distribution: 'temurin' + - name: Build with Maven + run: mvn -B clean package --file pom.xml \ No newline at end of file diff --git a/pom.xml b/pom.xml index 0786091c..b14a9849 100644 --- a/pom.xml +++ b/pom.xml @@ -100,7 +100,6 @@ 3.3.1 4.2.0 - 1.2.10 2.1.10 @@ -149,12 +148,6 @@ io.dropwizard dropwizard-jackson - - ch.qos.logback - logback-classic - ${logback.version} - test - org.junit.jupiter junit-jupiter-api @@ -190,10 +183,15 @@ ${java.release.version} + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + org.jacoco jacoco-maven-plugin - 0.8.6 + 0.8.8 @@ -227,7 +225,10 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.3.0 + 3.6.3 + + all,-missing + attach-javadocs @@ -286,6 +287,20 @@ + + + add-java-open-options-for-jdk16+ + + [16,) + + + + --add-opens java.base/java.net=ALL-UNNAMED + --add-opens java.base/sun.net=ALL-UNNAMED + + + diff --git a/ranger-core/src/test/java/io/appform/ranger/core/serviceprovider/ServiceProviderTest.java b/ranger-core/src/test/java/io/appform/ranger/core/serviceprovider/ServiceProviderTest.java index fe8446e6..cff88392 100644 --- a/ranger-core/src/test/java/io/appform/ranger/core/serviceprovider/ServiceProviderTest.java +++ b/ranger-core/src/test/java/io/appform/ranger/core/serviceprovider/ServiceProviderTest.java @@ -100,31 +100,23 @@ protected NodeDataSink> dataSink(Service service) { @Test void testInvalidServiceProvider() { - try { - new TestServiceProviderBuilder<>() - .withServiceName("test-service") - .withNamespace("test") - .withHostname("localhost-1") - .withPort(9000) - .build(); - } catch (NullPointerException exception) { - Assertions.assertTrue(true, "NPE has been caught"); - } + Assertions.assertThrowsExactly(NullPointerException.class, () -> new TestServiceProviderBuilder<>() + .withServiceName("test-service") + .withNamespace("test") + .withHostname("localhost-1") + .withPort(9000) + .build()); } @Test void testInvalidServiceProviderNoHealthCheck() { - try { - new TestServiceProviderBuilder<>() - .withServiceName("test-service") - .withNamespace("test") - .withHostname("localhost-1") - .withPort(9000) - .withSerializer(new TestSerializerImpl()) - .build(); - } catch (Exception exception) { - Assertions.assertTrue(exception instanceof IllegalArgumentException, "Illegal Argument Exception should be thrown"); - } + Assertions.assertThrowsExactly(IllegalArgumentException.class, () -> new TestServiceProviderBuilder<>() + .withServiceName("test-service") + .withNamespace("test") + .withHostname("localhost-1") + .withPort(9000) + .withSerializer(new TestSerializerImpl()) + .build()); } @Test diff --git a/ranger-discovery-bundle/perf/results/io.appform.ranger.discovery.bundle.id.IdGeneratorPerfTest.testGenerate.json b/ranger-discovery-bundle/perf/results/io.appform.ranger.discovery.bundle.id.IdGeneratorPerfTest.testGenerate.json index 6ae5d183..f19b937b 100644 --- a/ranger-discovery-bundle/perf/results/io.appform.ranger.discovery.bundle.id.IdGeneratorPerfTest.testGenerate.json +++ b/ranger-discovery-bundle/perf/results/io.appform.ranger.discovery.bundle.id.IdGeneratorPerfTest.testGenerate.json @@ -4,5 +4,5 @@ "iterations" : 4, "threads" : 1, "forks" : 3, - "mean_ops" : 639973.1997503598 + "mean_ops" : 644166.1778513143 } \ No newline at end of file diff --git a/ranger-discovery-bundle/perf/results/io.appform.ranger.discovery.bundle.id.IdGeneratorPerfTest.testGenerateBase36.json b/ranger-discovery-bundle/perf/results/io.appform.ranger.discovery.bundle.id.IdGeneratorPerfTest.testGenerateBase36.json index 08c716e8..272db000 100644 --- a/ranger-discovery-bundle/perf/results/io.appform.ranger.discovery.bundle.id.IdGeneratorPerfTest.testGenerateBase36.json +++ b/ranger-discovery-bundle/perf/results/io.appform.ranger.discovery.bundle.id.IdGeneratorPerfTest.testGenerateBase36.json @@ -4,5 +4,5 @@ "iterations" : 4, "threads" : 1, "forks" : 3, - "mean_ops" : 501189.9391797681 + "mean_ops" : 502644.4941310657 } \ No newline at end of file diff --git a/ranger-http-client/src/test/java/io/appform/ranger/client/http/BaseRangerHttpClientTest.java b/ranger-http-client/src/test/java/io/appform/ranger/client/http/BaseRangerHttpClientTest.java index 0d6f3e38..bdab6924 100644 --- a/ranger-http-client/src/test/java/io/appform/ranger/client/http/BaseRangerHttpClientTest.java +++ b/ranger-http-client/src/test/java/io/appform/ranger/client/http/BaseRangerHttpClientTest.java @@ -31,7 +31,6 @@ import lombok.Getter; import lombok.extern.slf4j.Slf4j; import lombok.val; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.RegisterExtension; @@ -53,7 +52,7 @@ public abstract class BaseRangerHttpClientTest { .build(); @BeforeEach - public void startTestCluster() throws Exception { + public void prepareHttpMocks() throws Exception { val testNode = TestNodeData.builder().shardId(1).build(); val node = ServiceNode.builder().host("127.0.0.1").port(80).nodeData(testNode).build(); node.setHealthcheckStatus(HealthcheckStatus.healthy); @@ -87,11 +86,6 @@ public void startTestCluster() throws Exception { log.debug("Started http subsystem"); } - @AfterEach - public void stopTestCluster() { - log.debug("Stopping http subsystem"); - } - protected ServiceNodesResponse read(final byte[] data) { try { return getObjectMapper().readValue(data, new TypeReference>() {}); diff --git a/ranger-http-server/pom.xml b/ranger-http-server/pom.xml index 3d376174..4989fdb9 100644 --- a/ranger-http-server/pom.xml +++ b/ranger-http-server/pom.xml @@ -21,11 +21,6 @@ io.dropwizard dropwizard-core - - ch.qos.logback - logback-classic - ${logback.version} - \ No newline at end of file diff --git a/ranger-server-bundle/src/test/java/io/appform/ranger/server/bundle/RangerServerBundleTest.java b/ranger-server-bundle/src/test/java/io/appform/ranger/server/bundle/RangerServerBundleTest.java index 207c0f9c..b5059bcd 100644 --- a/ranger-server-bundle/src/test/java/io/appform/ranger/server/bundle/RangerServerBundleTest.java +++ b/ranger-server-bundle/src/test/java/io/appform/ranger/server/bundle/RangerServerBundleTest.java @@ -45,15 +45,15 @@ public class RangerServerBundleTest { - private static final JerseyEnvironment jerseyEnvironment = mock(JerseyEnvironment.class); - private static final MetricRegistry metricRegistry = mock(MetricRegistry.class); - private static final LifecycleEnvironment lifecycleEnvironment = new LifecycleEnvironment(metricRegistry); - private static final Environment environment = mock(Environment.class); - private static final Bootstrap bootstrap = mock(Bootstrap.class); - private static final Configuration configuration = mock(Configuration.class); + private static final JerseyEnvironment JERSEY_ENVIRONMENT = mock(JerseyEnvironment.class); + private static final MetricRegistry METRIC_REGISTRY = mock(MetricRegistry.class); + private static final LifecycleEnvironment LIFECYCLE_ENVIRONMENT = new LifecycleEnvironment(METRIC_REGISTRY); + private static final Environment ENVIRONMENT = mock(Environment.class); + private static final Bootstrap BOOTSTRAP = mock(Bootstrap.class); + private static final Configuration CONFIGURATION = mock(Configuration.class); private static final RangerServerBundle, Configuration> - rangerServerBundle = new RangerServerBundle<>() { + RANGER_SERVER_BUNDLE = new RangerServerBundle<>() { @Override protected List>> withHubs(Configuration configuration) { @@ -68,21 +68,21 @@ protected List withHealthChecks(Configuration configuration) { @BeforeAll public static void setup() throws Exception { - when(jerseyEnvironment.getResourceConfig()).thenReturn(new DropwizardResourceConfig()); - when(environment.jersey()).thenReturn(jerseyEnvironment); - when(environment.lifecycle()).thenReturn(lifecycleEnvironment); - when(environment.getObjectMapper()).thenReturn(new ObjectMapper()); + when(JERSEY_ENVIRONMENT.getResourceConfig()).thenReturn(new DropwizardResourceConfig()); + when(ENVIRONMENT.jersey()).thenReturn(JERSEY_ENVIRONMENT); + when(ENVIRONMENT.lifecycle()).thenReturn(LIFECYCLE_ENVIRONMENT); + when(ENVIRONMENT.getObjectMapper()).thenReturn(new ObjectMapper()); val adminEnvironment = mock(AdminEnvironment.class); doNothing().when(adminEnvironment).addTask(any()); - when(environment.admin()).thenReturn(adminEnvironment); + when(ENVIRONMENT.admin()).thenReturn(adminEnvironment); val healthCheckRegistry = mock(HealthCheckRegistry.class); doNothing().when(healthCheckRegistry).register(anyString(), any()); - when(environment.healthChecks()).thenReturn(healthCheckRegistry); + when(ENVIRONMENT.healthChecks()).thenReturn(healthCheckRegistry); - rangerServerBundle.initialize(bootstrap); - rangerServerBundle.run(configuration, environment); - for (val lifeCycle : lifecycleEnvironment.getManagedObjects()) { + RANGER_SERVER_BUNDLE.initialize(BOOTSTRAP); + RANGER_SERVER_BUNDLE.run(CONFIGURATION, ENVIRONMENT); + for (val lifeCycle : LIFECYCLE_ENVIRONMENT.getManagedObjects()) { lifeCycle.start(); } } @@ -90,7 +90,7 @@ public static void setup() throws Exception { @Test void testRangerBundle() { - var hub = rangerServerBundle.getHubs().get(0); + var hub = RANGER_SERVER_BUNDLE.getHubs().get(0); Assertions.assertTrue(hub instanceof RangerTestHub); var node = hub.getNode(service).orElse(null); Assertions.assertNotNull(node); @@ -105,7 +105,7 @@ void testRangerBundle() { @AfterAll public static void tearDown() throws Exception { - for (LifeCycle lifeCycle : lifecycleEnvironment.getManagedObjects()) { + for (LifeCycle lifeCycle : LIFECYCLE_ENVIRONMENT.getManagedObjects()) { lifeCycle.stop(); } } diff --git a/ranger-zk-server/config/local.yml b/ranger-zk-server/config/local.yml index 0a09598d..793a1b29 100644 --- a/ranger-zk-server/config/local.yml +++ b/ranger-zk-server/config/local.yml @@ -1,13 +1,12 @@ name: ranger-server rangerConfiguration: - namespace: phonepe - zookeeper: stg-appzk001.phonepe.nb6:2181,stg-appzk002.phonepe.nb6:2181,stg-appzk003.phonepe.nb6:2181 - disablePushUpdaters: true + namespace: test + zookeeper: localhost:2181 server: - maxThreads: 1024 - minThreads: 1024 + maxThreads: 128 + minThreads: 128 applicationConnectors: - type: http port: 7080 diff --git a/ranger-zk-server/pom.xml b/ranger-zk-server/pom.xml index 0c114f94..b4a7f298 100644 --- a/ranger-zk-server/pom.xml +++ b/ranger-zk-server/pom.xml @@ -21,11 +21,6 @@ io.dropwizard dropwizard-core - - ch.qos.logback - logback-classic - ${logback.version} - \ No newline at end of file