Skip to content
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

tests,backup: fix flakiness by using current timestamps #982

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions tests/integration/backup/test_v3_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,13 @@ def test_roundtrip_from_kafka_state(
admin_client.update_topic_config(new_topic.topic, {"max.message.bytes": "999"})

# Populate topic.
producer.send(
first_record_fut = producer.send(
new_topic.topic,
key=b"bar",
value=b"foo",
partition=0,
timestamp=1683474641,
)
producer.send(
second_record_fut = producer.send(
new_topic.topic,
key=b"foo",
value=b"bar",
Expand All @@ -135,10 +134,12 @@ def test_roundtrip_from_kafka_state(
("some-header", b"some header value"),
("other-header", b"some other header value"),
],
timestamp=1683474657,
)
producer.flush()

first_message_timestamp = first_record_fut.result(timeout=5).timestamp()[1]
second_message_timestamp = second_record_fut.result(timeout=5).timestamp()[1]

topic_config = get_topic_configurations(admin_client, new_topic.topic, {ConfigSource.DYNAMIC_TOPIC_CONFIG})

# Execute backup creation.
Expand Down Expand Up @@ -212,7 +213,7 @@ def test_roundtrip_from_kafka_state(
# Note: This might be unreliable due to not using idempotent producer, i.e. we have
# no guarantee against duplicates currently.
assert first_record.offset() == 0
assert first_record.timestamp()[1] == 1683474641
assert first_record.timestamp()[1] == first_message_timestamp
assert first_record.timestamp()[0] == Timestamp.CREATE_TIME
assert first_record.key() == b"bar"
assert first_record.value() == b"foo"
Expand All @@ -223,7 +224,7 @@ def test_roundtrip_from_kafka_state(
assert second_record.topic() == new_topic.topic
assert second_record.partition() == partition
assert second_record.offset() == 1
assert second_record.timestamp()[1] == 1683474657
assert second_record.timestamp()[1] == second_message_timestamp
assert second_record.timestamp()[0] == Timestamp.CREATE_TIME
assert second_record.key() == b"foo"
assert second_record.value() == b"bar"
Expand Down
Loading