agingade commented on a change in pull request #7119:
URL: https://github.com/apache/geode/pull/7119#discussion_r755172218



##########
File path: 
geode-assembly/src/upgradeTest/java/org/apache/geode/management/RollingUpgradeWithSslDUnitTest.java
##########
@@ -0,0 +1,276 @@
+/*
+ * 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.geode.management;
+
+import static 
org.apache.geode.distributed.ConfigurationProperties.BIND_ADDRESS;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_ENABLED_COMPONENTS;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_ENDPOINT_IDENTIFICATION_ENABLED;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE_PASSWORD;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE_TYPE;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_REQUIRE_AUTHENTICATION;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_TYPE;
+import static 
org.apache.geode.test.junit.rules.gfsh.GfshRule.startLocatorCommand;
+import static 
org.apache.geode.test.junit.rules.gfsh.GfshRule.startServerCommand;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.security.GeneralSecurityException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.geode.cache.ssl.CertStores;
+import org.apache.geode.cache.ssl.CertificateBuilder;
+import org.apache.geode.cache.ssl.CertificateMaterial;
+import org.apache.geode.internal.UniquePortSupplier;
+import org.apache.geode.test.junit.categories.BackwardCompatibilityTest;
+import org.apache.geode.test.junit.rules.gfsh.GfshExecution;
+import org.apache.geode.test.junit.rules.gfsh.GfshRule;
+import org.apache.geode.test.junit.rules.gfsh.GfshScript;
+import 
org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory;
+import org.apache.geode.test.version.TestVersion;
+import org.apache.geode.test.version.VersionManager;
+
+/**
+ * This test iterates through the versions of Geode and executes client 
compatibility with
+ * the current version of Geode.
+ */
+@Category({BackwardCompatibilityTest.class})
+@RunWith(Parameterized.class)
[email protected](CategoryWithParameterizedRunnerFactory.class)
+public class RollingUpgradeWithSslDUnitTest {
+  private final UniquePortSupplier portSupplier = new UniquePortSupplier();
+  private final String hostName;
+  private final String keyStoreFileName;
+  private final String trustStoreFileName;
+  private File securityPropertiesFile;
+
+  @Parameterized.Parameters(name = "{0}")
+  public static Collection<String> data() {
+    final List<String> result = 
VersionManager.getInstance().getVersionsWithoutCurrent();
+    result.removeIf(s -> TestVersion.compare(s, "1.10.0") < 0);
+    return result;
+  }
+
+  @Rule
+  public GfshRule oldGfsh;
+
+  @Rule
+  public GfshRule currentGfsh;
+
+  @Rule
+  public TemporaryFolder tempFolder = new TemporaryFolder();
+
+  public RollingUpgradeWithSslDUnitTest(String version) throws 
UnknownHostException {
+    oldGfsh = new GfshRule(version);
+    currentGfsh = new GfshRule();
+    hostName = InetAddress.getLocalHost().getCanonicalHostName();
+    keyStoreFileName = hostName + "-keystore.jks";
+    trustStoreFileName = hostName + "-truststore.jks";
+  }
+
+  @Before
+  public void before() throws IOException, GeneralSecurityException {
+    generateStores();
+    /*
+     * We must use absolute paths for truststore and keystore in properties 
file and
+     * since we don't know those at coding-time, we must generate the file.
+     * Since GfshRule provides no way to pass along Properties object to start 
server etc,
+     * we must write the properties to an actual file.
+     */
+    final Properties properties = generateSslProperties();
+
+    securityPropertiesFile = tempFolder.newFile("gfsecurity.properties");
+    final FileOutputStream fileOutputStream =
+        new FileOutputStream(securityPropertiesFile.getAbsolutePath());
+    properties.store(fileOutputStream, "");
+  }
+
+  @Test
+  public void testRollingUpgradeWithDeployment() throws Exception {
+    final int locatorPort = portSupplier.getAvailablePort();
+    final int locatorJmxPort = portSupplier.getAvailablePort();
+    final int locator2Port = portSupplier.getAvailablePort();
+    final int locator2JmxPort = portSupplier.getAvailablePort();
+    final int server1Port = portSupplier.getAvailablePort();
+    final int server2Port = portSupplier.getAvailablePort();
+
+    final GfshExecution startupExecution =
+        GfshScript.of(
+            startLocatorCommandWithConfig("locator1", locatorPort, 
locatorJmxPort, -1))
+            .and(startLocatorCommandWithConfig("locator2", locator2Port, 
locator2JmxPort,
+                locatorPort))
+            .and(startServerCommandWithConfig("server1", server1Port, 
locatorPort))
+            .and(startServerCommandWithConfig("server2", server2Port, 
locatorPort))
+            .execute(oldGfsh, tempFolder.getRoot());
+
+    initializeRegion(locatorPort);
+    causeP2PTraffic(locatorPort);
+
+    // doing rolling upgrades
+    upgradeLocator("locator1", locatorPort, locatorJmxPort, locator2Port, 
startupExecution);
+    verifyListMembers(locatorPort);
+    causeP2PTraffic(locatorPort);
+
+    upgradeLocator("locator2", locator2Port, locator2JmxPort, locatorPort, 
startupExecution);
+    verifyListMembers(locatorPort);
+    causeP2PTraffic(locatorPort);
+
+    // make sure servers can do rolling upgrade too
+    upgradeServer("server1", server1Port, locatorPort, startupExecution);
+    causeP2PTraffic(locatorPort);

Review comment:
       This is not checking if the entry was made into server1 and read from 
server2; i am thinking thats the expectation here...Please correct me if I am 
missing anything.

##########
File path: 
geode-assembly/src/upgradeTest/java/org/apache/geode/management/DeploymentManagementUpgradeTest.java
##########
@@ -89,13 +89,13 @@ public void newLocatorCanReadOldConfigurationData() throws 
IOException {
     int locatorPort = ports[1];
     int jmxPort = ports[2];
     GfshExecution execute =
-        GfshScript.of(startLocatorCommand("test", locatorPort, jmxPort, 
httpPort, 0))
+        GfshScript.of(startLocatorCommand("test", "localhost", locatorPort, 
jmxPort, httpPort, 0))

Review comment:
       Isn't localhost default value?

##########
File path: 
geode-assembly/src/upgradeTest/java/org/apache/geode/management/RollingUpgradeWithSslDUnitTest.java
##########
@@ -0,0 +1,276 @@
+/*
+ * 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.geode.management;
+
+import static 
org.apache.geode.distributed.ConfigurationProperties.BIND_ADDRESS;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_ENABLED_COMPONENTS;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_ENDPOINT_IDENTIFICATION_ENABLED;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE_PASSWORD;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE_TYPE;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_REQUIRE_AUTHENTICATION;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_TYPE;
+import static 
org.apache.geode.test.junit.rules.gfsh.GfshRule.startLocatorCommand;
+import static 
org.apache.geode.test.junit.rules.gfsh.GfshRule.startServerCommand;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.security.GeneralSecurityException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.geode.cache.ssl.CertStores;
+import org.apache.geode.cache.ssl.CertificateBuilder;
+import org.apache.geode.cache.ssl.CertificateMaterial;
+import org.apache.geode.internal.UniquePortSupplier;
+import org.apache.geode.test.junit.categories.BackwardCompatibilityTest;
+import org.apache.geode.test.junit.rules.gfsh.GfshExecution;
+import org.apache.geode.test.junit.rules.gfsh.GfshRule;
+import org.apache.geode.test.junit.rules.gfsh.GfshScript;
+import 
org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory;
+import org.apache.geode.test.version.TestVersion;
+import org.apache.geode.test.version.VersionManager;
+
+/**
+ * This test iterates through the versions of Geode and executes client 
compatibility with
+ * the current version of Geode.
+ */
+@Category({BackwardCompatibilityTest.class})
+@RunWith(Parameterized.class)
[email protected](CategoryWithParameterizedRunnerFactory.class)
+public class RollingUpgradeWithSslDUnitTest {
+  private final UniquePortSupplier portSupplier = new UniquePortSupplier();
+  private final String hostName;
+  private final String keyStoreFileName;
+  private final String trustStoreFileName;
+  private File securityPropertiesFile;
+
+  @Parameterized.Parameters(name = "{0}")
+  public static Collection<String> data() {
+    final List<String> result = 
VersionManager.getInstance().getVersionsWithoutCurrent();
+    result.removeIf(s -> TestVersion.compare(s, "1.10.0") < 0);
+    return result;
+  }
+
+  @Rule
+  public GfshRule oldGfsh;
+
+  @Rule
+  public GfshRule currentGfsh;
+
+  @Rule
+  public TemporaryFolder tempFolder = new TemporaryFolder();
+
+  public RollingUpgradeWithSslDUnitTest(String version) throws 
UnknownHostException {
+    oldGfsh = new GfshRule(version);
+    currentGfsh = new GfshRule();
+    hostName = InetAddress.getLocalHost().getCanonicalHostName();
+    keyStoreFileName = hostName + "-keystore.jks";
+    trustStoreFileName = hostName + "-truststore.jks";
+  }
+
+  @Before
+  public void before() throws IOException, GeneralSecurityException {
+    generateStores();
+    /*
+     * We must use absolute paths for truststore and keystore in properties 
file and
+     * since we don't know those at coding-time, we must generate the file.
+     * Since GfshRule provides no way to pass along Properties object to start 
server etc,
+     * we must write the properties to an actual file.
+     */
+    final Properties properties = generateSslProperties();
+
+    securityPropertiesFile = tempFolder.newFile("gfsecurity.properties");
+    final FileOutputStream fileOutputStream =
+        new FileOutputStream(securityPropertiesFile.getAbsolutePath());
+    properties.store(fileOutputStream, "");
+  }
+
+  @Test
+  public void testRollingUpgradeWithDeployment() throws Exception {
+    final int locatorPort = portSupplier.getAvailablePort();
+    final int locatorJmxPort = portSupplier.getAvailablePort();
+    final int locator2Port = portSupplier.getAvailablePort();
+    final int locator2JmxPort = portSupplier.getAvailablePort();
+    final int server1Port = portSupplier.getAvailablePort();
+    final int server2Port = portSupplier.getAvailablePort();
+
+    final GfshExecution startupExecution =
+        GfshScript.of(
+            startLocatorCommandWithConfig("locator1", locatorPort, 
locatorJmxPort, -1))
+            .and(startLocatorCommandWithConfig("locator2", locator2Port, 
locator2JmxPort,
+                locatorPort))
+            .and(startServerCommandWithConfig("server1", server1Port, 
locatorPort))
+            .and(startServerCommandWithConfig("server2", server2Port, 
locatorPort))
+            .execute(oldGfsh, tempFolder.getRoot());
+
+    initializeRegion(locatorPort);
+    causeP2PTraffic(locatorPort);
+
+    // doing rolling upgrades
+    upgradeLocator("locator1", locatorPort, locatorJmxPort, locator2Port, 
startupExecution);
+    verifyListMembers(locatorPort);
+    causeP2PTraffic(locatorPort);
+
+    upgradeLocator("locator2", locator2Port, locator2JmxPort, locatorPort, 
startupExecution);
+    verifyListMembers(locatorPort);
+    causeP2PTraffic(locatorPort);
+
+    // make sure servers can do rolling upgrade too
+    upgradeServer("server1", server1Port, locatorPort, startupExecution);
+    causeP2PTraffic(locatorPort);
+
+    upgradeServer("server2", server2Port, locatorPort, startupExecution);
+    causeP2PTraffic(locatorPort);
+  }
+
+  private void upgradeLocator(String name, int locatorPort, int locatorJmxPort,
+      int connectedLocatorPort,
+      GfshExecution startupExecution) {
+    oldGfsh.stopLocator(startupExecution, name);
+    GfshScript
+        .of(startLocatorCommandWithConfig(name, locatorPort, locatorJmxPort, 
connectedLocatorPort))
+        .execute(currentGfsh, tempFolder.getRoot());
+  }
+
+  private void upgradeServer(String name, int serverPort, int locatorPort,
+      GfshExecution startupExecution) {
+    oldGfsh.stopServer(startupExecution, name);
+    GfshScript.of(startServerCommandWithConfig(name, serverPort, locatorPort))

Review comment:
       It will be nice to add verification to see old locator, server was 
successfully stopped and new locator and server started. I am thinking of case 
where the old locator and servers were not stopped. And in the verifyMembers we 
are only looking at any servers or locators (not version specific).

##########
File path: 
geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java
##########
@@ -1798,6 +1794,46 @@ private void createIoFilter(SocketChannel channel, 
boolean clientSocket) throws
     }
   }
 
+  private SSLEngine createSslEngine(final InetSocketAddress remoteAddress) {
+    final String hostName;
+    final boolean isSender = remoteMember != null;

Review comment:
       I am not expert in this area of the code...Earlier the caller used to 
pass true or pass based on sender or receiver connection; is the assumption is 
right; the earlier argument "clientSocket" passed reflects (or based on) 
remoteMember setting?




-- 
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]


Reply via email to