MCPcopy Create free account
hub / github.com/apache/impala / test_disconnected_session_timeout

Method test_disconnected_session_timeout

tests/custom_cluster/test_hs2.py:36–73  ·  view source on GitHub ↗

Test that a session gets closed if it has no active connections for more than disconnected_session_timeout.

(self)

Source from the content-addressed store, hash-verified

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 "

Callers

nothing calls this directly

Calls 9

setupMethod · 0.95
execute_statementMethod · 0.95
teardownMethod · 0.95
HS2TestSuiteClass · 0.90
operation_id_to_query_idFunction · 0.90
check_responseMethod · 0.80
get_query_statusMethod · 0.80
get_first_impaladMethod · 0.80
OpenSessionMethod · 0.45

Tested by

no test coverage detected