@@ -2975,6 +2975,97 @@ pip-audit: ## 🔒 Audit Python dependencies for CVEs
2975
2975
python3 -m pip install --quiet --upgrade pip-audit && \
2976
2976
pip-audit --strict || true"
2977
2977
2978
+
2979
+
2980
+ # # --------------------------------------------------------------------------- ##
2981
+ # # Async Code Testing and Performance Profiling
2982
+ # # --------------------------------------------------------------------------- ##
2983
+ .PHONY : async-test async-lint profile async-monitor async-debug profile-serve
2984
+
2985
+ ASYNC_TEST_DIR := async_testing
2986
+ PROFILE_DIR := $(ASYNC_TEST_DIR ) /profiles
2987
+ REPORTS_DIR := $(ASYNC_TEST_DIR ) /reports
2988
+ VENV_PYTHON := $(VENV_DIR ) /bin/python
2989
+
2990
+ async-test : async-lint async-debug
2991
+ @echo " 🔄 Running comprehensive async safety tests..."
2992
+ @mkdir -p $(REPORTS_DIR )
2993
+ @PYTHONASYNCIODEBUG=1 $(VENV_PYTHON ) -m pytest \
2994
+ tests/ \
2995
+ --asyncio-mode=auto \
2996
+ --tb=short \
2997
+ --junitxml=$(REPORTS_DIR ) /async-test-results.xml \
2998
+ -v
2999
+
3000
+ async-lint :
3001
+ @echo " 🔍 Running async-aware linting..."
3002
+ @$(VENV_DIR ) /bin/ruff check mcpgateway/ tests/ \
3003
+ --select=F,E,B,ASYNC \
3004
+ --output-format=github
3005
+ @$(VENV_DIR ) /bin/flake8 mcpgateway/ tests/ \
3006
+ --extend-select=B,ASYNC \
3007
+ --max-line-length=100
3008
+ @$(VENV_DIR ) /bin/mypy mcpgateway/ \
3009
+ --warn-unused-coroutine \
3010
+ --strict
3011
+
3012
+ profile :
3013
+ @echo " 📊 Generating async performance profiles..."
3014
+ @mkdir -p $(PROFILE_DIR )
3015
+ @$(VENV_PYTHON ) $(ASYNC_TEST_DIR ) /profiler.py \
3016
+ --scenarios websocket,database,mcp_calls \
3017
+ --output $(PROFILE_DIR ) \
3018
+ --duration 60
3019
+ @echo " 🌐 Starting SnakeViz server..."
3020
+ @$(VENV_DIR ) /bin/snakeviz $(PROFILE_DIR ) /combined_profile.prof \
3021
+ --server --port 8080
3022
+
3023
+ profile-serve :
3024
+ @echo " 🌐 Starting SnakeViz profile server..."
3025
+ @$(VENV_DIR ) /bin/snakeviz $(PROFILE_DIR ) \
3026
+ --server --port 8080 --hostname 0.0.0.0
3027
+
3028
+ async-monitor :
3029
+ @echo " 👁️ Starting aiomonitor for live async debugging..."
3030
+ @$(VENV_PYTHON ) $(ASYNC_TEST_DIR ) /monitor_runner.py \
3031
+ --webui_port 50101 \
3032
+ --console_port 50102 \
3033
+ --host localhost \
3034
+ --console-enabled
3035
+
3036
+ async-debug :
3037
+ @echo " 🐛 Running async tests with debug mode..."
3038
+ @PYTHONASYNCIODEBUG=1 $(VENV_PYTHON ) -X dev \
3039
+ -m pytest tests/ \
3040
+ --asyncio-mode=auto \
3041
+ --capture=no \
3042
+ -v
3043
+
3044
+ async-benchmark :
3045
+ @echo " ⚡ Running async performance benchmarks..."
3046
+ @$(VENV_PYTHON ) $(ASYNC_TEST_DIR ) /benchmarks.py \
3047
+ --output $(REPORTS_DIR ) /benchmark-results.json \
3048
+ --iterations 1000
3049
+
3050
+ profile-compare :
3051
+ @echo " 📈 Comparing performance profiles..."
3052
+ @$(VENV_PYTHON ) $(ASYNC_TEST_DIR ) /profile_compare.py \
3053
+ --baseline $(PROFILE_DIR ) /combined_profile.prof \
3054
+ --current $(PROFILE_DIR ) /mcp_calls_profile.prof \
3055
+ --output $(REPORTS_DIR ) /profile-comparison.json
3056
+
3057
+ async-validate :
3058
+ @echo " ✅ Validating async code patterns..."
3059
+ @$(VENV_PYTHON ) $(ASYNC_TEST_DIR ) /async_validator.py \
3060
+ --source mcpgateway/ \
3061
+ --report $(REPORTS_DIR ) /async-validation.json
3062
+
3063
+ async-clean :
3064
+ @echo " 🧹 Cleaning async testing artifacts..."
3065
+ @rm -rf $(PROFILE_DIR ) /* $(REPORTS_DIR ) /*
3066
+ @pkill -f " aiomonitor" || true
3067
+ @pkill -f " snakeviz" || true
3068
+
2978
3069
# # --------------------------------------------------------------------------- ##
2979
3070
# # Gitleaks (Go binary - separate installation)
2980
3071
# # --------------------------------------------------------------------------- ##
0 commit comments