diff --git a/checks/remotesettings/uptake_max_age.py b/checks/remotesettings/uptake_max_age.py index cda067c8..8b2c30e0 100644 --- a/checks/remotesettings/uptake_max_age.py +++ b/checks/remotesettings/uptake_max_age.py @@ -96,6 +96,9 @@ async def run( age_percentiles = rows[0]["age_percentiles"] + if len(set(age_percentiles)) < 2: + return True, {"percentiles": "Not enough data during this period."} + percentiles = {} for percentile, max_value in max_percentiles.items(): value = age_percentiles[int(percentile)] diff --git a/tests/checks/remotesettings/test_uptake_max_age.py b/tests/checks/remotesettings/test_uptake_max_age.py index 98d99dc6..416e42db 100644 --- a/tests/checks/remotesettings/test_uptake_max_age.py +++ b/tests/checks/remotesettings/test_uptake_max_age.py @@ -39,6 +39,24 @@ async def test_positive_no_data(): assert data["percentiles"] == "No broadcast data during this period." +async def test_positive_single_row(): + with patch_async( + f"{MODULE}.fetch_bigquery", + return_value=[ + { + "channel": "release", + "age_percentiles": [23 for i in range(100)], + "min_timestamp": datetime.fromisoformat("2019-09-16T02:36:12.348"), + "max_timestamp": datetime.fromisoformat("2019-09-16T06:24:58.741"), + }, + ], + ): + status, data = await run(max_percentiles={"50": 42}, channels=["aurora"]) + + assert status is True + assert data["percentiles"] == "Not enough data during this period." + + async def test_negative(): with patch_async(f"{MODULE}.fetch_bigquery", return_value=FAKE_ROWS): status, data = await run(max_percentiles={"10": 99})