ChinmaySKulkarni commented on a change in pull request #749: PHOENIX-4521: 
Allow Pherf scenario to define per query max allowed query execution duration 
after which thread is interrupted
URL: https://github.com/apache/phoenix/pull/749#discussion_r405881609
 
 

 ##########
 File path: 
phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/MultiThreadedRunnerTest.java
 ##########
 @@ -0,0 +1,102 @@
+package org.apache.phoenix.pherf.workload;
+
+import org.apache.hadoop.hbase.util.Pair;
+import org.apache.phoenix.pherf.configuration.Query;
+import org.apache.phoenix.pherf.configuration.Scenario;
+import org.apache.phoenix.pherf.configuration.XMLConfigParser;
+import org.apache.phoenix.pherf.result.DataModelResult;
+import org.apache.phoenix.pherf.result.ThreadTime;
+import org.apache.phoenix.pherf.rules.RulesApplier;
+import org.apache.phoenix.util.DefaultEnvironmentEdge;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import java.sql.ResultSet;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class MultiThreadedRunnerTest {
+
+    @Test
+    public void testExpectedRowsMismatch() throws Exception {
+        XMLConfigParser mockParser = Mockito.mock(XMLConfigParser.class);
+        DataModelResult mockDMR = Mockito.mock(DataModelResult.class);
+        RulesApplier mockRA = Mockito.mock(RulesApplier.class);
+        ThreadTime mockTT = Mockito.mock(ThreadTime.class);
+        Scenario mockScenario = Mockito.mock(Scenario.class);
+        WorkloadExecutor mockWE = Mockito.mock(WorkloadExecutor.class);
+        Query mockQuery = Mockito.mock(Query.class);
+        Mockito.when(mockQuery.getExpectedAggregateRowCount()).thenReturn(1L);
+        MultiThreadedRunner mtr = new MultiThreadedRunner("test",
+                mockQuery, mockDMR, mockTT,
+                10L, 1000L,
+                true, mockRA,
+                mockScenario, mockWE, mockParser);
+        ResultSet mockRS = Mockito.mock(ResultSet.class);
+        Mockito.when(mockRS.next()).thenReturn(true);
+        Mockito.when(mockRS.getLong(1)).thenReturn(2L);
+        try {
+            mtr.getResults(mockRS, "test_iteration", false);
+            fail();
+        } catch (RuntimeException e) {
+            //pass;
+        }
+
+    }
+
+    @Test
+    public void testTimeout() throws Exception {
+        DefaultEnvironmentEdge myClock = 
Mockito.mock(DefaultEnvironmentEdge.class);
+        Mockito.when(myClock.currentTime()).thenReturn(0L,0L, 0L, 5000L); 
//currentTime() gets called twice during MTR construction
 
 Review comment:
   @christinefeng I don't think this comment is correct. There's no calls to 
`EnvironmentEdgeManager.currentTimeMillis()` inside the MTR constructor and 
later when we call mtr.getResults, there's just 2 calls: 1 for startTime and 1 
for endTime, right?
   We don't call any other method on mtr like `call`, etc. Can you please 
clarify this? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to