-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
710 lines (601 loc) · 27.8 KB
/
Makefile
File metadata and controls
710 lines (601 loc) · 27.8 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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
# Makefile for Go IMAP Server Testing
#
# Quick Reference:
# make test - Run all tests
# make test-db - Run all database tests
# make test-db-init - Run database initialization tests
# make test-blob-storage - Run blob storage tests
# make test-db-domain - Run domain management tests
# make test-db-user - Run user management tests
# make test-db-mailbox - Run mailbox operations tests
# make test-db-message - Run message management tests
# make test-db-blob - Run blob storage tests
# make test-db-manager - Run DB manager tests
# make test-conf - Run configuration tests
# make test-utils - Run server utilities tests
# make test-response - Run server response tests
# make test-storage - Run delivery storage tests
# make test-noop - Run NOOP command tests
# make test-idle - Run IDLE command tests
# make test-namespace - Run NAMESPACE command tests
# make test-check - Run CHECK command tests
# make test-close - Run CLOSE command tests
# make test-expunge - Run EXPUNGE command tests
# make test-capability - Run CAPABILITY command tests
# make test-logout - Run LOGOUT command tests
# make test-append - Run APPEND command tests
# make test-authenticate - Run AUTHENTICATE command tests
# make test-auth-coverage - Run auth tests with coverage report
# make test-login - Run LOGIN command tests
# make test-starttls - Run STARTTLS command tests
# make test-select - Run SELECT command tests
# make test-examine - Run EXAMINE command tests
# make test-create - Run CREATE command tests
# make test-list - Run LIST command tests
# make test-list-extended - Run LIST extended tests (RFC3501, wildcards, etc.)
# make test-delete - Run DELETE command tests
# make test-rename - Run RENAME command tests
# make test-subscribe - Run SUBSCRIBE command tests
# make test-unsubscribe - Run UNSUBSCRIBE command tests
# make test-lsub - Run LSUB command tests
# make test-status - Run STATUS command tests
# make test-rename - Run RENAME command tests
# make test-search - Run SEARCH command tests
# make test-fetch - Run FETCH command tests
# make test-store - Run STORE command tests
# make test-commands - Run all command tests
# make docker-build - Build all Docker images
# make docker-build-sasl - Build SASL Docker image
# make docker-build-lmtp - Build LMTP Docker image
# make docker-build-imap - Build IMAP Docker image
# make docker-build-socketmap - Build Socketmap Docker image
# make docker-build-all - Build combined Docker image
# make help - Show all available targets
.PHONY: test test-integration test-integration-db test-integration-server \
test-integration-delivery test-integration-sasl test-e2e \
test-e2e-delivery test-e2e-imap test-e2e-auth test-e2e-concurrency \
test-e2e-persistence test-e2e-coverage test-e2e-minimal \
test-integration-coverage test-integration-race test-db test-db-init \
test-db-domain test-db-user test-db-mailbox test-db-message \
test-db-blob test-db-role test-db-manager test-capability test-noop \
test-check test-close test-expunge test-authenticate test-login \
test-starttls test-select test-examine test-create test-list \
test-list-extended test-delete test-status test-search test-fetch \
test-store test-copy test-uid test-commands test-delivery test-parser \
test-parser-coverage test-sasl test-conf test-utils test-response \
test-storage test-models test-middleware test-selection \
test-core-server test-verbose test-coverage test-race clean \
docker-build docker-build-sasl docker-build-lmtp docker-build-imap \
docker-build-socketmap docker-build-all docker-run docker-run-sasl \
docker-run-lmtp docker-run-imap docker-run-socketmap docker-run-all \
docker-stop docker-clean docker-images docker-logs docker-logs-sasl \
docker-logs-lmtp docker-logs-imap docker-logs-socketmap docker-logs-all
# Build delivery service
build-delivery:
go build -o bin/raven-delivery ./cmd/delivery
# Run delivery service
run-delivery:
go run ./cmd/delivery
# Test delivery service
test-delivery:
go test -tags=test -v ./internal/delivery/...
# Test parser
test-parser:
go test -v ./internal/delivery/parser/...
# Test parser with coverage
test-parser-coverage:
go test -v -coverprofile=coverage.out ./internal/delivery/parser/... && go tool cover -func=coverage.out | grep "internal/delivery/parser"
# Test SASL authentication service
test-sasl:
go test -tags=test -v ./internal/sasl
# Test configuration
test-conf:
go test -v ./internal/conf/...
# Test server utilities
test-utils:
go test -v ./internal/server/utils/...
# Test server response formatting
test-response:
go test -v ./internal/server/response/...
# Test delivery storage
test-storage:
go test -v ./internal/delivery/storage/...
# Test blobstorage package
test-blob-storage:
go test -v ./internal/blobstorage/...
# ============================================================================
# Integration Tests - Cross-Module Testing
# ============================================================================
# Run all integration tests
test-integration:
@echo "Running all integration tests..."
@go test -v ./test/integration/...
# Run database integration tests
test-integration-db:
@echo "Running database integration tests..."
@go test -v ./test/integration/db/...
# Run IMAP server integration tests
test-integration-server:
@echo "Running IMAP server integration tests..."
@go test -v ./test/integration/server/...
# Run LMTP delivery integration tests
test-integration-delivery:
@echo "Running LMTP delivery integration tests..."
@go test -v ./test/integration/delivery/...
# Run SASL authentication integration tests
test-integration-sasl:
@echo "Running SASL authentication integration tests..."
@go test -v ./test/integration/sasl/...
# Run end-to-end tests (LMTP → DB → IMAP flow)
test-e2e:
@echo "Running end-to-end tests (LMTP→DB→IMAP)..."
@go test -v ./test/e2e/...
# Run core delivery flow test (most important)
test-e2e-delivery:
@echo "Running E2E delivery tests..."
@go test -v ./test/e2e -run "TestE2E_LMTP"
# Run IMAP-specific e2e tests
test-e2e-imap:
@echo "Running IMAP e2e tests..."
@go test -v ./test/e2e -run "TestE2E_IMAP"
# Run authentication e2e tests
test-e2e-auth:
@echo "Running authentication e2e tests..."
@go test -v ./test/e2e -run "TestE2E_SASL"
# Run concurrency e2e tests
test-e2e-concurrency:
@echo "Running concurrency e2e tests..."
@go test -v ./test/e2e -run "TestE2E_Concurrent"
# Run persistence e2e tests
test-e2e-persistence:
@echo "Running persistence e2e tests..."
@go test -v ./test/e2e -run "TestE2E_ServerRestart"
# Run all e2e tests with coverage
test-e2e-coverage:
@echo "Running e2e tests with coverage..."
@go test -v -cover -coverprofile=coverage_e2e.out ./test/e2e/...
@go tool cover -html=coverage_e2e.out -o coverage_e2e.html
@echo "Coverage report: coverage_e2e.html"
# Run minimal E2E suite (6 essential tests)
test-e2e-minimal:
@echo "Running minimal E2E suite (6 essential tests)..."
@go test -v ./test/e2e -run "TestE2E_LMTP_To_IMAP_ReceiveEmail|TestE2E_SASL_Authentication|TestE2E_IMAP_UID|TestE2E_Concurrent|TestE2E_ServerRestart"
# Run message management tests
test-db-message:
go test -v ./internal/db -run "TestCreateMessage|TestAddMessageToMailbox|TestGetMessages|TestMessageFlags"
# Run blob storage tests
test-db-blob:
go test -v ./internal/db -run "TestStoreBlob|TestGetBlob|TestDecrementBlobReference"
# Run subscription tests
test-db-subscription:
go test -v ./internal/db -run "TestSubscribe|TestUnsubscribe|TestIsMailboxSubscribed"
# Run delivery and outbound queue tests
test-db-delivery:
go test -v ./internal/db -run "TestRecordDelivery|TestQueueOutbound|TestGetPendingOutbound|TestUpdateOutboundStatus|TestRetryOutbound"
# Run DB manager tests
test-db-manager:
go test -v ./internal/db -run "TestGetSharedDB|TestGetUserDB|TestClose|TestCaching"
# Run all database tests with verbose output and coverage
test-db-all:
@echo "Running all database tests with coverage..."
@echo "\n=== Database Initialization Tests ==="
@go test -v ./internal/db -run "TestInitDB|TestNewDBManager"
@echo "\n=== Domain Management Tests ==="
@go test -v ./internal/db -run "TestCreateDomain|TestGetDomainByName|TestGetOrCreateDomain"
@echo "\n=== User Management Tests ==="
@go test -v ./internal/db -run "TestCreateUser|TestGetUser|TestUserExists"
@echo "\n=== Mailbox Operations Tests ==="
@go test -v ./internal/db -run "TestCreateMailbox|TestGetMailbox|TestDeleteMailbox|TestRenameMailbox|TestMailboxExists"
@echo "\n=== Message Management Tests ==="
@go test -v ./internal/db -run "TestCreateMessage|TestAddMessageToMailbox|TestGetMessages|TestMessageFlags"
@echo "\n=== Blob Storage Tests ==="
@go test -v ./internal/db -run "TestStoreBlob|TestGetBlob|TestDecrementBlobReference"
@echo "\n=== Subscription Tests ==="
@go test -v ./internal/db -run "TestSubscribe|TestUnsubscribe|TestIsMailboxSubscribed"
@echo "\n=== Delivery & Outbound Queue Tests ==="
@go test -v ./internal/db -run "TestRecordDelivery|TestQueueOutbound|TestGetPendingOutbound|TestUpdateOutboundStatus|TestRetryOutbound"
@echo "\n=== DB Manager Tests ==="
@go test -v ./internal/db -run "TestGetSharedDB|TestGetUserDB|TestClose|TestCaching"
@echo "\n=== Full Database Test Suite with Coverage ==="
@go test -v -cover ./internal/db/...
# Build SASL authentication service
build-sasl:
go build -o bin/raven-sasl ./cmd/sasl
# Run SASL authentication service
run-sasl:
go run ./cmd/sasl
# Build all services
build-all: build-delivery build-sasl
# Run all tests
test:
go test -tags=test ./...
# Run only capability-related tests
test-capability:
go test -tags=test -v ./internal/server -run "TestCapabilityCommand"
# Run only NOOP-related tests
test-noop:
go test -tags=test -v ./internal/server -run "TestNoopCommand"
# Run only IDLE-related tests
test-idle:
go test -v ./internal/server/extension -run "TestIdleCommand"
# Run only NAMESPACE-related tests
test-namespace:
go test -v ./internal/server/extension -run "TestNamespaceCommand"
# Run only CHECK-related tests
test-check:
go test -tags=test -v ./internal/server -run "TestCheckCommand"
# Run only CLOSE-related tests
test-close:
go test -tags=test -v ./internal/server -run "TestCloseCommand"
# Run only EXPUNGE-related tests
test-expunge:
go test -tags=test -v ./internal/server -run "TestExpungeCommand"
# Run only LOGOUT-related tests
test-logout:
go test -tags=test -v ./internal/server -run "TestLogoutCommand"
# Run only APPEND-related tests
test-append:
go test -tags=test -v ./internal/server -run "TestAppendCommand"
# Run only AUTHENTICATE-related tests
test-authenticate:
go test -tags=test -v ./internal/server -run "TestAuthenticate"
# Run auth tests with coverage
test-auth-coverage:
@echo "Running auth tests with coverage..."
@go test -tags=test -coverprofile=auth_coverage.out ./internal/server/auth/... || true
@echo "\n=== Coverage Report ==="
@go tool cover -func=auth_coverage.out | grep -E "(handler_auth.go|total)"
@echo "\nFor detailed HTML coverage report, run: go tool cover -html=auth_coverage.out"
@COVERAGE=$$(go tool cover -func=auth_coverage.out | grep total | awk '{print $$3}' | sed 's/%//'); \
echo "\nTotal auth coverage: $${COVERAGE}%"; \
if [ "$$(echo "$${COVERAGE} >= 80.0" | bc)" -eq 1 ]; then \
echo "✓ Coverage target met (≥80%)"; \
else \
echo "✗ Coverage below target (target: ≥80%)"; \
exit 1; \
fi
# Run AUTHENTICATE benchmarks
bench-authenticate:
go test -tags=test -bench=BenchmarkAuthenticate -benchmem ./internal/server
# Run only LOGIN-related tests
test-login:
go test -tags=test -v ./internal/server -run "TestLoginCommand"
# Run only STARTTLS-related tests
test-starttls:
go test -tags=test -v ./internal/server -run "TestStartTLS"
# Run only SELECT-related tests
test-select:
go test -tags=test -v ./internal/server -run "TestSelectCommand"
# Run only EXAMINE-related tests
test-examine:
go test -tags=test -v ./internal/server -run "TestExamineCommand"
# Run only CREATE-related tests
test-create:
go test -tags=test -v ./internal/server -run "TestCreateCommand"
# Run only LIST-related tests
test-list:
go test -tags=test -v ./internal/server -run "TestListCommand"
# Run LIST extended tests (RFC3501, wildcards, hierarchy, etc.)
test-list-extended:
go test -tags=test -v ./internal/server -run "TestListCommand.*RFC3501|TestListCommand.*Wildcard|TestListCommand.*Hierarchy|TestListCommand.*Reference|TestListCommand.*Error|TestListCommand.*Special"
# Run only DELETE-related tests
test-delete:
go test -tags=test -v ./internal/server -run "TestDeleteCommand"
# Run only SUBSCRIBE-related tests
test-subscribe:
go test -tags=test -v ./internal/server -run "TestSubscribeCommand"
# Run only UNSUBSCRIBE-related tests
test-unsubscribe:
go test -tags=test -v ./internal/server -run "TestUnsubscribeCommand"
# Run only LSUB-related tests
test-lsub:
go test -tags=test -v ./internal/server -run "TestLsubCommand"
# Run only STATUS-related tests
test-status:
go test -tags=test -v ./internal/server -run "TestStatusCommand"
# Run only RENAME-related tests
test-rename:
go test -tags=test -v ./internal/server -run "TestRenameCommand"
# Run only SEARCH-related tests
test-search:
go test -tags=test -v ./internal/server -run "TestSearchCommand"
# Run only FETCH-related tests
test-fetch:
go test -tags=test -v ./internal/server -run "TestFetchCommand"
# Run only STORE-related tests
test-store:
go test -tags=test -v ./internal/server -run "TestStoreCommand"
# Run only COPY-related tests
test-copy:
go test -tags=test -v ./internal/server -run "TestCopyCommand"
# Run only UID-related tests
test-uid:
go test -tags=test -v ./internal/server -run "TestUID"
# Run all command tests (CAPABILITY + NOOP + CHECK + CLOSE + EXPUNGE + LOGOUT + APPEND + AUTHENTICATE + LOGIN + STARTTLS + SELECT + EXAMINE + CREATE + LIST + LIST-EXTENDED + DELETE + SUBSCRIBE + UNSUBSCRIBE + LSUB + STATUS + RENAME + SEARCH + FETCH + STORE + COPY + UID)
test-commands:
@echo "Running CAPABILITY tests..."
@go test -tags=test -v ./internal/server -run "TestCapabilityCommand"
@echo "\nRunning NOOP tests..."
@go test -tags=test -v ./internal/server -run "TestNoopCommand"
@echo "\nRunning CHECK tests..."
@go test -tags=test -v ./internal/server -run "TestCheckCommand"
@echo "\nRunning CLOSE tests..."
@go test -tags=test -v ./internal/server -run "TestCloseCommand"
@echo "\nRunning EXPUNGE tests..."
@go test -tags=test -v ./internal/server -run "TestExpungeCommand"
@echo "\nRunning LOGOUT tests..."
@go test -tags=test -v ./internal/server -run "TestLogoutCommand"
@echo "\nRunning APPEND tests..."
@go test -tags=test -v ./internal/server -run "TestAppendCommand"
@echo "\nRunning AUTHENTICATE tests..."
@go test -tags=test -v ./internal/server -run "TestAuthenticate"
@echo "\nRunning LOGIN tests..."
@go test -tags=test -v ./internal/server -run "TestLoginCommand"
@echo "\nRunning STARTTLS tests..."
@go test -tags=test -v ./internal/server -run "TestStartTLS"
@echo "\nRunning SELECT tests..."
@go test -tags=test -v ./internal/server -run "TestSelectCommand"
@echo "\nRunning EXAMINE tests..."
@go test -tags=test -v ./internal/server -run "TestExamineCommand"
@echo "\nRunning CREATE tests..."
@go test -tags=test -v ./internal/server -run "TestCreateCommand"
@echo "\nRunning LIST tests..."
@go test -tags=test -v ./internal/server -run "TestListCommand"
@echo "\nRunning LIST extended tests..."
@go test -tags=test -v ./internal/server -run "TestListCommand.*RFC3501|TestListCommand.*Wildcard|TestListCommand.*Hierarchy|TestListCommand.*Reference|TestListCommand.*Error|TestListCommand.*Special"
@echo "\nRunning DELETE tests..."
@go test -tags=test -v ./internal/server -run "TestDeleteCommand"
@echo "\nRunning SUBSCRIBE tests..."
@go test -tags=test -v ./internal/server -run "TestSubscribeCommand"
@echo "\nRunning UNSUBSCRIBE tests..."
@go test -tags=test -v ./internal/server -run "TestUnsubscribeCommand"
@echo "\nRunning LSUB tests..."
@go test -tags=test -v ./internal/server -run "TestLsubCommand"
@echo "\nRunning STATUS tests..."
@go test -tags=test -v ./internal/server -run "TestStatusCommand"
@echo "\nRunning RENAME tests..."
@go test -tags=test -v ./internal/server -run "TestRenameCommand"
@echo "\nRunning SEARCH tests..."
@go test -tags=test -v ./internal/server -run "TestSearchCommand"
@echo "\nRunning FETCH tests..."
@go test -tags=test -v ./internal/server -run "TestFetchCommand"
@echo "\nRunning STORE tests..."
@go test -tags=test -v ./internal/server -run "TestStoreCommand"
@echo "\nRunning COPY tests..."
@go test -tags=test -v ./internal/server -run "TestCopyCommand"
@echo "\nRunning UID tests..."
@go test -tags=test -v ./internal/server -run "TestUID"
# Run tests with verbose output
test-verbose:
go test -tags=test -v ./...
# Run tests with coverage
test-coverage:
go test -tags=test -cover ./...
go test -tags=test -coverprofile=coverage.out ./internal/server
go tool cover -html=coverage.out -o coverage.html
@echo "\nCoverage report generated: coverage.html"
# Run tests with race detection
test-race:
go test -tags=test -race ./...
# Run models tests
test-models:
go test -v ./internal/models/...
# Run middleware tests
test-middleware:
go test -tags=test -v ./internal/server/middleware/...
# Run selection tests
test-selection:
go test -tags=test -v ./internal/server/selection/...
# Run core server tests
test-core-server:
go test -tags=test -v ./internal/server
# Run capability tests with detailed output (deprecated, use test-capability)
test-capability-detailed:
go test -tags=test -v -run "TestCapabilityCommand" ./internal/server
# Run benchmarks
bench:
go test -tags=test -bench=. ./internal/server
# Clean test artifacts
clean:
rm -f coverage.out coverage.html auth_coverage.out
# Run specific test
test-single:
@echo "Usage: make test-single TEST=TestCapabilityCommand_NonTLSConnection"
@if [ -z "$(TEST)" ]; then \
echo "Please specify TEST variable"; \
exit 1; \
fi
go test -tags=test -v -run "$(TEST)" ./internal/server
# Install test dependencies
deps:
go mod tidy
go mod download
# Format code
fmt:
go fmt ./...
# Lint code
lint:
golangci-lint run ./...
# All quality checks
check: fmt lint test-race test-coverage
# Run tests in CI environment
ci: deps check
# ============================================================================
# Docker Configuration
# ============================================================================
VERSION ?= latest
# Docker image names (local only)
DOCKER_IMAGE_SASL := raven-sasl
DOCKER_IMAGE_LMTP := raven-lmtp
DOCKER_IMAGE_IMAP := raven-imap
DOCKER_IMAGE_SOCKETMAP := raven-socketmap
DOCKER_IMAGE_ALL := raven
# ============================================================================
# Docker Targets
# ============================================================================
# Build all Docker images locally
docker-build:
@echo "Building all Docker images locally..."
@$(MAKE) docker-build-sasl
@$(MAKE) docker-build-lmtp
@$(MAKE) docker-build-imap
@$(MAKE) docker-build-socketmap
@$(MAKE) docker-build-all
# Build individual service images
docker-build-sasl:
@echo "Building SASL Docker image..."
docker build --target raven-sasl -t $(DOCKER_IMAGE_SASL):$(VERSION) -t $(DOCKER_IMAGE_SASL):latest .
docker-build-lmtp:
@echo "Building LMTP Docker image..."
docker build --target raven-lmtp -t $(DOCKER_IMAGE_LMTP):$(VERSION) -t $(DOCKER_IMAGE_LMTP):latest .
docker-build-imap:
@echo "Building IMAP Docker image..."
docker build --target raven-imap -t $(DOCKER_IMAGE_IMAP):$(VERSION) -t $(DOCKER_IMAGE_IMAP):latest .
docker-build-socketmap:
@echo "Building Socketmap Docker image..."
docker build --target raven-socketmap -t $(DOCKER_IMAGE_SOCKETMAP):$(VERSION) -t $(DOCKER_IMAGE_SOCKETMAP):latest .
docker-build-all:
@echo "Building combined Docker image..."
docker build --target raven -t $(DOCKER_IMAGE_ALL):$(VERSION) -t $(DOCKER_IMAGE_ALL):latest .
# Run Docker containers for testing
docker-run:
@echo "Starting all services using Docker Compose..."
docker-compose up -d
docker-run-sasl:
docker run -d --name raven-sasl -p 12345:12345 -v $(PWD)/config/raven.yaml:/etc/raven/raven.yaml:ro $(DOCKER_IMAGE_SASL):$(VERSION)
docker-run-lmtp:
docker run -d --name raven-lmtp -p 24:24 -v raven-data:/app/data $(DOCKER_IMAGE_LMTP):$(VERSION)
docker-run-imap:
docker run -d --name raven-imap -p 143:143 -p 993:993 -v raven-data:/app/data $(DOCKER_IMAGE_IMAP):$(VERSION)
docker-run-socketmap:
docker run -d --name raven-socketmap -p 9100:9100 -v $(PWD)/config/raven.yaml:/etc/raven/raven.yaml:ro $(DOCKER_IMAGE_SOCKETMAP):$(VERSION)
docker-run-all:
docker run -d --name raven-all -p 143:143 -p 993:993 -p 24:24 -p 12345:12345 -p 9100:9100 -v raven-data:/app/data -v $(PWD)/config/raven.yaml:/etc/raven/raven.yaml:ro $(DOCKER_IMAGE_ALL):$(VERSION)
# Stop and remove Docker containers
docker-stop:
@echo "Stopping Docker containers..."
-docker-compose down
-docker stop raven-sasl raven-lmtp raven-imap raven-socketmap raven-all 2>/dev/null || true
-docker rm raven-sasl raven-lmtp raven-imap raven-socketmap raven-all 2>/dev/null || true
# Clean Docker images and volumes
docker-clean: docker-stop
@echo "Cleaning Docker images and volumes..."
-docker rmi $(DOCKER_IMAGE_SASL):$(VERSION) $(DOCKER_IMAGE_SASL):latest 2>/dev/null || true
-docker rmi $(DOCKER_IMAGE_LMTP):$(VERSION) $(DOCKER_IMAGE_LMTP):latest 2>/dev/null || true
-docker rmi $(DOCKER_IMAGE_IMAP):$(VERSION) $(DOCKER_IMAGE_IMAP):latest 2>/dev/null || true
-docker rmi $(DOCKER_IMAGE_SOCKETMAP):$(VERSION) $(DOCKER_IMAGE_SOCKETMAP):latest 2>/dev/null || true
-docker rmi $(DOCKER_IMAGE_ALL):$(VERSION) $(DOCKER_IMAGE_ALL):latest 2>/dev/null || true
-docker volume rm raven-data 2>/dev/null || true
# Show Docker images
docker-images:
@echo "Raven Docker images:"
@docker images | grep -E "raven|REPOSITORY" || echo "No Raven images found"
# Show Docker container logs
docker-logs:
docker-compose logs -f
docker-logs-sasl:
docker logs -f raven-sasl
docker-logs-lmtp:
docker logs -f raven-lmtp
docker-logs-imap:
docker logs -f raven-imap
docker-logs-socketmap:
docker logs -f raven-socketmap
docker-logs-all:
docker logs -f raven-all
# Help
help:
@echo "Available targets:"
@echo ""
@echo "Build & Run:"
@echo " build-delivery - Build delivery service binary"
@echo " build-sasl - Build SASL authentication service binary"
@echo " build-all - Build all services"
@echo " run-delivery - Run delivery service"
@echo " run-sasl - Run SASL authentication service"
@echo ""
@echo "Testing:"
@echo " test - Run all tests"
@echo " test-integration - Run all integration tests"
@echo " test-integration-db - Run database integration tests"
@echo " test-integration-server - Run IMAP server integration tests"
@echo " test-integration-delivery - Run LMTP delivery integration tests"
@echo " test-integration-sasl - Run SASL authentication integration tests"
@echo " test-e2e - Run end-to-end tests"
@echo " test-e2e-imap - Run IMAP e2e tests specifically"
@echo " test-e2e-delivery - Run delivery e2e tests specifically"
@echo " test-e2e-coverage - Run e2e tests with coverage"
@echo " test-e2e-race - Run e2e tests with race detection"
@echo " test-integration-coverage - Run integration tests with coverage"
@echo " test-integration-race - Run integration tests with race detection"
@echo " test-db - Run all database tests"
@echo " test-db-coverage - Run database tests with coverage"
@echo " test-db-init - Run database initialization tests"
@echo " test-blob-storage - Run blob storage tests"
@echo " test-db-domain - Run domain management tests"
@echo " test-db-user - Run user management tests"
@echo " test-db-mailbox - Run mailbox operations tests"
@echo " test-db-message - Run message management tests"
@echo " test-db-blob - Run blob storage tests"
@echo " test-db-subscription - Run subscription tests"
@echo " test-db-delivery - Run delivery & outbound queue tests"
@echo " test-db-manager - Run DB manager tests"
@echo " test-db-all - Run all database tests with detailed output"
@echo " test-delivery - Run delivery service tests"
@echo " test-parser - Run email parser tests"
@echo " test-parser-coverage - Run email parser tests with coverage"
@echo " test-sasl - Run SASL authentication service tests"
@echo " test-conf - Run configuration tests"
@echo " test-utils - Run server utilities tests"
@echo " test-response - Run server response tests"
@echo " test-storage - Run delivery storage tests"
@echo " test-models - Run models tests"
@echo " test-middleware - Run server middleware tests"
@echo " test-selection - Run mailbox selection tests"
@echo " test-core-server - Run core server tests"
@echo " test-capability - Run CAPABILITY command tests only"
@echo " test-noop - Run NOOP command tests only"
@echo " test-check - Run CHECK command tests only"
@echo " test-close - Run CLOSE command tests only"
@echo " test-expunge - Run EXPUNGE command tests only"
@echo " test-e2e - Run end-to-end tests (LMTP→DB→IMAP)"
@echo " test-e2e-delivery - Run delivery E2E tests"
@echo " test-e2e-imap - Run IMAP E2E tests"
@echo " test-e2e-auth - Run authentication E2E tests"
@echo " test-e2e-concurrency - Run concurrency E2E tests"
@echo " test-e2e-persistence - Run persistence E2E tests"
@echo " test-e2e-coverage - Run E2E tests with coverage"
@echo " test-e2e-minimal - Run minimal E2E suite (6 essential tests)"
@echo " test-create - Run CREATE command tests only"
@echo " test-list - Run LIST command tests only"
@echo " test-list-extended - Run LIST extended tests (RFC3501, wildcards, hierarchy, etc.)"
@echo " test-delete - Run DELETE command tests only"
@echo " test-subscribe - Run SUBSCRIBE command tests only"
@echo " test-unsubscribe - Run UNSUBSCRIBE command tests only"
@echo " test-lsub - Run LSUB command tests only"
@echo " test-status - Run STATUS command tests only"
@echo " test-rename - Run RENAME command tests only"
@echo " test-search - Run SEARCH command tests only"
@echo " test-fetch - Run FETCH command tests only"
@echo " test-store - Run STORE command tests only"
@echo " test-copy - Run COPY command tests only"
@echo " test-uid - Run UID command tests only"
@echo " test-commands - Run all command tests (CAPABILITY + NOOP + CHECK + CLOSE + EXPUNGE + LOGOUT + APPEND + AUTHENTICATE + LOGIN + STARTTLS + SELECT + EXAMINE + CREATE + LIST + LIST-EXTENDED + DELETE + SUBSCRIBE + UNSUBSCRIBE + LSUB + STATUS + RENAME + SEARCH + FETCH + STORE + COPY + UID)"
@echo " test-verbose - Run tests with verbose output"
@echo " test-coverage - Run tests with coverage report"
@echo " test-race - Run tests with race detection"
@echo " bench - Run all benchmarks"
@echo " bench-authenticate - Run AUTHENTICATE benchmarks"
@echo " test-single TEST=... - Run a specific test"
@echo ""
@echo "Development:"
@echo " deps - Install dependencies"
@echo " fmt - Format code"
@echo " lint - Lint code"
@echo " clean - Clean test artifacts"
@echo ""
@echo "CI/CD:"
@echo " check - Run all quality checks"
@echo " ci - Run CI pipeline"
@echo ""
@echo " help - Show this help"