UpgradeRegistry { public static UpgradeAction findUpgradeAction(InteractionProtocol protocol, Version distributionVersion) { Version clusterVersion = protocol.getVersion(); if (clusterVersion == null) { boolean isPre0_6Cluster = protocol.getZkClient().exists( protocol.getZkConfiguration().getZkRootPath() + "/indexes"); if (isPre0_6Cluster) { LOG.info("version of cluster not found - assuming 0.5"); clusterVersion = new Version("0.5", "Unknown", "Unknown", "Unknown"); } else { clusterVersion = distributionVersion; } } LOG.info("version of distribution " + distributionVersion.getNumber()); LOG.info("version of cluster " + clusterVersion.getNumber()); if (clusterVersion.equals(distributionVersion)) { return null; } VersionPair currentVersionPair = new VersionPair(clusterVersion.getNumber(), distributionVersion.getNumber()); LOG.warn("cluster version differs from distribution version " + currentVersionPair); for (VersionPair versionPair : _upgradeActionsByVersion.keySet()) { LOG.info("checking upgrade action " + versionPair); if (currentVersionPair.getFromVersion().startsWith(versionPair.getFromVersion()) && currentVersionPair.getToVersion().startsWith(versionPair.getToVersion())) { LOG.info("found matching upgrade action"); return _upgradeActionsByVersion.get(versionPair); } } LOG.warn("found no upgrade action for " + currentVersionPair + " out of " + _upgradeActionsByVersion.keySet()); return null; }  static UpgradeAction findUpgradeAction(InteractionProtocol protocol, Version distributionVersion);  }
@Test public void testNoUpgradeFound() throws Exception { when(_protocol.getVersion()).thenReturn(createVersion("0.1")); Version distributionVersion = createVersion("0.2"); assertNull(UpgradeRegistry.findUpgradeAction(_protocol, distributionVersion)); }