|
| 1 | +""" |
| 2 | +Valkey-search integration tests for Dragonfly |
| 3 | +
|
| 4 | +This module automatically adapts original valkey-search tests to run on Dragonfly |
| 5 | +by replacing valkeytestframework imports with Dragonfly equivalents. |
| 6 | +""" |
| 7 | + |
| 8 | +import sys |
| 9 | +import types |
| 10 | +import os |
| 11 | +from . import util |
| 12 | +from .integration import compatibility |
| 13 | + |
| 14 | +# Add current directory to path for imports |
| 15 | +current_dir = os.path.dirname(os.path.abspath(__file__)) |
| 16 | +if current_dir not in sys.path: |
| 17 | + sys.path.insert(0, current_dir) |
| 18 | + |
| 19 | +# Import the Dragonfly-specific test case classes |
| 20 | +exec(open(os.path.join(current_dir, "valkey_search_test_case_dragonfly.py")).read()) |
| 21 | + |
| 22 | +# Create a mock module for valkey_search_test_case |
| 23 | +mock_module = types.ModuleType("valkey_search_test_case") |
| 24 | +mock_module.ValkeySearchTestCaseBase = ValkeySearchTestCaseBase |
| 25 | +mock_module.ValkeySearchTestCaseDebugMode = ValkeySearchTestCaseDebugMode |
| 26 | +mock_module.ValkeySearchClusterTestCase = ValkeySearchClusterTestCase |
| 27 | +mock_module.ValkeySearchClusterTestCaseDebugMode = ValkeySearchClusterTestCaseDebugMode |
| 28 | +mock_module.Node = Node |
| 29 | +mock_module.ReplicationGroup = ReplicationGroup |
| 30 | + |
| 31 | +# Replace the module in sys.modules |
| 32 | +sys.modules["valkey_search_test_case"] = mock_module |
| 33 | + |
| 34 | +# Also need to provide valkeytestframework modules |
| 35 | +valkey_test_framework = types.ModuleType("valkeytestframework") |
| 36 | + |
| 37 | +valkey_test_case = types.ModuleType("valkeytestframework.valkey_test_case") |
| 38 | +valkey_test_case.ValkeyTestCase = ValkeyTestCase |
| 39 | +valkey_test_case.ReplicationTestCase = ReplicationTestCase |
| 40 | +valkey_test_case.ValkeyServerHandle = ValkeyServerHandle |
| 41 | + |
| 42 | +util_module = types.ModuleType("valkeytestframework.util") |
| 43 | +waiters_module = types.ModuleType("valkeytestframework.util.waiters") |
| 44 | + |
| 45 | +waiters_module.wait_for_true = util.waiters.wait_for_true |
| 46 | +waiters_module.wait_for_equal = util.waiters.wait_for_equal |
| 47 | +waiters_module.wait_for_not_equal = util.waiters.wait_for_not_equal |
| 48 | +waiters_module.wait_for_condition = util.waiters.wait_for_condition |
| 49 | +util_module.waiters = waiters_module |
| 50 | + |
| 51 | +# Also add direct util module access |
| 52 | +sys.modules["util"] = util_module |
| 53 | +sys.modules["util.waiters"] = waiters_module |
| 54 | + |
| 55 | +conftest_module = types.ModuleType("valkeytestframework.conftest") |
| 56 | +conftest_module.resource_port_tracker = types.ModuleType("resource_port_tracker") |
| 57 | + |
| 58 | +# Setup compatibility as a module in sys.modules |
| 59 | +sys.modules["compatibility"] = compatibility |
| 60 | + |
| 61 | +# Also set up the submodules |
| 62 | +if hasattr(compatibility, "data_sets"): |
| 63 | + sys.modules["compatibility.data_sets"] = compatibility.data_sets |
| 64 | + |
| 65 | +# Add all modules to sys.modules |
| 66 | +sys.modules["valkeytestframework"] = valkey_test_framework |
| 67 | +sys.modules["valkeytestframework.valkey_test_case"] = valkey_test_case |
| 68 | +sys.modules["valkeytestframework.util"] = util_module |
| 69 | +sys.modules["valkeytestframework.util.waiters"] = waiters_module |
| 70 | +sys.modules["valkeytestframework.conftest"] = conftest_module |
0 commit comments