|
6 | 6 | test_crud_operations.py. |
7 | 7 | """ |
8 | 8 |
|
9 | | -import asyncio |
10 | 9 | import uuid |
11 | 10 |
|
12 | 11 | import pytest |
@@ -117,51 +116,3 @@ async def test_error_handling(self, cassandra_session): |
117 | 116 | await cassandra_session.execute("INVALID SQL QUERY") |
118 | 117 | # Could be SyntaxException or InvalidRequest depending on driver version |
119 | 118 | assert "Syntax" in str(exc_info.value) or "Invalid" in str(exc_info.value) |
120 | | - |
121 | | - async def test_concurrent_queries(self, cassandra_session): |
122 | | - """Test executing multiple queries concurrently with proper patterns.""" |
123 | | - # Get the unique table name |
124 | | - users_table = cassandra_session._test_users_table |
125 | | - |
126 | | - try: |
127 | | - # Prepare statement |
128 | | - insert_stmt = await cassandra_session.prepare( |
129 | | - f""" |
130 | | - INSERT INTO {users_table} (id, name, email, age) |
131 | | - VALUES (?, ?, ?, ?) |
132 | | - """ |
133 | | - ) |
134 | | - |
135 | | - # Execute multiple queries concurrently |
136 | | - async def insert_user(i: int): |
137 | | - user_id = uuid.uuid4() |
138 | | - try: |
139 | | - await cassandra_session.execute( |
140 | | - insert_stmt, [user_id, f"Concurrent{i}", f"concurrent{i}@example.com", 30] |
141 | | - ) |
142 | | - return user_id |
143 | | - except Exception as e: |
144 | | - pytest.fail(f"Failed to insert concurrent user {i}: {e}") |
145 | | - |
146 | | - # Insert 20 users concurrently |
147 | | - try: |
148 | | - user_ids = await asyncio.gather(*[insert_user(i) for i in range(20)]) |
149 | | - except Exception as e: |
150 | | - pytest.fail(f"Failed concurrent insertion: {e}") |
151 | | - |
152 | | - # Verify all were inserted |
153 | | - select_stmt = await cassandra_session.prepare( |
154 | | - f"SELECT * FROM {users_table} WHERE id = ?" |
155 | | - ) |
156 | | - |
157 | | - for i, user_id in enumerate(user_ids): |
158 | | - try: |
159 | | - result = await cassandra_session.execute(select_stmt, [user_id]) |
160 | | - row = result.one() |
161 | | - assert row is not None |
162 | | - assert row.name == f"Concurrent{i}" |
163 | | - except Exception as e: |
164 | | - pytest.fail(f"Failed to verify concurrent user {i}: {e}") |
165 | | - |
166 | | - except Exception as e: |
167 | | - pytest.fail(f"Concurrent query test setup failed: {e}") |
0 commit comments