Commit Graph

1189 Commits

Author SHA1 Message Date
Oliver Falk
2d1fc16268 Merge branch 'robohash_optimization' into 'devel'
Optimize robohash performance with directory caching and improved algorithms

See merge request oliver/ivatar!274
2025-10-24 17:08:08 +02:00
Oliver Falk
ed4b6dc41a Add robohash performance optimization
- Add OptimizedRobohash class with directory caching and optimized file selection
- Integrate optimization into ivatar views for 2-6x performance improvement
- Add comprehensive tests covering functionality, pixel-perfect identity, and performance
- Add ROBOHASH_OPTIMIZATION_ENABLED configuration setting
- Maintain 100% compatibility with original robohash output

Performance improvements:
- Directory structure caching eliminates repeated filesystem scans
- Reduced natsort calls from 163 to ~10 per generation
- 2-6x faster generation times while maintaining identical image output
- Significantly improved concurrent throughput

Tests added:
- Functionality verification
- Pixel-perfect identical results with random email addresses
- Performance measurement across multiple configurations
- Integration testing with create_optimized_robohash function
2025-10-24 16:18:08 +02:00
Oliver Falk
497468e58e Merge branch 'master' into devel 2025-10-24 14:22:20 +02:00
Oliver Falk
96a62fe006 Merge branch 'devel' into 'master'
Enhance performance tests

See merge request oliver/ivatar!273
2025-10-24 13:51:46 +02:00
Oliver Falk
9cf1cb4745 Enhance performance tests 2025-10-24 13:51:45 +02:00
Oliver Falk
27dd40b4aa Improve CI output visibility and remove buffering
- Add flush=True to all colored_print calls for immediate output
- Add PYTHONUNBUFFERED=1 to all deployment and performance test jobs
- Replace simple sleep with countdown progress indicator
- Show 'Retrying in X seconds...' with real-time countdown
- Clear progress line after countdown completes
- Better visibility of what the script is doing during long waits
2025-10-24 13:06:57 +02:00
Oliver Falk
8fbdf35c02 Fix deployment verification: install git and improve fallback logic
- Install git in deployment verification jobs (was missing in Alpine image)
- Add string comparison fallback when git commands fail
- Safer approach: wait for deployment when commit comparison fails
- This ensures we don't run performance tests against wrong versions
- Fixes 'No such file or directory: git' error in CI
2025-10-24 12:39:08 +02:00
Oliver Falk
43b8b2abef Improve deployment verification commit checking
- Use CI_COMMIT_SHA environment variable when available (more reliable in CI)
- Add timestamp-based commit comparison as primary method
- Fallback to git merge-base for ancestry checking
- Add detailed debugging output for commit comparison
- Handle short vs long commit hash matching
- Better error handling for shallow git clones in CI
- More robust version detection and waiting logic
2025-10-24 12:07:24 +02:00
Oliver Falk
173ddaae8f Fix dev performance tests: ignore cache warnings
- Add --ignore-cache-warnings flag for dev environments
- Cache configuration may differ between dev and production
- Dev environment now ignores cache warnings to prevent false failures
- Production still validates cache performance strictly
- All other performance metrics are still validated in dev
2025-10-24 11:37:47 +02:00
Oliver Falk
03fa0fb911 Make all performance thresholds configurable for dev environment
- Add --response-threshold and --p95-threshold parameters
- Dev environment now uses relaxed thresholds:
  * Avatar generation: 2500ms (vs 1000ms prod)
  * Response time: 2500ms (vs 1000ms prod)
  * 95th percentile: 5000ms (vs 2000ms prod)
- Fixes CI failures due to dev environment being slower than production
- Production maintains strict performance standards
2025-10-24 11:16:45 +02:00
Oliver Falk
80df736433 Fix deployment verification to wait for correct version
- Modified check_deployment.py to wait for the correct commit hash
- Now retries until the expected version is deployed (not just site responding)
- Prevents performance tests from running against old versions
- Maintains existing retry logic with proper version checking
- Only runs functionality tests after version verification passes
2025-10-24 11:00:05 +02:00
Oliver Falk
7350afd988 Adjust performance thresholds for dev environment
- Add --avatar-threshold parameter to performance tests
- Set dev environment threshold to 2500ms (vs 1000ms for prod)
- Dev environments are expected to be slower due to resource constraints
- Production keeps strict 1000ms threshold for optimal performance
2025-10-24 10:41:54 +02:00
Oliver Falk
13f580023b Fix CI: Add DNS dependencies for performance test jobs
- Add dnspython and py3dns to performance test jobs
- Fixes ModuleNotFoundError: No module named 'DNS' in pyLibravatar
- Required for libravatar URL resolution in performance tests
2025-10-24 10:15:54 +02:00
Oliver Falk
5556f7bd9a Fix local performance tests: Handle Django redirects properly
- Add follow=True to Django test client requests to handle redirects
- Fix content length handling for FileResponse objects
- Local performance tests now pass correctly showing  status

