cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bened...@apache.org
Subject [2/6] cassandra git commit: Replace IndexSummaryManagerTest.testCompactionRace with DataTrackerTest.testCompactOnlyCorrectInstance
Date Wed, 03 Jun 2015 21:58:48 GMT
Replace IndexSummaryManagerTest.testCompactionRace with DataTrackerTest.testCompactOnlyCorrectInstance

patch by benedict; reviewed by ariel for CASSANDRA-9271


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

Branch: refs/heads/cassandra-2.2
Commit: be3e3895863211fa79556170be1a584db71f8543
Parents: 80ef282
Author: Benedict Elliott Smith <benedict@apache.org>
Authored: Wed Jun 3 22:47:32 2015 +0100
Committer: Benedict Elliott Smith <benedict@apache.org>
Committed: Wed Jun 3 22:47:32 2015 +0100

----------------------------------------------------------------------
 .../apache/cassandra/db/DataTrackerTest.java    | 65 ++++++++++++++++++
 .../io/sstable/IndexSummaryManagerTest.java     | 72 --------------------
 2 files changed, 65 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/be3e3895/test/unit/org/apache/cassandra/db/DataTrackerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/DataTrackerTest.java b/test/unit/org/apache/cassandra/db/DataTrackerTest.java
new file mode 100644
index 0000000..b557ee3
--- /dev/null
+++ b/test/unit/org/apache/cassandra/db/DataTrackerTest.java
@@ -0,0 +1,65 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*    http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.cassandra.db;
+
+import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.Set;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import org.junit.Test;
+
+import junit.framework.Assert;
+import org.apache.cassandra.SchemaLoader;
+import org.apache.cassandra.Util;
+import org.apache.cassandra.io.sstable.SSTableReader;
+import org.apache.cassandra.utils.ByteBufferUtil;
+
+public class DataTrackerTest extends SchemaLoader
+{
+    private static final String KEYSPACE = "Keyspace1";
+    private static final String CF = "Standard1";
+
+    @Test
+    public void testCompactOnlyCorrectInstance()
+    {
+        Keyspace keyspace = Keyspace.open(KEYSPACE);
+        ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
+        cfs.truncateBlocking();
+        for (int j = 0; j < 100; j ++)
+        {
+            ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(j));
+            Mutation rm = new Mutation(KEYSPACE, key);
+            rm.add(CF, Util.cellname("0"), ByteBufferUtil.EMPTY_BYTE_BUFFER, j);
+            rm.apply();
+        }
+        cfs.forceBlockingFlush();
+        Set<SSTableReader> sstables = new HashSet<>(cfs.getSSTables());
+        assert sstables.size() == 1;
+        SSTableReader reader = Iterables.getFirst(sstables, null);
+        SSTableReader reader2 = reader.cloneAsShadowed(new Runnable() { public void run()
{ } });
+        Assert.assertFalse(cfs.getDataTracker().markCompacting(ImmutableList.of(reader2)));
+        Assert.assertTrue(cfs.getDataTracker().markCompacting(ImmutableList.of(reader)));
+        cfs.getDataTracker().replaceWithNewInstances(ImmutableList.of(reader), ImmutableList.of(reader2));
+        cfs.getDataTracker().unmarkCompacting(ImmutableList.of(reader));
+        cfs.truncateBlocking();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/be3e3895/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java b/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java
index 877b6e6..64d3354 100644
--- a/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java
@@ -499,76 +499,4 @@ public class IndexSummaryManagerTest extends SchemaLoader
                 assertTrue(entry.getValue() >= cfs.metadata.getMinIndexInterval());
         }
     }
-
-    //This test runs last, since cleaning up compactions and tp is a pain
-    @Test
-    public void testCompactionRace() throws InterruptedException, ExecutionException
-    {
-        String ksname = "Keyspace1";
-        String cfname = "StandardRace"; // index interval of 8, no key caching
-        Keyspace keyspace = Keyspace.open(ksname);
-        ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfname);
-        int numSSTables = 50;
-        int numRows = 1 << 10;
-        createSSTables(ksname, cfname, numSSTables, numRows);
-
-        List<SSTableReader> sstables = new ArrayList<>(cfs.getSSTables());
-
-        ExecutorService tp = Executors.newFixedThreadPool(2);
-
-        final AtomicBoolean failed = new AtomicBoolean(false);
-
-        for (int i = 0; i < 2; i++)
-        {
-            tp.submit(new Runnable()
-            {
-                @Override
-                public void run()
-                {
-                    while(!failed.get())
-                    {
-                        try
-                        {
-                            IndexSummaryManager.instance.redistributeSummaries();
-                        }
-                        catch (Throwable e)
-                        {
-                            failed.set(true);
-                        }
-                    }
-                }
-            });
-        }
-
-        while ( cfs.getSSTables().size() != 1 )
-            cfs.forceMajorCompaction();
-
-        try
-        {
-            Assert.assertFalse(failed.getAndSet(true));
-
-            for (SSTableReader sstable : sstables)
-            {
-                Assert.assertEquals(true, sstable.isMarkedCompacted());
-            }
-
-            Assert.assertEquals(numSSTables, sstables.size());
-
-            try
-            {
-                totalOffHeapSize(sstables);
-                Assert.fail("This should have failed");
-            } catch (AssertionError e)
-            {
-
-            }
-        }
-        finally
-        {
-            tp.shutdownNow();
-            CompactionManager.instance.finishCompactionsAndShutdown(10, TimeUnit.SECONDS);
-        }
-
-        cfs.truncateBlocking();
-    }
 }


Mime
View raw message