cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1071805 - /cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
Date Thu, 17 Feb 2011 21:55:06 GMT
Author: jbellis
Date: Thu Feb 17 21:55:06 2011
New Revision: 1071805

URL: http://svn.apache.org/viewvc?rev=1071805&view=rev
Log:
add testTransferOfMultipleColumnFamilies
patch by Pavel Yaskevich; reviewed by jbellis for CASSANDRA-2154

Modified:
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java?rev=1071805&r1=1071804&r2=1071805&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
Thu Feb 17 21:55:06 2011
@@ -28,6 +28,7 @@ import java.util.*;
 
 import org.apache.cassandra.CleanupHelper;
 import org.apache.cassandra.Util;
+import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.columniterator.IdentityQueryFilter;
 import org.apache.cassandra.db.filter.IFilter;
@@ -155,4 +156,49 @@ public class StreamingTransferTest exten
         assert null != cfstore.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("test"),
new QueryPath("Standard1")));
         assert null != cfstore.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("transfer1"),
new QueryPath("Standard1")));
     }
+
+    @Test
+    public void testTransferOfMultipleColumnFamilies() throws Exception
+    {
+        String keyspace = "Keyspace1";
+        IPartitioner p = StorageService.getPartitioner();
+        String[] columnFamilies = new String[] { "Standard1", "Standard2", "Standard3" };
+        List<SSTableReader> ssTableReaders = new ArrayList<SSTableReader>();
+
+        // ranges to transfer
+        List<Range> ranges = new ArrayList<Range>();
+
+        for (String cf : columnFamilies)
+        {
+            Set<String> content = new HashSet<String>();
+
+            content.add("data-" + cf + "-1");
+            content.add("data-" + cf + "-2");
+            content.add("data-" + cf + "-3");
+
+            SSTableUtils.Context context = SSTableUtils.prepare().ks(keyspace).cf(cf);
+
+            ssTableReaders.add(context.write(content));
+            ranges.add(new Range(p.getMinimumToken(), p.getToken(ByteBufferUtil.bytes("data-"
+ cf + "-3"))));
+        }
+
+        StreamOutSession session = StreamOutSession.create(keyspace, LOCAL, null);
+        StreamOut.transferSSTables(session, ssTableReaders, ranges);
+
+        session.await();
+
+        for (String cf : columnFamilies)
+        {
+            ColumnFamilyStore store = Table.open(keyspace).getColumnFamilyStore(cf);
+            List<Row> rows = Util.getRangeSlice(store);
+
+            assert rows.size() >= 3;
+
+            for (int i = 0; i < 3; i++)
+            {
+                String expectedKey = "data-" + cf + "-" + (i + 1);
+                assertEquals(p.decorateKey(ByteBufferUtil.bytes(expectedKey)), rows.get(i).key);
+            }
+        }
+    }
 }



Mime
View raw message