You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2011/04/08 00:46:28 UTC
svn commit: r1090054 -
/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CleanupTest.java
Author: slebresne
Date: Thu Apr 7 22:46:28 2011
New Revision: 1090054
URL: http://svn.apache.org/viewvc?rev=1090054&view=rev
Log:
Fix unit tests for CASSANDRA-2428
Modified:
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CleanupTest.java
Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CleanupTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CleanupTest.java?rev=1090054&r1=1090053&r2=1090054&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CleanupTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CleanupTest.java Thu Apr 7 22:46:28 2011
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTru
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.net.InetAddress;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
@@ -36,6 +37,7 @@ import org.apache.cassandra.config.Confi
import org.apache.cassandra.db.columniterator.IdentityQueryFilter;
import org.apache.cassandra.db.filter.IFilter;
import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.dht.BytesToken;
import org.apache.cassandra.dht.IPartitioner;
import org.apache.cassandra.dht.Range;
import org.apache.cassandra.locator.TokenMetadata;
@@ -108,10 +110,14 @@ public class CleanupTest extends Cleanup
rows = table.getColumnFamilyStore(CF1).scan(clause, range, filter);
assertEquals(LOOPS, rows.size());
- // nuke our token so cleanup will remove everything
+ // we don't allow cleanup when the local host has no range to avoid wipping up all data when a node has not join the ring.
+ // So to make sure cleanup erase everything here, we give the localhost the tiniest possible range.
TokenMetadata tmd = StorageService.instance.getTokenMetadata();
- tmd.clearUnsafe();
- assert StorageService.instance.getLocalRanges(TABLE1).isEmpty();
+ byte[] tk1 = new byte[1], tk2 = new byte[1];
+ tk1[0] = 2;
+ tk2[0] = 1;
+ tmd.updateNormalToken(new BytesToken(tk1), InetAddress.getByName("127.0.0.1"));
+ tmd.updateNormalToken(new BytesToken(tk2), InetAddress.getByName("127.0.0.2"));
CompactionManager.instance.performCleanup(cfs);