This resolves the issue where all avatar generation tests were showing
'Failed' status even though they were working correctly.
2025-10-23 19:07:23 +02:00
Oliver Falk
81582bcf45 Fix CI pipeline: Add missing dependencies for performance tests
- Add Pillow, prettytable, and pyLibravatar to performance test jobs
- Make performance_tests.py work without Django dependencies
- Add local implementations of generate_random_email and random_string
- Fix ModuleNotFoundError: No module named 'PIL' in CI environment
- Fix flake8 redefinition warning

This resolves the pipeline failure in performance_tests_dev job.
2025-10-23 18:11:55 +02:00
Oliver Falk
ac58c9f626 Add comprehensive type hints to performance tests
🔧 Type Safety Improvements:
- Added typing imports (Dict, List, Any, Optional, Tuple)
- Added type hints to all 25+ methods and functions
- Added type annotations to class attributes and instance variables
- Added proper return type annotations

📝 Enhanced Code Quality:
- Class attributes: AVATAR_STYLES: List[str], AVATAR_SIZES: List[int]
- Method parameters: All parameters now have explicit types
- Return types: All methods have proper return type annotations
- Complex types: Tuple[float, float], List[Dict[str, Any]], etc.

��️ Safety Improvements:
- Added runtime checks for None values
- Proper error handling for uninitialized clients
- Better type safety for optional parameters
- Enhanced IDE support and error detection

 Benefits:
- Better autocomplete and refactoring support
- Types serve as inline documentation
- Catch type-related errors before runtime
- Easier maintenance and collaboration
- Follows modern Python best practices

All functionality preserved and tested successfully.
2025-10-23 15:59:59 +02:00
Oliver Falk
202ae44346 Enhance performance tests with comprehensive improvements
Major enhancements to scripts/performance_tests.py:

🚀 Features Added:
- Complete avatar style coverage (identicon, monsterid, robohash, pagan, retro, wavatar, mm, mmng)
- All sizes tested (80px, 256px) for each style
- Cache hit/miss tracking and display
- Random email generation for realistic testing
- Full libravatar URL generation using official library
- Professional table output with PrettyTable

📊 Display Improvements:
- Perfect alignment with PrettyTable library
- Visual dividers between avatar styles
- Status icons ( success, ⚠️ mixed,  failed)
- Cache status indicators (hit/miss/mixed/error)
- Email address and example URL display
- Grouped results by avatar style with averages

🔧 Technical Improvements:
- Integrated libravatar library for URL generation
- Replaced manual URL construction with proper library calls
- Enhanced error handling and reporting
- Added prettytable dependency to requirements.txt
- Improved code organization and maintainability

🎯 Testing Coverage:
- 8 avatar styles × 2 sizes = 16 test combinations
- Cache performance testing with hit/miss analysis
- Concurrent load testing with cache statistics
- Both local and remote testing modes supported

The performance tests now provide comprehensive, professional output
that's easy to read and analyze, with complete coverage of all
avatar generation functionality.
2025-10-23 15:26:38 +02:00
Oliver Falk
63dd743dca Add helper function to generate a random mail address 2025-10-22 15:53:53 +02:00
Oliver Falk
d9c3c512f4 pyupgrade and prettifier doing their job 2025-10-22 14:05:44 +02:00
Oliver Falk
b4f224cd4d Enhance the performance tests 2025-10-22 14:00:23 +02:00
Oliver Falk
671ebbdae2 Update pre-commit config 2025-10-22 14:00:18 +02:00
Oliver Falk
e87d2bcda7 Update pre-commit config 2025-10-22 13:51:34 +02:00
Oliver Falk
f0c604a523 Merge branch 'devel' 2025-10-22 12:53:42 +02:00
Oliver Falk
dead9cbd78 Merge branch 'devel' into 'master'
Add performance tests for produciton (merge latest development efforts)

See merge request oliver/ivatar!272
2025-10-22 12:52:30 +02:00
Oliver Falk
13165579e8 Add performance tests for produciton (merge latest development efforts) 2025-10-22 12:52:29 +02:00
Oliver Falk
84c209f453 Conditional django setup for local testing vs. remote testing 2025-10-22 12:39:36 +02:00
Oliver Falk
4103fcff55 Add performance tests 2025-10-22 11:56:54 +02:00
Oliver Falk
5119328346 Merge branch 'devel' into 'master'
ci: Make production deployment verification automatic

