Skip to content

Commit 308389c

Browse files
CodingAnarchyclaude
andcommitted
feat: Add comprehensive TestQueue implementation for unit testing
Implement complete in-memory test queue functionality with MockClock for deterministic testing of job queues without database dependencies. ### Added - Complete TestQueue implementation of DatabaseQueue trait - MockClock for time-based testing control - Support for all queue operations: enqueue, dequeue, batches, workflows - Priority-aware job selection with weighted algorithms - Job dependency management and workflow execution - Comprehensive statistics and monitoring capabilities ### Fixed - Job scheduling timestamp logic to use MockClock consistently - Retry logic off-by-one error (jobs now fail after 3 attempts, not 4) - Workflow fail-fast policy implementation - Workflow status preservation for cancelled workflows - Dead job purging time comparison logic - Cron job scheduling to use 6-field format with seconds - Queue statistics to count Dead jobs as failed for reporting ### Enhanced - Delayed job execution with time control - Batch operations with PartialFailureMode support - Workflow dependency resolution and cancellation policies - Dead job management with purging and retry capabilities - Job result storage with expiration and cleanup - Throttling configuration management All 19 TestQueue integration tests now passing with full feature parity. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2f71265 commit 308389c

File tree

9 files changed

+3763
-30
lines changed

9 files changed

+3763
-30
lines changed

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,46 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.2.2] - 2025-07-01
9+
10+
### Added
11+
- **🧪 Comprehensive TestQueue Implementation**
12+
- Complete in-memory test implementation of DatabaseQueue trait for unit testing
13+
- MockClock for deterministic time-based testing of delayed jobs and cron schedules
14+
- Full support for all queue operations: enqueue, dequeue, batch operations, workflows, cron jobs
15+
- Priority-aware job selection with weighted and strict priority algorithms
16+
- Job dependency management and workflow execution testing
17+
- Comprehensive statistics and monitoring capabilities for test scenarios
18+
19+
### Enhanced
20+
- **⚡ TestQueue Feature Completeness**
21+
- Delayed job execution with time control using MockClock
22+
- Batch operations with PartialFailureMode support (ContinueOnError, FailFast)
23+
- Workflow dependency resolution and cancellation policies
24+
- Cron job scheduling with timezone support (6-field cron expressions)
25+
- Dead job management with purging and retry capabilities
26+
- Job result storage with expiration and cleanup
27+
- Throttling configuration management
28+
- Queue statistics with accurate failed/dead job counting
29+
30+
### Fixed
31+
- **🐛 TestQueue Core Functionality**
32+
- Fixed job scheduling timestamp logic to use MockClock consistently across all enqueue methods
33+
- Fixed retry logic off-by-one error where jobs required 4 failures instead of 3 to become dead
34+
- Fixed workflow fail-fast policy implementation to automatically fail related jobs
35+
- Fixed workflow status preservation for cancelled workflows
36+
- Fixed dead job purging time comparison logic (changed from `<` to `<=`)
37+
- Fixed cron job scheduling to use 6-field format with seconds
38+
- Fixed queue statistics to count Dead jobs as failed for reporting purposes
39+
40+
### Technical Implementation
41+
- All 19 TestQueue integration tests now passing
42+
- Proper mock clock integration across enqueue, batch, and workflow operations
43+
- Fail-fast logic implementation for both workflows and batches
44+
- Comprehensive error handling and status management
45+
- Support for complex job dependency graphs and workflow execution
46+
- Full compatibility with DatabaseQueue trait for drop-in testing
47+
848
## [1.2.1] - 2025-06-30
949

1050
### Fixed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ members = [
99
resolver = "2"
1010

1111
[workspace.package]
12-
version = "1.2.1"
12+
version = "1.2.2"
1313
edition = "2024"
1414
license = "MIT"
1515
repository = "https://github.com/CodingAnarchy/hammerwork"
@@ -19,7 +19,7 @@ documentation = "https://docs.rs/hammerwork"
1919
rust-version = "1.86"
2020

2121
[workspace.dependencies]
22-
hammerwork = { version = "1.2.1", path = "." }
22+
hammerwork = { version = "1.2.2", path = "." }
2323
tokio = { version = "1.0", features = ["full"] }
2424
sqlx = { version = "0.8", features = ["runtime-tokio-rustls", "chrono", "uuid", "json"] }
2525
chrono = { version = "0.4", features = ["serde"] }
@@ -90,6 +90,7 @@ mysql = ["sqlx/mysql"]
9090
metrics = ["prometheus", "warp"]
9191
alerting = ["reqwest"]
9292
tracing = ["opentelemetry", "opentelemetry_sdk", "opentelemetry-otlp", "tracing-opentelemetry"]
93+
test = []
9394

9495
[dev-dependencies]
9596
tokio-test = { workspace = true }

ROADMAP.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,6 @@ let archival_policy = ArchivalPolicy::new()
2121
queue.set_archival_policy(archival_policy).await?;
2222
```
2323

24-
### 🔧 Job Testing & Simulation
25-
**Impact: Medium** | **Complexity: Medium** | **Priority: Medium**
26-
27-
Valuable for development and testing workflows.
28-
29-
```rust
30-
// Test job handlers without database
31-
let test_queue = TestQueue::new()
32-
.with_mock_dependencies()
33-
.with_time_control(); // Fast-forward time for testing
34-
35-
// Job simulation and load testing
36-
let load_test = LoadTest::new()
37-
.with_job_template(job_template)
38-
.with_rate(100) // 100 jobs/second
39-
.with_duration(Duration::from_minutes(10))
40-
.run().await?;
41-
```
4224

4325
### ⚡ Dynamic Job Spawning
4426
**Impact: Medium** | **Complexity: Medium-High** | **Priority: Medium**

0 commit comments

Comments
 (0)