mdayakar commented on code in PR #6168:
URL: https://github.com/apache/hive/pull/6168#discussion_r2498527801


##########
service/src/test/org/apache/hive/service/cli/session/TestSessionManagerMetrics.java:
##########
@@ -396,4 +397,45 @@ public void testAbandonedSessionMetrics() throws Exception 
{
     } while (!expectedValue.equals(currentValue) && --count > 0);
     Assert.assertEquals(expectedValue, currentValue);
   }
+
+  @Test
+  public void testSessionLimitsPerUserWhenSessionCreationFails() throws 
Exception {
+    sm.start();
+    HashMap<String, String> sessionConf = new HashMap<>(1);
+    // modifying this property at runtime is not allowed, it will throw 
exception and session will not be created
+    sessionConf.put("hive.in.test", "true");
+    for (int i = 0; i < 3; i++) {
+      try {
+        sm.openSession(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V9, "user", 
"passw", "127.0.0.1", sessionConf);
+      } catch (HiveSQLException e) {
+        // Here 'hive.server2.limit.connections.per.user' property value set 
as 2 so when we create 3 sessions, for all 3 sessions it should throw exception 
with failure reason
+        // It should not throw exception with 'Connection limit per user 
reached (user: user limit: 2)' message
+        if (i == 0 || i == 1) {
+          Assert.assertEquals(
+              "Failed to open new session: Cannot modify hive.in.test at 
runtime. It is in the list of parameters that can't be modified at runtime or 
is prefixed by a restricted variable",
+              e.getMessage());
+        }
+        // for the 3rd session creation also it should throw exception with 
actual failure reason, should not throw exception with limit reason.
+        if (i == 2) {
+          Assert.assertNotEquals("Connection limit per user reached (user: 
user limit: 2)", e.getMessage());
+          Assert.assertEquals(
+              "Failed to open new session: Cannot modify hive.in.test at 
runtime. It is in the list of parameters that can't be modified at runtime or 
is prefixed by a restricted variable",
+              e.getMessage());

Review Comment:
   Actually here my intension is during 3rd session creation/opening it should 
not throw connection limit exception, should throw only the actual reason for 
not opening the session. Anyway I also felt now this is not required, anyway 
proper java comments added above so removed it.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to