-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'stability-improvements' into fix-logging
- Loading branch information
Showing
13 changed files
with
249 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
...or/src/test/java/io/pravega/sensor/collector/file/csvfile/CSVFileEventGeneratorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/** | ||
* Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.pravega.sensor.collector.file.csvfile; | ||
|
||
import com.google.common.io.CountingInputStream; | ||
import io.pravega.sensor.collector.file.EventGenerator; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import io.pravega.sensor.collector.util.PravegaWriterEvent; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CSVFileEventGeneratorTests { | ||
private static final Logger log = LoggerFactory.getLogger(CSVFileEventGeneratorTests.class); | ||
|
||
@Test | ||
public void Test3by2() throws IOException { | ||
final EventGenerator eventGenerator = CsvFileEventGenerator.create("routingKey1", 2); | ||
final String csvStr = | ||
"\"Time\",\"X\",\"Y\",\"Z\",\"IN_PROGRESS\"\n" + | ||
"\"2020-07-15 23:59:50.352\",\"0.305966\",\"0.0\",\"9.331963\",\"0\"\n" + | ||
"\"2020-07-15 23:59:50.362\",\"1.305966\",\"0.1\",\"1.331963\",\"0\"\n" + | ||
"\"2020-07-15 23:59:50.415\",\"0.305966\",\"0.0\",\"9.331963\",\"0\"\n"; | ||
final CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(csvStr.getBytes(StandardCharsets.UTF_8))); | ||
final List<PravegaWriterEvent> events = new ArrayList<>(); | ||
Pair<Long, Long> nextSequenceNumberAndOffset = eventGenerator.generateEventsFromInputStream(inputStream, 100, events::add); | ||
log.info("events={}", events); | ||
Assertions.assertEquals(102L, (long) nextSequenceNumberAndOffset.getLeft()); | ||
Assertions.assertEquals(csvStr.length(), (long) nextSequenceNumberAndOffset.getRight()); | ||
} | ||
|
||
@Test | ||
public void Test3by3() throws IOException { | ||
final EventGenerator eventGenerator = CsvFileEventGenerator.create("routingKey1", 3); | ||
final String csvStr = | ||
"\"Time\",\"X\",\"Y\",\"Z\",\"IN_PROGRESS\"\n" + | ||
"\"2020-07-15 23:59:50.352\",\"0.305966\",\"0.0\",\"9.331963\",\"0\"\n" + | ||
"\"2020-07-15 23:59:50.362\",\"1.305966\",\"0.1\",\"1.331963\",\"0\"\n" + | ||
"\"2020-07-15 23:59:50.415\",\"0.305966\",\"0.0\",\"9.331963\",\"0\"\n"; | ||
final CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(csvStr.getBytes(StandardCharsets.UTF_8))); | ||
final List<PravegaWriterEvent> events = new ArrayList<>(); | ||
Pair<Long, Long> nextSequenceNumberAndOffset = eventGenerator.generateEventsFromInputStream(inputStream, 100, events::add); | ||
log.info("events={}", events); | ||
Assertions.assertEquals(101L, (long) nextSequenceNumberAndOffset.getLeft()); | ||
Assertions.assertEquals(csvStr.length(), (long) nextSequenceNumberAndOffset.getRight()); | ||
} | ||
|
||
@Test | ||
public void Test1by3() throws IOException { | ||
final EventGenerator eventGenerator = CsvFileEventGenerator.create("routingKey1", 3); | ||
final String csvStr = | ||
"\"Time\",\"X\",\"Y\",\"Z\",\"IN_PROGRESS\"\n" + | ||
"\"2020-07-15 23:59:50.352\",\"0.305966\",\"0.0\",\"9.331963\",\"0\"\n"; | ||
final CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(csvStr.getBytes(StandardCharsets.UTF_8))); | ||
final List<PravegaWriterEvent> events = new ArrayList<>(); | ||
Pair<Long, Long> nextSequenceNumberAndOffset = eventGenerator.generateEventsFromInputStream(inputStream, 100, events::add); | ||
log.info("events={}", events); | ||
Assertions.assertEquals(101L, (long) nextSequenceNumberAndOffset.getLeft()); | ||
Assertions.assertEquals(csvStr.length(), (long) nextSequenceNumberAndOffset.getRight()); | ||
} | ||
|
||
@Test | ||
public void Test0by3() throws IOException { | ||
final EventGenerator eventGenerator = CsvFileEventGenerator.create("routingKey1", 3); | ||
final String csvStr = | ||
"\"Time\",\"X\",\"Y\",\"Z\",\"IN_PROGRESS\"\n"; | ||
final CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(csvStr.getBytes(StandardCharsets.UTF_8))); | ||
final List<PravegaWriterEvent> events = new ArrayList<>(); | ||
Pair<Long, Long> nextSequenceNumberAndOffset = eventGenerator.generateEventsFromInputStream(inputStream, 100, events::add); | ||
log.info("events={}", events); | ||
Assertions.assertEquals(100L, (long) nextSequenceNumberAndOffset.getLeft()); | ||
Assertions.assertEquals(csvStr.length(), (long) nextSequenceNumberAndOffset.getRight()); | ||
} | ||
|
||
@Test | ||
public void TestEmptyFile() throws IOException { | ||
final EventGenerator eventGenerator = CsvFileEventGenerator.create("routingKey1", 3); | ||
final String csvStr = ""; | ||
final CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(csvStr.getBytes(StandardCharsets.UTF_8))); | ||
final List<PravegaWriterEvent> events = new ArrayList<>(); | ||
Pair<Long, Long> nextSequenceNumberAndOffset = eventGenerator.generateEventsFromInputStream(inputStream, 100, events::add); | ||
log.info("events={}", events); | ||
Assertions.assertEquals(100L, (long) nextSequenceNumberAndOffset.getLeft()); | ||
Assertions.assertEquals(csvStr.length(), (long) nextSequenceNumberAndOffset.getRight()); | ||
} | ||
|
||
@Test | ||
public void test7by3() throws IOException { | ||
final EventGenerator eventGenerator = CsvFileEventGenerator.create("routingKey1", 3); | ||
final String csvStr = | ||
"\"Time\",\"X\",\"Y\",\"Z\",\"IN_PROGRESS\"\n" + | ||
"\"2020-07-15 23:59:50.352\",\"0.305966\",\"0.0\",\"9.331963\",\"0\"\n" + | ||
"\"2020-07-15 23:59:50.362\",\"1.305966\",\"0.1\",\"1.331963\",\"0\"\n" + | ||
"\"2020-07-15 23:59:50.352\",\"0.305966\",\"0.0\",\"9.331963\",\"0\"\n" + | ||
"\"2020-07-15 23:59:50.362\",\"1.305966\",\"0.1\",\"1.331963\",\"0\"\n" + | ||
"\"2020-07-15 23:59:50.352\",\"0.305966\",\"0.0\",\"9.331963\",\"0\"\n" + | ||
"\"2020-07-15 23:59:50.362\",\"1.305966\",\"0.1\",\"1.331963\",\"0\"\n" + | ||
"\"2020-07-15 23:59:50.415\",\"0.305966\",\"0.0\",\"9.331963\",\"0\"\n"; | ||
final CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(csvStr.getBytes(StandardCharsets.UTF_8))); | ||
final List<PravegaWriterEvent> events = new ArrayList<>(); | ||
Pair<Long, Long> nextSequenceNumberAndOffset = eventGenerator.generateEventsFromInputStream(inputStream, 100, events::add); | ||
log.info("events={}", events); | ||
Assertions.assertEquals(103L, (long) nextSequenceNumberAndOffset.getLeft()); | ||
Assertions.assertEquals(csvStr.length(), (long) nextSequenceNumberAndOffset.getRight()); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...or/src/test/java/io/pravega/sensor/collector/file/parquet/ParquetEventGeneratorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.pravega.sensor.collector.file.parquet; | ||
|
||
import com.google.common.io.CountingInputStream; | ||
import io.pravega.sensor.collector.file.EventGenerator; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import io.pravega.sensor.collector.util.FileNameWithOffset; | ||
import io.pravega.sensor.collector.util.FileUtils; | ||
import io.pravega.sensor.collector.util.PravegaWriterEvent; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ParquetEventGeneratorTests { | ||
private static final Logger log = LoggerFactory.getLogger(ParquetEventGeneratorTests.class); | ||
|
||
@Test | ||
public void TestFile() throws IOException { | ||
final EventGenerator eventGenerator = ParquetEventGenerator.create("routingKey1",100); | ||
final List<FileNameWithOffset> files = FileUtils.getDirectoryListing("../parquet-file-sample-data","parquet"); | ||
File parquetData= new File(files.get(0).fileName); | ||
|
||
final CountingInputStream inputStream = new CountingInputStream(new FileInputStream(parquetData)); | ||
final List<PravegaWriterEvent> events = new ArrayList<>(); | ||
Pair<Long, Long> nextSequenceNumberAndOffset = eventGenerator.generateEventsFromInputStream(inputStream, 1, events::add); | ||
log.info("events={}", events); | ||
Assert.assertEquals(501L, (long) nextSequenceNumberAndOffset.getLeft()); | ||
Assert.assertEquals(parquetData.length(), (long) nextSequenceNumberAndOffset.getRight()); | ||
} | ||
|
||
} |
Oops, something went wrong.