mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-16 23:41:43 +00:00
test: qualify integration cleanup and replay invocation
This commit is contained in:
parent
92e0b72e2d
commit
d7c13625e9
2 changed files with 11 additions and 10 deletions
|
|
@ -14,7 +14,7 @@ guard6_installed=false
|
|||
cleanup() {
|
||||
original_status=$?
|
||||
trap - EXIT INT TERM
|
||||
.venv/bin/python .circleci/scripts/stop_integration_processes.py "$integration_identity" \
|
||||
sudo .venv/bin/python .circleci/scripts/stop_integration_processes.py "$integration_identity" "$(id -u)" \
|
||||
> "$results/process-cleanup.txt" 2>&1 || original_status=1
|
||||
for owned_pid in "$proxy_pid" "$upstream_pid"; do
|
||||
if [ -n "$owned_pid" ]; then
|
||||
|
|
@ -128,7 +128,8 @@ with httpx.Client(trust_env=False, timeout=2) as client:
|
|||
PY
|
||||
|
||||
if [ "$suite" = providers ]; then
|
||||
INTEGRATION_RUN_ID="$integration_identity" .venv/bin/python -m pytest --noconftest -p no:pytest-retry -p no:rerunfailures --timeout=30 \
|
||||
INTEGRATION_RUN_ID="$integration_identity" .venv/bin/python -m pytest --noconftest -o addopts= \
|
||||
--strict-markers --strict-config -p no:pytest-retry -p no:rerunfailures --timeout=30 \
|
||||
tests/e2e/test_provider_edge.py::TestReplayMode::test_content_drift_returns_the_miss_status_naming_both_keys \
|
||||
tests/e2e/test_provider_edge.py::TestReplayMode::test_exhausted_key_returns_the_miss_status \
|
||||
tests/e2e/test_provider_edge.py::TestReplayLeftover::test_partially_consumed_recording_names_the_leftover \
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
import os
|
||||
import sys
|
||||
from typing import Final
|
||||
|
||||
import psutil
|
||||
|
||||
|
||||
def owned_processes(identity: str) -> tuple[psutil.Process, ...]:
|
||||
def owned_processes(identity: str, owner_uid: int) -> tuple[psutil.Process, ...]:
|
||||
owned: Final[list[psutil.Process]] = []
|
||||
for process in psutil.process_iter(["uids"]):
|
||||
if process.info["uids"].real != os.getuid():
|
||||
if process.info["uids"].real != owner_uid:
|
||||
continue
|
||||
try:
|
||||
if process.environ().get("INTEGRATION_RUN_ID") == identity:
|
||||
|
|
@ -18,25 +17,26 @@ def owned_processes(identity: str) -> tuple[psutil.Process, ...]:
|
|||
return tuple(owned)
|
||||
|
||||
|
||||
def main(identity: str) -> int:
|
||||
owned: Final = owned_processes(identity)
|
||||
def main(identity: str, owner_uid: int) -> int:
|
||||
assert owner_uid > 0, "The integration process owner must be a non-root UID"
|
||||
owned: Final = owned_processes(identity, owner_uid)
|
||||
for process in owned:
|
||||
try:
|
||||
process.terminate()
|
||||
except psutil.NoSuchProcess:
|
||||
continue
|
||||
psutil.wait_procs(owned, timeout=8)
|
||||
remaining: Final = owned_processes(identity)
|
||||
remaining: Final = owned_processes(identity, owner_uid)
|
||||
for process in remaining:
|
||||
try:
|
||||
process.kill()
|
||||
except psutil.NoSuchProcess:
|
||||
continue
|
||||
psutil.wait_procs(remaining, timeout=2)
|
||||
survivors: Final = owned_processes(identity)
|
||||
survivors: Final = owned_processes(identity, owner_uid)
|
||||
print(f"Owned integration processes: {len(owned)}, forced: {len(remaining)}, remaining: {len(survivors)}")
|
||||
return 1 if remaining or survivors else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main(sys.argv[1]))
|
||||
raise SystemExit(main(sys.argv[1], int(sys.argv[2])))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue