cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [09/10] cassandra git commit: Merge branch 'cassandra-3.0' into cassandra-3.11
Date Mon, 04 Sep 2017 13:05:21 GMT
Merge branch 'cassandra-3.0' into cassandra-3.11


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

Branch: refs/heads/trunk
Commit: 37d67306accb2fefed9cfc57856fcca4df93a407
Parents: bed7fa5 b0eba5f
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Mon Sep 4 15:04:04 2017 +0200
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Mon Sep 4 15:04:04 2017 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 .../db/compaction/CompactionManager.java        |   4 +-
 .../db/compaction/CompactionExecutorTest.java   | 109 +++++++++++++++++++
 3 files changed, 112 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/37d67306/CHANGES.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37d67306/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37d67306/test/unit/org/apache/cassandra/db/compaction/CompactionExecutorTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/db/compaction/CompactionExecutorTest.java
index 0000000,9b07da9..2f8b5b2
mode 000000,100644..100644
--- a/test/unit/org/apache/cassandra/db/compaction/CompactionExecutorTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/CompactionExecutorTest.java
@@@ -1,0 -1,107 +1,109 @@@
+ /*
+  * 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.compaction;
+ 
+ import java.util.concurrent.Future;
+ import java.util.concurrent.TimeUnit;
+ 
+ import org.junit.After;
+ import org.junit.Before;
+ import org.junit.Test;
+ import org.apache.cassandra.concurrent.DebuggableThreadPoolExecutor;
++import org.apache.cassandra.config.DatabaseDescriptor;
+ 
+ import static org.junit.Assert.assertEquals;
+ import static org.junit.Assert.assertNotNull;
+ 
+ public class CompactionExecutorTest
+ {
+     static Throwable testTaskThrowable = null;
+     private static class TestTaskExecutor extends CompactionManager.CompactionExecutor
+     {
+         @Override
+         public void afterExecute(Runnable r, Throwable t)
+         {
+             if (t == null)
+             {
+                 t = DebuggableThreadPoolExecutor.extractThrowable(r);
+             }
+             testTaskThrowable = t;
+         }
+         @Override
+         protected void beforeExecute(Thread t, Runnable r)
+         {
+         }
+     }
+     private CompactionManager.CompactionExecutor executor;
+ 
+     @Before
+     public void setup()
+     {
++        DatabaseDescriptor.daemonInitialization();
+         executor = new TestTaskExecutor();
+     }
+ 
+     @After
+     public void destroy() throws Exception
+     {
+         executor.shutdown();
+         executor.awaitTermination(1, TimeUnit.MINUTES);
+     }
+ 
+     @Test
+     public void testFailedRunnable() throws Exception
+     {
+         testTaskThrowable = null;
+         Future<?> tt = executor.submitIfRunning(
+             () -> { assert false : "testFailedRunnable"; }
+             , "compactionExecutorTest");
+ 
+         while (!tt.isDone())
+             Thread.sleep(10);
+         assertNotNull(testTaskThrowable);
+         assertEquals(testTaskThrowable.getMessage(), "testFailedRunnable");
+     }
+ 
+     @Test
+     public void testFailedCallable() throws Exception
+     {
+         testTaskThrowable = null;
+         Future<?> tt = executor.submitIfRunning(
+             () -> { assert false : "testFailedCallable"; return 1; }
+             , "compactionExecutorTest");
+ 
+         while (!tt.isDone())
+             Thread.sleep(10);
+         assertNotNull(testTaskThrowable);
+         assertEquals(testTaskThrowable.getMessage(), "testFailedCallable");
+     }
+ 
+     @Test
+     public void testExceptionRunnable() throws Exception
+     {
+         testTaskThrowable = null;
+         Future<?> tt = executor.submitIfRunning(
+         () -> { throw new RuntimeException("testExceptionRunnable"); }
+         , "compactionExecutorTest");
+ 
+         while (!tt.isDone())
+             Thread.sleep(10);
+         assertNotNull(testTaskThrowable);
+         assertEquals(testTaskThrowable.getMessage(), "testExceptionRunnable");
+     }
+ }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message