Skip to content

Conversation

k-raina
Copy link
Member

@k-raina k-raina commented Aug 28, 2025

Why

This PR enables automated performance testing of the Kafka Python client using the ducktape distributed testing framework.

What's Added

New Semaphore CI Block

  • Job: "Standard Ducktape Producer Tests"
  • Environment: Linux x64 with Python 3.9
  • Kafka Setup: KRaft mode (controller-less) for faster startup
  • Dependencies: ducktape, psutil, confluent-kafka with librdkafka

Environment-Based Benchmark Configuration

  • Local Environment: Relaxed thresholds for development (1000 msg/s, 2000ms latency)
  • CI Environment: Strict production-like bounds (1500 msg/s, 1500ms latency)
  • Auto-Detection: CI automatically uses stricter bounds, local defaults to relaxed

Technical Implementation

Files Added/Modified

  • .semaphore/semaphore.yml - New ducktape CI block with KRaft Kafka setup
  • tests/ducktape/benchmark_bounds.json - Environment-based performance bounds
  • tests/ducktape/benchmark_metrics.py - Environment detection logic
  • tests/ducktape/run_ducktape_test.py - Enhanced test runner with error handling
  • tests/docker/docker-compose.ducktape.yml - Dedicated KRaft Kafka for CI

Testing PR

  • When bounds are violated -> Pipeline fails check link
  • When bounds are not voilated -> Pipeline passes link

Benefits

  • Automated Performance Monitoring: Catches performance regressions in CI
  • Extensible: Easy to add new environments and customize thresholds

Usage Examples

# Default (local development)
python tests/ducktape/run_ducktape_test.py

# CI environment (automatic in Semaphore)
BENCHMARK_ENVIRONMENT=ci python tests/ducktape/run_ducktape_test.py

# Custom environment
BENCHMARK_ENVIRONMENT=staging python tests/ducktape/run_ducktape_test.py

@Copilot Copilot AI review requested due to automatic review settings August 28, 2025 14:46
@k-raina k-raina requested review from MSeal and a team as code owners August 28, 2025 14:46
@confluent-cla-assistant
Copy link

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

Copy link

@Copilot Copilot AI left a 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 a new Ducktape performance test block to the Semaphore CI configuration to enable testing of the confluent-kafka Python client using the ducktape framework.

  • Adds a new CI job for running ducktape performance tests on Linux x64
  • Configures environment setup including Python 3.9, ducktape framework, and Kafka cluster
  • Implements test execution with CI-specific benchmark bounds configuration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- cd tests/docker && ./bin/cluster_up.sh

# Wait for Kafka to be ready
- timeout 60 bash -c 'until docker-compose -f tests/docker/docker-compose.yaml exec -T kafka kafka-topics --bootstrap-server localhost:9092 --list >/dev/null 2>&1; do echo "Waiting for Kafka..."; sleep 5; done'
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

The hardcoded path 'tests/docker/docker-compose.yaml' in the timeout command doesn't match the working directory change in line 316. Since the script changes to 'tests/docker', the path should be relative: 'docker-compose.yaml' or use an absolute path.

Suggested change
- timeout 60 bash -c 'until docker-compose -f tests/docker/docker-compose.yaml exec -T kafka kafka-topics --bootstrap-server localhost:9092 --list >/dev/null 2>&1; do echo "Waiting for Kafka..."; sleep 5; done'
- timeout 60 bash -c 'until docker-compose -f docker-compose.yaml exec -T kafka kafka-topics --bootstrap-server localhost:9092 --list >/dev/null 2>&1; do echo "Waiting for Kafka..."; sleep 5; done'

Copilot uses AI. Check for mistakes.

- timeout 60 bash -c 'until docker-compose -f tests/docker/docker-compose.yaml exec -T kafka kafka-topics --bootstrap-server localhost:9092 --list >/dev/null 2>&1; do echo "Waiting for Kafka..."; sleep 5; done'

# Run standard ducktape tests with CI bounds
- export BENCHMARK_BOUNDS_CONFIG=tests/ducktape/ci_bounds.json
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

The BENCHMARK_BOUNDS_CONFIG environment variable is being set twice - once in the env_vars section (line 290) and again as an export command. The duplicate export is redundant since the environment variable is already configured at the block level.

Suggested change
- export BENCHMARK_BOUNDS_CONFIG=tests/ducktape/ci_bounds.json

Copilot uses AI. Check for mistakes.

@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

1 similar comment
@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

1 similar comment
@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

@k-raina k-raina changed the title {WIP} - Add semaphore block for ducktape tests Add semaphore block for ducktape tests Aug 29, 2025
@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent
Copy link

Passed

Analysis Details

1 Issue

  • Bug 0 Bugs
  • Vulnerability 0 Vulnerabilities
  • Code Smell 1 Code Smell

Coverage and Duplications

  • Coverage No coverage information (66.40% Estimated after merge)
  • Duplications No duplication information (5.60% Estimated after merge)

Project ID: confluent-kafka-python

View in SonarQube

task:
agent:
machine:
type: s1-prod-ubuntu24-04-amd64-3
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, how is the machine type chosen?

Copy link
Member Author

Choose a reason for hiding this comment

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

"s1-prod-" this is a production grade system, which is used by other semaphore jobs. IMO, its already timetested for this repository, so we should keep using it.

KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
CLUSTER_ID: 4L6g3nShT-eMCtK--X86sw
Copy link
Member

Choose a reason for hiding this comment

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

For my knowledge, is this the cluster dedicated for kafka testing? https://github.com/search?q=org%3Aconfluentinc%204L6g3nShT-eMCtK--X86sw&type=code

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes Each CI job spins up its own isolated Kafka container with this ID

@k-raina k-raina requested a review from fangnx September 1, 2025 12:18
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