Github user DivineEnder commented on a diff in the pull request:

    https://github.com/apache/geode/pull/712#discussion_r133012849
  
    --- Diff: 
geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTest.java
 ---
    @@ -0,0 +1,254 @@
    +/*
    + * 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.session.tests;
    +
    +import static org.junit.Assert.assertEquals;
    +
    +import java.io.BufferedReader;
    +import java.io.File;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.io.InputStreamReader;
    +import java.net.URISyntaxException;
    +import java.util.Collection;
    +import java.util.List;
    +
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.TestName;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.Parameterized;
    +
    +import org.apache.geode.internal.AvailablePortHelper;
    +import org.apache.geode.management.internal.cli.i18n.CliStrings;
    +import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
    +import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
    +import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
    +import org.apache.geode.test.dunit.standalone.VersionManager;
    +import org.apache.geode.test.junit.categories.BackwardCompatibilityTest;
    +import org.apache.geode.test.junit.categories.DistributedTest;
    +import 
org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory;
    +
    +/**
    + * This test iterates through the versions of Geode and executes session 
client compatibility with
    + * the current version of Geode.
    + */
    +@Category({DistributedTest.class, BackwardCompatibilityTest.class})
    +@RunWith(Parameterized.class)
    
+@Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
    +public class TomcatSessionBackwardsCompatibilityTest {
    +
    +  @Parameterized.Parameters
    +  public static Collection<String> data() {
    +    List<String> result = 
VersionManager.getInstance().getVersionsWithoutCurrent();
    +    result.removeIf(s -> Integer.parseInt(s) < 120);
    +    if (result.size() < 1) {
    +      throw new RuntimeException("No older versions of Geode were found to 
test against");
    +    }
    +    return result;
    +  }
    +
    +  @Rule
    +  public transient GfshShellConnectionRule gfsh = new 
GfshShellConnectionRule();
    +
    +  @Rule
    +  public transient LocatorServerStartupRule locatorStartup = new 
LocatorServerStartupRule();
    +
    +  @Rule
    +  public transient TestName testName = new TestName();
    +
    +  public transient Client client;
    +  public transient ContainerManager manager;
    +
    +  File oldBuild;
    +  File oldModules;
    +
    +  TomcatInstall tomcat7079AndOldModules;
    +  TomcatInstall tomcat7079AndCurrentModules;
    +  TomcatInstall tomcat8AndOldModules;
    +  TomcatInstall tomcat8AndCurrentModules;
    +
    +  int locatorPort;
    +  String classPathTomcat7079;
    +  String classPathTomcat8;
    +
    +  public TomcatSessionBackwardsCompatibilityTest(String version) {
    +    VersionManager versionManager = VersionManager.getInstance();
    +    String installLocation = versionManager.getInstall(version);
    +    oldBuild = new File(installLocation);
    +    oldModules = new File(installLocation + "/tools/Modules/");
    +  }
    +
    +  protected void startServer(String name, String classPath, int 
locatorPort) throws Exception {
    +    CommandStringBuilder command = new 
CommandStringBuilder(CliStrings.START_SERVER);
    +    command.addOption(CliStrings.START_SERVER__NAME, name);
    +    command.addOption(CliStrings.START_SERVER__SERVER_PORT, "0");
    +    command.addOption(CliStrings.START_SERVER__CLASSPATH, classPath);
    +    command.addOption(CliStrings.START_SERVER__LOCATORS, "localhost[" + 
locatorPort + "]");
    +    gfsh.executeAndVerifyCommand(command.toString());
    +  }
    +
    +  protected void startLocator(String name, String classPath, int port) 
throws Exception {
    +    CommandStringBuilder locStarter = new 
CommandStringBuilder(CliStrings.START_LOCATOR);
    +    locStarter.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, "loc");
    +    locStarter.addOption(CliStrings.START_LOCATOR__CLASSPATH, classPath);
    +    locStarter.addOption(CliStrings.START_LOCATOR__PORT, 
Integer.toString(port));
    +    gfsh.executeAndVerifyCommand(locStarter.toString());
    +
    +  }
    +
    +  @Before
    +  public void setup() throws Exception {
    +    tomcat7079AndOldModules = new 
TomcatInstall(TomcatInstall.TomcatVersion.TOMCAT779,
    +        ContainerInstall.ConnectionType.CLIENT_SERVER,
    +        ContainerInstall.DEFAULT_INSTALL_DIR + "Tomcat7079AndOldModules",
    +        oldModules.getAbsolutePath(), oldBuild.getAbsolutePath() + "/lib");
    +
    +    tomcat7079AndCurrentModules = new 
TomcatInstall(TomcatInstall.TomcatVersion.TOMCAT779,
    +        ContainerInstall.ConnectionType.CLIENT_SERVER,
    +        ContainerInstall.DEFAULT_INSTALL_DIR + 
"Tomcat7079AndCurrentModules");
    +
    +    tomcat8AndOldModules = new 
TomcatInstall(TomcatInstall.TomcatVersion.TOMCAT8,
    +        ContainerInstall.ConnectionType.CLIENT_SERVER,
    +        ContainerInstall.DEFAULT_INSTALL_DIR + "Tomcat8AndOldModules", 
oldModules.getAbsolutePath(),
    +        oldBuild.getAbsolutePath() + "/lib");
    +
    +    tomcat8AndCurrentModules = new 
TomcatInstall(TomcatInstall.TomcatVersion.TOMCAT8,
    +        ContainerInstall.ConnectionType.CLIENT_SERVER,
    +        ContainerInstall.DEFAULT_INSTALL_DIR + "Tomcat8AndCurrentModules");
    +
    +    classPathTomcat7079 = tomcat7079AndCurrentModules.getHome() + "/lib/*" 
+ File.pathSeparator
    +        + tomcat7079AndCurrentModules.getHome() + "/bin/*";
    +    classPathTomcat8 = tomcat8AndCurrentModules.getHome() + "/lib/*" + 
File.pathSeparator
    +        + tomcat8AndCurrentModules.getHome() + "/bin/*";
    +
    +    // Get available port for the locator
    +    locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
    +
    +    tomcat7079AndOldModules.setDefaultLocator("localhost", locatorPort);
    +    tomcat7079AndCurrentModules.setDefaultLocator("localhost", 
locatorPort);
    +
    +    tomcat8AndOldModules.setDefaultLocator("localhost", locatorPort);
    +    tomcat8AndCurrentModules.setDefaultLocator("localhost", locatorPort);
    +
    +    client = new Client();
    +    manager = new ContainerManager();
    +    // Due to parameterization of the test name, the URI would be 
malformed. Instead, it strips off
    +    // the [] symbols
    +    manager.setTestName(testName.getMethodName().replace("[", 
"").replace("]", ""));
    +  }
    +
    +  private void startClusterWithTomcat(String tomcatClassPath) throws 
Exception {
    +    startLocator("loc", tomcatClassPath, locatorPort);
    +    startServer("server", tomcatClassPath, locatorPort);
    +  }
    +
    +  /**
    +   * Stops all containers that were previously started and cleans up their 
configurations
    +   */
    +  @After
    +  public void stop() throws Exception {
    +    manager.stopAllActiveContainers();
    +    manager.cleanUp();
    +
    +    tomcat8AndCurrentModules.clearPreviousRuns();
    --- End diff --
    
    Change clearPreviousRuns to remove only previous runs of current version 
being added


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to