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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//! Comprehensive tests for storage backends
// NOTE: The backends and traits modules have been removed in the storage consolidation.
// These tests are preserved as dormant code for future reference.
use crate;
use crateStorageResult;
use crate*;
use Utc;
use HashMap;
use TempDir;
use Uuid;
/// Create a test session
/// Create a test event
/// Create a test checkpoint
/// Create a test DLQ item
// Test functions commented out as the UnifiedStorage trait no longer exists
// after storage consolidation
// /// Test harness for running tests against any storage backend
// async fn test_backend<T: UnifiedStorage>(storage: &T) -> StorageResult<()> {
// // Test session storage
// test_session_storage(storage.session_storage()).await?;
//
// // Test event storage
// test_event_storage(storage.event_storage()).await?;
//
// // Test checkpoint storage
// test_checkpoint_storage(storage.checkpoint_storage()).await?;
//
// // Test DLQ storage
// test_dlq_storage(storage.dlq_storage()).await?;
//
// // Test health check
// let health = storage.health_check().await?;
// assert!(health.healthy);
//
// Ok(())
// }
// /// Test session storage operations
// async fn test_session_storage(storage: &dyn SessionStorage) -> StorageResult<()> {
// let session = create_test_session("session-1");
//
// // Test save
// storage.save(&session).await?;
//
// // Test load
// let loaded = storage.load(&session.id).await?;
// assert!(loaded.is_some());
// assert_eq!(loaded.unwrap().id.0, session.id.0);
//
// // Test update state
// storage
// .update_state(&session.id, SessionState::Completed)
// .await?;
//
// // Test delete
// storage.delete(&session.id).await?;
//
// Ok(())
// }
// /// Test event storage operations
// async fn test_event_storage(storage: &dyn EventStorage) -> StorageResult<()> {
// let job_id = "test-job-1";
// let events = vec![
// create_test_event(job_id, "started"),
// create_test_event(job_id, "progress"),
// create_test_event(job_id, "completed"),
// ];
//
// // Test append
// storage.append(events).await?;
//
// // Test aggregate (may return 0 for stub implementations)
// let _stats = storage.aggregate(job_id).await?;
// // Don't assert on the exact count as it may be stubbed
//
// Ok(())
// }
// /// Test checkpoint storage operations
// async fn test_checkpoint_storage(storage: &dyn CheckpointStorage) -> StorageResult<()> {
// let checkpoint = create_test_checkpoint("checkpoint-001");
//
// // Test save
// storage.save(&checkpoint).await?;
//
// // Test load
// let loaded = storage.load(&checkpoint.id).await?;
// assert!(loaded.is_some() || loaded.is_none()); // May be stubbed
//
// // Test delete
// storage.delete(&checkpoint.id).await?;
//
// Ok(())
// }
// /// Test DLQ storage operations
// async fn test_dlq_storage(storage: &dyn DLQStorage) -> StorageResult<()> {
// let item = create_test_dlq_item("job-001");
//
// // Test enqueue
// storage.enqueue(item.clone()).await?;
//
// // Test dequeue
// let items = storage.dequeue(10).await?;
// assert!(items.is_empty() || !items.is_empty()); // May be stubbed
//
// // Test delete
// storage.delete(&item.id).await?;
//
// Ok(())
// }
// Tests are commented out as the backends module has been removed
// during storage consolidation
// #[tokio::test]
// async fn test_memory_backend() -> StorageResult<()> {
// let config = MemoryConfig {
// max_memory: 1024 * 1024 * 100, // 100MB
// persist_to_disk: false,
// persistence_path: None,
// };
// let storage = MemoryBackend::from_memory_config(&config)?;
// test_backend(&storage).await?;
// Ok(())
// }
//
// #[tokio::test]
// async fn test_file_backend() -> StorageResult<()> {
// let temp_dir = TempDir::new()?;
// let config = StorageConfig {
// backend: BackendType::File,
// connection_pool_size: 10,
// retry_policy: RetryPolicy::default(),
// timeout: std::time::Duration::from_secs(30),
// backend_config: BackendConfig::File(FileConfig {
// base_dir: temp_dir.path().to_path_buf(),
// use_global: false,
// enable_file_locks: true,
// max_file_size: 1024 * 1024 * 10, // 10MB
// enable_compression: false,
// }),
// enable_locking: true,
// enable_cache: false,
// cache_config: CacheConfig::default(),
// };
// let storage = FileBackend::new(&config).await?;
// test_backend(&storage).await?;
// Ok(())
// }