Skip to content

Commit

Permalink
rptest: add RpkToolTest::test_produce_and_consume_tombstones
Browse files Browse the repository at this point in the history
  • Loading branch information
WillemKauf committed Sep 11, 2024
1 parent 8613940 commit 8d35402
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/rptest/tests/rpk_topic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,46 @@ def cond():

raise ducktape.errors.TimeoutError(
f'Message in {topic} never appeared.')

@cluster(num_nodes=4)
def test_produce_and_consume_tombstones(self):
topic = 'rp_dt_test_produce_and_consume_tombstones'
self._rpk.create_topic(topic)

num_messages = 2

tombstone_key = 'ISTOMBSTONE'
tombstone_value = ''

# Producing a record with an empty value and -Z flag results in a tombstone.
self._rpk.produce(topic,
tombstone_key,
tombstone_value,
tombstone=True)

not_tombstone_key = 'ISNOTTOMBSTONE'

# Producing a record with an empty value without the -Z flag results in an empty value.
self._rpk.produce(topic,
not_tombstone_key,
tombstone_value,
tombstone=False)

c = RpkConsumer(self._ctx, self.redpanda, topic)
c.start()

def cond():
return len(c.messages) == num_messages

wait_until(cond,
timeout_sec=30,
backoff_sec=2,
err_msg=f'Messages in {topic} never appeared.')

# Tombstone records do not have a value in the returned JSON
assert c.messages[0]['key'] == tombstone_key
assert 'value' not in c.messages[0]

# Records with an empty string have a value of `""` in the returned JSON
assert c.messages[1]['key'] == not_tombstone_key
assert c.messages[1]['value'] == ""

0 comments on commit 8d35402

Please sign in to comment.