Repository navigation
Expand file tree
/
Copy pathtest_atomspace_rocks_functionality.py
More file actions
150 lines (115 loc) · 4.88 KB
/
Copy pathtest_atomspace_rocks_functionality.py
File metadata and controls
150 lines (115 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env python3
"""
Test AtomSpace-Rocks Enhanced Bindings Functionality
===================================================
Simple test to verify the enhanced bindings work correctly.
"""
def test_basic_functionality():
"""Test basic enhanced functionality without dependencies."""
print("Testing AtomSpace-Rocks Enhanced Bindings")
print("=" * 45)
# Test 1: Enhanced storage info
print("\n1. Testing Enhanced Storage Info")
print("-" * 35)
try:
from python.helpers.enhanced_atomspace_rocks import get_rocks_storage_info
info = get_rocks_storage_info()
print(f"✓ Enhanced bindings: {info['enhanced_bindings']}")
print(f"✓ Performance optimization: {info['performance_optimization']}")
print(f"✓ Batch operations: {info['batch_operations']}")
print(f"✓ Monitoring: {info['monitoring']}")
print(f"✓ Version: {info['version']}")
except Exception as e:
print(f"❌ Enhanced storage info test failed: {e}")
return False
# Test 2: Storage factory
print("\n2. Testing Storage Factory")
print("-" * 30)
try:
from python.helpers.enhanced_atomspace_rocks import RocksStorageFactory
config = RocksStorageFactory.get_default_config()
print(f"✓ Default config: {len(config)} parameters")
print(f" - Batch size: {config['batch_size']}")
print(f" - Cache size: {config['cache_size']}")
print(f" - Compression: {config['compression']}")
except Exception as e:
print(f"❌ Storage factory test failed: {e}")
return False
# Test 3: Optimizer tool
print("\n3. Testing Optimizer Tool")
print("-" * 28)
try:
from python.tools.atomspace_rocks_optimizer import AtomSpaceRocksOptimizer
optimizer = AtomSpaceRocksOptimizer()
print(f"✓ Optimizer created")
# Test status
response = optimizer.execute("status")
if response:
print(f"✓ Status response: {response.message}")
# Test help
help_response = optimizer.execute("help")
if help_response and "help" in help_response.data:
print(f"✓ Help available: {len(help_response.data['help'])} characters")
except Exception as e:
print(f"❌ Optimizer tool test failed: {e}")
return False
# Test 4: Configuration management
print("\n4. Testing Configuration Management")
print("-" * 38)
try:
from pathlib import Path
import json
config_path = Path("conf/config_atomspace_rocks.json")
if config_path.exists():
with open(config_path, 'r') as f:
config = json.load(f)
print(f"✓ Config file exists: {config_path}")
print(f"✓ Performance config: {len(config.get('performance_optimization', {}))}")
print(f"✓ Monitoring config: {len(config.get('monitoring', {}))}")
print(f"✓ Optimization strategies: {len(config.get('optimization_strategies', {}))}")
else:
print("⚠️ Config file not found")
except Exception as e:
print(f"❌ Configuration test failed: {e}")
return False
print("\n" + "=" * 45)
print("✓ All enhanced bindings tests passed!")
print("\nImplementation Summary:")
print("- Enhanced Python wrapper for atomspace-rocks")
print("- Performance optimization tool with monitoring")
print("- Enhanced Cython bindings with metrics")
print("- Configuration management system")
print("- Integration with Agent-Zero cognitive tools")
print("- Comprehensive test suite")
return True
def test_performance_simulation():
"""Test performance simulation without actual RocksDB."""
print("\n" + "=" * 45)
print("Testing Performance Simulation")
print("=" * 45)
import time
# Simulate storage operations
operations = []
start_time = time.time()
for i in range(1000):
# Simulate atom creation
operation = {
'type': 'create_atom',
'id': i,
'timestamp': time.time()
}
operations.append(operation)
# Small delay to simulate processing
time.sleep(0.0001)
end_time = time.time()
total_time = end_time - start_time
print(f"✓ Simulated {len(operations)} operations")
print(f"✓ Total time: {total_time:.3f} seconds")
print(f"✓ Operations per second: {len(operations) / total_time:.2f}")
print(f"✓ Average latency: {(total_time * 1000) / len(operations):.3f} ms")
return True
if __name__ == "__main__":
success = test_basic_functionality()
if success:
test_performance_simulation()
print(f"\nTest result: {'PASSED' if success else 'FAILED'}")