queen-mq 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client-v2/Queen.js +5 -3
- package/client-v2/http/HttpClient.js +7 -2
- package/client-v2/utils/defaults.js +2 -1
- package/package.json +1 -1
- package/test-v2/bootstrap.js +316 -0
- package/test-v2/run.js +4 -15
- package/test-v2/AI_TEST_SUMMARY.md +0 -226
- package/test-v2/GETTING_STARTED.md +0 -181
- package/test-v2/MAINTENANCE_TEST.md +0 -148
- package/test-v2/README_SUBSCRIPTION_TESTS.md +0 -201
- package/test-v2/ai_buffering.js +0 -194
- package/test-v2/ai_error_handling.js +0 -223
- package/test-v2/ai_lease_renewal.js +0 -206
- package/test-v2/ai_mixed_scenarios.js +0 -278
- package/test-v2/ai_priority.js +0 -169
- package/test-v2/ai_resources.js +0 -217
- package/test-v2/ai_ttl_retention.js +0 -170
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
# Getting Started with AI-Generated Tests
|
|
2
|
-
|
|
3
|
-
## Quick Start
|
|
4
|
-
|
|
5
|
-
The AI has identified and created tests for **7 major gaps** in your test coverage:
|
|
6
|
-
|
|
7
|
-
### 1. **Error Handling** (`ai_error_handling.js`) - 10 tests
|
|
8
|
-
Critical edge cases like invalid inputs, expired leases, and system limits.
|
|
9
|
-
|
|
10
|
-
### 2. **Lease Renewal** (`ai_lease_renewal.js`) - 5 tests
|
|
11
|
-
Manual lease extension API for long-running message processing.
|
|
12
|
-
|
|
13
|
-
### 3. **Resources/Status** (`ai_resources.js`) - 8 tests
|
|
14
|
-
Administrative APIs for monitoring queues, namespaces, tasks, and system health.
|
|
15
|
-
|
|
16
|
-
### 4. **Client Buffering** (`ai_buffering.js`) - 6 tests
|
|
17
|
-
Client-side message buffering for high-throughput scenarios.
|
|
18
|
-
|
|
19
|
-
### 5. **Priority Queues** (`ai_priority.js`) - 4 tests
|
|
20
|
-
Message priority handling across queues, namespaces, and tasks.
|
|
21
|
-
|
|
22
|
-
### 6. **TTL & Retention** (`ai_ttl_retention.js`) - 5 tests
|
|
23
|
-
Message expiration, retention policies, and DLQ based on wait time.
|
|
24
|
-
|
|
25
|
-
### 7. **Mixed Scenarios** (`ai_mixed_scenarios.js`) - 7 tests
|
|
26
|
-
Complex real-world scenarios combining multiple features.
|
|
27
|
-
|
|
28
|
-
## Running the New Tests
|
|
29
|
-
|
|
30
|
-
### Run ONLY AI-generated tests:
|
|
31
|
-
```bash
|
|
32
|
-
cd client-js/test-v2
|
|
33
|
-
node run.js ai
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Run ONLY human-written tests:
|
|
37
|
-
```bash
|
|
38
|
-
node run.js human
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Run all tests (both AI and human):
|
|
42
|
-
```bash
|
|
43
|
-
node run.js
|
|
44
|
-
# or
|
|
45
|
-
node run.js all
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Run a specific test:
|
|
49
|
-
```bash
|
|
50
|
-
node run.js testManualLeaseRenewal
|
|
51
|
-
node run.js testInvalidQueueName
|
|
52
|
-
node run.js testListQueues
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### List all available tests:
|
|
56
|
-
```bash
|
|
57
|
-
# Run with invalid argument to see help
|
|
58
|
-
node run.js help
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## What Was Missing Before?
|
|
62
|
-
|
|
63
|
-
| Area | Status Before | Status Now |
|
|
64
|
-
|------|--------------|------------|
|
|
65
|
-
| Error Handling | ❌ No coverage | ✅ 10 tests |
|
|
66
|
-
| Lease Renewal API | ❌ Only auto-renewal | ✅ Manual renewal covered |
|
|
67
|
-
| Resource APIs | ❌ Not tested | ✅ All endpoints covered |
|
|
68
|
-
| Buffer Management | ❌ Basic buffering only | ✅ Full coverage |
|
|
69
|
-
| Priority Queues | ❌ Config only | ✅ Behavior validated |
|
|
70
|
-
| TTL/Retention | ❌ Not tested | ✅ Complete lifecycle |
|
|
71
|
-
| Complex Scenarios | ⚠️ Partial | ✅ Real-world workflows |
|
|
72
|
-
|
|
73
|
-
## Key Test Highlights
|
|
74
|
-
|
|
75
|
-
### Most Important Tests
|
|
76
|
-
|
|
77
|
-
1. **`testManualLeaseRenewal`** - Essential for long-running tasks
|
|
78
|
-
2. **`testAckExpiredLease`** - Prevents data loss from expired leases
|
|
79
|
-
3. **`testCrossQueueWorkflow`** - Validates transactional pipelines
|
|
80
|
-
4. **`testBufferStatistics`** - Monitors client-side batching
|
|
81
|
-
5. **`testPriorityWithNamespace`** - Ensures priority ordering works
|
|
82
|
-
|
|
83
|
-
### Production-Critical Tests
|
|
84
|
-
|
|
85
|
-
- `testAckWithoutPartitionId` - Prevents acknowledging wrong messages
|
|
86
|
-
- `testBatchAckMixedResults` - Handles partial batch failures
|
|
87
|
-
- `testHighConcurrencyMixedOperations` - Validates concurrency handling
|
|
88
|
-
- `testEncryptedWithPartitionAndGroup` - Complex security scenario
|
|
89
|
-
|
|
90
|
-
## File Structure
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
test-v2/
|
|
94
|
-
├── queue.js # Original: Queue CRUD
|
|
95
|
-
├── push.js # Original: Push operations
|
|
96
|
-
├── pop.js # Original: Pop operations
|
|
97
|
-
├── consume.js # Original: Consumer patterns
|
|
98
|
-
├── load.js # Original: Load testing
|
|
99
|
-
├── dlq.js # Original: Dead letter queue
|
|
100
|
-
├── complete.js # Original: Workflows
|
|
101
|
-
├── transaction.js # Original: Transactions
|
|
102
|
-
├── ai_error_handling.js # NEW: Error & edge cases
|
|
103
|
-
├── ai_lease_renewal.js # NEW: Lease management
|
|
104
|
-
├── ai_resources.js # NEW: Admin APIs
|
|
105
|
-
├── ai_buffering.js # NEW: Buffer management
|
|
106
|
-
├── ai_priority.js # NEW: Priority behavior
|
|
107
|
-
├── ai_ttl_retention.js # NEW: Message lifecycle
|
|
108
|
-
├── ai_mixed_scenarios.js # NEW: Complex scenarios
|
|
109
|
-
├── run.js # Test runner (updated)
|
|
110
|
-
├── AI_TEST_SUMMARY.md # Detailed documentation
|
|
111
|
-
└── GETTING_STARTED.md # This file
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Before Running Tests
|
|
115
|
-
|
|
116
|
-
Make sure:
|
|
117
|
-
1. ✅ Queen server is running on `http://localhost:6632`
|
|
118
|
-
2. ✅ PostgreSQL database is accessible
|
|
119
|
-
3. ✅ Environment variables are set (if needed)
|
|
120
|
-
4. ✅ No production data in test database
|
|
121
|
-
|
|
122
|
-
## Testing with Different Server Configurations
|
|
123
|
-
|
|
124
|
-
### Standard Configuration (Default)
|
|
125
|
-
|
|
126
|
-
Run server with default settings:
|
|
127
|
-
```bash
|
|
128
|
-
./bin/queen-server
|
|
129
|
-
node test-v2/run.js
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
**Expected:** Consumer groups without explicit `.subscriptionMode()` process all historical messages.
|
|
133
|
-
|
|
134
|
-
### With DEFAULT_SUBSCRIPTION_MODE="new"
|
|
135
|
-
|
|
136
|
-
Run server with "new" as default:
|
|
137
|
-
```bash
|
|
138
|
-
DEFAULT_SUBSCRIPTION_MODE="new" ./bin/queen-server
|
|
139
|
-
node test-v2/run.js
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
**Expected:**
|
|
143
|
-
- Tests with explicit `.subscriptionMode('new')` work the same
|
|
144
|
-
- Tests without explicit mode will skip historical messages
|
|
145
|
-
- `subscriptionModeServerDefault` test detects and reports server default
|
|
146
|
-
|
|
147
|
-
**All tests pass with both configurations!** The tests are designed to be agnostic to server defaults.
|
|
148
|
-
|
|
149
|
-
## Test Philosophy
|
|
150
|
-
|
|
151
|
-
The AI-generated tests follow these principles:
|
|
152
|
-
|
|
153
|
-
1. **Isolated** - Each test uses unique queue names
|
|
154
|
-
2. **Self-contained** - Tests don't depend on each other
|
|
155
|
-
3. **Realistic** - Tests mirror production scenarios
|
|
156
|
-
4. **Defensive** - Tests validate error conditions
|
|
157
|
-
5. **Complete** - Tests cover happy path and edge cases
|
|
158
|
-
|
|
159
|
-
## Next Steps
|
|
160
|
-
|
|
161
|
-
1. Review the tests in each file
|
|
162
|
-
2. Run the full test suite: `node run.js`
|
|
163
|
-
3. Check for any failures specific to your environment
|
|
164
|
-
4. Adjust configuration if needed (ports, timeouts, etc.)
|
|
165
|
-
5. Integrate into your CI/CD pipeline
|
|
166
|
-
|
|
167
|
-
## Need Help?
|
|
168
|
-
|
|
169
|
-
- **See all tests**: `node run.js` (no arguments)
|
|
170
|
-
- **Run specific test**: `node run.js <testName>`
|
|
171
|
-
- **Read detailed docs**: See `AI_TEST_SUMMARY.md`
|
|
172
|
-
- **Check original tests**: Files without `ai_` prefix
|
|
173
|
-
|
|
174
|
-
## Test Count Summary
|
|
175
|
-
|
|
176
|
-
- **Original tests**: 49
|
|
177
|
-
- **AI-generated tests**: 45
|
|
178
|
-
- **Total coverage**: 94 tests
|
|
179
|
-
|
|
180
|
-
You've nearly **doubled your test coverage** with these additions! 🎉
|
|
181
|
-
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
# Maintenance Mode Test
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Comprehensive test for the maintenance mode feature with file buffer.
|
|
6
|
-
|
|
7
|
-
## Test Scenario
|
|
8
|
-
|
|
9
|
-
1. **Start consumer** - Begins consuming messages from queue
|
|
10
|
-
2. **Start producer** - Produces 10 messages/second
|
|
11
|
-
3. **Enable maintenance** - Triggers maintenance mode via API
|
|
12
|
-
4. **Verify buffering** - Consumer stops receiving (messages go to file buffer)
|
|
13
|
-
5. **Continue producing** - Producer keeps running for 10 seconds during maintenance
|
|
14
|
-
6. **Disable maintenance** - Deactivates maintenance mode via API
|
|
15
|
-
7. **Verify drain** - Consumer resumes receiving messages
|
|
16
|
-
8. **Stop producer** - Halts message production
|
|
17
|
-
9. **Wait for completion** - Waits 10 seconds for file buffer to drain
|
|
18
|
-
10. **Verify counts** - Ensures all produced messages were received
|
|
19
|
-
|
|
20
|
-
## Running the Test
|
|
21
|
-
|
|
22
|
-
### Standalone
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
cd /Users/alice/Work/queen/client-js/test-v2
|
|
26
|
-
node maintenance.js
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Via Test Runner
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
# Run just this test
|
|
33
|
-
node run.js test_maintenance_mode
|
|
34
|
-
|
|
35
|
-
# Run all human tests (includes this one)
|
|
36
|
-
node run.js human
|
|
37
|
-
|
|
38
|
-
# Run all tests
|
|
39
|
-
node run.js
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Expected Output
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
🧪 Testing Maintenance Mode with File Buffer
|
|
46
|
-
|
|
47
|
-
📋 Step 1: Configuring queue "test-maintenance-queue"...
|
|
48
|
-
✅ Queue configured
|
|
49
|
-
|
|
50
|
-
📥 Step 2: Starting consumer...
|
|
51
|
-
✅ Consumer started
|
|
52
|
-
|
|
53
|
-
📤 Step 3: Starting producer (10 msgs/sec)...
|
|
54
|
-
✅ Producer started
|
|
55
|
-
|
|
56
|
-
⏱️ Step 4: Waiting 3 seconds for normal message flow...
|
|
57
|
-
📨 Received 10 messages (total: 10)
|
|
58
|
-
📨 Received 10 messages (total: 20)
|
|
59
|
-
📨 Received 10 messages (total: 30)
|
|
60
|
-
Produced: 30, Received: 30
|
|
61
|
-
|
|
62
|
-
🔧 Step 5: Enabling MAINTENANCE MODE...
|
|
63
|
-
Response: { maintenanceMode: true, bufferedMessages: 0, ... }
|
|
64
|
-
✅ Maintenance mode enabled
|
|
65
|
-
|
|
66
|
-
⏱️ Step 6: Waiting 2 seconds - consumer should stop receiving...
|
|
67
|
-
Messages received during maintenance: 0
|
|
68
|
-
Total: Produced=50, Received=30
|
|
69
|
-
|
|
70
|
-
⏱️ Step 7: Producing during maintenance for 10 seconds...
|
|
71
|
-
(Messages should go to file buffer)
|
|
72
|
-
|
|
73
|
-
Maintenance period complete:
|
|
74
|
-
- Total produced: 150
|
|
75
|
-
- Total received: 30
|
|
76
|
-
- Buffered (should be ~100): 120
|
|
77
|
-
|
|
78
|
-
📊 Step 8: Checking maintenance status...
|
|
79
|
-
Status: { maintenanceMode: true, bufferedMessages: 120, ... }
|
|
80
|
-
|
|
81
|
-
✅ Step 9: Disabling MAINTENANCE MODE...
|
|
82
|
-
Response: { maintenanceMode: false, bufferedMessages: 120, ... }
|
|
83
|
-
(File buffer should start draining to database)
|
|
84
|
-
|
|
85
|
-
⏱️ Step 10: Waiting for messages to resume...
|
|
86
|
-
📨 Received 10 messages (total: 40)
|
|
87
|
-
Messages received after resuming: 10
|
|
88
|
-
✅ Messages are flowing again!
|
|
89
|
-
|
|
90
|
-
🛑 Step 11: Stopping producer...
|
|
91
|
-
Final produced count: 150
|
|
92
|
-
|
|
93
|
-
⏱️ Step 12: Waiting 10 seconds for file buffer to drain...
|
|
94
|
-
1s - Received: 50/150 (33.3%)
|
|
95
|
-
📨 Received 10 messages (total: 60)
|
|
96
|
-
2s - Received: 70/150 (46.7%)
|
|
97
|
-
📨 Received 10 messages (total: 80)
|
|
98
|
-
3s - Received: 90/150 (60.0%)
|
|
99
|
-
📨 Received 10 messages (total: 100)
|
|
100
|
-
4s - Received: 110/150 (73.3%)
|
|
101
|
-
📨 Received 10 messages (total: 120)
|
|
102
|
-
5s - Received: 130/150 (86.7%)
|
|
103
|
-
📨 Received 10 messages (total: 140)
|
|
104
|
-
6s - Received: 150/150 (100.0%)
|
|
105
|
-
✅ All messages received!
|
|
106
|
-
|
|
107
|
-
🛑 Step 13: Stopping consumer...
|
|
108
|
-
✅ Consumer stopped
|
|
109
|
-
|
|
110
|
-
📊 Final Verification:
|
|
111
|
-
|
|
112
|
-
Total Produced: 150
|
|
113
|
-
Total Received: 150
|
|
114
|
-
Difference: 0
|
|
115
|
-
|
|
116
|
-
✅ SUCCESS: All messages accounted for!
|
|
117
|
-
Maintenance mode works correctly with file buffer.
|
|
118
|
-
|
|
119
|
-
👋 Queen client closed
|
|
120
|
-
|
|
121
|
-
✅ All tests passed!
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## What It Tests
|
|
125
|
-
|
|
126
|
-
✅ **Maintenance mode activation** - API responds correctly
|
|
127
|
-
✅ **Message buffering** - Messages go to file buffer (consumer stops receiving)
|
|
128
|
-
✅ **Continued production** - Can push messages during maintenance
|
|
129
|
-
✅ **Maintenance mode deactivation** - API responds correctly
|
|
130
|
-
✅ **Automatic drain** - File buffer drains to database
|
|
131
|
-
✅ **Message ordering** - All messages received in order (FIFO)
|
|
132
|
-
✅ **No message loss** - Produced count == Received count
|
|
133
|
-
✅ **Multi-instance support** - Uses database for state (works across restarts)
|
|
134
|
-
|
|
135
|
-
## Success Criteria
|
|
136
|
-
|
|
137
|
-
- All produced messages are eventually received
|
|
138
|
-
- Consumer stops receiving during maintenance
|
|
139
|
-
- Consumer resumes receiving after maintenance is disabled
|
|
140
|
-
- No duplicates or lost messages
|
|
141
|
-
- Drain completes within 10 seconds
|
|
142
|
-
|
|
143
|
-
## Notes
|
|
144
|
-
|
|
145
|
-
- Uses `axios` for direct API calls (maintenance endpoints)
|
|
146
|
-
- Uses Queen client for queue operations (push/pop/ack)
|
|
147
|
-
- Test takes ~25 seconds total (3s warmup + 10s maintenance + 10s drain)
|
|
148
|
-
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
# Subscription Mode Tests
|
|
2
|
-
|
|
3
|
-
Tests for consumer group subscription modes, compatible with any server `DEFAULT_SUBSCRIPTION_MODE` configuration.
|
|
4
|
-
|
|
5
|
-
## Test Overview
|
|
6
|
-
|
|
7
|
-
| Test Function | Description | Explicit Mode Used |
|
|
8
|
-
|--------------|-------------|-------------------|
|
|
9
|
-
| `subscriptionModeNew` | Validates `.subscriptionMode('new')` skips historical messages | Yes (`new`) |
|
|
10
|
-
| `subscriptionModeNewOnly` | Validates alias `.subscriptionMode('new-only')` | Yes (`new-only`) |
|
|
11
|
-
| `subscriptionFromNow` | Validates `.subscriptionFrom('now')` | Yes (`now`) |
|
|
12
|
-
| `subscriptionFromTimestamp` | Validates timestamp-based subscription | Yes (timestamp) |
|
|
13
|
-
| `subscriptionModeAll` | Tests default behavior (depends on server config) | Mixed |
|
|
14
|
-
| `subscriptionModeServerDefault` | **NEW:** Detects and validates server default | Mixed |
|
|
15
|
-
|
|
16
|
-
## Running the Tests
|
|
17
|
-
|
|
18
|
-
### Run all subscription tests:
|
|
19
|
-
```bash
|
|
20
|
-
cd client-js/test-v2
|
|
21
|
-
node run.js subscription
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Run specific subscription test:
|
|
25
|
-
```bash
|
|
26
|
-
node run.js subscriptionModeNew
|
|
27
|
-
node run.js subscriptionModeServerDefault
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Server Configuration Compatibility
|
|
31
|
-
|
|
32
|
-
These tests work with **any** server `DEFAULT_SUBSCRIPTION_MODE` configuration:
|
|
33
|
-
|
|
34
|
-
### Configuration 1: Standard (Default)
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# Start server without default
|
|
38
|
-
./bin/queen-server
|
|
39
|
-
|
|
40
|
-
# Run tests
|
|
41
|
-
node run.js subscription
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**Expected Behavior:**
|
|
45
|
-
- Consumer groups without explicit mode process all historical messages
|
|
46
|
-
- Consumer groups with `.subscriptionMode('new')` skip history
|
|
47
|
-
- `subscriptionModeServerDefault` reports: "all (or empty string)"
|
|
48
|
-
|
|
49
|
-
### Configuration 2: With DEFAULT_SUBSCRIPTION_MODE="new"
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
# Start server with "new" as default
|
|
53
|
-
DEFAULT_SUBSCRIPTION_MODE="new" ./bin/queen-server
|
|
54
|
-
|
|
55
|
-
# Run tests
|
|
56
|
-
node run.js subscription
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
**Expected Behavior:**
|
|
60
|
-
- Consumer groups without explicit mode skip historical messages
|
|
61
|
-
- Consumer groups with `.subscriptionMode('new')` skip history (same)
|
|
62
|
-
- `subscriptionModeServerDefault` reports: "new"
|
|
63
|
-
|
|
64
|
-
**✅ All tests pass with both configurations!**
|
|
65
|
-
|
|
66
|
-
## Test Details
|
|
67
|
-
|
|
68
|
-
### subscriptionModeNew
|
|
69
|
-
|
|
70
|
-
Tests the explicit `.subscriptionMode('new')` behavior:
|
|
71
|
-
|
|
72
|
-
1. Pushes 5 historical messages
|
|
73
|
-
2. Creates two consumer groups:
|
|
74
|
-
- One without explicit mode (behavior depends on server)
|
|
75
|
-
- One with `.subscriptionMode('new')` (always skips)
|
|
76
|
-
3. Verifies the `new` mode group gets 0 historical messages
|
|
77
|
-
4. Pushes 3 new messages
|
|
78
|
-
5. Verifies both groups get the new messages
|
|
79
|
-
|
|
80
|
-
**Key Assertion:** `.subscriptionMode('new')` always skips historical messages.
|
|
81
|
-
|
|
82
|
-
### subscriptionModeServerDefault (NEW)
|
|
83
|
-
|
|
84
|
-
Detects and validates the server's default subscription mode:
|
|
85
|
-
|
|
86
|
-
1. Pushes historical messages
|
|
87
|
-
2. Creates consumer group WITHOUT explicit subscription mode
|
|
88
|
-
3. Detects server default based on behavior:
|
|
89
|
-
- Got historical messages → server default is "all"
|
|
90
|
-
- Got 0 messages → server default is "new"
|
|
91
|
-
4. Validates explicit `.subscriptionMode('new')` still works
|
|
92
|
-
5. Verifies new messages are received by both groups
|
|
93
|
-
|
|
94
|
-
**Key Assertion:** Server default affects groups without explicit mode, but explicit modes always work.
|
|
95
|
-
|
|
96
|
-
### subscriptionFromTimestamp
|
|
97
|
-
|
|
98
|
-
Tests timestamp-based subscription:
|
|
99
|
-
|
|
100
|
-
1. Pushes "first batch" of messages
|
|
101
|
-
2. Records cutoff timestamp
|
|
102
|
-
3. Pushes "second batch" of messages
|
|
103
|
-
4. Creates consumer group with `.subscriptionFrom(cutoffTimestamp)`
|
|
104
|
-
5. Verifies only messages after timestamp are received
|
|
105
|
-
|
|
106
|
-
**Note:** Timestamp precision may vary based on database clock.
|
|
107
|
-
|
|
108
|
-
## Common Issues
|
|
109
|
-
|
|
110
|
-
### Issue: Test fails with "expected X, got Y"
|
|
111
|
-
|
|
112
|
-
**Cause:** Server has different default than test expects.
|
|
113
|
-
|
|
114
|
-
**Solution:** Check server configuration:
|
|
115
|
-
```bash
|
|
116
|
-
# Check if DEFAULT_SUBSCRIPTION_MODE is set
|
|
117
|
-
echo $DEFAULT_SUBSCRIPTION_MODE
|
|
118
|
-
|
|
119
|
-
# Check server logs on startup
|
|
120
|
-
LOG_LEVEL=debug ./bin/queen-server | grep "default subscription"
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### Issue: Consumer group exists from previous run
|
|
124
|
-
|
|
125
|
-
**Cause:** Consumer groups persist between test runs.
|
|
126
|
-
|
|
127
|
-
**Solution:** The test runner cleans up test data automatically:
|
|
128
|
-
```javascript
|
|
129
|
-
await dbPool.query(`DELETE FROM queen.queues WHERE name LIKE 'test-%'`)
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
Or manually:
|
|
133
|
-
```sql
|
|
134
|
-
DELETE FROM queen.partition_consumers
|
|
135
|
-
WHERE consumer_group LIKE 'group-%';
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Issue: Timing-related test failures
|
|
139
|
-
|
|
140
|
-
**Cause:** Messages not fully persisted before consumption.
|
|
141
|
-
|
|
142
|
-
**Solution:** Tests include appropriate delays. If still failing, increase delays:
|
|
143
|
-
```javascript
|
|
144
|
-
await new Promise(resolve => setTimeout(resolve, 500)) // Increase if needed
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## Adding New Subscription Tests
|
|
148
|
-
|
|
149
|
-
When adding new subscription mode tests:
|
|
150
|
-
|
|
151
|
-
1. **Use unique queue/group names** to avoid conflicts
|
|
152
|
-
2. **Be explicit about subscription modes** in test assertions
|
|
153
|
-
3. **Document expected behavior** for both server configurations
|
|
154
|
-
4. **Use descriptive group names** like `group-explicit-new` vs `group-default`
|
|
155
|
-
|
|
156
|
-
Example:
|
|
157
|
-
```javascript
|
|
158
|
-
export async function testNewFeature(client) {
|
|
159
|
-
// Setup
|
|
160
|
-
await client.queue('test-new-feature').create()
|
|
161
|
-
|
|
162
|
-
// Test explicit behavior (works with any server default)
|
|
163
|
-
const result = await client
|
|
164
|
-
.queue('test-new-feature')
|
|
165
|
-
.group('group-explicit-new')
|
|
166
|
-
.subscriptionMode('new') // Explicit!
|
|
167
|
-
.pop()
|
|
168
|
-
|
|
169
|
-
// Assert based on explicit mode, not server default
|
|
170
|
-
// ...
|
|
171
|
-
}
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
## Debugging Failed Tests
|
|
175
|
-
|
|
176
|
-
Enable detailed logging:
|
|
177
|
-
|
|
178
|
-
```bash
|
|
179
|
-
# Client logging
|
|
180
|
-
QUEEN_CLIENT_LOG=true node run.js subscriptionModeNew
|
|
181
|
-
|
|
182
|
-
# Server logging
|
|
183
|
-
LOG_LEVEL=debug ./bin/queen-server
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
Look for these log lines:
|
|
187
|
-
```
|
|
188
|
-
Consumer group 'group-xxx' exists: false, has subscription options: true
|
|
189
|
-
Subscription mode 'new' - starting from latest message: <uuid>
|
|
190
|
-
Applying default subscription mode 'new' for consumer group 'group-yyy'
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## Summary
|
|
194
|
-
|
|
195
|
-
- ✅ Tests work with any `DEFAULT_SUBSCRIPTION_MODE` configuration
|
|
196
|
-
- ✅ Explicit subscription modes are always tested and validated
|
|
197
|
-
- ✅ Server default behavior is detected and reported
|
|
198
|
-
- ✅ All tests are documented and maintainable
|
|
199
|
-
|
|
200
|
-
Run the tests and see them pass! 🎉
|
|
201
|
-
|