cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [08/10] cassandra git commit: Merge branch 'cassandra-2.2' into cassandra-3.0
Date Thu, 11 Feb 2016 08:05:37 GMT
Merge branch 'cassandra-2.2' into cassandra-3.0


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

Branch: refs/heads/cassandra-3.0
Commit: 11bfd1963249491981d78d6bc47185c5dbb1b78c
Parents: fdd2cd0 984e174
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Thu Feb 11 09:03:15 2016 +0100
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Thu Feb 11 09:03:15 2016 +0100

----------------------------------------------------------------------
 .../db/compaction/CompactionsCQLTest.java       | 53 +++++++++-----------
 1 file changed, 25 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/11bfd196/test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java
index 3c0098b,4553a45..5d42aae
--- a/test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java
@@@ -24,19 -24,14 +24,16 @@@ import org.junit.Test
  
  import org.apache.cassandra.cql3.CQLTester;
  import org.apache.cassandra.cql3.UntypedResultSet;
--import org.apache.cassandra.db.ColumnFamilyStore;
--import org.apache.cassandra.db.Keyspace;
- import org.apache.cassandra.utils.FBUtilities;
 +
- import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertFalse;
  import static org.junit.Assert.assertTrue;
+ import static org.junit.Assert.fail;
  
  public class CompactionsCQLTest extends CQLTester
  {
 +
-     public static final int SLEEP_TIME = FBUtilities.isWindows()? 2000 : 1000;
++    public static final int SLEEP_TIME = 5000;
 +
      @Test
      public void testTriggerMinorCompactionSTCS() throws Throwable
      {
@@@ -46,8 -41,7 +43,7 @@@
          flush();
          execute("insert into %s (id) values ('1')");
          flush();
-         Thread.sleep(SLEEP_TIME);
-         assertTrue(minorWasTriggered(KEYSPACE, currentTable()));
 -        waitForMinor(KEYSPACE, currentTable(), 5000, true);
++        waitForMinor(KEYSPACE, currentTable(), SLEEP_TIME, true);
      }
  
      @Test
@@@ -59,8 -53,7 +55,7 @@@
          flush();
          execute("insert into %s (id) values ('1')");
          flush();
-         Thread.sleep(SLEEP_TIME);
-         assertTrue(minorWasTriggered(KEYSPACE, currentTable()));
 -        waitForMinor(KEYSPACE, currentTable(), 5000, true);
++        waitForMinor(KEYSPACE, currentTable(), SLEEP_TIME, true);
      }
  
  
@@@ -73,8 -66,7 +68,7 @@@
          flush();
          execute("insert into %s (id) values ('1')");
          flush();
-         Thread.sleep(SLEEP_TIME);
-         assertTrue(minorWasTriggered(KEYSPACE, currentTable()));
 -        waitForMinor(KEYSPACE, currentTable(), 5000, true);
++        waitForMinor(KEYSPACE, currentTable(), SLEEP_TIME, true);
      }
  
      @Test
@@@ -86,8 -78,7 +80,7 @@@
          flush();
          execute("insert into %s (id) values ('1')");
          flush();
-         Thread.sleep(SLEEP_TIME);
-         assertFalse(minorWasTriggered(KEYSPACE, currentTable()));
 -        waitForMinor(KEYSPACE, currentTable(), 5000, false);
++        waitForMinor(KEYSPACE, currentTable(), SLEEP_TIME, false);
      }
  
      @Test
@@@ -101,8 -92,7 +94,7 @@@
          flush();
          execute("insert into %s (id) values ('1')");
          flush();
-         Thread.sleep(SLEEP_TIME);
-         assertTrue(minorWasTriggered(KEYSPACE, currentTable()));
 -        waitForMinor(KEYSPACE, currentTable(), 5000, true);
++        waitForMinor(KEYSPACE, currentTable(), SLEEP_TIME, true);
      }
  
      @Test
@@@ -116,8 -106,7 +108,7 @@@
          flush();
          execute("insert into %s (id) values ('1')");
          flush();
-         Thread.sleep(SLEEP_TIME);
-         assertFalse(minorWasTriggered(KEYSPACE, currentTable()));
 -        waitForMinor(KEYSPACE, currentTable(), 5000, false);
++        waitForMinor(KEYSPACE, currentTable(), SLEEP_TIME, false);
      }
  
      @Test
@@@ -131,8 -120,7 +122,7 @@@
          flush();
          execute("insert into %s (id) values ('1')");
          flush();
-         Thread.sleep(SLEEP_TIME);
-         assertFalse(minorWasTriggered(KEYSPACE, currentTable()));
 -        waitForMinor(KEYSPACE, currentTable(), 5000, false);
++        waitForMinor(KEYSPACE, currentTable(), SLEEP_TIME, false);
      }
  
      @Test
@@@ -146,8 -134,7 +136,7 @@@
          flush();
          execute("insert into %s (id) values ('1')");
          flush();
-         Thread.sleep(SLEEP_TIME);
-         assertTrue(minorWasTriggered(KEYSPACE, currentTable()));
 -        waitForMinor(KEYSPACE, currentTable(), 5000, true);
++        waitForMinor(KEYSPACE, currentTable(), SLEEP_TIME, true);
      }
  
      @Test
@@@ -224,15 -213,28 +213,23 @@@
          return found;
      }
  
-     private boolean minorWasTriggered(String keyspace, String cf) throws Throwable
 -    private ColumnFamilyStore getCurrentColumnFamilyStore()
 -    {
 -        return Keyspace.open(KEYSPACE).getColumnFamilyStore(currentTable());
 -    }
 -
+     private void waitForMinor(String keyspace, String cf, long maxWaitTime, boolean shouldFind)
throws Throwable
      {
-         UntypedResultSet res = execute("SELECT * FROM system.compaction_history");
-         boolean minorWasTriggered = false;
-         for (UntypedResultSet.Row r : res)
+         long startTime = System.currentTimeMillis();
+         while (System.currentTimeMillis() - startTime < maxWaitTime)
          {
-             if (r.getString("keyspace_name").equals(keyspace) && r.getString("columnfamily_name").equals(cf))
-                 minorWasTriggered = true;
+             UntypedResultSet res = execute("SELECT * FROM system.compaction_history");
+             for (UntypedResultSet.Row r : res)
+             {
+                 if (r.getString("keyspace_name").equals(keyspace) && r.getString("columnfamily_name").equals(cf))
+                     if (shouldFind)
+                         return;
+                     else
+                         fail("Found minor compaction");
+             }
+             Thread.sleep(100);
          }
-         return minorWasTriggered;
+         if (shouldFind)
+             fail("No minor compaction triggered in "+maxWaitTime+"ms");
      }
  }


Mime
View raw message