Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /CIRISAI_CIRISAgent /tests /test_all_startup_fixes.py
| #!/usr/bin/env python3 | |
| """ | |
| Final comprehensive test to verify all startup fixes. | |
| Tests: | |
| 1. Full initialization | |
| 2. Wakeup processor starts without errors | |
| 3. Clean shutdown | |
| """ | |
| import asyncio | |
| import os | |
| import sys | |
| import tempfile | |
| # Add parent directory to path for imports | |
| sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| import logging | |
| from ciris_engine.logic.runtime.ciris_runtime import CIRISRuntime | |
| from ciris_engine.logic.utils.shutdown_manager import request_global_shutdown | |
| from ciris_engine.schemas.config.essential import EssentialConfig | |
| # Set up logging | |
| logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") | |
| logger = logging.getLogger(__name__) | |
| async def test_full_startup_and_wakeup(): | |
| """Test complete startup including wakeup sequence.""" | |
| # Create a temporary directory for test data | |
| with tempfile.TemporaryDirectory() as temp_dir: | |
| # Ensure directory is writable | |
| os.chmod(temp_dir, 0o777) | |
| # Save and set environment variables for test (restore after) | |
| saved_data_dir = os.environ.get("CIRIS_DATA_DIR") | |
| saved_api_key = os.environ.get("OPENAI_API_KEY") | |
| os.environ["CIRIS_DATA_DIR"] = temp_dir | |
| os.environ["OPENAI_API_KEY"] = "test-key" | |
| try: | |
| logger.info("Creating runtime...") | |
| config = EssentialConfig() | |
| runtime = CIRISRuntime( | |
| adapter_types=["cli"], | |
| essential_config=config, | |
| startup_channel_id="test-channel", | |
| adapter_configs={}, | |
| mock_llm=True, | |
| timeout=5, | |
| ) | |
| logger.info("Initializing runtime...") | |
| await runtime.initialize() | |
| logger.info("✓ Runtime initialized!") | |
| # Start processing to test wakeup | |
| logger.info("Starting agent processor...") | |
| processor_task = asyncio.create_task(runtime.agent_processor.start_processing(num_rounds=3)) | |
| # Let it run for a few seconds | |
| await asyncio.sleep(3) | |
| # Check status | |
| if hasattr(runtime.agent_processor, "wakeup_processor"): | |
| status = runtime.agent_processor.wakeup_processor.get_status() | |
| logger.info(f"Wakeup processor status: {status}") | |
| if "error" not in str(status): | |
| logger.info("✓ Wakeup processor running without errors!") | |
| else: | |
| logger.error("❌ Wakeup processor has errors") | |
| return False | |
| # Request shutdown | |
| logger.info("Requesting shutdown...") | |
| request_global_shutdown("Test completed") | |
| # Cancel processor | |
| processor_task.cancel() | |
| try: | |
| await processor_task | |
| except asyncio.CancelledError: | |
| pass | |
| # Shutdown | |
| await runtime.shutdown() | |
| logger.info("✓ Shutdown completed!") | |
| logger.info("\n✅ ALL TESTS PASSED!") | |
| logger.info("\nThe CIRIS Agent now:") | |
| logger.info(" ✓ Initializes all services correctly") | |
| logger.info(" ✓ Registers TimeService in ServiceRegistry") | |
| logger.info(" ✓ Stores and retrieves identity properly") | |
| logger.info(" ✓ Starts wakeup sequence without validation errors") | |
| logger.info(" ✓ Uses async shutdown functions correctly") | |
| logger.info(" ✓ Handles Task schema without metadata field") | |
| logger.info(" ✓ Shuts down services in correct order") | |
| logger.info("\nThe agent is ready for use!") | |
| return True | |
| except Exception as e: | |
| logger.error(f"\n❌ TEST FAILED: {e}", exc_info=True) | |
| return False | |
| finally: | |
| # Restore environment variables | |
| if saved_data_dir is not None: | |
| os.environ["CIRIS_DATA_DIR"] = saved_data_dir | |
| else: | |
| os.environ.pop("CIRIS_DATA_DIR", None) | |
| if saved_api_key is not None: | |
| os.environ["OPENAI_API_KEY"] = saved_api_key | |
| else: | |
| os.environ.pop("OPENAI_API_KEY", None) | |
| async def main(): | |
| """Run the test.""" | |
| success = await test_full_startup_and_wakeup() | |
| sys.exit(0 if success else 1) | |
| if __name__ == "__main__": | |
| asyncio.run(main()) | |
Xet Storage Details
- Size:
- 4.45 kB
- Xet hash:
- bb166fe323a11d56c912d4c3c97bda7d359e0780061a4f6c3600e3dfd777d62f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.