Skip to content

Commit

Permalink
Add more session tests (#5256)
Browse files Browse the repository at this point in the history
Co-authored-by: Sophie <[email protected]>
  • Loading branch information
Aiee and Sophie-Xie authored Jan 14, 2023
1 parent 913cb8b commit 5015bc3
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions tests/job/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def cleanup(self):
def test_sessions(self):
# 1: test add session with right username
try:
client_ok = self.client_pool.get_session('session_user', '123456')
assert client_ok is not None
user_session = self.client_pool.get_session('session_user', '123456')
assert user_session is not None
assert True
except Exception as e:
assert False, e
Expand Down Expand Up @@ -114,7 +114,7 @@ def test_sessions(self):
assert session_id != 0

# 4: test get session info
resp = client_ok.execute('USE nba')
resp = user_session.execute('USE nba')
self.check_resp_succeeded(resp)

# wait for session sync.
Expand Down Expand Up @@ -158,6 +158,16 @@ def test_sessions(self):
self.check_resp_succeeded(resp)
time.sleep(3)

# 6: test privilege
# show sessions with non-root user, only the root user can show all sessions
try:
non_root_session = self.client_pool.get_session('session_user', '123456')
assert non_root_session is not None
resp = non_root_session.execute('SHOW SESSIONS')
self.check_resp_failed(resp)
except Exception as e:
assert False, e

def test_the_same_id_to_different_graphd(self):

conn1 = self.get_connection(self.addr_host1, self.addr_port1)
Expand Down Expand Up @@ -431,15 +441,8 @@ def test_kill_session_multi_graph(self):
self.check_resp_succeeded(ResultSet(resp, 0))
assert user1_session_num == len(ResultSet(resp, 0).rows()) + 1

# execute query with the killed session
resp = conn2.execute(
session_id2,
'SHOW HOSTS',
)
# the session has not been synced to host2, so the query should succeed
self.check_resp_succeeded(ResultSet(resp, 0))

# wait for the session to be synced (in test session_reclaim_interval_secs=2)
# and execute a query with the killed session
time.sleep(4)
resp = conn2.execute(
session_id2,
Expand Down

0 comments on commit 5015bc3

Please sign in to comment.