Bill commented on a change in pull request #7119: URL: https://github.com/apache/geode/pull/7119#discussion_r759561184
########## 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: We'll consider these improvement suggestions in a future PR. -- 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]
