Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D831B182F4 for ; Thu, 11 Feb 2016 08:05:40 +0000 (UTC) Received: (qmail 7258 invoked by uid 500); 11 Feb 2016 08:05:31 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 7179 invoked by uid 500); 11 Feb 2016 08:05:31 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 6762 invoked by uid 99); 11 Feb 2016 08:05:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Feb 2016 08:05:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CD075E699F; Thu, 11 Feb 2016 08:05:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: marcuse@apache.org To: commits@cassandra.apache.org Date: Thu, 11 Feb 2016 08:05:37 -0000 Message-Id: <374ce66603c44bf589a4616b6d0bc960@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [08/10] cassandra git commit: Merge branch 'cassandra-2.2' into cassandra-3.0 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 Authored: Thu Feb 11 09:03:15 2016 +0100 Committer: Marcus Eriksson 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"); } }