See merge request oliver/ivatar!271
2025-10-18 14:41:40 +02:00
Oliver Falk
f8f8beb52e ci: Make production deployment verification automatic
- Change verify_prod_deployment from 'when: manual' to 'when: on_success'
- Production deployment verification will now run automatically on master branch
- Ensures production deployments are verified just like dev deployments
- Maintains safety with allow_failure: false
2025-10-18 13:59:05 +02:00
Oliver Falk
8e556bb14d Merge branch 'devel' into 'master'
Fix deployment version endpoint and add comprehensive Prometheus metrics testing

See merge request oliver/ivatar!270
2025-10-18 13:53:18 +02:00
Oliver Falk
97c9b36258 feat: Add comprehensive Prometheus metrics testing for CI
- Add PrometheusMetricsIntegrationTest class with 7 comprehensive tests
- Test Prometheus server startup, custom metrics availability, and port conflict handling
- Test metrics increment, different labels, histogram metrics, and production mode
- Use random ports (9470-9570) to avoid conflicts between tests
- Make tests lenient about custom metrics timing (collection delays)
- Update OpenTelemetry configuration to handle MeterProvider conflicts gracefully
- Update documentation to clarify production vs development Prometheus usage
- Ensure metrics are properly exported via OTLP in production
- Verify comprehensive test coverage for CI environments

All 34 OpenTelemetry tests pass successfully.
2025-10-18 13:46:20 +02:00
Oliver Falk
eca9db8d16 Merge remote-tracking branch 'origin/master' into devel 2025-10-18 13:03:27 +02:00
Oliver Falk
7b34bdef87 Update cursor rules 2025-10-18 13:01:20 +02:00
Oliver Falk
c7efcb7246 Fix /deployment/version/ endpoint to show commit_date and add deployment_date
- Fix commit_date parsing from git logs (was showing 'unknown')
- Add deployment_date field using manage.py modification time
- Improve git log parsing to handle author names with spaces
- Both dates now show in proper format: YYYY-MM-DD HH:MM:SS +timezone

The endpoint now returns:
- commit_date: When the commit was made (from git logs)
- deployment_date: When the code was deployed (from file mtime)
2025-10-18 12:48:37 +02:00
Oliver Falk
fd10f66dab Merge branch 'devel' into 'master'
Get OTEL fixed

See merge request oliver/ivatar!269
2025-10-18 12:30:38 +02:00
Oliver Falk
b9fbf37308 Get OTEL fixed 2025-10-18 12:30:37 +02:00
Oliver Falk
6f39be3b6d Keep OTEL enabled - last merge disabled it again 2025-10-18 11:32:09 +02:00
Oliver Falk
4c5c4ab8fa Merge master into devel - resolve OpenTelemetry middleware conflict 2025-10-18 11:31:26 +02:00
Oliver Falk
4aeacf9fab Fix traces 2025-10-18 11:15:40 +02:00
Oliver Falk
d228674d4b Fix test with DjangoInstrumentor 2025-10-18 11:08:40 +02:00
Oliver Falk
c3c4a23619 Enable OTEL again, but only in one place 2025-10-18 11:00:49 +02:00
Oliver Falk
45387a1a43 Merge branch 'devel' into 'master'
Merge latest devel fixes

See merge request oliver/ivatar!268
2025-10-17 16:56:14 +02:00
Oliver Falk
8b2675591e Merge latest devel fixes 2025-10-17 16:56:13 +02:00
Oliver Falk
54426c84bc Merge branch 'master' into devel 2025-10-17 16:54:54 +02:00
Oliver Falk
a10a73c56e Do not add the OTEL middleware currently 2025-10-17 16:54:04 +02:00
Oliver Falk
f699a66236 Temporarily disable Django instrumentation to test Host header issue
- Comment out DjangoInstrumentor().instrument() to test if it's causing duplicate Host headers
- Remove unused DjangoInstrumentor import
- Keep other instrumentation (database, HTTP client) enabled
- This is a temporary test to isolate the Host header duplication issue
2025-10-17 15:42:53 +02:00
Oliver Falk
ac9c8fcbc3 Merge devel into master - resolve OpenTelemetry conflict
- Resolve merge conflict in opentelemetry_config.py
- Keep improved OSError handling for 'Address in use' error
- Include latest OpenTelemetry multiple initialization fix
2025-10-17 14:57:48 +02:00
Oliver Falk
ad4e5068b9 Fix OpenTelemetry multiple initialization issue
- Add _ot_initialized flag to prevent multiple setup calls
- Make setup_opentelemetry() idempotent
- Handle 'Address in use' error gracefully for Prometheus server
- Prevent OpenTelemetry setup failures due to multiple initialization
2025-10-17 14:56:15 +02:00
Oliver Falk
684cdca4e4 Merge branch 'devel' into 'master'
Enhance the version endpoint and fix OTEL deployment

See merge request oliver/ivatar!267
2025-10-17 14:49:10 +02:00
Oliver Falk
6db3450b20 Enhance the version endpoint and fix OTEL deployment 2025-10-17 14:49:10 +02:00