Skip to content
This repository was archived by the owner on Feb 18, 2026. It is now read-only.

Commit fabdf4d

Browse files
committed
Add Loki-based migration test generation and timing reports
- Add script to fetch API calls from Loki logs and generate pytest tests - Add migration timing report fixture to compare old vs new server performance - Consolidate migration test targets in Makefile - Use logging instead of print statements for linter compliance
1 parent 02ca495 commit fabdf4d

7 files changed

Lines changed: 775 additions & 202 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,6 @@ gsrest/plugins
9393

9494
.ruff_cache/
9595
local
96+
tests/test_loki_generated.py
97+
tests/loki_generated_calls.json
98+
tests/migration_timing_report.json

Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,19 @@ test-reset-cassandra-image:
2424
test-regression:
2525
@export SKIP_REST_CONTAINER_SETUP=True && uv run pytest -m "regression" -s
2626

27-
# Migration testing targets
28-
test-migration: setup-migration-worktree
29-
@echo "Starting migration test pipeline..."
30-
@./scripts/run_migration_tests.sh $(WORKTREE_DIR) $(OLD_SERVER_PORT) $(NEW_SERVER_PORT)
27+
# Loki-based migration test generation
28+
generate-migration-tests:
29+
uv run scripts/generate_migration_tests_from_loki.py
30+
31+
# Migration testing - compares old vs new server responses
32+
# Requires both servers running: make serve-old (terminal 1), make serve-new (terminal 2)
33+
# Generates timing report at tests/migration_timing_report.json
34+
# Runs both manual tests (test_fastapi_migration.py) and Loki-generated tests (test_loki_generated.py)
35+
test-migration:
36+
@export SKIP_REST_CONTAINER_SETUP=True && \
37+
export OLD_SERVER=http://localhost:$(OLD_SERVER_PORT) && \
38+
export NEW_SERVER=http://localhost:$(NEW_SERVER_PORT) && \
39+
uv run pytest tests/test_fastapi_migration.py tests/test_loki_generated.py -v -m "migration" --override-ini="addopts="
3140

3241
setup-migration-worktree:
3342
@if [ ! -d "$(WORKTREE_DIR)" ]; then \
@@ -100,4 +109,4 @@ tag-version: ensure-versions-alignment
100109
-git diff --exit-code && git diff --staged --exit-code && git tag -a v$(GS_REST_SERVICE_VERSIONM) -m 'Release v$(GS_REST_SERVICE_VERSION)' || (echo "Repo is dirty please commit first" && exit 1)
101110
git diff --exit-code && git diff --staged --exit-code && git tag -a v$(GS_REST_SERVICE_VERSION) -m 'Release v$(GS_REST_SERVICE_VERSION)' || (echo "Repo is dirty please commit first" && exit 1)
102111

103-
.PHONY: format lint test ensure-versions-alignment run-codegen serve serve-docker pre-commit install-dev tag-version generate-python-client build-docker build-test-cassandra test-reset-cassandra-image test-migration setup-migration-worktree clean-migration-worktree serve-old serve-new test-regression
112+
.PHONY: format lint test ensure-versions-alignment run-codegen serve serve-docker pre-commit install-dev tag-version generate-python-client build-docker build-test-cassandra test-reset-cassandra-image test-migration setup-migration-worktree clean-migration-worktree serve-old serve-new test-regression generate-migration-tests

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "gsrest"
33
version = "1.16.0rc2"
44
description = "GraphSense API REST API"
55
readme = "README.md"
6-
keywords = ["OpenAPI", "GraphSense API"]
6+
keywords = ["GraphSense API"]
77
requires-python = ">=3.10"
88
license-files = ["LICENSE"]
99
license = "MIT"
@@ -17,7 +17,6 @@ dependencies = [
1717
"fastapi>=0.115.0",
1818
"graphsense-lib[conversions,tagpacks]>=2.8.9",
1919
"httpx>=0.27.0",
20-
"openapi-schema-validator>=0.2.3",
2120
"python-dateutil>=2.9.0",
2221
"redis>=7.1.0",
2322
"uvicorn[standard]>=0.32.0",
@@ -33,7 +32,7 @@ requires = ["setuptools>=61.0", "wheel"]
3332
build-backend = "setuptools.build_meta"
3433

3534
[tool.setuptools.packages.find]
36-
include = ["gsrest*", "openapi_server.models*"]
35+
include = ["gsrest*"]
3736
exclude = ["clients*", "tests*", "scripts*", "gsrest.test", "gsrest.test.*"]
3837

3938
[tool.setuptools]
@@ -45,6 +44,7 @@ asyncio_default_fixture_loop_scope = "function"
4544
markers = [
4645
"regression: mark test as regression test",
4746
"migration: mark test as FastAPI migration comparison test",
47+
"loki_generated: mark test as generated from Loki API logs",
4848
]
4949
addopts = "-m 'not regression and not migration'"
5050
testpaths = [

0 commit comments

Comments
 (0)