diff --git a/swh/storage/interface.py b/swh/storage/interface.py --- a/swh/storage/interface.py +++ b/swh/storage/interface.py @@ -175,33 +175,6 @@ """ ... - @deprecated - @remote_api_endpoint("content/range") - def content_get_range( - self, start: bytes, end: bytes, limit: int = 1000 - ) -> Dict[str, Any]: - """Retrieve contents within range [start, end] bound by limit. - - Note that this function may return more than one blob per hash. The - limit is enforced with multiplicity (ie. two blobs with the same hash - will count twice toward the limit). - - Args: - **start**: Starting identifier range (expected smaller - than end) - **end**: Ending identifier range (expected larger - than start) - **limit**: Limit result (default to 1000) - - Returns: - a dict with keys: - - contents [dict]: iterable of contents in between the range. - - next (bytes): There remains content in the range - starting from this next sha1 - - """ - ... - @remote_api_endpoint("content/partition") def content_get_partition( self, diff --git a/swh/storage/tests/test_cassandra.py b/swh/storage/tests/test_cassandra.py --- a/swh/storage/tests/test_cassandra.py +++ b/swh/storage/tests/test_cassandra.py @@ -351,30 +351,6 @@ def test_origin_count(self): pass - @pytest.mark.skip("Not supported by Cassandra") - def test_generate_content_get_range_limit(self): - pass - - @pytest.mark.skip("Not supported by Cassandra") - def test_generate_content_get_range_no_limit(self): - pass - - @pytest.mark.skip("Not supported by Cassandra") - def test_generate_content_get_range(self): - pass - - @pytest.mark.skip("Not supported by Cassandra") - def test_generate_content_get_range_empty(self): - pass - - @pytest.mark.skip("Not supported by Cassandra") - def test_generate_content_get_range_limit_none(self): - pass - - @pytest.mark.skip("Not supported by Cassandra") - def test_generate_content_get_range_full(self): - pass - @pytest.mark.skip("Not supported by Cassandra") def test_origin_count_with_visit_no_visits(self): pass diff --git a/swh/storage/tests/test_storage.py b/swh/storage/tests/test_storage.py --- a/swh/storage/tests/test_storage.py +++ b/swh/storage/tests/test_storage.py @@ -3852,100 +3852,6 @@ expected_contents, actual_contents, keys_to_check=keys_to_check ) - def test_generate_content_get_range(self, swh_storage, swh_contents): - """content_get_range returns complete range""" - present_contents = [c.to_dict() for c in swh_contents if c.status != "absent"] - - get_sha1s = sorted([c.sha1 for c in swh_contents if c.status != "absent"]) - start = get_sha1s[2] - end = get_sha1s[-2] - actual_result = swh_storage.content_get_range(start, end) - - assert actual_result["next"] is None - - actual_contents = actual_result["contents"] - expected_contents = [c for c in present_contents if start <= c["sha1"] <= end] - if expected_contents: - assert_contents_ok(expected_contents, actual_contents, ["sha1"]) - else: - assert actual_contents == [] - - def test_generate_content_get_range_full(self, swh_storage, swh_contents): - """content_get_range for a full range returns all available contents""" - present_contents = [c.to_dict() for c in swh_contents if c.status != "absent"] - - start = b"0" * 40 - end = b"f" * 40 - actual_result = swh_storage.content_get_range(start, end) - assert actual_result["next"] is None - - actual_contents = actual_result["contents"] - expected_contents = [c for c in present_contents if start <= c["sha1"] <= end] - if expected_contents: - assert_contents_ok(expected_contents, actual_contents, ["sha1"]) - else: - assert actual_contents == [] - - def test_generate_content_get_range_empty(self, swh_storage, swh_contents): - """content_get_range for an empty range returns nothing""" - start = b"0" * 40 - end = b"f" * 40 - actual_result = swh_storage.content_get_range(end, start) - assert actual_result["next"] is None - assert len(actual_result["contents"]) == 0 - - def test_generate_content_get_range_limit_none(self, swh_storage): - """content_get_range call with wrong limit input should fail""" - with pytest.raises(StorageArgumentException) as e: - swh_storage.content_get_range(start=None, end=None, limit=None) - - assert e.value.args == ("limit should not be None",) - - def test_generate_content_get_range_no_limit(self, swh_storage, swh_contents): - """content_get_range returns contents within range provided""" - # input the list of sha1s we want from storage - get_sha1s = sorted([c.sha1 for c in swh_contents if c.status != "absent"]) - start = get_sha1s[0] - end = get_sha1s[-1] - - # retrieve contents - actual_result = swh_storage.content_get_range(start, end) - - actual_contents = actual_result["contents"] - assert actual_result["next"] is None - assert len(actual_contents) == len(get_sha1s) - - expected_contents = [c.to_dict() for c in swh_contents if c.status != "absent"] - assert_contents_ok(expected_contents, actual_contents, ["sha1"]) - - def test_generate_content_get_range_limit(self, swh_storage, swh_contents): - """content_get_range paginates results if limit exceeded""" - contents_map = {c.sha1: c.to_dict() for c in swh_contents} - - # input the list of sha1s we want from storage - get_sha1s = sorted([c.sha1 for c in swh_contents if c.status != "absent"]) - start = get_sha1s[0] - end = get_sha1s[-1] - - # retrieve contents limited to n-1 results - limited_results = len(get_sha1s) - 1 - actual_result = swh_storage.content_get_range(start, end, limit=limited_results) - - actual_contents = actual_result["contents"] - assert actual_result["next"] == get_sha1s[-1] - assert len(actual_contents) == limited_results - - expected_contents = [contents_map[sha1] for sha1 in get_sha1s[:-1]] - assert_contents_ok(expected_contents, actual_contents, ["sha1"]) - - # retrieve next part - actual_results2 = swh_storage.content_get_range(start=end, end=end) - assert actual_results2["next"] is None - actual_contents2 = actual_results2["contents"] - assert len(actual_contents2) == 1 - - assert_contents_ok([contents_map[get_sha1s[-1]]], actual_contents2, ["sha1"]) - @pytest.mark.parametrize("limit", [1, 7, 10, 100, 1000]) def test_origin_list(self, swh_storage, swh_origins, limit): returned_origins = []