cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [1/3] git commit: Add helper to create sstables for legacy leveled manifest test
Date Thu, 25 Apr 2013 16:22:07 GMT
Updated Branches:
  refs/heads/trunk bf2ee0443 -> 32f4e2cce


Add helper to create sstables for legacy leveled manifest test


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/591b8ca4
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/591b8ca4
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/591b8ca4

Branch: refs/heads/trunk
Commit: 591b8ca4b3cd1074f6c62414975950a69149748d
Parents: 3c93e8c6
Author: Marcus Eriksson <marcuse@spotify.com>
Authored: Thu Apr 25 18:04:12 2013 +0200
Committer: Marcus Eriksson <marcuse@spotify.com>
Committed: Thu Apr 25 18:04:12 2013 +0200

----------------------------------------------------------------------
 test/unit/org/apache/cassandra/SchemaLoader.java   |    3 +
 .../LegacyLeveledManifestTestHelper.java           |   57 +++++++++++++++
 2 files changed, 60 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/591b8ca4/test/unit/org/apache/cassandra/SchemaLoader.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/SchemaLoader.java b/test/unit/org/apache/cassandra/SchemaLoader.java
index 3db1fc5..b2ae83a 100644
--- a/test/unit/org/apache/cassandra/SchemaLoader.java
+++ b/test/unit/org/apache/cassandra/SchemaLoader.java
@@ -220,6 +220,9 @@ public class SchemaLoader
                                                           null),
                                            standardCFMD(ks1, "StandardLeveled", withOldCfIds)
                                                                                .compactionStrategyClass(LeveledCompactionStrategy.class)
+                                                                               .compactionStrategyOptions(leveledOptions),
+                                           standardCFMD(ks1, "legacyleveled", withOldCfIds)
+                                                                               .compactionStrategyClass(LeveledCompactionStrategy.class)
                                                                                .compactionStrategyOptions(leveledOptions)));
 
         // Keyspace 2

http://git-wip-us.apache.org/repos/asf/cassandra/blob/591b8ca4/test/unit/org/apache/cassandra/db/compaction/LegacyLeveledManifestTestHelper.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/compaction/LegacyLeveledManifestTestHelper.java
b/test/unit/org/apache/cassandra/db/compaction/LegacyLeveledManifestTestHelper.java
new file mode 100644
index 0000000..9ce60ea
--- /dev/null
+++ b/test/unit/org/apache/cassandra/db/compaction/LegacyLeveledManifestTestHelper.java
@@ -0,0 +1,57 @@
+package org.apache.cassandra.db.compaction;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.apache.cassandra.SchemaLoader;
+import org.apache.cassandra.io.sstable.Descriptor;
+import org.apache.cassandra.io.sstable.SSTableReader;
+import org.apache.cassandra.io.sstable.SSTableUtils;
+import org.apache.cassandra.io.util.FileUtils;
+
+@Ignore
+public class LegacyLeveledManifestTestHelper extends SchemaLoader
+{
+    public final static String PROP = "migration-sstable-root";
+    public final static String KS = "Keyspace1";
+    public final static String CF = "legacyleveled";
+    /**
+     * Generates two sstables to be used to test migrating from a .json manifest to keeping
the level in the sstable
+     * metadata.
+     *
+     * Do this:
+     * 1. remove @Ignore
+     * 2. comment out the @Before and @After methods above
+     * 3. run this method
+     * 4. checkout trunk
+     * 5. copy the .json file from the previous version to the current one
+     *    (ie; test/data/migration-sstables/ic/Keyspace1/legacyleveled/legacyleveled.json)
+     * 6. update LegacyLeveledManifestTest to use the new version.
+     */
+    @Test
+    public void generateSSTable() throws IOException
+    {
+        File legacySSTableDir = getLegacySSTableDir(Descriptor.Version.current_version);
+        FileUtils.createDirectory(legacySSTableDir);
+        Set<String> keys = new HashSet<String>();
+        for(int i = 0; i < 10; i++)
+        {
+            keys.add("key"+i);
+        }
+        for(int i = 0; i < 3; i++)
+        {
+            SSTableReader ssTable = SSTableUtils.prepare().ks(KS).cf(CF).dest(new Descriptor(legacySSTableDir,
KS, CF, i, false)).write(keys);
+            System.out.println(ssTable);
+        }
+    }
+    public static File getLegacySSTableDir(String version)
+    {
+        return new File(System.getProperty(PROP) + File.separator + version + File.separator
+ KS + File.separator + CF);
+    }
+
+}


Mime
View raw message