mdayakar commented on code in PR #6168:
URL: https://github.com/apache/hive/pull/6168#discussion_r2498519891
##########
service/src/test/org/apache/hive/service/cli/TestCLIServiceConnectionLimits.java:
##########
@@ -345,6 +347,83 @@ public void testConnectionForwardedIpAddresses() throws
HiveSQLException {
}
}
+ @Test
+ public void testConnectionLimitPerUserWhenSessionCreationFails() throws
HiveSQLException {
+ conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_LIMIT_CONNECTIONS_PER_USER,
2);
+
conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_LIMIT_CONNECTIONS_PER_IPADDRESS,
0);
+
conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_LIMIT_CONNECTIONS_PER_USER_IPADDRESS,
0);
+ CLIService service = getService(conf);
+ 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");
+ try {
+ // Here limit is set as 2 but if session creation fails it shouldn't
increment the count
+ for (int i = 0; i < 3 + 1; i++) {
+ try {
+ service.openSession(CLIService.SERVER_VERSION, "foo", "bar",
IPStackUtils.resolveLoopbackAddress(),
+ sessionConf);
+ } catch (HiveSQLException he) {
+ 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",
+ he.getMessage());
+ }
+ }
+ } finally {
+ service.stop();
+ }
+ }
+
+ @Test
+ public void testConnectionLimitPerIpAddressWhenSessionCreationFails() throws
HiveSQLException {
+ conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_LIMIT_CONNECTIONS_PER_USER,
0);
+
conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_LIMIT_CONNECTIONS_PER_IPADDRESS,
2);
+
conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_LIMIT_CONNECTIONS_PER_USER_IPADDRESS,
0);
+ CLIService service = getService(conf);
+ 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");
+ try {
+ // Here limit is set as 2 but if session creation fails it shouldn't
increment the count
+ for (int i = 0; i < 3 + 1; i++) {
+ try {
+ service.openSession(CLIService.SERVER_VERSION, "foo", "bar",
IPStackUtils.resolveLoopbackAddress(),
+ sessionConf);
+ } catch (HiveSQLException he) {
+ 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",
+ he.getMessage());
+ }
+ }
+ } finally {
+ service.stop();
+ }
+ }
+
+ @Test
+ public void testConnectionLimitPerUserIpAddressWhenSessionCreationFails()
throws HiveSQLException {
+ conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_LIMIT_CONNECTIONS_PER_USER,
0);
+
conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_LIMIT_CONNECTIONS_PER_IPADDRESS,
0);
+
conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_LIMIT_CONNECTIONS_PER_USER_IPADDRESS,
2);
+ CLIService service = getService(conf);
+ 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");
+ try {
+ // Here limit is set as 2 but if session creation fails it shouldn't
increment the count
+ for (int i = 0; i < 3 + 1; i++) {
+ try {
+ service.openSession(CLIService.SERVER_VERSION, "foo", "bar",
IPStackUtils.resolveLoopbackAddress(), sessionConf);
+ } catch (HiveSQLException he) {
+ 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",
+ he.getMessage());
+ }
+ }
+ } finally {
+ service.stop();
+ }
+ }
Review Comment:
Done.
--
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]