|
| 1 | +"""Test profiler with S3 and HTTPS files. |
| 2 | +
|
| 3 | +NOTE: while not in GDAL>=3.10 the number of GET/Head requests might not be right |
| 4 | +see: https://github.com/vincentsarago/vsifile/issues/13#issuecomment-2683310594 |
| 5 | +
|
| 6 | +""" |
| 7 | + |
| 8 | +import pytest |
| 9 | +from rio_tiler.io import Reader |
| 10 | + |
| 11 | +from tilebench import profile as profiler |
| 12 | + |
| 13 | + |
| 14 | +@pytest.mark.parametrize( |
| 15 | + "src_path,head,get", |
| 16 | + [ |
| 17 | + ( |
| 18 | + "s3://sentinel-cogs/sentinel-s2-l2a-cogs/15/T/VK/2023/10/S2B_15TVK_20231008_0_L2A/TCI.tif", |
| 19 | + 0, |
| 20 | + 3, |
| 21 | + ), |
| 22 | + ( |
| 23 | + "https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/15/T/VK/2023/10/S2B_15TVK_20231008_0_L2A/TCI.tif", |
| 24 | + 1, |
| 25 | + 3, |
| 26 | + ), |
| 27 | + ], |
| 28 | +) |
| 29 | +@pytest.mark.xfail |
| 30 | +def test_profiler(src_path, head, get): |
| 31 | + """Test profiler.""" |
| 32 | + config = { |
| 33 | + "AWS_NO_SIGN_REQUEST": True, |
| 34 | + "AWS_DEFAULT_REGION": "us-west-2", |
| 35 | + "GDAL_DISABLE_READDIR_ON_OPEN": "EMPTY_DIR", |
| 36 | + } |
| 37 | + |
| 38 | + @profiler( |
| 39 | + quiet=True, |
| 40 | + add_to_return=True, |
| 41 | + config=config, |
| 42 | + ) |
| 43 | + def _read_tile(src_path: str, x: int, y: int, z: int, tilesize: int = 256): |
| 44 | + with Reader(src_path) as cog: |
| 45 | + return cog.tile(x, y, z, tilesize=tilesize) |
| 46 | + |
| 47 | + (_, _), stats = _read_tile(src_path, 121, 185, 9) |
| 48 | + assert stats["HEAD"]["count"] == head |
| 49 | + assert stats["GET"]["count"] == get |
| 50 | + assert stats["GET"]["bytes"] == 386677 |
0 commit comments