Skip to content

Commit

Permalink
BufferedStreamConsumerTest: remove non-determinism in size of generat…
Browse files Browse the repository at this point in the history
…ed test records (#9274)

* generate records fixed 40 bytes of size

* fix buffer flush

Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
  • Loading branch information
grubberr authored Jan 4, 2022
1 parent 103e003 commit c0a46c1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected void acceptTracked(final AirbyteMessage message) throws Exception {
// are serialized again when writing to
// the destination
long messageSizeInBytes = ByteUtils.getSizeInBytesForUTF8CharSet(Jsons.serialize(recordMessage.getData()));
if (bufferSizeInBytes + messageSizeInBytes >= maxQueueSizeInBytes) {
if (bufferSizeInBytes + messageSizeInBytes > maxQueueSizeInBytes) {
LOGGER.info("Flushing buffer...");
flushQueueToDestination();
bufferSizeInBytes = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private static List<AirbyteMessage> generateRecords(final long targetSizeInBytes
List<AirbyteMessage> output = Lists.newArrayList();
long bytesCounter = 0;
for (int i = 0;; i++) {
JsonNode payload = Jsons.jsonNode(ImmutableMap.of("id", RandomStringUtils.randomAscii(7), "name", "human " + String.format("%5d", i)));
JsonNode payload = Jsons.jsonNode(ImmutableMap.of("id", RandomStringUtils.randomAlphabetic(7), "name", "human " + String.format("%8d", i)));
long sizeInBytes = ByteUtils.getSizeInBytesForUTF8CharSet(Jsons.serialize(payload));
bytesCounter += sizeInBytes;
AirbyteMessage airbyteMessage = new AirbyteMessage()
Expand Down

0 comments on commit c0a46c1

Please sign in to comment.