From 43ce0aef3df746a04356dbe293a8ff9a0548a67a Mon Sep 17 00:00:00 2001 From: Nadav Har'El Date: Sun, 13 Dec 2020 16:36:12 +0200 Subject: [PATCH] alternator test: fix test wrongly failing on AWS The test test_query_filter.py::test_query_filter_paging fails on AWS and shouldn't fail, so this patch fixes the test. Note that this is only a test problem - no fix is needed for Alternator itself. The test reads 20 results with 1-result pages, and assumed that 21 pages are returned. The 21st page may happen because when the server returns the 20th, it might not yet know there will be no additional results, so another page is needed - and will be empty. Still a different implementation might notice that the last page completed the iteration, and not return an extra empty page. This is perfectly fine, and this is what AWS DynamoDB does today - and should not be considered an error. Refs #7778 Signed-off-by: Nadav Har'El Message-Id: <20201213143612.2761943-1-nyh@scylladb.com> --- test/alternator/test_query_filter.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/alternator/test_query_filter.py b/test/alternator/test_query_filter.py index 3919efce7d..28712817a5 100644 --- a/test/alternator/test_query_filter.py +++ b/test/alternator/test_query_filter.py @@ -529,11 +529,15 @@ def test_query_filter_paging(test_table_sn_with_data): Limit=1) expected_items = [item for item in items if item['bool'] == True] assert(got_items == expected_items) - # We expect the number of pages to be len(items)+1. The "+1" is because - # the 20th page found one last item to consider (it may or may not have - # passed the filter), but doesn't know it is really the last item - it - # takes one more query to discover there are no more. - assert(pages == len(items) + 1) + # The total number of pages may be len(items) or len(items)+1, depending + # on the implementation: The "+1" can happen if the 20th page found one + # last item to consider (it may or may not have passed the filter), but + # doesn't know it is really the last item - it may take one more query to + # discover there are no more. Currently, Alternator returns len(items)+1 + # while DynamoDB returns len(items), but neither is more correct than the + # other - nor should any user case about this difference, as empty pages + # are a documented possibility. + assert(pages == len(items) or pages == len(items) + 1) # Test that a QueryFilter and AttributesToGet may be given together. # In particular, test that QueryFilter may inspect attributes which will