diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 320789e57e6..c3408b096f1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -30,7 +30,7 @@ javax = "1.3.2" jetbrainsAnnotations = "20.1.0" jline = "3.21.0" jmh = "1.35" -junit5 = "5.9.1" +junit5 = "5.9.3" junitPioneer = "2.0.1" jsr305 = "3.0.2" okhttp = "4.9.1" diff --git a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/NodeConfig.java b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/NodeConfig.java index cd533dd4076..798233bc450 100644 --- a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/NodeConfig.java +++ b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/NodeConfig.java @@ -40,8 +40,10 @@ public class NodeConfig { + " },\n" + " },\n" + " clientConnector.port: {} ,\n" - + " rest: {" + + " rest: {\n" + + " port: {}\n" + " ssl: {\n" + + " port: {},\n" + " enabled: true,\n" + " keyStore: {\n" + " path: \"" + escapeWindowsPath(resolvedKeystorePath) + "\",\n" @@ -77,6 +79,10 @@ public class NodeConfig { + " password: " + trustStorePassword + "\n" + " }\n" + " }\n" + + " },\n" + + " rest: {\n" + + " port: {},\n" + + " ssl.port: {}\n" + " }\n" + "}"; } diff --git a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/CliIntegrationTestBase.java b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/CliIntegrationTestBase.java index 8d822429cf0..b9bd5b99dd9 100644 --- a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/CliIntegrationTestBase.java +++ b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/CliIntegrationTestBase.java @@ -55,6 +55,10 @@ public abstract class CliIntegrationTestBase extends IntegrationTestBase { + " }\n" + " },\n" + " clientConnector: { port:{} }\n" + + " rest: {\n" + + " port: {}\n" + + " ssl.port: {}\n" + + " }\n" + "}"; diff --git a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/rest/ItGeneratedRestClientTest.java b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/rest/ItGeneratedRestClientTest.java index 56646af6aec..44d314ef4d1 100644 --- a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/rest/ItGeneratedRestClientTest.java +++ b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/rest/ItGeneratedRestClientTest.java @@ -138,7 +138,8 @@ private static String buildConfig(int nodeIdx) { + " netClusterNodes: [ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ] \n" + " }\n" + " },\n" - + " clientConnector.port: " + (BASE_CLIENT_PORT + nodeIdx) + "\n" + + " clientConnector.port: " + (BASE_CLIENT_PORT + nodeIdx) + ",\n" + + " rest.port: " + (BASE_REST_PORT + nodeIdx) + "\n" + "}"; } diff --git a/modules/cli/src/integrationTest/resources/hardcoded-ports-config.json b/modules/cli/src/integrationTest/resources/hardcoded-ports-config.json index c2d5d7c48f7..5af4d412a90 100644 --- a/modules/cli/src/integrationTest/resources/hardcoded-ports-config.json +++ b/modules/cli/src/integrationTest/resources/hardcoded-ports-config.json @@ -7,8 +7,7 @@ } }, "rest": { - "port": , - "portRange": 0 + "port": }, "clientConnector": { "port": diff --git a/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/IntegrationTestBase.java b/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/IntegrationTestBase.java index 7eecc395444..af828dafc41 100644 --- a/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/IntegrationTestBase.java +++ b/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/IntegrationTestBase.java @@ -49,8 +49,20 @@ @MicronautTest(rebuildContext = true) @ExtendWith(WorkDirectoryExtension.class) public class IntegrationTestBase extends BaseIgniteAbstractTest { + /** Base port network number. */ + private static final int BASE_PORT = 3344; + + /** Base client port. */ + private static final int BASE_CLIENT_PORT = 10800; + + /** Base HTTP port. */ + private static final int BASE_HTTP_PORT = 10300; + + /** Base HTTPS port. */ + private static final int BASE_HTTPS_PORT = 10400; + /** Correct ignite cluster url. */ - protected static final String NODE_URL = "http://localhost:10300"; + protected static final String NODE_URL = "http://localhost:" + BASE_HTTP_PORT; /** Cluster nodes. */ protected static final List CLUSTER_NODES = new ArrayList<>(); @@ -65,12 +77,6 @@ public class IntegrationTestBase extends BaseIgniteAbstractTest { private static final IgniteLogger LOG = Loggers.forClass(IntegrationTestBase.class); - /** Base port number. */ - - private static final int BASE_PORT = 3344; - - private static final int BASE_CLIENT_PORT = 10800; - /** Nodes bootstrap configuration pattern. */ private static final String NODE_BOOTSTRAP_CFG = "{\n" + " network: {\n" @@ -80,7 +86,11 @@ public class IntegrationTestBase extends BaseIgniteAbstractTest { + " netClusterNodes: [ {} ]\n" + " }\n" + " },\n" - + " clientConnector: { port:{} }\n" + + " clientConnector: { port: {} }\n" + + " rest: {\n" + + " port:{},\n" + + " ssl: { port: {} }\n" + + " }\n" + "}"; /** Futures that are going to be completed when all nodes are started and the cluster is initialized. */ @@ -107,7 +117,9 @@ protected void startNodes(TestInfo testInfo) { nodeBootstrapConfigTemplate(), BASE_PORT + i, connectNodeAddr, - BASE_CLIENT_PORT + i); + BASE_CLIENT_PORT + i, + BASE_HTTP_PORT + i, + BASE_HTTPS_PORT + i); NODE_CONFIGS.put(nodeName, config); diff --git a/modules/rest/src/main/java/org/apache/ignite/internal/rest/RestComponent.java b/modules/rest/src/main/java/org/apache/ignite/internal/rest/RestComponent.java index fc7174079a9..866ef432a88 100644 --- a/modules/rest/src/main/java/org/apache/ignite/internal/rest/RestComponent.java +++ b/modules/rest/src/main/java/org/apache/ignite/internal/rest/RestComponent.java @@ -91,44 +91,17 @@ public void start() { boolean sslEnabled = sslConfigurationView.enabled(); boolean dualProtocol = restConfiguration.dualProtocol().value(); - int desiredHttpPort = restConfigurationView.port(); - int portRange = restConfigurationView.portRange(); - int desiredHttpsPort = sslConfigurationView.port(); - int httpsPortRange = sslConfigurationView.portRange(); - int httpPortCandidate = desiredHttpPort; - int httpsPortCandidate = desiredHttpsPort; - - while (httpPortCandidate <= desiredHttpPort + portRange - && httpsPortCandidate <= desiredHttpsPort + httpsPortRange) { - if (startServer(httpPortCandidate, httpsPortCandidate)) { - return; - } - LOG.debug("Got exception during node start, going to try again [httpPort={}, httpsPort={}]", - httpPortCandidate, - httpsPortCandidate); - - if (sslEnabled && dualProtocol) { - httpPortCandidate++; - httpsPortCandidate++; - } else if (sslEnabled) { - httpsPortCandidate++; - } else { - httpPortCandidate++; - } + if (startServer(restConfigurationView.port(), sslConfigurationView.port(), sslEnabled, dualProtocol)) { + return; } - LOG.debug("Unable to start REST endpoint." - + " Couldn't find available port for HTTP or HTTPS" - + " [HTTP ports=[{}, {}]]," - + " [HTTPS ports=[{}, {}]]", - desiredHttpPort, (desiredHttpPort + portRange), - desiredHttpsPort, (desiredHttpsPort + httpsPortRange)); - String msg = "Cannot start REST endpoint." + " Couldn't find available port for HTTP or HTTPS" - + " [HTTP ports=[" + desiredHttpPort + ", " + desiredHttpPort + portRange + "]]," - + " [HTTPS ports=[" + desiredHttpsPort + ", " + desiredHttpsPort + httpsPortRange + "]]"; + + " [HTTP port=" + httpPort + "]," + + " [HTTPS port=" + httpsPort + "]"; + + LOG.error(msg); throw new IgniteException(Common.COMPONENT_NOT_STARTED_ERR, msg); } @@ -137,9 +110,11 @@ public void start() { * * @param httpPortCandidate HTTP port candidate. * @param httpsPortCandidate HTTPS port candidate. + * @param sslEnabled SSL enabled flag. + * @param dualProtocol Dual protocol flag. * @return {@code True} if server was started successfully, {@code False} if couldn't bind one of the ports. */ - private boolean startServer(int httpPortCandidate, int httpsPortCandidate) { + private synchronized boolean startServer(int httpPortCandidate, int httpsPortCandidate, boolean sslEnabled, boolean dualProtocol) { try { httpPort = httpPortCandidate; httpsPort = httpsPortCandidate; @@ -147,7 +122,8 @@ private boolean startServer(int httpPortCandidate, int httpsPortCandidate) { .deduceEnvironment(false) .environments(BARE_METAL) .start(); - LOG.info("REST protocol started successfully"); + + logSuccessRestStart(sslEnabled, dualProtocol); return true; } catch (ApplicationStartupException e) { BindException bindException = findBindException(e); @@ -158,6 +134,20 @@ private boolean startServer(int httpPortCandidate, int httpsPortCandidate) { } } + private void logSuccessRestStart(boolean sslEnabled, boolean dualProtocol) { + String successReportMsg = null; + + if (sslEnabled && dualProtocol) { + successReportMsg = "[httpPort=" + httpPort + "], [httpsPort=" + httpsPort + "]"; + } else if (sslEnabled) { + successReportMsg = "[httpsPort=" + httpsPort + "]"; + } else { + successReportMsg = "[httpPort=" + httpPort + "]"; + } + + LOG.info("REST server started successfully: " + successReportMsg); + } + @Nullable private BindException findBindException(ApplicationStartupException e) { var throwable = e.getCause(); diff --git a/modules/rest/src/main/java/org/apache/ignite/internal/rest/configuration/RestConfigurationSchema.java b/modules/rest/src/main/java/org/apache/ignite/internal/rest/configuration/RestConfigurationSchema.java index 7f144dac26c..1ef8615f361 100644 --- a/modules/rest/src/main/java/org/apache/ignite/internal/rest/configuration/RestConfigurationSchema.java +++ b/modules/rest/src/main/java/org/apache/ignite/internal/rest/configuration/RestConfigurationSchema.java @@ -35,11 +35,6 @@ public class RestConfigurationSchema { @Value(hasDefault = true) public final int port = 10300; - /** TCP port range. */ - @Range(min = 0) - @Value(hasDefault = true) - public final int portRange = 100; - /** The dual protocol (http/https) configuration. */ @Value(hasDefault = true) public final boolean dualProtocol = false; diff --git a/modules/rest/src/main/java/org/apache/ignite/internal/rest/configuration/RestSslConfigurationSchema.java b/modules/rest/src/main/java/org/apache/ignite/internal/rest/configuration/RestSslConfigurationSchema.java index dbd2908d413..503f4e9fd81 100644 --- a/modules/rest/src/main/java/org/apache/ignite/internal/rest/configuration/RestSslConfigurationSchema.java +++ b/modules/rest/src/main/java/org/apache/ignite/internal/rest/configuration/RestSslConfigurationSchema.java @@ -30,9 +30,4 @@ public class RestSslConfigurationSchema extends AbstractSslConfigurationSchema { @Range(min = 1024, max = 0xFFFF) @Value(hasDefault = true) public final int port = 10400; - - /** SSL port range. */ - @Range(min = 0) - @Value(hasDefault = true) - public final int portRange = 100; } diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/BaseIgniteRestartTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/BaseIgniteRestartTest.java index 26c110b3a16..2d65f6f0a46 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/BaseIgniteRestartTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/BaseIgniteRestartTest.java @@ -67,6 +67,10 @@ public abstract class BaseIgniteRestartTest extends IgniteAbstractTest { protected static final int DEFAULT_CLIENT_PORT = 10800; + protected static final int DEFAULT_HTTP_PORT = 10300; + + protected static final int DEFAULT_HTTPS_PORT = 10400; + @Language("HOCON") protected static final String RAFT_CFG = "{\n" + " fsync: false,\n" @@ -87,7 +91,11 @@ public abstract class BaseIgniteRestartTest extends IgniteAbstractTest { + " },\n" + " },\n" + " raft: " + RAFT_CFG + ",\n" - + " clientConnector.port: {}\n" + + " clientConnector.port: {},\n" + + " rest: {\n" + + " port: {}, \n" + + " ssl.port: {} \n" + + " }\n" + "}"; public TestInfo testInfo; @@ -203,11 +211,13 @@ public static T findComponent(List protected static String configurationString(int idx) { int port = DEFAULT_NODE_PORT + idx; int clientPort = DEFAULT_CLIENT_PORT + idx; + int httpPort = DEFAULT_HTTP_PORT + idx; + int httpsPort = DEFAULT_HTTPS_PORT + idx; // The address of the first node. @Language("HOCON") String connectAddr = "[localhost\":\"" + DEFAULT_NODE_PORT + "]"; - return IgniteStringFormatter.format(NODE_BOOTSTRAP_CFG, port, connectAddr, clientPort); + return IgniteStringFormatter.format(NODE_BOOTSTRAP_CFG, port, connectAddr, clientPort, httpPort, httpsPort); } /** diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ClusterPerTestIntegrationTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ClusterPerTestIntegrationTest.java index df0d863f028..bf8032fe284 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ClusterPerTestIntegrationTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ClusterPerTestIntegrationTest.java @@ -37,9 +37,6 @@ public abstract class ClusterPerTestIntegrationTest extends IgniteIntegrationTest { private static final IgniteLogger LOG = Loggers.forClass(ClusterPerTestIntegrationTest.class); - /** Base port number. */ - private static final int BASE_PORT = 3344; - /** Nodes bootstrap configuration pattern. */ private static final String NODE_BOOTSTRAP_CFG_TEMPLATE = "{\n" + " network: {\n" @@ -48,7 +45,8 @@ public abstract class ClusterPerTestIntegrationTest extends IgniteIntegrationTes + " netClusterNodes: [ {} ]\n" + " }\n" + " },\n" - + " clientConnector: { port:{} }\n" + + " clientConnector: { port:{} },\n" + + " rest.port: {}\n" + "}"; /** Template for node bootstrap config with Scalecube settings for fast failure detection. */ @@ -68,7 +66,8 @@ public abstract class ClusterPerTestIntegrationTest extends IgniteIntegrationTes + " },\n" + " }\n" + " },\n" - + " clientConnector: { port:{} }\n" + + " clientConnector: { port:{} }, \n" + + " rest.port: {}\n" + "}"; /** Template for node bootstrap config with Scalecube settings for a disabled failure detection. */ @@ -82,7 +81,8 @@ public abstract class ClusterPerTestIntegrationTest extends IgniteIntegrationTes + " failurePingInterval: 1000000000\n" + " }\n" + " },\n" - + " clientConnector: { port:{} }\n" + + " clientConnector: { port:{} },\n" + + " rest.port: {}\n" + "}"; protected Cluster cluster; diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/cluster/management/ItClusterInitTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/cluster/management/ItClusterInitTest.java index 0c5eac07c26..3f1886c5efd 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/cluster/management/ItClusterInitTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/cluster/management/ItClusterInitTest.java @@ -108,7 +108,8 @@ private void createCluster(TestInfo testInfo, int numNodes) { String config = "{" + " network.port: " + port + "," + " clientConnector.port: " + (port + 8000) + "," - + " network.nodeFinder.netClusterNodes: " + nodeFinderConfig + + " network.nodeFinder.netClusterNodes: " + nodeFinderConfig + "," + + " rest.port: " + (port + 10000) + "}"; String nodeName = testNodeName(testInfo, port); diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/compute/ItLogicalTopologyTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/compute/ItLogicalTopologyTest.java index 4a5dc99c0dc..bc665b234c9 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/compute/ItLogicalTopologyTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/compute/ItLogicalTopologyTest.java @@ -71,7 +71,8 @@ class ItLogicalTopologyTest extends ClusterPerTestIntegrationTest { + " nodeAttributes: {\n" + " nodeAttributes: " + NODE_ATTRIBUTES + " },\n" - + " clientConnector: { port:{} }\n" + + " clientConnector: { port:{} },\n" + + " rest.port: {}\n" + "}"; private final LogicalTopologyEventListener listener = new LogicalTopologyEventListener() { diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/distribution/zones/ItDistributionZonesFilterTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/distribution/zones/ItDistributionZonesFilterTest.java index 5b98facf864..136bb01ee6a 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/distribution/zones/ItDistributionZonesFilterTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/distribution/zones/ItDistributionZonesFilterTest.java @@ -82,7 +82,8 @@ private static String createStartConfig(@Language("JSON") String nodeAttributes) + " nodeAttributes: {\n" + " nodeAttributes: " + nodeAttributes + " },\n" - + " clientConnector: { port:{} }\n" + + " clientConnector: { port:{} },\n" + + " rest.port: {}\n" + "}"; } diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/raftsnapshot/ItTableRaftSnapshotsTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/raftsnapshot/ItTableRaftSnapshotsTest.java index 71ae733343c..2c97b2b7b4e 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/raftsnapshot/ItTableRaftSnapshotsTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/raftsnapshot/ItTableRaftSnapshotsTest.java @@ -131,7 +131,8 @@ class ItTableRaftSnapshotsTest extends IgniteIntegrationTest { + " }\n" + " },\n" + " raft.rpcInstallSnapshotTimeout: 10000,\n" - + " clientConnector.port: {}\n" + + " clientConnector.port: {},\n" + + " rest.port: {}\n" + "}"; /** diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/rest/AbstractRestTestBase.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/rest/AbstractRestTestBase.java index 48c05814321..c8d51b1a43d 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/rest/AbstractRestTestBase.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/rest/AbstractRestTestBase.java @@ -49,10 +49,16 @@ */ abstract class AbstractRestTestBase extends IgniteIntegrationTest { /** Network ports of the test nodes. */ - static final int[] PORTS = {3344, 3345, 3346}; + static final int[] NETWORK_PORTS = {3344, 3345, 3346}; + + /** Client ports of the test nodes. */ + static final int[] CLIENT_PORTS = {10800, 10801, 10802}; + + /** HTTP ports of the test nodes. */ + static final int[] HTTP_PORTS = {10300, 10301, 10302}; /** HTTP host and port url part. */ - static final String HTTP_HOST_PORT = "http://localhost:10300"; + static final String HTTP_HOST_PORT = "http://localhost:" + HTTP_PORTS[0]; /** Nodes bootstrap configuration. */ final Map nodesBootstrapCfg = new LinkedHashMap<>(); @@ -101,20 +107,22 @@ void setUp(TestInfo testInfo) throws IOException, InterruptedException { } private void startAllNodesWithoutInit(TestInfo testInfo) { - String node0Name = testNodeName(testInfo, PORTS[0]); - String node1Name = testNodeName(testInfo, PORTS[1]); - String node2Name = testNodeName(testInfo, PORTS[2]); + String node0Name = testNodeName(testInfo, NETWORK_PORTS[0]); + String node1Name = testNodeName(testInfo, NETWORK_PORTS[1]); + String node2Name = testNodeName(testInfo, NETWORK_PORTS[2]); nodesBootstrapCfg.put( node0Name, "{\n" + " network: {\n" - + " port: " + PORTS[0] + ",\n" + + " port: " + NETWORK_PORTS[0] + ",\n" + " nodeFinder: {\n" - + " netClusterNodes: [ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + + " netClusterNodes: [ \"localhost:" + NETWORK_PORTS[0] + "\", \"localhost:" + NETWORK_PORTS[1] + + "\", \"localhost:" + NETWORK_PORTS[2] + "\" ]\n" + " }\n" + " },\n" - + " clientConnector.port: 10800" + + " clientConnector.port: " + CLIENT_PORTS[0] + ", \n" + + " rest.port: " + HTTP_PORTS[0] + "}" ); @@ -122,12 +130,14 @@ private void startAllNodesWithoutInit(TestInfo testInfo) { node1Name, "{\n" + " network: {\n" - + " port: " + PORTS[1] + ",\n" + + " port: " + NETWORK_PORTS[1] + ",\n" + " nodeFinder: {\n" - + " netClusterNodes: [ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + + " netClusterNodes: [ \"localhost:" + NETWORK_PORTS[0] + "\", \"localhost:" + NETWORK_PORTS[1] + + "\", \"localhost:" + NETWORK_PORTS[2] + "\" ]\n" + " }\n" + " },\n" - + " clientConnector.port: 10801" + + " clientConnector.port: " + CLIENT_PORTS[1] + ", \n" + + " rest.port: " + HTTP_PORTS[1] + "}" ); @@ -135,12 +145,14 @@ private void startAllNodesWithoutInit(TestInfo testInfo) { node2Name, "{\n" + " network: {\n" - + " port: " + PORTS[2] + ",\n" + + " port: " + NETWORK_PORTS[2] + ",\n" + " nodeFinder: {\n" - + " netClusterNodes: [ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + + " netClusterNodes: [ \"localhost:" + NETWORK_PORTS[0] + "\", \"localhost:" + NETWORK_PORTS[1] + + "\", \"localhost:" + NETWORK_PORTS[2] + "\" ]\n" + " }\n" + " },\n" - + " clientConnector.port: 10802" + + " clientConnector.port: " + CLIENT_PORTS[2] + ", \n" + + " rest.port: " + HTTP_PORTS[2] + "}" ); diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/rest/ItPortRangeTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/rest/ItRestPortsTest.java similarity index 95% rename from modules/runner/src/integrationTest/java/org/apache/ignite/internal/rest/ItPortRangeTest.java rename to modules/runner/src/integrationTest/java/org/apache/ignite/internal/rest/ItRestPortsTest.java index 1bcb4f9f9f6..5bd261d6971 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/rest/ItPortRangeTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/rest/ItRestPortsTest.java @@ -50,8 +50,8 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -/** Tests for the REST port range configuration. */ -public class ItPortRangeTest extends IgniteIntegrationTest { +/** Tests for the REST ports configuration. */ +public class ItRestPortsTest extends IgniteIntegrationTest { /** Trust store path. */ private static final String trustStorePath = "ssl/truststore.jks"; @@ -85,7 +85,7 @@ private static Stream sslConfigurationProperties() { } @ParameterizedTest - @DisplayName("Port range works in all configurations") + @DisplayName("Ports are configured in all configurations") @MethodSource("sslConfigurationProperties") void portRange(boolean sslEnabled, boolean dualProtocol, TestInfo testInfo) throws IOException, InterruptedException { List nodes = IntStream.range(0, 3) @@ -94,8 +94,8 @@ void portRange(boolean sslEnabled, boolean dualProtocol, TestInfo testInfo) thro .workDir(workDir) .name(testNodeName(testInfo, id)) .networkPort(3344 + id) - .httpPort(10300) - .httpsPort(10400) + .httpPort(10300 + id) + .httpsPort(10400 + id) .sslEnabled(sslEnabled) .dualProtocol(dualProtocol) .build(); diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/AbstractSchemaChangeTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/AbstractSchemaChangeTest.java index b0db4e95c78..49170e4c49a 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/AbstractSchemaChangeTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/AbstractSchemaChangeTest.java @@ -78,7 +78,8 @@ void setUp(TestInfo testInfo) { + " netClusterNodes: [ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + " }\n" + " },\n" - + " clientConnector: { port:10901 }\n" + + " clientConnector: { port:10901 },\n" + + " rest.port: 10300\n" + "}" ); @@ -91,7 +92,8 @@ void setUp(TestInfo testInfo) { + " netClusterNodes: [ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + " }\n" + " },\n" - + " clientConnector: { port:10902 }\n" + + " clientConnector: { port:10902 },\n" + + " rest.port: 10301\n" + "}" ); @@ -104,7 +106,8 @@ void setUp(TestInfo testInfo) { + " netClusterNodes: [ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + " }\n" + " },\n" - + " clientConnector: { port:10903 }\n" + + " clientConnector: { port:10903 },\n" + + " rest.port: 10302\n" + "}" ); } diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItDataSchemaSyncTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItDataSchemaSyncTest.java index 1bb53990214..b2a3891f90a 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItDataSchemaSyncTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItDataSchemaSyncTest.java @@ -70,7 +70,8 @@ public class ItDataSchemaSyncTest extends IgniteAbstractTest { + " \"nodeFinder\": {\n" + " \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + " }\n" - + " }\n" + + " },\n" + + " rest.port: 10300\n" + "}", "node1", "{\n" @@ -80,7 +81,8 @@ public class ItDataSchemaSyncTest extends IgniteAbstractTest { + " \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + " }\n" + " },\n" - + " clientConnector: { port:10801 }\n" + + " clientConnector: { port:10801 },\n" + + " rest.port: 10301\n" + "}", "node2", "{\n" @@ -90,7 +92,8 @@ public class ItDataSchemaSyncTest extends IgniteAbstractTest { + " \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + " }\n" + " },\n" - + " clientConnector: { port:10802 }\n" + + " clientConnector: { port:10802 },\n" + + " rest.port: 10302\n" + "}" ); diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java index 3344d977044..946067cb407 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java @@ -1026,7 +1026,9 @@ public void testRestartDiffConfig() { @Language("HOCON") String cfgString = IgniteStringFormatter.format(NODE_BOOTSTRAP_CFG, DEFAULT_NODE_PORT + 11, "[\"localhost:" + DEFAULT_NODE_PORT + "\"]", - DEFAULT_CLIENT_PORT + 11 + DEFAULT_CLIENT_PORT + 11, + DEFAULT_HTTP_PORT + 11, + DEFAULT_HTTPS_PORT + 11 ); IgniteImpl node1 = startNode(1, cfgString); diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgnitionTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgnitionTest.java index 77715c6f5fa..5f7347ac027 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgnitionTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgnitionTest.java @@ -83,7 +83,8 @@ void setUp(TestInfo testInfo) { + " netClusterNodes: [ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + " }\n" + " },\n" - + " clientConnector.port: 10800\n" + + " clientConnector.port: 10800,\n" + + " rest.port: 10300\n" + "}" ); @@ -96,7 +97,8 @@ void setUp(TestInfo testInfo) { + " netClusterNodes: [ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + " }\n" + " },\n" - + " clientConnector.port: 10801\n" + + " clientConnector.port: 10801,\n" + + " rest.port: 10301\n" + "}" ); @@ -109,7 +111,8 @@ void setUp(TestInfo testInfo) { + " netClusterNodes: [ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + " }\n" + " },\n" - + " clientConnector.port: 10802\n" + + " clientConnector.port: 10802,\n" + + " rest.port: 10302\n" + "}" ); } diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItTablesApiTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItTablesApiTest.java index 7a4c8ff7c35..ba2d4c106b7 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItTablesApiTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItTablesApiTest.java @@ -70,17 +70,20 @@ public class ItTablesApiTest extends IgniteAbstractTest { private final List nodesBootstrapCfg = List.of( "{\n" + " network.port :3344, clientConnector.port: 10800,\n" - + " network.nodeFinder.netClusterNodes:[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + + " network.nodeFinder.netClusterNodes:[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ],\n" + + " rest.port: 10300\n" + "}", "{\n" + " network.port :3345, clientConnector.port: 10801,\n" - + " network.nodeFinder.netClusterNodes:[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + + " network.nodeFinder.netClusterNodes:[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ],\n" + + " rest.port: 10301\n" + "}", "{\n" + " network.port :3346, clientConnector.port: 10802,\n" - + " network.nodeFinder.netClusterNodes:[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + + " network.nodeFinder.netClusterNodes:[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ],\n" + + " rest.port: 10302\n" + "}" ); diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/PlatformTestNodeRunner.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/PlatformTestNodeRunner.java index a523f2cc022..575d9cb772a 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/PlatformTestNodeRunner.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/PlatformTestNodeRunner.java @@ -121,7 +121,8 @@ public class PlatformTestNodeRunner { + " \"nodeFinder\": {\n" + " \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\", \"localhost:3347\" ]\n" + " }\n" - + " }\n" + + " },\n" + + " rest.port: 10300\n" + "}", NODE_NAME2, "{\n" @@ -132,7 +133,8 @@ public class PlatformTestNodeRunner { + " \"nodeFinder\": {\n" + " \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\", \"localhost:3347\" ]\n" + " }\n" - + " }\n" + + " },\n" + + " rest.port: 10301\n" + "}", NODE_NAME3, "{\n" @@ -153,7 +155,8 @@ public class PlatformTestNodeRunner { + " \"nodeFinder\": {\n" + " \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\", \"localhost:3347\" ]\n" + " }\n" - + " }\n" + + " },\n" + + " rest.port: 10303\n" + "}", NODE_NAME4, "{\n" @@ -179,7 +182,8 @@ public class PlatformTestNodeRunner { + " \"nodeFinder\": {\n" + " \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\", \"localhost:3347\" ]\n" + " }\n" - + " }\n" + + " },\n" + + " rest.port: 10304\n" + "}" ); diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItAbstractThinClientTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItAbstractThinClientTest.java index 0e801307dd3..6ea27a3825a 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItAbstractThinClientTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItAbstractThinClientTest.java @@ -79,7 +79,8 @@ void beforeAll(TestInfo testInfo, @WorkDirectory Path workDir) throws Interrupte "{\n" + " network.port: 3344,\n" + " network.nodeFinder.netClusterNodes: [ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" - + " clientConnector.port: 10800\n" + + " clientConnector.port: 10800,\n" + + " rest.port: 10300\n" + "}" ); @@ -90,7 +91,8 @@ void beforeAll(TestInfo testInfo, @WorkDirectory Path workDir) throws Interrupte + " network.nodeFinder.netClusterNodes: [ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" + " clientConnector.sendServerExceptionStackTraceToClient: true\n" + " clientConnector.metricsEnabled: true\n" - + " clientConnector.port: 10801\n" + + " clientConnector.port: 10801,\n" + + " rest.port: 10301\n" + "}" ); diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ClusterPerClassIntegrationTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ClusterPerClassIntegrationTest.java index f91270958ae..d73953bc136 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ClusterPerClassIntegrationTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ClusterPerClassIntegrationTest.java @@ -98,6 +98,9 @@ public abstract class ClusterPerClassIntegrationTest extends IgniteIntegrationTe /** Base client port number. */ private static final int BASE_CLIENT_PORT = 10800; + /** Base rest port number. */ + protected static final int BASE_REST_PORT = 10300; + /** Nodes bootstrap configuration pattern. */ private static final String NODE_BOOTSTRAP_CFG = "{\n" + " \"network\": {\n" @@ -106,7 +109,8 @@ public abstract class ClusterPerClassIntegrationTest extends IgniteIntegrationTe + " \"netClusterNodes\": [ {} ]\n" + " }\n" + " },\n" - + " clientConnector: { port:{} }\n" + + " clientConnector: { port:{} },\n" + + " rest.port: {}\n" + "}"; /** Cluster nodes. */ @@ -149,7 +153,10 @@ protected void startCluster() { for (int i = 0; i < nodes(); i++) { String nodeName = testNodeName(testInfo, i); - String config = IgniteStringFormatter.format(NODE_BOOTSTRAP_CFG, BASE_PORT + i, connectNodeAddr, BASE_CLIENT_PORT + i); + String config = IgniteStringFormatter.format( + NODE_BOOTSTRAP_CFG, + BASE_PORT + i, connectNodeAddr, BASE_CLIENT_PORT + i, BASE_REST_PORT + i + ); futures.add(TestIgnitionManager.start(nodeName, config, WORK_DIR.resolve(nodeName))); } diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/sqllogic/ItSqlLogicTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/sqllogic/ItSqlLogicTest.java index c8e9e03f724..2eba527ec57 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/sqllogic/ItSqlLogicTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/sqllogic/ItSqlLogicTest.java @@ -157,6 +157,8 @@ public class ItSqlLogicTest extends IgniteIntegrationTest { private static final int BASE_CLIENT_PORT = 10800; + private static final int BASE_REST_PORT = 10300; + /** Nodes bootstrap configuration pattern. */ private static final String NODE_BOOTSTRAP_CFG = "{\n" + " \"network\": {\n" @@ -165,7 +167,8 @@ public class ItSqlLogicTest extends IgniteIntegrationTest { + " \"netClusterNodes\": [ {} ]\n" + " }\n" + " },\n" - + " clientConnector.port: {}\n" + + " clientConnector.port: {},\n" + + " rest.port: {}\n" + "}"; /** Cluster nodes. */ @@ -322,7 +325,9 @@ private static void startNodes() { .mapToObj(i -> { String nodeName = NODE_NAME_PREFIX + i; - String config = IgniteStringFormatter.format(NODE_BOOTSTRAP_CFG, BASE_PORT + i, connectNodeAddr, BASE_CLIENT_PORT + i); + String config = IgniteStringFormatter.format( + NODE_BOOTSTRAP_CFG, BASE_PORT + i, connectNodeAddr, BASE_CLIENT_PORT + i, BASE_REST_PORT + i + ); return TestIgnitionManager.start(nodeName, config, WORK_DIR.resolve(nodeName)); }) diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ssl/ItSslTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ssl/ItSslTest.java index d1bf959de2f..cfc9ba4fd1f 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ssl/ItSslTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ssl/ItSslTest.java @@ -90,7 +90,11 @@ class ClusterWithoutSsl { + " netClusterNodes: [ {}, \"localhost:3355\", \"localhost:3356\" ]\n" + " }\n" + " },\n" - + " clientConnector: { port: {} }\n" + + " clientConnector: { port: {} },\n" + + " rest: {\n" + + " port: {},\n" + + " ssl.port: {}\n" + + " }\n" + "}"; @BeforeAll @@ -189,6 +193,10 @@ class ClusterWithSsl { + " path: \"" + escapeWindowsPath(keyStorePath) + "\",\n" + " password: \"" + password + "\"\n" + " }\n" + + " },\n" + + " rest: {\n" + + " port: {},\n" + + " ssl.port: {}\n" + " }\n" + "}"; @@ -405,6 +413,10 @@ class ClusterWithSslAndClientAuth { + " password: \"" + password + "\"," + " path: \"" + escapeWindowsPath(trustStorePath) + "\"" + " }\n" + + " },\n" + + " rest: {\n" + + " port: {}, \n" + + " ssl.port: {} \n" + " }\n" + "}"; @@ -503,30 +515,32 @@ void jdbcCanConnectWithSslAndClientAuth() throws SQLException { @Test @DisplayName("Cluster is not initialized when nodes are configured with incompatible ciphers") void incompatibleCiphersNodes(TestInfo testInfo) { - Cluster cluster = new Cluster(testInfo, WORK_DIR); - - String sslEnabledWithCipher1BoostrapConfig = createBoostrapConfig("TLS_AES_256_GCM_SHA384"); - String sslEnabledWithCipher2BoostrapConfig = createBoostrapConfig("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"); + Cluster incompatibleTestCluster = new Cluster(testInfo, WORK_DIR); - CompletableFuture node1 = cluster.startNodeAsync(0, sslEnabledWithCipher1BoostrapConfig); + try { + String sslEnabledWithCipher1BoostrapConfig = createBoostrapConfig("TLS_AES_256_GCM_SHA384"); + String sslEnabledWithCipher2BoostrapConfig = createBoostrapConfig("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"); - String metaStorageAndCmgNodeName = testNodeName(testInfo, 0); + CompletableFuture node1 = incompatibleTestCluster.startNodeAsync(10, sslEnabledWithCipher1BoostrapConfig); - InitParameters initParameters = InitParameters.builder() - .destinationNodeName(metaStorageAndCmgNodeName) - .metaStorageNodeNames(List.of(metaStorageAndCmgNodeName)) - .clusterName("cluster") - .build(); + String metaStorageAndCmgNodeName = testNodeName(testInfo, 10); - TestIgnitionManager.init(initParameters); + InitParameters initParameters = InitParameters.builder() + .destinationNodeName(metaStorageAndCmgNodeName) + .metaStorageNodeNames(List.of(metaStorageAndCmgNodeName)) + .clusterName("cluster") + .build(); - // First node will initialize the cluster with single node successfully since the second node can't connect to it. - assertThat(node1, willCompleteSuccessfully()); + TestIgnitionManager.init(initParameters); - CompletableFuture node2 = cluster.startNodeAsync(1, sslEnabledWithCipher2BoostrapConfig); - assertThat(node2, willTimeoutIn(1, TimeUnit.SECONDS)); + // First node will initialize the cluster with single node successfully since the second node can't connect to it. + assertThat(node1, willCompleteSuccessfully()); - cluster.shutdown(); + CompletableFuture node2 = incompatibleTestCluster.startNodeAsync(11, sslEnabledWithCipher2BoostrapConfig); + assertThat(node2, willTimeoutIn(1, TimeUnit.SECONDS)); + } finally { + incompatibleTestCluster.shutdown(); + } } @Language("JSON") @@ -559,6 +573,10 @@ private String createBoostrapConfig(String ciphers) { + " path: \"" + escapeWindowsPath(keyStorePath) + "\",\n" + " password: \"" + password + "\"\n" + " }\n" + + " },\n" + + " rest: {\n" + + " port: {},\n" + + " ssl.port: {}\n" + " }\n" + "}"; } diff --git a/modules/runner/src/integrationTest/resources/ignite-config-rest-port-not-default.json b/modules/runner/src/integrationTest/resources/ignite-config-rest-port-not-default.json index bd4c4666f7d..fdb059abbff 100644 --- a/modules/runner/src/integrationTest/resources/ignite-config-rest-port-not-default.json +++ b/modules/runner/src/integrationTest/resources/ignite-config-rest-port-not-default.json @@ -9,7 +9,6 @@ } }, "rest": { - "port": 10333, - "portRange": 10 + "port": 10333 } } diff --git a/modules/runner/src/testFixtures/java/org/apache/ignite/internal/Cluster.java b/modules/runner/src/testFixtures/java/org/apache/ignite/internal/Cluster.java index ad35cc6d977..632c1388d6d 100644 --- a/modules/runner/src/testFixtures/java/org/apache/ignite/internal/Cluster.java +++ b/modules/runner/src/testFixtures/java/org/apache/ignite/internal/Cluster.java @@ -83,6 +83,10 @@ public class Cluster { private static final int BASE_CLIENT_PORT = 10800; + private static final int BASE_HTTP_PORT = 10300; + + private static final int BASE_HTTPS_PORT = 10400; + private static final String CONNECT_NODE_ADDR = "\"localhost:" + BASE_PORT + '\"'; /** Timeout for SQL queries (in milliseconds). */ @@ -97,6 +101,10 @@ public class Cluster { + " }\n" + " },\n" + " clientConnector: { port:{} }\n" + + " rest: {\n" + + " port: {},\n" + + " ssl.port: {}\n" + + " }\n" + "}"; private final TestInfo testInfo; @@ -237,7 +245,10 @@ public CompletableFuture startNodeAsync(int nodeIndex, String nodeBo nodeBootstrapConfigTemplate, BASE_PORT + nodeIndex, CONNECT_NODE_ADDR, - BASE_CLIENT_PORT + nodeIndex); + BASE_CLIENT_PORT + nodeIndex, + BASE_HTTP_PORT + nodeIndex, + BASE_HTTPS_PORT + nodeIndex + ); return TestIgnitionManager.start(nodeName, config, workDir.resolve(nodeName)) .thenApply(IgniteImpl.class::cast)