mdayakar commented on code in PR #6168:
URL: https://github.com/apache/hive/pull/6168#discussion_r2498931197
##########
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());
+ }
+ }
+ }
+ SessionHandle handle = null;
+ // After 3 unsuccessful session creation now with session creation with
proper details should be able to create the session
+ try {
+ handle = sm.openSession(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V9,
"user", "passw", "127.0.0.1",
+ new HashMap<String, String>());
+ } catch (Exception e) {
+ Assert.fail("Should not throw exception, session should be created
successfully. " + e.getMessage());
+ }
Review Comment:
Removed the catch.
--
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]