You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by gs...@apache.org on 2026/10/13 03:45:01 UTC
(tooling-llmao) 09/09: tests: split what was left of test_entitlements by what it tests
This is an automated email from the ASF dual-hosted git repository.
gstein pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-llmao.git
commit e3b27cc0c957fc4a61484081a21d3da3299cb077
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Mon Oct 12 22:42:06 2026 -0500
tests: split what was left of test_entitlements by what it tests
With the tier tests gone, tests/test_entitlements.py held two unrelated
things under a name that fitted neither: the rolling token allowance, and
parsing a box's metrics for the contention sampler.
It is renamed tests/test_token_window.py, after the module it tests, and
the two contention tests move to tests/test_contention.py.
No test is added, dropped or changed. The contention tests import
parse_metrics once at the top of their file rather than inside each test.
Co-Authored-By: Claude Opus 5.5 <no...@anthropic.com>
---
tests/test_contention.py | 47 +++++++++++++++++++++
.../{test_entitlements.py => test_token_window.py} | 49 ++--------------------
2 files changed, 50 insertions(+), 46 deletions(-)
diff --git a/tests/test_contention.py b/tests/test_contention.py
new file mode 100644
index 0000000..1764edd
--- /dev/null
+++ b/tests/test_contention.py
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Contention sampling (llmao/contention.py).
+
+The pilot's one unanswerable-after-the-fact question: did anyone wait?
+"""
+
+from llmao.contention import parse_metrics
+
+
+def test_parse_metrics_reads_the_four_figures():
+ text = "\n".join(
+ [
+ "# HELP vllm:num_requests_running whatever",
+ 'vllm:num_requests_running{engine="0",model_name="x"} 4.0',
+ 'vllm:num_requests_waiting{engine="0",model_name="x"} 2.0',
+ 'vllm:gpu_cache_usage_perc{engine="0",model_name="x"} 0.31',
+ 'vllm:num_preemptions_total{engine="0",model_name="x"} 3.0',
+ ]
+ )
+ got = parse_metrics("gemma4-26b", text, now=1.0).as_dict()
+ assert got["running"] == 4.0
+ assert got["waiting"] == 2.0
+ assert got["preempted"] == 3.0
+ # exposed as a fraction, reported as a percentage
+ assert got["kv_pct"] == 31.0
+
+
+def test_parse_metrics_survives_an_unexpected_body():
+ """A box returning HTML, or nothing, must not stop the sampler."""
+ for body in ("", "<html>503</html>", "vllm:num_requests_running{} notanumber"):
+ got = parse_metrics("x", body, now=1.0)
+ assert got.running == 0.0
diff --git a/tests/test_entitlements.py b/tests/test_token_window.py
similarity index 73%
rename from tests/test_entitlements.py
rename to tests/test_token_window.py
index 407a918..a8b4219 100644
--- a/tests/test_entitlements.py
+++ b/tests/test_token_window.py
@@ -15,12 +15,10 @@
# specific language governing permissions and limitations
# under the License.
-"""Entitlement resolution and the rolling token allowance.
+"""The rolling token allowance (llmao/token_window.py).
-These matter more than most because the failure is silent in both
-directions. A key minted without limits looks identical to a limited one
-until something saturates the fleet; an allowance that never ages out looks
-identical to a working one until somebody's week does not reset.
+The failure here is silent: an allowance that never ages out looks identical
+to a working one until somebody's week does not reset.
"""
import datetime as dt
@@ -29,11 +27,6 @@ from llmao.token_window import RollingAllowance
UTC = dt.UTC
-
-# ---------------------------------------------------------------------------
-# The rolling allowance
-# ---------------------------------------------------------------------------
-
DAY0 = dt.datetime(2026, 9, 1, 12, tzinfo=UTC)
@@ -161,39 +154,3 @@ def test_window_length_is_honoured():
a.spend(1_000_000, DAY0)
assert a.exhausted(DAY0)
assert not a.exhausted(_at(1))
-
-
-# ---------------------------------------------------------------------------
-# Contention sampling
-#
-# The pilot's one unanswerable-after-the-fact question: did anyone wait?
-# ---------------------------------------------------------------------------
-
-
-def test_parse_metrics_reads_the_four_figures():
- from llmao.contention import parse_metrics
-
- text = "\n".join(
- [
- "# HELP vllm:num_requests_running whatever",
- 'vllm:num_requests_running{engine="0",model_name="x"} 4.0',
- 'vllm:num_requests_waiting{engine="0",model_name="x"} 2.0',
- 'vllm:gpu_cache_usage_perc{engine="0",model_name="x"} 0.31',
- 'vllm:num_preemptions_total{engine="0",model_name="x"} 3.0',
- ]
- )
- got = parse_metrics("gemma4-26b", text, now=1.0).as_dict()
- assert got["running"] == 4.0
- assert got["waiting"] == 2.0
- assert got["preempted"] == 3.0
- # exposed as a fraction, reported as a percentage
- assert got["kv_pct"] == 31.0
-
-
-def test_parse_metrics_survives_an_unexpected_body():
- """A box returning HTML, or nothing, must not stop the sampler."""
- from llmao.contention import parse_metrics
-
- for body in ("", "<html>503</html>", "vllm:num_requests_running{} notanumber"):
- got = parse_metrics("x", body, now=1.0)
- assert got.running == 0.0
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org