GEODE-3040: Compare gateway profile order policy against 9.0 instead of current


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/11b20a18
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/11b20a18
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/11b20a18

Branch: refs/heads/feature/GEODE-3023
Commit: 11b20a1829100bdd2960f24dfe1b4c3c0fec236b
Parents: 119bdc5
Author: Barry Oglesby <[email protected]>
Authored: Mon Jun 5 18:02:28 2017 -0700
Committer: Udo Kohlmeyer <[email protected]>
Committed: Fri Jun 9 13:12:03 2017 -0700

----------------------------------------------------------------------
 .../cache/wan/GatewaySenderAdvisor.java         |   4 +-
 geode-wan/build.gradle                          |   1 +
 .../cache/wan/WANRollingUpgradeDUnitTest.java   | 123 +++++++++++++++++++
 3 files changed, 126 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/11b20a18/geode-core/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderAdvisor.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderAdvisor.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderAdvisor.java
index 72ad77b..ca82ac6 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderAdvisor.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderAdvisor.java
@@ -551,7 +551,7 @@ public class GatewaySenderAdvisor extends 
DistributionAdvisor {
       this.senderEventListenerClassNames = DataSerializer.readArrayList(in);
       this.isDiskSynchronous = in.readBoolean();
       this.dispatcherThreads = in.readInt();
-      if 
(InternalDataSerializer.getVersionForDataStream(in).compareTo(Version.CURRENT) 
< 0) {
+      if 
(InternalDataSerializer.getVersionForDataStream(in).compareTo(Version.GFE_90) < 
0) {
         Gateway.OrderPolicy oldOrderPolicy = DataSerializer.readObject(in);
         if (oldOrderPolicy != null) {
           if (oldOrderPolicy.name().equals(OrderPolicy.KEY.name())) {
@@ -592,7 +592,7 @@ public class GatewaySenderAdvisor extends 
DistributionAdvisor {
       DataSerializer.writeArrayList(senderEventListenerClassNames, out);
       out.writeBoolean(isDiskSynchronous);
       out.writeInt(dispatcherThreads);
-      if 
(InternalDataSerializer.getVersionForDataStream(out).compareTo(Version.CURRENT) 
< 0
+      if 
(InternalDataSerializer.getVersionForDataStream(out).compareTo(Version.GFE_90) 
< 0
           && this.orderPolicy != null) {
         String orderPolicyName = this.orderPolicy.name();
         if (orderPolicyName.equals(Gateway.OrderPolicy.KEY.name())) {

http://git-wip-us.apache.org/repos/asf/geode/blob/11b20a18/geode-wan/build.gradle
----------------------------------------------------------------------
diff --git a/geode-wan/build.gradle b/geode-wan/build.gradle
index b3a8449..7cbbf85 100644
--- a/geode-wan/build.gradle
+++ b/geode-wan/build.gradle
@@ -20,4 +20,5 @@ dependencies {
 
   testCompile files(project(':geode-core').sourceSets.test.output)
   testCompile project(':geode-junit')
+  testCompile project(':geode-old-versions')
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/11b20a18/geode-wan/src/test/java/org/apache/geode/cache/wan/WANRollingUpgradeDUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-wan/src/test/java/org/apache/geode/cache/wan/WANRollingUpgradeDUnitTest.java
 
b/geode-wan/src/test/java/org/apache/geode/cache/wan/WANRollingUpgradeDUnitTest.java
new file mode 100644
index 0000000..b5776cd
--- /dev/null
+++ 
b/geode-wan/src/test/java/org/apache/geode/cache/wan/WANRollingUpgradeDUnitTest.java
@@ -0,0 +1,123 @@
+/*
+ * 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.cache.wan;
+
+import org.apache.geode.distributed.Locator;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.internal.AvailablePort;
+import org.apache.geode.test.dunit.DistributedTestUtils;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.IgnoredException;
+import org.apache.geode.test.dunit.NetworkUtils;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
+import org.apache.geode.test.dunit.standalone.DUnitLauncher;
+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;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+
+@Category({DistributedTest.class, BackwardCompatibilityTest.class})
+@RunWith(Parameterized.class)
[email protected](CategoryWithParameterizedRunnerFactory.class)
+public class WANRollingUpgradeDUnitTest extends JUnit4CacheTestCase {
+
+  @Parameterized.Parameters
+  public static Collection<String> data() {
+    List<String> result = 
VersionManager.getInstance().getVersionsWithoutCurrent();
+    if (result.size() < 1) {
+      throw new RuntimeException("No older versions of Geode were found to 
test against");
+    } else {
+      System.out.println("running against these versions: " + result);
+    }
+    return result;
+  }
+
+  // the old version of Geode we're testing against
+  private String oldVersion;
+
+  public WANRollingUpgradeDUnitTest(String version) {
+    oldVersion = version;
+  }
+
+  @Test
+  // This test verifies that a GatewaySenderProfile serializes properly 
between versions.
+  public void testVerifyGatewaySenderProfile() throws Exception {
+    doTestVerifyGatewaySenderProfile(oldVersion);
+  }
+
+  private void doTestVerifyGatewaySenderProfile(String oldVersion) throws 
Exception {
+    final Host host = Host.getHost(0);
+    VM oldLocator = host.getVM(oldVersion, 0);
+    VM oldServer = host.getVM(oldVersion, 1);
+    VM currentServer = host.getVM(2);
+
+    // Start locator
+    final int port = 
AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    DistributedTestUtils.deleteLocatorStateFile(port);
+    final String locators = NetworkUtils.getServerHostName(host) + "[" + port 
+ "]";
+    oldLocator.invoke(() -> startLocator(port, locators));
+
+    IgnoredException ie =
+        IgnoredException.addIgnoredException("could not get remote locator 
information");
+    try {
+      // Start old server
+      oldServer.invoke(() -> startServer(locators));
+
+      // Create GatewaySender in old server
+      oldServer.invoke(() -> createGatewaySender());
+
+      // Start current server
+      currentServer.invoke(() -> startServer(locators));
+
+      // Attempt to create GatewaySender in new server
+      currentServer.invoke(() -> createGatewaySender());
+    } finally {
+      ie.remove();
+    }
+  }
+
+  private void startLocator(int port, String locators) throws IOException {
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+    props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
+    props.setProperty(DistributionConfig.LOG_LEVEL_NAME, 
DUnitLauncher.logLevel);
+    Locator.startLocatorAndDS(port, null, props);
+  }
+
+  private void startServer(String locators) {
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+    props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
+    props.setProperty(DistributionConfig.LOG_LEVEL_NAME, 
DUnitLauncher.logLevel);
+    getCache(props);
+  }
+
+  protected void createGatewaySender() throws Exception {
+    GatewaySenderFactory gsf = getCache().createGatewaySenderFactory();
+    gsf.setParallel(true);
+    gsf.setOrderPolicy(GatewaySender.DEFAULT_ORDER_POLICY);
+    gsf.create(getName() + "_gatewaysender", 10);
+  }
+}

Reply via email to