Skip to content

Commit

Permalink
Merge pull request #982 from Aiven-Open/davide-armand/fix-flaky-test_…
Browse files Browse the repository at this point in the history
…roundtrip_from_kafka_state

tests,backup: fix flakiness by using current timestamps
  • Loading branch information
eliax1996 authored Oct 25, 2024
2 parents 60b5db6 + cfc4e1a commit 8e3d735
Showing 1 changed file with 7 additions and 6 deletions.
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

0 comments on commit 8e3d735

Please sign in to comment.