Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 77750200CA9 for ; Thu, 1 Jun 2017 17:32:28 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 76168160BB5; Thu, 1 Jun 2017 15:32:28 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9EADA160BE5 for ; Thu, 1 Jun 2017 17:32:27 +0200 (CEST) Received: (qmail 92751 invoked by uid 500); 1 Jun 2017 15:32:26 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 92558 invoked by uid 99); 1 Jun 2017 15:32:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Jun 2017 15:32:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 86475E2F41; Thu, 1 Jun 2017 15:32:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Thu, 01 Jun 2017 15:32:34 -0000 Message-Id: <88b0b885d8144386ae8f6542ed6a1d59@git.apache.org> In-Reply-To: <61283999f3e04d6db422b234b79bb492@git.apache.org> References: <61283999f3e04d6db422b234b79bb492@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [09/28] ignite git commit: IGNITE-5210 - If enabled security authentication, server is unable to restart if client tries to reconnect archived-at: Thu, 01 Jun 2017 15:32:28 -0000 IGNITE-5210 - If enabled security authentication, server is unable to restart if client tries to reconnect Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a7e56606 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a7e56606 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a7e56606 Branch: refs/heads/ignite-5075-pds Commit: a7e566068c143a5c33ea0f583157bd197068b321 Parents: 738451c Author: dkarachentsev Authored: Wed May 31 15:35:34 2017 +0300 Committer: dkarachentsev Committed: Wed May 31 15:35:34 2017 +0300 ---------------------------------------------------------------------- .../ignite/spi/discovery/tcp/ClientImpl.java | 14 +++- .../discovery/AuthenticationRestartTest.java | 88 ++++++++++++++++++++ .../IgniteSpiDiscoverySelfTestSuite.java | 2 + 3 files changed, 100 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/a7e56606/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java index 619b4cc..d5bacdb 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java @@ -89,8 +89,8 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessa import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryDuplicateIdMessage; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHandshakeRequest; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHandshakeResponse; -import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryMetricsUpdateMessage; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryJoinRequestMessage; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryMetricsUpdateMessage; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddFinishedMessage; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddedMessage; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeFailedMessage; @@ -639,9 +639,12 @@ class ClientImpl extends TcpDiscoveryImpl { if (!recon) { TcpDiscoveryNode node = locNode; - if (locNode.order() > 0) + if (locNode.order() > 0) { node = locNode.clientReconnectNode(spi.spiCtx.nodeAttributes()); + marshalCredentials(node); + } + msg = new TcpDiscoveryJoinRequestMessage( node, spi.collectExchangeData(new DiscoveryDataPacket(getLocalNodeId()))); @@ -736,8 +739,11 @@ class ClientImpl extends TcpDiscoveryImpl { // Use security-unsafe getter. Map attrs = new HashMap<>(node.getAttributes()); - attrs.put(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS, - U.marshal(spi.marshaller(), attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS))); + Object creds = attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS); + + assert !(creds instanceof byte[]); + + attrs.put(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS, U.marshal(spi.marshaller(), creds)); node.setAttributes(attrs); } http://git-wip-us.apache.org/repos/asf/ignite/blob/a7e56606/modules/core/src/test/java/org/apache/ignite/spi/discovery/AuthenticationRestartTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AuthenticationRestartTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AuthenticationRestartTest.java new file mode 100644 index 0000000..5841094 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AuthenticationRestartTest.java @@ -0,0 +1,88 @@ +/* + * 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.spi.discovery; + +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.util.lang.GridAbsPredicate; +import org.apache.ignite.lang.IgniteFuture; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.TestReconnectPluginProvider; +import org.apache.ignite.spi.discovery.tcp.TestReconnectProcessor; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; + +/** + * Checks whether client is able to reconnect to restarted cluster with + * enabled security. + */ +public class AuthenticationRestartTest extends GridCommonAbstractTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setClientMode(igniteInstanceName.contains("client")); + + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setJoinTimeout(1120_000); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + TestReconnectPluginProvider.enabled = true; + TestReconnectProcessor.enabled = true; + + startGrid("server"); + startGrid("client"); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + TestReconnectPluginProvider.enabled = false; + TestReconnectProcessor.enabled = false; + + stopAllGrids(); + } + + /** + * @throws Exception If failed. + */ + public void testClientReconnect() throws Exception { + stopGrid("server"); + + final IgniteEx client = grid("client"); + + waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + return client.cluster().clientReconnectFuture() != null; + } + }, 10_000); + + startGrid("server"); + + IgniteFuture fut = client.cluster().clientReconnectFuture(); + + assertNotNull(fut); + + fut.get(); + + assertEquals(2, client.cluster().nodes().size()); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/a7e56606/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java index e6b39f7..1287149 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java @@ -19,6 +19,7 @@ package org.apache.ignite.testsuites; import junit.framework.TestSuite; import org.apache.ignite.spi.GridTcpSpiForwardingSelfTest; +import org.apache.ignite.spi.discovery.AuthenticationRestartTest; import org.apache.ignite.spi.discovery.tcp.TcpClientDiscoveryMarshallerCheckSelfTest; import org.apache.ignite.spi.discovery.tcp.TcpClientDiscoverySpiFailureTimeoutSelfTest; import org.apache.ignite.spi.discovery.tcp.TcpClientDiscoverySpiMulticastTest; @@ -87,6 +88,7 @@ public class IgniteSpiDiscoverySelfTestSuite extends TestSuite { suite.addTest(new TestSuite(TcpDiscoveryMultiThreadedTest.class)); suite.addTest(new TestSuite(TcpDiscoveryNodeAttributesUpdateOnReconnectTest.class)); + suite.addTest(new TestSuite(AuthenticationRestartTest.class)); // SSL. suite.addTest(new TestSuite(TcpDiscoverySslSelfTest.class));