commit 5cad3af56b690f4c4640638eb5c2e013d0f82be4 Author: Andrew Sherman Date: Fri Mar 2 13:22:00 2018 -0800 HIVE-18791 Fix TestJdbcWithMiniHS2#testHttpHeaderSize The test TestJdbcWithMiniHS2.testHttpHeaderSize() is testing that HS2 can be reconfigured to use different maximum sizes of http headers when Thrift uses http as its transport. In this mode the http header contains a user name and password encoded using http basic encoding. The original test varies the length of the user name to test (1) that that a too large header fails with 413 Payload Too Large, and (2) that increasing the maximum sizes of http headers allows the large header to work. In HS2 when the connection is made a Session is created (note that in this configuration the user name and password are not verified). The local scratch directory for the session uses the username as part of its path. When this name is more than 255 chars (on most modern file systems) then the directory creation will fail. HIVE-18625 made this failure newly throw an exception, which caused a regression in testHttpHeaderSize() when the session was created with a long user name. Fix this by having the test vary the password rather then the user name. The test is functionally identical but does not hit the directory creation exception. diff --git itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java index a70ef634328d85b32c6b3f353191c962ad03a0a8..f45fb5078f04fc79d2ce0de798e29878473e2821 100644 --- itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java +++ itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java @@ -960,12 +960,14 @@ public void testHttpHeaderSize() throws Exception { conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_HTTP_RESPONSE_HEADER_SIZE, 1024); startMiniHS2(conf, true); - // Username is added to the request header - String userName = StringUtils.leftPad("*", 100); + // Username and password are added to the http request header. + // We will test the reconfiguration of the header size by changing the password length. + String userName = "userName"; + String password = StringUtils.leftPad("*", 100); Connection conn = null; // This should go fine, since header should be less than the configured header size try { - conn = getConnection(miniHS2.getJdbcURL(testDbName), userName, "password"); + conn = getConnection(miniHS2.getJdbcURL(testDbName), userName, password); } catch (Exception e) { fail("Not expecting exception: " + e); } finally { @@ -976,11 +978,11 @@ public void testHttpHeaderSize() throws Exception { // This should fail with given HTTP response code 413 in error message, since header is more // than the configured the header size - userName = StringUtils.leftPad("*", 2000); + password = StringUtils.leftPad("*", 2000); Exception headerException = null; try { conn = null; - conn = getConnection(miniHS2.getJdbcURL(testDbName), userName, "password"); + conn = getConnection(miniHS2.getJdbcURL(testDbName), userName, password); } catch (Exception e) { headerException = e; } finally { @@ -1002,7 +1004,7 @@ public void testHttpHeaderSize() throws Exception { // This should now go fine, since we increased the configured header size try { conn = null; - conn = getConnection(miniHS2.getJdbcURL(testDbName), userName, "password"); + conn = getConnection(miniHS2.getJdbcURL(testDbName), userName, password); } catch (Exception e) { fail("Not expecting exception: " + e); } finally {