SystemKeyspaceTest handles dev versions properly Patch by Sam Tunnicliffe; reviewed by Aleksey Yeschenko for CASSANDRA-9422
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f9b6d3da Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f9b6d3da Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f9b6d3da Branch: refs/heads/trunk Commit: f9b6d3dac7d60b4409f05c25e743dfbbf32a50f4 Parents: 0088e5f Author: Sam Tunnicliffe <s...@beobal.com> Authored: Tue May 19 13:11:21 2015 +0100 Committer: Sam Tunnicliffe <s...@beobal.com> Committed: Wed May 20 14:17:24 2015 +0100 ---------------------------------------------------------------------- .../org/apache/cassandra/db/SystemKeyspaceTest.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/f9b6d3da/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java b/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java index b0101bc..7531b06 100644 --- a/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java +++ b/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java @@ -90,8 +90,7 @@ public class SystemKeyspaceTest assertTrue(getSystemSnapshotFiles().isEmpty()); // now setup system.local as if we're upgrading from a previous version - SemanticVersion next = getCurrentReleaseVersion(); - setupReleaseVersion(new SemanticVersion(String.format("%s.%s.%s", next.major - 1, next.minor, next.patch))); + setupReleaseVersion(getOlderVersionString()); Keyspace.clearSnapshot(null, SystemKeyspace.NAME); assertTrue(getSystemSnapshotFiles().isEmpty()); @@ -102,15 +101,18 @@ public class SystemKeyspaceTest // clear out the snapshots & set the previous recorded version equal to the latest, we shouldn't // see any new snapshots created this time. Keyspace.clearSnapshot(null, SystemKeyspace.NAME); - setupReleaseVersion(getCurrentReleaseVersion()); + setupReleaseVersion(FBUtilities.getReleaseVersionString()); SystemKeyspace.snapshotOnVersionChange(); assertTrue(getSystemSnapshotFiles().isEmpty()); } - private SemanticVersion getCurrentReleaseVersion() + private String getOlderVersionString() { - return new SemanticVersion(FBUtilities.getReleaseVersionString()); + String version = FBUtilities.getReleaseVersionString(); + SemanticVersion semver = new SemanticVersion(version.contains("-") ? version.substring(0, version.indexOf('-')) + : version); + return (String.format("%s.%s.%s", semver.major - 1, semver.minor, semver.patch)); } private Set<String> getSystemSnapshotFiles() @@ -124,7 +126,7 @@ public class SystemKeyspaceTest return snapshottedTableNames; } - private void setupReleaseVersion(SemanticVersion version) + private void setupReleaseVersion(String version) { // besides the release_version, we also need to insert the cluster_name or the check // in SystemKeyspace.checkHealth were we verify it matches DatabaseDescriptor will fail @@ -133,7 +135,7 @@ public class SystemKeyspaceTest version, DatabaseDescriptor.getClusterName())); String r = readLocalVersion(); - assertEquals(String.format("Expected %s, got %s", version, r), version.toString(), r); + assertEquals(String.format("Expected %s, got %s", version, r), version, r); } private String readLocalVersion()