sashapolo commented on code in PR #3297: URL: https://github.com/apache/ignite-3/pull/3297#discussion_r1505991481
########## modules/client-handler/src/integrationTest/java/org/apache/ignite/client/handler/ItClientHandlerBindTest.java: ########## @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.client.handler; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.concurrent.CompletionException; +import org.apache.ignite.client.handler.configuration.ClientConnectorConfiguration; +import org.apache.ignite.internal.configuration.testframework.ConfigurationExtension; +import org.apache.ignite.internal.configuration.testframework.InjectConfiguration; +import org.apache.ignite.internal.network.configuration.NetworkConfiguration; +import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * Client connector address configuration tests. + */ +@ExtendWith(ConfigurationExtension.class) +public class ItClientHandlerBindTest extends BaseIgniteAbstractTest { Review Comment: Why is it considered an integration test? ########## modules/client-handler/src/integrationTest/java/org/apache/ignite/client/handler/ItClientHandlerBindTest.java: ########## @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.client.handler; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.concurrent.CompletionException; +import org.apache.ignite.client.handler.configuration.ClientConnectorConfiguration; +import org.apache.ignite.internal.configuration.testframework.ConfigurationExtension; +import org.apache.ignite.internal.configuration.testframework.InjectConfiguration; +import org.apache.ignite.internal.network.configuration.NetworkConfiguration; +import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * Client connector address configuration tests. + */ +@ExtendWith(ConfigurationExtension.class) +public class ItClientHandlerBindTest extends BaseIgniteAbstractTest { + @InjectConfiguration + private NetworkConfiguration networkConfiguration; + + @Test + void connectSpecificAddress( + TestInfo testInfo, + @InjectConfiguration("mock.listenAddress=localhost") ClientConnectorConfiguration clientConnectorConfiguration) { + TestServer server = new TestServer(null, null, clientConnectorConfiguration, networkConfiguration); + + server.start(testInfo); Review Comment: It would be nice to wrap this line with `assertNotThrows` to clarify the intent of this test ########## modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java: ########## @@ -147,16 +147,30 @@ public void testStartTwice() { } /** - * Tests that bootstrap tries to bind to host specified in network.bindHost. + * Tests that bootstrap tries to bind to address specified in configuration. */ @Test public void testBindHost() { - String host = "unknown-host"; + String host = "localhost"; assertThat(serverCfg.listenAddress().update(host), willCompleteSuccessfully()); + getServer(true); + + assertThat(serverCfg.listenAddress().update(""), willCompleteSuccessfully()); Review Comment: What does this line check? ########## modules/network/src/main/java/org/apache/ignite/internal/network/configuration/NetworkConfigurationSchema.java: ########## @@ -36,6 +36,10 @@ public class NetworkConfigurationSchema { @Value(hasDefault = true) public final int port = DEFAULT_PORT; + /** Address (IP or hostname) to listen to. Listen to all interfaces if not provided. */ Review Comment: Please update as suggested in the previous comment ########## modules/client-handler/src/integrationTest/java/org/apache/ignite/client/handler/ItClientHandlerTest.java: ########## @@ -59,32 +60,36 @@ public class ItClientHandlerTest extends BaseIgniteAbstractTest { @InjectConfiguration(rootName = "security") private SecurityConfiguration securityConfiguration; - @BeforeEach - public void setUp(TestInfo testInfo) { - testServer = new TestServer(null, securityConfiguration); - serverModule = testServer.start(testInfo); - serverPort = serverModule.localAddress().getPort(); - } + @InjectConfiguration + private ClientConnectorConfiguration clientConnectorConfiguration; - @AfterEach - public void tearDown() throws Exception { - serverModule.stop(); - testServer.tearDown(); - } + @InjectConfiguration + private NetworkConfiguration networkConfiguration; @Test - void testHandshakeInvalidMagicHeaderDropsConnection() throws Exception { + void testHandshakeInvalidMagicHeaderDropsConnection(TestInfo testInfo) throws Exception { + testServer = new TestServer(null, securityConfiguration, clientConnectorConfiguration, networkConfiguration); Review Comment: Why did you do this? All tests have a lot of copy-paste now. If this is because you wanted to provide a different clientConnectorConfiguration, then I would suggest to move those tests into a different class ########## modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java: ########## @@ -80,7 +83,10 @@ public class NettyServerTest extends BaseIgniteAbstractTest { */ @AfterEach final void tearDown() throws Exception { - server.stop().join(); + if (server != null) { Review Comment: I would also suggest to use `IgniteUtils.closeAll` here ########## modules/client-handler/src/integrationTest/java/org/apache/ignite/client/handler/TestServer.java: ########## @@ -66,33 +59,29 @@ public class TestServer { private final CmgMessagesFactory msgFactory = new CmgMessagesFactory(); - private final ClientConnectorConfiguration connectorConfiguration; + private final ClientConnectorConfiguration clientConnectorConfiguration; + + private final NetworkConfiguration networkConfiguration; private long idleTimeout = 5000; - public TestServer() { - this(null, null, null); + public TestServer(ClientConnectorConfiguration clientConnectorConfiguration, NetworkConfiguration networkConfiguration) { + this(null, null, clientConnectorConfiguration, networkConfiguration); } TestServer( @Nullable TestSslConfig testSslConfig, @Nullable SecurityConfiguration securityConfiguration, - @Nullable ClientConnectorConfiguration connectorConfiguration + ClientConnectorConfiguration clientConnectorConfiguration, + NetworkConfiguration networkConfiguration ) { this.testSslConfig = testSslConfig; this.authenticationManager = securityConfiguration == null ? new DummyAuthenticationManager() : new AuthenticationManagerImpl(securityConfiguration); this.generator = new ConfigurationTreeGenerator(ClientConnectorConfiguration.KEY, NetworkConfiguration.KEY); Review Comment: Do we still need this guy? ########## modules/client-handler/src/main/java/org/apache/ignite/client/handler/configuration/ClientConnectorConfigurationSchema.java: ########## @@ -36,6 +36,10 @@ public class ClientConnectorConfigurationSchema { @Value(hasDefault = true) public final int port = 10800; + /** Address (IP or hostname) to listen to. Listen to all interfaces if not provided. */ Review Comment: ```suggestion /** Address (IP or hostname) to listen on. Will listen on all interfaces if empty. */ ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
