You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by ka...@apache.org on 2018/02/13 08:50:18 UTC
[1/2] storm git commit: STORM-2841 Use extended class instead of
partial mock for TestHiveBolt
Repository: storm
Updated Branches:
refs/heads/1.x-branch 3cfb6bb0a -> a689d78f8
STORM-2841 Use extended class instead of partial mock for TestHiveBolt
* while mocking partially, oddly it calls real method intermittently which breaks test
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/daa715c7
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/daa715c7
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/daa715c7
Branch: refs/heads/1.x-branch
Commit: daa715c705b9f076fd33c9d40407c9006bcd95a6
Parents: 3cfb6bb
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Mon Feb 12 17:55:48 2018 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Tue Feb 13 17:48:53 2018 +0900
----------------------------------------------------------------------
.../apache/storm/hive/bolt/TestHiveBolt.java | 33 ++++++++++++++------
1 file changed, 23 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/daa715c7/external/storm-hive/src/test/java/org/apache/storm/hive/bolt/TestHiveBolt.java
----------------------------------------------------------------------
diff --git a/external/storm-hive/src/test/java/org/apache/storm/hive/bolt/TestHiveBolt.java b/external/storm-hive/src/test/java/org/apache/storm/hive/bolt/TestHiveBolt.java
index a223c41..f7cd046 100644
--- a/external/storm-hive/src/test/java/org/apache/storm/hive/bolt/TestHiveBolt.java
+++ b/external/storm-hive/src/test/java/org/apache/storm/hive/bolt/TestHiveBolt.java
@@ -19,6 +19,7 @@
package org.apache.storm.hive.bolt;
import org.apache.storm.Config;
+import org.apache.storm.hive.common.HiveWriter;
import org.apache.storm.task.GeneralTopologyContext;
import org.apache.storm.task.OutputCollector;
import org.apache.storm.topology.TopologyBuilder;
@@ -45,7 +46,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;
@@ -306,6 +306,23 @@ public class TestHiveBolt {
bolt.cleanup();
}
+ private static class FlushFailureHiveBolt extends HiveBolt {
+
+ public FlushFailureHiveBolt(HiveOptions options) {
+ super(options);
+ }
+
+ @Override
+ void flushAllWriters(boolean rollToNext) throws HiveWriter.CommitFailure, HiveWriter.TxnBatchFailure, HiveWriter.TxnFailure,
+ InterruptedException {
+ if (rollToNext) {
+ throw new InterruptedException();
+ } else {
+ super.flushAllWriters(false);
+ }
+ }
+ }
+
@Test
public void testNoAcksIfFlushFails() throws Exception
{
@@ -316,24 +333,20 @@ public class TestHiveBolt {
.withTxnsPerBatch(2)
.withBatchSize(2);
- HiveBolt spyBolt = Mockito.spy(new HiveBolt(hiveOptions));
-
- //This forces a failure of all the flush attempts
- doThrow(new InterruptedException()).when(spyBolt).flushAllWriters(true);
-
+ HiveBolt failingBolt = new FlushFailureHiveBolt(hiveOptions);
- spyBolt.prepare(config, null, new OutputCollector(collector));
+ failingBolt.prepare(config, null, new OutputCollector(collector));
Tuple tuple1 = generateTestTuple(1,"SJC","Sunnyvale","CA");
Tuple tuple2 = generateTestTuple(2,"SFO","San Jose","CA");
- spyBolt.execute(tuple1);
- spyBolt.execute(tuple2);
+ failingBolt.execute(tuple1);
+ failingBolt.execute(tuple2);
verify(collector, never()).ack(tuple1);
verify(collector, never()).ack(tuple2);
- spyBolt.cleanup();
+ failingBolt.cleanup();
}
@Test
[2/2] storm git commit: Merge branch 'STORM-2841-1.x-merge' into
1.x-branch
Posted by ka...@apache.org.
Merge branch 'STORM-2841-1.x-merge' into 1.x-branch
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/a689d78f
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/a689d78f
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/a689d78f
Branch: refs/heads/1.x-branch
Commit: a689d78f81e8783b442fc96ef2cbc7295c7a931d
Parents: 3cfb6bb daa715c
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Tue Feb 13 17:48:57 2018 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Tue Feb 13 17:48:57 2018 +0900
----------------------------------------------------------------------
.../apache/storm/hive/bolt/TestHiveBolt.java | 33 ++++++++++++++------
1 file changed, 23 insertions(+), 10 deletions(-)
----------------------------------------------------------------------