def test_control_record_parse():
    record = ControlRecord.parse(b"\x00\x01\x00\x01")
    assert record.version == 1
    assert record.type_ == 1

    record = ControlRecord.parse(b"\xFF\xFF\xFF\xFF")
    assert record.version == 65535
    assert record.type_ == 65535

    record = ControlRecord.parse(b"\x00\xFF\x00\x00")
    assert record.version == 255
    assert record.type_ == 0
Beispiel #2
0
 def _contains_abort_marker(self, next_batch):
     # Control Marker is used to specify when we can stop
     # aborting batches
     try:
         control_record = next(next_batch)
     except StopIteration:  # pragma: no cover
         raise Errors.KafkaError(
             "Control batch did not contain any records")
     return ControlRecord.parse(control_record.key) == ABORT_MARKER
Beispiel #3
0
 def _contains_abort_marker(self, next_batch):
     # Control Marker is used to specify when we can stop
     # aborting batches
     try:
         control_record = next(next_batch)
     except StopIteration:  # pragma: no cover
         raise Errors.KafkaError(
             "Control batch did not contain any records")
     return ControlRecord.parse(control_record.key) == ABORT_MARKER
def test_control_record_other():
    record = ControlRecord.parse(b"\x00\x00\x00\x01")
    assert record != 1
    assert record != object()

    assert repr(record) == "ControlRecord(version=0, type_=1)"
def test_control_record_serde(data, marker):
    assert ControlRecord.parse(data) == marker