Skip to content

test(queue/sql): add comprehensive e2e integration tests#35

Merged
behinddwalls merged 1 commit into
mainfrom
preetam/sql-queue-e2e
Feb 21, 2026
Merged

test(queue/sql): add comprehensive e2e integration tests#35
behinddwalls merged 1 commit into
mainfrom
preetam/sql-queue-e2e

Conversation

@behinddwalls
Copy link
Copy Markdown
Collaborator

@behinddwalls behinddwalls commented Feb 20, 2026

Summary

Why?

The SQL queue implementation needs comprehensive integration testing against real MySQL to verify production-like behavior including message workflows, partition management, retries, DLQ
handling, and consumer group coordination.

What?

  • Add 15 e2e integration tests using testcontainers-go covering: basic ops, partitions, visibility timeout, retries, DLQ, concurrency, crash recovery, and consumer groups
  • Refactor test infrastructure: extract MySQL utilities to testutil/mysql.go for reusability across test suites
  • Add integration_tests/queue/README.md documenting test coverage and running instructions

Test Plan

bazel test //integration_tests/queue:queue_test

Issues

@behinddwalls behinddwalls marked this pull request as ready for review February 20, 2026 23:14
@behinddwalls behinddwalls requested review from a team and sbalabanov as code owners February 20, 2026 23:14
behinddwalls added a commit that referenced this pull request Feb 20, 2026
## Summary
## Why?
Need to integrate publisher and subscriber with Queue factory interface
and provide comprehensive documentation and end-to-end testing.

## What?
- Factory creates publisher and subscriber singletons with lifecycle
management
- Comprehensive README with usage examples and architecture docs

## Test Plan


## Issues


## Stack
1. @ #24
1. #34
1. #35
Copy link
Copy Markdown
Contributor

@sbalabanov sbalabanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to discuss how many e2e test suites we want to maintain. All these containers are notoriously slow to setup and start

)

// TestLogger is a simple test-aware logger that records elapsed time between logs.
type TestLogger struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mysql.go is probably not the best filename for this now

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes..we could probably just do one container for mysql for the whole suite and use it for all cases...

@behinddwalls behinddwalls force-pushed the preetam/sql-queue-refactor branch from 4cfb4c5 to fca4ddc Compare February 20, 2026 23:57
behinddwalls added a commit that referenced this pull request Feb 21, 2026
## Summary
Why?
Previously, DLQ messages were stored in a separate queue_dlq table,
requiring separate schema management and limiting the ability to
consume from DLQ topics. By merging DLQ into the messages table with
a topic suffix pattern (e.g., "orders" → "orders_dlq"), we can:
- Reuse existing subscriber/publisher logic for DLQ consumption
- Simplify schema management (single table)
- Track DLQ-specific metadata (failure_count, last_error, etc.)
- Enable DLQ reprocessing workflows

What?
- Add TopicSuffix to DLQConfig (default "_dlq")
- Add DLQ columns to queue_messages schema (failed_at, failure_count,
  last_error, original_topic) as nullable fields
- Update MoveToDLQ to insert into queue_messages with DLQ topic name
- Expose DLQ metadata through delivery metadata for testing
- Remove separate queue_dlq.sql schema
- Update FetchByOffset to select and populate DLQ fields
- Fix unit test mocks to include all 11 columns
- Document retry_count vs failure_count distinction in schema

## Stack
1. @ #34
1. #35
@behinddwalls behinddwalls changed the base branch from preetam/sql-queue-refactor to main February 21, 2026 00:14
Why?
The SQL queue implementation needs thorough integration testing against
a real MySQL database to validate end-to-end functionality including:
- Message publishing and consumption workflows
- Partition management and isolation
- Visibility timeout and retry mechanisms
- DLQ (Dead Letter Queue) handling
- Concurrency and crash recovery scenarios
- Consumer group coordination and load balancing

Without these tests, we cannot verify that the queue behaves correctly
in production-like scenarios with a real database.

What?
- Add 15 comprehensive integration tests using testcontainers-go:
  * Basic operations: publish/subscribe, metadata preservation
  * Partition management: multiple partitions, isolation
  * Reliability: visibility timeout, retry, nack with delay
  * Correctness: idempotent publish, message ordering
  * Concurrency: concurrent publishers, concurrent subscribers
  * Crash recovery: lease expiration and message recovery
  * Consumer groups: multiple groups, multiple workers, load balancing
  * DLQ: max retries, DLQ metadata, failure tracking
  * Edge cases: late subscriber, empty topic, graceful shutdown

- Add integration_tests/queue/README.md with:
  * Test coverage documentation
  * Prerequisites (Docker)
  * Running instructions (Bazel, go test, verbose output)
  * Test descriptions and what each validates

- Refactor integration_tests/testutil for reusability:
  * Extract MySQL container utilities to testutil/mysql.go
  * Share MySQL setup across integration test suites
  * Add schema application helpers

- Test infrastructure improvements:
  * Use testify/suite for setup/teardown lifecycle
  * Tag tests with "integration" for selective execution
  * Support for verbose test output (--test_arg=-test.v)
  * Proper container cleanup in all scenarios

All 15 tests passing in ~2 minutes runtime.

Co-Authored-By: Preetam Dwivedi <preetam@uber.com>
@behinddwalls behinddwalls merged commit 5ce3f0f into main Feb 21, 2026
1 check passed
@behinddwalls behinddwalls deleted the preetam/sql-queue-e2e branch June 2, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants