aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/statistics
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-04-17 14:40:30 +0200
committerJon Bratseth <bratseth@oath.com>2018-04-17 14:40:30 +0200
commitc8cdfb65631a6814f2d85e18171badc9144ed33e (patch)
treef807a0a4a9fd288c658611e36e5e9bb25e740b65 /container-search/src/test/java/com/yahoo/search/statistics
parent6b9f956080484c22e894ee0ccd2692c2f442a333 (diff)
Remove usage of junit.framework
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/statistics')
-rw-r--r--container-search/src/test/java/com/yahoo/search/statistics/ElapsedTimeTestCase.java25
-rw-r--r--container-search/src/test/java/com/yahoo/search/statistics/TimingSearcherTestCase.java12
2 files changed, 29 insertions, 8 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/statistics/ElapsedTimeTestCase.java b/container-search/src/test/java/com/yahoo/search/statistics/ElapsedTimeTestCase.java
index 42a6a7e00d0..e9bb2365de1 100644
--- a/container-search/src/test/java/com/yahoo/search/statistics/ElapsedTimeTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/statistics/ElapsedTimeTestCase.java
@@ -10,17 +10,20 @@ import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
-import com.yahoo.search.statistics.ElapsedTime;
-import com.yahoo.search.statistics.TimeTracker;
import com.yahoo.search.statistics.TimeTracker.Activity;
import com.yahoo.search.statistics.TimeTracker.SearcherTimer;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
/**
* Check sanity of TimeTracker and ElapsedTime.
*
- * @author <a href="steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
*/
-public class ElapsedTimeTestCase extends TestCase {
+public class ElapsedTimeTestCase {
private static final long[] SEARCH_TIMESEQUENCE = new long[] { 1L, 2L, 3L, 4L, 5L, 6L, 7L };
@@ -137,6 +140,7 @@ public class ElapsedTimeTestCase extends TestCase {
}
}
+ @Test
public void testBasic() {
TimeTracker t = new TimeTracker(null);
t.injectTimeSource(new CreativeTimeSource(new long[] {1L, 2L, 3L, 4L}));
@@ -155,6 +159,7 @@ public class ElapsedTimeTestCase extends TestCase {
assertEquals(3L, t.totalTime());
}
+ @Test
public void testMultiSearchAndPing() {
TimeTracker t = new TimeTracker(null);
t.injectTimeSource(new CreativeTimeSource(new long[] {1L, 4L, 16L, 32L, 64L, 128L, 256L}));
@@ -193,6 +198,7 @@ public class ElapsedTimeTestCase extends TestCase {
assertEquals(2L, e.firstFill());
}
+ @Test
public void testBasicBreakdown() {
TimeTracker t = new TimeTracker(new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
@@ -212,6 +218,7 @@ public class ElapsedTimeTestCase extends TestCase {
// This test is to make sure the other tests correctly simulate the call
// order into the TimeTracker
+ @Test
public void testBasicBreakdownFullyWiredIn() {
Chain<? extends Searcher> chain = new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
@@ -238,6 +245,7 @@ public class ElapsedTimeTestCase extends TestCase {
assertEquals(Long.valueOf(1L), searchers[0 + offset].getReturning(Activity.SEARCH));
}
+ @Test
public void testBasicBreakdownWithFillFullyWiredIn() {
Chain<? extends Searcher> chain = new Chain<>(
new UselessSearcher("first"), new UselessSearcher("second"),
@@ -266,6 +274,7 @@ public class ElapsedTimeTestCase extends TestCase {
assertEquals(Long.valueOf(1L), searchers[0 + offset].getReturning(Activity.FILL));
}
+ @Test
public void testBasicBreakdownFullyWiredInFirstSearcherNotFirstInChain() {
Chain<? extends Searcher> chain = new Chain<>(
new TestingSearcher(),
@@ -275,6 +284,7 @@ public class ElapsedTimeTestCase extends TestCase {
exec.search(new Query());
}
+ @Test
public void testBasicBreakdownWithFillFullyWiredInFirstSearcherNotFirstInChain() {
Chain<? extends Searcher> chain = new Chain<>(
new SecondTestingSearcher(),
@@ -284,6 +294,7 @@ public class ElapsedTimeTestCase extends TestCase {
exec.search(new Query());
}
+ @Test
public void testTimingWithShortChain() {
Chain<? extends Searcher> chain = new Chain<>(
new ShortChainTestingSearcher(),
@@ -292,6 +303,7 @@ public class ElapsedTimeTestCase extends TestCase {
exec.search(new Query());
}
+ @Test
public void testBasicBreakdownReturnInsideSearchChain() {
TimeTracker t = new TimeTracker(new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
@@ -313,6 +325,7 @@ public class ElapsedTimeTestCase extends TestCase {
assertEquals(Long.valueOf(1L) ,searchers[0].getReturning(Activity.SEARCH));
}
+ @Test
public void testBasicBreakdownWithFill() {
TimeTracker t = new TimeTracker(new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
@@ -343,7 +356,6 @@ public class ElapsedTimeTestCase extends TestCase {
assertEquals(Long.valueOf(1L), searchers[0].getReturning(Activity.FILL));
}
-
private void runSomeTraffic(TimeTracker t) {
t.injectTimeSource(new CreativeTimeSource(new long[] {
1L, 2L, 3L,
@@ -383,6 +395,7 @@ public class ElapsedTimeTestCase extends TestCase {
t.sampleSearchReturn(0, true, null);
}
+ @Test
public void testMixedActivity() {
TimeTracker t = new TimeTracker(new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
@@ -406,6 +419,7 @@ public class ElapsedTimeTestCase extends TestCase {
assertNull(searchers[2].getReturning(Activity.FILL));
}
+ @Test
public void testReportGeneration() {
TimeTracker t = new TimeTracker(new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
@@ -430,4 +444,5 @@ public class ElapsedTimeTestCase extends TestCase {
public static void doInjectTimeSource(TimeTracker t, TimeTracker.TimeSource s) {
t.injectTimeSource(s);
}
+
}
diff --git a/container-search/src/test/java/com/yahoo/search/statistics/TimingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/statistics/TimingSearcherTestCase.java
index fabd8ed9fa3..acdfd6370d6 100644
--- a/container-search/src/test/java/com/yahoo/search/statistics/TimingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/statistics/TimingSearcherTestCase.java
@@ -1,8 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.statistics;
-import junit.framework.TestCase;
-
import com.yahoo.component.ComponentId;
import com.yahoo.prelude.Ping;
import com.yahoo.search.Query;
@@ -12,8 +10,12 @@ import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.statistics.TimingSearcher.Parameters;
import com.yahoo.statistics.Statistics;
import com.yahoo.statistics.Value;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class TimingSearcherTestCase {
-public class TimingSearcherTestCase extends TestCase {
public static class MockValue extends Value {
public int putCount = 0;
@@ -27,6 +29,7 @@ public class TimingSearcherTestCase extends TestCase {
}
}
+ @Test
public void testMeasurementSearchPath() {
Parameters p = new Parameters("timingtest", TimeTracker.Activity.SEARCH);
TimingSearcher ts = new TimingSearcher(new ComponentId("lblblbl"), p, Statistics.nullImplementation);
@@ -45,6 +48,7 @@ public class TimingSearcherTestCase extends TestCase {
assertEquals(1, v.putCount);
}
+ @Test
public void testMeasurementFillPath() {
Parameters p = new Parameters("timingtest", TimeTracker.Activity.FILL);
TimingSearcher ts = new TimingSearcher(new ComponentId("lblblbl"), p, Statistics.nullImplementation);
@@ -63,6 +67,7 @@ public class TimingSearcherTestCase extends TestCase {
assertEquals(2, v.putCount);
}
+ @Test
public void testMeasurementPingPath() {
Parameters p = new Parameters("timingtest", TimeTracker.Activity.PING);
TimingSearcher ts = new TimingSearcher(new ComponentId("lblblbl"), p, Statistics.nullImplementation);
@@ -80,4 +85,5 @@ public class TimingSearcherTestCase extends TestCase {
exec.ping(new Ping());
assertEquals(3, v.putCount);
}
+
}