-
Notifications
You must be signed in to change notification settings - Fork 10
[DMS-808] Kafka e2e tests #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds Kafka end-to-end (E2E) testing capabilities to the Data Management Service (DMS), enabling automated testing of Kafka message production when DMS operations occur.
- Implements Kafka E2E test infrastructure with message collection and comparison utilities
- Adds test scenarios for Kafka connectivity and message validation
- Refactors existing test utilities to support reusable JSON comparison logic
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.
Show a summary per file
File | Description |
---|---|
StepDefinitions/KafkaStepDefinitions.cs |
New step definitions for Kafka connectivity testing and message validation |
Management/KafkaMessageCollector.cs |
Core Kafka consumer for collecting test messages with proper lifecycle management |
Management/JsonTestUtilities.cs |
Extracted reusable JSON comparison utilities from existing step definitions |
StepDefinitions/StepDefinitions.cs |
Refactored to use centralized JSON comparison utilities |
Features/General/KafkaMessaging.feature |
Test scenarios for Kafka functionality |
Configuration files | Updates to support Kafka testing in CI environment |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/dms/tests/EdFi.DataManagementService.Tests.E2E/StepDefinitions/KafkaStepDefinitions.cs
Outdated
Show resolved
Hide resolved
src/dms/tests/EdFi.DataManagementService.Tests.E2E/StepDefinitions/KafkaStepDefinitions.cs
Outdated
Show resolved
Hide resolved
src/dms/tests/EdFi.DataManagementService.Tests.E2E/Management/KafkaMessageCollector.cs
Outdated
Show resolved
Hide resolved
src/dms/tests/EdFi.DataManagementService.Tests.E2E/Management/KafkaMessageCollector.cs
Outdated
Show resolved
Hide resolved
src/dms/tests/EdFi.DataManagementService.Tests.E2E/Management/KafkaMessageCollector.cs
Show resolved
Hide resolved
src/dms/tests/EdFi.DataManagementService.Tests.E2E/Management/ContainerSetupBase.cs
Show resolved
Hide resolved
|
||
- name: Build | ||
run: ./build-dms.ps1 Build -Configuration ${{ env.CONFIGURATION }} -IdentityProvider ${{matrix.identityprovider}} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kafka E2E Test Connectivity Fix
Challenge
Kafka E2E tests passed locally but failed in CI with message consumption errors. The issue was a Docker networking mismatch between Kafka's advertised listeners and how clients connect in different environments.
Root Cause
- Kafka advertises
PLAINTEXT://dms-kafka1:9092
- E2E tests were hardcoded to
localhost:9092
- Local works with host file entry (
127.0.0.1 dms-kafka1
) - CI fails because
dms-kafka1
hostname doesn't resolve
Attempted Solutions
- Dual listeners (INTERNAL/EXTERNAL) - Failed due to topic isolation between listeners
- Single listener with localhost - Failed because containers can't reach each other via localhost
- Network aliases - Failed due to Kafka's advertised listener behavior
Final Solution
Made E2E test connection configurable via environment variable:
- Added
KAFKA_BOOTSTRAP_SERVERS
environment variable toKafkaStepDefinitions.cs
- CI uses
dms-kafka1:9092
with host file entry - Local development continues using
localhost:9092
with host file entry - Kept original Kafka configuration intact
@@ -17,38 +17,17 @@ public static class SetupHooks | |||
[BeforeTestRun] | |||
public static async Task BeforeTestRun(PlaywrightContext context, TestLogger logger) | |||
{ | |||
if (AppSettings.UseTestContainers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed dead code from the TestContainers days. (It really trips up AI)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
085368c
to
4b33f44
Compare
src/dms/tests/EdFi.DataManagementService.Tests.E2E/Management/JsonTestUtilities.cs
Show resolved
Hide resolved
namespace EdFi.DataManagementService.Tests.E2E.StepDefinitions; | ||
|
||
[Binding] | ||
public class KafkaStepDefinitions(TestLogger logger) : IDisposable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is sweet!
private readonly TestLogger _logger; | ||
private readonly DateTime _collectionStartTime; | ||
|
||
public KafkaMessageCollector(string bootstrapServers, TestLogger logger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a comment that this is the Kafka listener/consumer
No description provided.