| |
| """ |
| Basic integration test for EV2 Service in ShinkaEvolve. |
| |
| This script tests the configuration integration without running a full evolution. |
| """ |
|
|
| import sys |
| from pathlib import Path |
|
|
| |
| sys.path.insert(0, str(Path(__file__).parent.parent)) |
|
|
| from shinka.core import EvolutionConfig |
|
|
|
|
| def test_config_backward_compatibility(): |
| """Test that default config doesn't enable eval service.""" |
| print("Test 1: Backward compatibility (default config)...") |
| |
| config = EvolutionConfig() |
| assert config.eval_service_url is None, "Default should be None" |
| |
| print(" β
Default config: eval_service_url=None") |
|
|
|
|
| def test_config_with_service(): |
| """Test that eval service can be enabled.""" |
| print("\nTest 2: Enable eval service...") |
| |
| config = EvolutionConfig( |
| eval_service_url="http://localhost:8765" |
| ) |
| assert config.eval_service_url == "http://localhost:8765" |
| |
| print(" β
Config with service: eval_service_url='http://localhost:8765'") |
|
|
|
|
| def test_config_from_kwargs(): |
| """Test that eval service can be set via kwargs.""" |
| print("\nTest 3: Set via kwargs...") |
| |
| kwargs = { |
| "num_generations": 10, |
| "max_parallel_jobs": 2, |
| "eval_service_url": "http://192.168.1.100:8000", |
| } |
| config = EvolutionConfig(**kwargs) |
| |
| assert config.num_generations == 10 |
| assert config.max_parallel_jobs == 2 |
| assert config.eval_service_url == "http://192.168.1.100:8000" |
| |
| print(" β
Kwargs config works correctly") |
|
|
|
|
| def test_notify_method_exists(): |
| """Test that _notify_eval_service method exists in EvolutionRunner.""" |
| print("\nTest 4: _notify_eval_service method exists...") |
| |
| from shinka.core import EvolutionRunner |
| |
| |
| assert hasattr(EvolutionRunner, '_notify_eval_service') |
| |
| |
| import inspect |
| sig = inspect.signature(EvolutionRunner._notify_eval_service) |
| params = list(sig.parameters.keys()) |
| |
| assert 'self' in params |
| assert 'generation' in params |
| assert 'combined_score' in params |
| assert 'results_dir' in params |
| |
| print(" β
_notify_eval_service method exists") |
| print(f" - Parameters: {params}") |
|
|
|
|
| if __name__ == "__main__": |
| print("=" * 60) |
| print("EV2 Service Integration - Basic Tests") |
| print("=" * 60) |
| |
| try: |
| test_config_backward_compatibility() |
| test_config_with_service() |
| test_config_from_kwargs() |
| test_notify_method_exists() |
| |
| print("\n" + "=" * 60) |
| print("β
All basic integration tests passed!") |
| print("=" * 60) |
| |
| except Exception as e: |
| print("\n" + "=" * 60) |
| print(f"β Test failed: {e}") |
| print("=" * 60) |
| sys.exit(1) |
|
|