mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
make it great agin
This commit is contained in:
@ -1,7 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from datetime import timedelta
|
|
||||||
from enum import StrEnum, auto
|
from enum import StrEnum, auto
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from typing import Concatenate, ParamSpec, TypeVar
|
from typing import Concatenate, ParamSpec, TypeVar
|
||||||
@ -10,7 +9,7 @@ from flask import current_app, request
|
|||||||
from flask_login import user_logged_in
|
from flask_login import user_logged_in
|
||||||
from flask_restx import Resource
|
from flask_restx import Resource
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from sqlalchemy import select, update
|
from sqlalchemy import select
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from werkzeug.exceptions import Forbidden, NotFound, Unauthorized
|
from werkzeug.exceptions import Forbidden, NotFound, Unauthorized
|
||||||
|
|
||||||
|
|||||||
@ -206,8 +206,8 @@ class TestApiTokenCacheRedisIntegration:
|
|||||||
|
|
||||||
def test_concurrent_cache_access(self):
|
def test_concurrent_cache_access(self):
|
||||||
"""Test concurrent cache access doesn't cause issues."""
|
"""Test concurrent cache access doesn't cause issues."""
|
||||||
from unittest.mock import MagicMock
|
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
mock_token = MagicMock()
|
mock_token = MagicMock()
|
||||||
mock_token.id = "test-id"
|
mock_token.id = "test-id"
|
||||||
@ -389,7 +389,6 @@ class TestEndToEndCacheFlow:
|
|||||||
2. Second request (cache hit) -> return from cache
|
2. Second request (cache hit) -> return from cache
|
||||||
3. Verify Redis state
|
3. Verify Redis state
|
||||||
"""
|
"""
|
||||||
from unittest.mock import MagicMock
|
|
||||||
|
|
||||||
test_token_value = "test-e2e-token"
|
test_token_value = "test-e2e-token"
|
||||||
test_scope = "app"
|
test_scope = "app"
|
||||||
@ -441,8 +440,8 @@ class TestEndToEndCacheFlow:
|
|||||||
|
|
||||||
def test_high_concurrency_simulation(self):
|
def test_high_concurrency_simulation(self):
|
||||||
"""Simulate high concurrency access to cache."""
|
"""Simulate high concurrency access to cache."""
|
||||||
from unittest.mock import MagicMock
|
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
test_token_value = "test-concurrent-token"
|
test_token_value = "test-concurrent-token"
|
||||||
test_scope = "app"
|
test_scope = "app"
|
||||||
@ -478,7 +477,7 @@ class TestEndToEndCacheFlow:
|
|||||||
assert elapsed < 1.0, f"Too slow: {elapsed}s for 100 cache reads"
|
assert elapsed < 1.0, f"Too slow: {elapsed}s for 100 cache reads"
|
||||||
|
|
||||||
print(f"\n✓ 100 concurrent cache reads in {elapsed:.3f}s")
|
print(f"\n✓ 100 concurrent cache reads in {elapsed:.3f}s")
|
||||||
print(f"✓ Average: {(elapsed/100)*1000:.2f}ms per read")
|
print(f"✓ Average: {(elapsed / 100) * 1000:.2f}ms per read")
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
# Cleanup
|
# Cleanup
|
||||||
|
|||||||
Reference in New Issue
Block a user