Skip to content

Commit 163d14c

Browse files
committed
revert e2e
1 parent e6106da commit 163d14c

File tree

1 file changed

+0
-142
lines changed

1 file changed

+0
-142
lines changed

tests/e2e/test_driver.py

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -808,148 +808,6 @@ def test_catalogs_returns_arrow_table(self):
808808
results = cursor.fetchall_arrow()
809809
assert isinstance(results, pyarrow.Table)
810810

811-
def test_close_connection_closes_cursors(self):
812-
813-
from databricks.sql.thrift_api.TCLIService import ttypes
814-
815-
with self.connection() as conn:
816-
cursor = conn.cursor()
817-
cursor.execute(
818-
"SELECT id, id `id2`, id `id3` FROM RANGE(1000000) order by RANDOM()"
819-
)
820-
ars = cursor.active_result_set
821-
822-
# We must manually run this check because thrift_backend always forces `has_been_closed_server_side` to True
823-
824-
# Cursor op state should be open before connection is closed
825-
status_request = ttypes.TGetOperationStatusReq(
826-
operationHandle=ars.command_id, getProgressUpdate=False
827-
)
828-
op_status_at_server = ars.thrift_backend._client.GetOperationStatus(
829-
status_request
830-
)
831-
assert (
832-
op_status_at_server.operationState
833-
!= ttypes.TOperationState.CLOSED_STATE
834-
)
835-
836-
conn.close()
837-
838-
# When connection closes, any cursor operations should no longer exist at the server
839-
with pytest.raises(SessionAlreadyClosedError) as cm:
840-
op_status_at_server = ars.thrift_backend._client.GetOperationStatus(
841-
status_request
842-
)
843-
844-
def test_closing_a_closed_connection_doesnt_fail(self, caplog):
845-
caplog.set_level(logging.DEBUG)
846-
# Second .close() call is when this context manager exits
847-
with self.connection() as conn:
848-
# First .close() call is explicit here
849-
conn.close()
850-
851-
assert "Session appears to have been closed already" in caplog.text
852-
853-
conn = None
854-
try:
855-
with pytest.raises(KeyboardInterrupt):
856-
with self.connection() as c:
857-
conn = c
858-
raise KeyboardInterrupt("Simulated interrupt")
859-
finally:
860-
if conn is not None:
861-
assert (
862-
not conn.open
863-
), "Connection should be closed after KeyboardInterrupt"
864-
865-
def test_cursor_close_properly_closes_operation(self):
866-
"""Test that Cursor.close() properly closes the active operation handle on the server."""
867-
with self.connection() as conn:
868-
cursor = conn.cursor()
869-
try:
870-
cursor.execute("SELECT 1 AS test")
871-
assert cursor.active_op_handle is not None
872-
cursor.close()
873-
assert cursor.active_op_handle is None
874-
assert not cursor.open
875-
finally:
876-
if cursor.open:
877-
cursor.close()
878-
879-
conn = None
880-
cursor = None
881-
try:
882-
with self.connection() as c:
883-
conn = c
884-
with pytest.raises(KeyboardInterrupt):
885-
with conn.cursor() as cur:
886-
cursor = cur
887-
raise KeyboardInterrupt("Simulated interrupt")
888-
finally:
889-
if cursor is not None:
890-
assert (
891-
not cursor.open
892-
), "Cursor should be closed after KeyboardInterrupt"
893-
894-
def test_nested_cursor_context_managers(self):
895-
"""Test that nested cursor context managers properly close operations on the server."""
896-
with self.connection() as conn:
897-
with conn.cursor() as cursor1:
898-
cursor1.execute("SELECT 1 AS test1")
899-
assert cursor1.active_op_handle is not None
900-
901-
with conn.cursor() as cursor2:
902-
cursor2.execute("SELECT 2 AS test2")
903-
assert cursor2.active_op_handle is not None
904-
905-
# After inner context manager exit, cursor2 should be not open
906-
assert not cursor2.open
907-
assert cursor2.active_op_handle is None
908-
909-
# After outer context manager exit, cursor1 should be not open
910-
assert not cursor1.open
911-
assert cursor1.active_op_handle is None
912-
913-
def test_cursor_error_handling(self):
914-
"""Test that cursor close handles errors properly to prevent orphaned operations."""
915-
with self.connection() as conn:
916-
cursor = conn.cursor()
917-
918-
cursor.execute("SELECT 1 AS test")
919-
920-
op_handle = cursor.active_op_handle
921-
922-
assert op_handle is not None
923-
924-
# Manually close the operation to simulate server-side closure
925-
conn.thrift_backend.close_command(op_handle)
926-
927-
cursor.close()
928-
929-
assert not cursor.open
930-
931-
def test_result_set_close(self):
932-
"""Test that ResultSet.close() properly closes operations on the server and handles state correctly."""
933-
with self.connection() as conn:
934-
cursor = conn.cursor()
935-
try:
936-
cursor.execute("SELECT * FROM RANGE(10)")
937-
938-
result_set = cursor.active_result_set
939-
assert result_set is not None
940-
941-
initial_op_state = result_set.op_state
942-
943-
result_set.close()
944-
945-
assert result_set.op_state == result_set.thrift_backend.CLOSED_OP_STATE
946-
assert result_set.op_state != initial_op_state
947-
948-
# Closing the result set again should be a no-op and not raise exceptions
949-
result_set.close()
950-
finally:
951-
cursor.close()
952-
953811

954812
# use a RetrySuite to encapsulate these tests which we'll typically want to run together; however keep
955813
# the 429/503 subsuites separate since they execute under different circumstances.

0 commit comments

Comments
 (0)