hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pv...@apache.org
Subject hive git commit: HIVE-20964: Create a test that checks the level of the parallel compilation (Peter Vary, reviewed by Denys Kuzmenko and Marta Kuczora)
Date Fri, 23 Nov 2018 09:23:28 GMT
Repository: hive
Updated Branches:
  refs/heads/master 16d58e5a6 -> 0fee288e0


HIVE-20964: Create a test that checks the level of the parallel compilation (Peter Vary, reviewed
by Denys Kuzmenko and Marta Kuczora)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/0fee288e
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/0fee288e
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/0fee288e

Branch: refs/heads/master
Commit: 0fee288e0ced19c8f3849ae6279dbf7dd2d38f09
Parents: 16d58e5
Author: Peter Vary <pvary@cloudera.com>
Authored: Fri Nov 23 10:22:30 2018 +0100
Committer: Peter Vary <pvary@cloudera.com>
Committed: Fri Nov 23 10:22:30 2018 +0100

----------------------------------------------------------------------
 .../apache/hadoop/hive/ql/TestCompileLock.java  | 46 ++++++++++++++++++--
 1 file changed, 43 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/0fee288e/ql/src/test/org/apache/hadoop/hive/ql/TestCompileLock.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/TestCompileLock.java b/ql/src/test/org/apache/hadoop/hive/ql/TestCompileLock.java
index 8dc05ff..a9917cf 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/TestCompileLock.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/TestCompileLock.java
@@ -64,6 +64,8 @@ import static org.mockito.Matchers.eq;
 public class TestCompileLock {
 
   private static final int CONCURRENT_COMPILATION = 15151;
+  private static final String SHORT_QUERY = "<SHORT_QUERY>";
+  private static final String LONG_QUERY = "<LONG_QUERY>";
 
   private Driver driver;
   private HiveConf conf;
@@ -90,7 +92,13 @@ public class TestCompileLock {
       Thread.sleep(500);
       verifyThatWaitingCompileOpsCountIsEqualTo(count.decrementAndGet());
       return null;
-    }).when(driver).compile(eq("<QUERY>"), eq(true), eq(false));
+    }).when(driver).compile(eq(SHORT_QUERY), eq(true), eq(false));
+
+    Mockito.doAnswer(invocation -> {
+      Thread.sleep(5000);
+      verifyThatWaitingCompileOpsCountIsEqualTo(count.decrementAndGet());
+      return null;
+    }).when(driver).compile(eq(LONG_QUERY), eq(true), eq(false));
   }
 
   @Test
@@ -161,6 +169,23 @@ public class TestCompileLock {
     verifyThatTimedOutCompileOpsCountIsNotZero(responseList);
   }
 
+  /**
+   * Test that checks that the queries above the quota are timed out, so the compilation
quota maximum is honored.
+   * @throws Exception
+   */
+  @Test
+  public void testParallelCompilationTimeoutWithMultipleQuota() throws Exception {
+    conf.setBoolVar(HIVE_SERVER2_PARALLEL_COMPILATION, true);
+    conf.setIntVar(HIVE_SERVER2_PARALLEL_COMPILATION_LIMIT, 4);
+    conf.setTimeVar(HIVE_SERVER2_COMPILE_LOCK_TIMEOUT, 1, TimeUnit.SECONDS);
+
+    initDriver(conf, 10);
+    List<CommandProcessorResponse> responseList = compileAndRespond(LONG_QUERY, 10);
+
+    verifyThatWaitingCompileOpsCountIsEqualTo(0);
+    verifyThatTimedOutCompileOpsCount(responseList, 6);
+  }
+
   @Test
   public void testParallelCompilationWithSingleQuotaAndZeroTimeout() throws Exception {
     conf.setBoolVar(HIVE_SERVER2_PARALLEL_COMPILATION, true);
@@ -220,10 +245,20 @@ public class TestCompileLock {
   }
 
   private List<CommandProcessorResponse> compileAndRespond(int threadCount) throws
Exception {
-    return compileAndRespond(false, threadCount);
+    return compileAndRespond(SHORT_QUERY, false, threadCount);
   }
 
   private List<CommandProcessorResponse> compileAndRespond(boolean reuseSession, int
threadCount) throws Exception {
+    return compileAndRespond(SHORT_QUERY, reuseSession, threadCount);
+  }
+
+
+  private List<CommandProcessorResponse> compileAndRespond(String query, int threadCount)
throws Exception {
+    return compileAndRespond(query, false, threadCount);
+  }
+
+  private List<CommandProcessorResponse> compileAndRespond(String query, boolean reuseSession,
int threadCount)
+      throws Exception {
     List<CommandProcessorResponse> responseList = new ArrayList<>();
     SessionState sessionState = new SessionState(conf);
 
@@ -235,7 +270,7 @@ public class TestCompileLock {
 
         CommandProcessorResponse response;
         try{
-          response = driver.compileAndRespond("<QUERY>");
+          response = driver.compileAndRespond(query);
 
         } finally {
           SessionState.detachSession();
@@ -292,6 +327,11 @@ public class TestCompileLock {
         is(not(equalTo(0))), responseList);
   }
 
+  private void verifyThatTimedOutCompileOpsCount(List<CommandProcessorResponse> responseList,
int count) {
+    verifyErrorCount(ErrorMsg.COMPILE_LOCK_TIMED_OUT.getErrorCode(),
+        is(equalTo(count)), responseList);
+  }
+
   private void verifyThatConcurrentCompilationWasIndeed(List<CommandProcessorResponse>
responseList){
     verifyErrorCount(CONCURRENT_COMPILATION,
         is(not(equalTo(0))), responseList);


Mime
View raw message