Test that a session gets closed if it has no active connections for more than disconnected_session_timeout.
(self)
| 34 | @pytest.mark.execute_serially |
| 35 | @CustomClusterTestSuite.with_args("--disconnected_session_timeout=1") |
| 36 | def test_disconnected_session_timeout(self): |
| 37 | """Test that a session gets closed if it has no active connections for more than |
| 38 | disconnected_session_timeout.""" |
| 39 | conn = HS2TestSuite() |
| 40 | conn.setup() |
| 41 | open_session_req = TCLIService.TOpenSessionReq() |
| 42 | open_session_resp = conn.hs2_client.OpenSession(open_session_req) |
| 43 | HS2TestSuite.check_response(open_session_resp) |
| 44 | conn.session_handle = open_session_resp.sessionHandle |
| 45 | # Ren a query, which should succeed. |
| 46 | conn.execute_statement("select 1") |
| 47 | |
| 48 | # Set up another connection and run a long-running query with the same session. |
| 49 | conn2 = HS2TestSuite() |
| 50 | conn2.setup() |
| 51 | conn2.session_handle = open_session_resp.sessionHandle |
| 52 | execute_resp = conn2.execute_statement("select sleep(10000)") |
| 53 | |
| 54 | # Close one connection and wait for longer than disconnected_session_timeout. The |
| 55 | # session should still be available since there's still one active connection. |
| 56 | conn2.teardown() |
| 57 | sleep(5) |
| 58 | conn.execute_statement("select 3") |
| 59 | |
| 60 | # Close the other connection and sleep again. THe session shuold now be closed. |
| 61 | conn.teardown() |
| 62 | sleep(5) |
| 63 | conn.setup() |
| 64 | |
| 65 | # Run another query, which should fail since the session is closed. |
| 66 | conn.execute_statement("select 2", expected_error_prefix="Invalid session id", |
| 67 | expected_status_code=TCLIService.TStatusCode.ERROR_STATUS) |
| 68 | conn.teardown() |
| 69 | |
| 70 | # Check that the query was cancelled correctly. |
| 71 | query_id = operation_id_to_query_id(execute_resp.operationHandle.operationId) |
| 72 | status = self.cluster.get_first_impalad().service.get_query_status(query_id) |
| 73 | assert status == "Session closed because it has no active connections" |
| 74 | |
| 75 | @pytest.mark.execute_serially |
| 76 | @CustomClusterTestSuite.with_args("--idle_session_timeout=1 " |
nothing calls this directly
no test coverage detected