From b5a1bc7db7b1f1aeade285aeffbffcb860bdaafb Mon Sep 17 00:00:00 2001 From: Aiee <18348405+Aiee@users.noreply.github.com> Date: Fri, 13 Jan 2023 17:37:52 +0800 Subject: [PATCH] Add more session tests --- tests/job/test_session.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/job/test_session.py b/tests/job/test_session.py index 5c524c0b58b..2d36c8878bd 100644 --- a/tests/job/test_session.py +++ b/tests/job/test_session.py @@ -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 @@ -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. @@ -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) @@ -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,