Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more session tests #5256

Merged
merged 2 commits into from
Jan 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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