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 A849F200CA4 for ; Wed, 7 Jun 2017 19:24:33 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A6F99160BD0; Wed, 7 Jun 2017 17:24:33 +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 C6AD8160BBF for ; Wed, 7 Jun 2017 19:24:32 +0200 (CEST) Received: (qmail 2729 invoked by uid 500); 7 Jun 2017 17:24:32 -0000 Mailing-List: contact commits-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list commits@geode.apache.org Received: (qmail 2716 invoked by uid 99); 7 Jun 2017 17:24:32 -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; Wed, 07 Jun 2017 17:24:32 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DF78EDFC8B; Wed, 7 Jun 2017 17:24:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: boglesby@apache.org To: commits@geode.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: geode git commit: GEODE-3040: Compare gateway profile order policy against 9.0 instead of current Date: Wed, 7 Jun 2017 17:24:31 +0000 (UTC) archived-at: Wed, 07 Jun 2017 17:24:33 -0000 Repository: geode Updated Branches: refs/heads/develop 6fc757aba -> 934b61a69 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/934b61a6 Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/934b61a6 Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/934b61a6 Branch: refs/heads/develop Commit: 934b61a6924641260d104f01c1db8c0a8c54e659 Parents: 6fc757a Author: Barry Oglesby Authored: Mon Jun 5 18:02:28 2017 -0700 Committer: Barry Oglesby Committed: Wed Jun 7 10:16:17 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/934b61a6/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/934b61a6/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/934b61a6/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) +@Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class) +public class WANRollingUpgradeDUnitTest extends JUnit4CacheTestCase { + + @Parameterized.Parameters + public static Collection data() { + List 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); + } +}