From 5ff4b8b5f83a040090e752b05ea352cd0604f876 Mon Sep 17 00:00:00 2001 From: Alejo Sanchez Date: Fri, 18 Nov 2022 11:11:14 +0100 Subject: [PATCH] pytest: catch rare exception for random tables test On rare occassions a SELECT on a DROPpped table throws cassandra.ReadFailure instead of cassandra.InvalidRequest. This could not be reproduced locally. Catch both exceptions as the table is not present anyway and it's correctly marked as a failure. Signed-off-by: Alejo Sanchez Closes #12027 --- test/topology/test_random_tables.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/topology/test_random_tables.py b/test/topology/test_random_tables.py index 4860ac8dc5..df49ea3253 100644 --- a/test/topology/test_random_tables.py +++ b/test/topology/test_random_tables.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later # import pytest -from cassandra.protocol import InvalidRequest # type: ignore +from cassandra.protocol import InvalidRequest, ReadFailure # type: ignore # Simple test of schema helper @@ -24,7 +24,9 @@ async def test_new_table(manager, random_tables): assert len(res) == 1 assert list(res[0])[:2] == vals await random_tables.drop_table(table) - with pytest.raises(InvalidRequest, match='unconfigured table'): + # NOTE: On rare occasions the exception is ReadFailure + with pytest.raises((InvalidRequest, ReadFailure), + match='(unconfigured table|failed to execute read)'): await cql.run_async(f"SELECT * FROM {table}") await random_tables.verify_schema()