-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration test #49
Merged
abhinb
merged 8 commits into
pravega:stability-improvements-v2
from
dada-dell-emc:stability-improvements-v2
Feb 13, 2024
Merged
Integration test #49
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
def9f6f
Added end to end integration test
dada-dell-emc afd9ded
Removed unused object
dada-dell-emc d4398b1
Reverted pravega version upgrade
dada-dell-emc b9057af
Added new test case to validate pravega integration
dada-dell-emc b975344
Removed test execution ordering, extracted validation code.
dada-dell-emc 173688c
Changed garbage completed files time interval from minute to seconds,…
dada-dell-emc 0ad1f34
Merge branch 'stability-improvements-v2' into stability-improvements-v2
dada-dell-emc 90fc626
Fixed post merge changes to work integration tests
dada-dell-emc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello World. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ public abstract class FileIngestService extends DeviceDriver { | |
private static final String EXACTLY_ONCE_KEY = "EXACTLY_ONCE"; | ||
private static final String TRANSACTION_TIMEOUT_MINUTES_KEY = "TRANSACTION_TIMEOUT_MINUTES"; | ||
private static final String MIN_TIME_IN_MILLIS_TO_UPDATE_FILE_KEY = "MIN_TIME_IN_MILLIS_TO_UPDATE_FILE"; | ||
private static final String DELETE_COMPLETED_FILES_INTERVAL_IN_MINUTES_KEY = "DELETE_COMPLETED_FILES_INTERVAL_IN_MINUTES"; | ||
private static final String DELETE_COMPLETED_FILES_INTERVAL_IN_SECONDS_KEY = "DELETE_COMPLETED_FILES_INTERVAL_IN_SECONDS"; | ||
private static final String ENABLE_LARGE_EVENT = "ENABLE_LARGE_EVENT"; | ||
|
||
private static final int DEFAULT_SAMPLES_PER_EVENT_KEY = 100; | ||
|
@@ -137,8 +137,8 @@ long getMinTimeInMillisToUpdateFile() { | |
return Long.parseLong(getProperty(MIN_TIME_IN_MILLIS_TO_UPDATE_FILE_KEY, "5000")); | ||
} | ||
|
||
long getDeleteCompletedFilesIntervalInMinutes() { | ||
return Long.parseLong(getProperty(DELETE_COMPLETED_FILES_INTERVAL_IN_MINUTES_KEY, "720")); | ||
long getDeleteCompletedFilesIntervalInSeconds() { | ||
return Long.parseLong(getProperty(DELETE_COMPLETED_FILES_INTERVAL_IN_SECONDS_KEY, "43200")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it like are we trying to delete completed file every 12 hours? @dada-dell-emc There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
} | ||
|
||
boolean getLargeEventEnable() { | ||
|
@@ -167,14 +167,14 @@ protected void processFiles() { | |
} | ||
|
||
protected void deleteCompletedFiles() { | ||
LOG.trace("deleteCompletedFiles: BEGIN"); | ||
LOG.debug("deleteCompletedFiles: BEGIN"); | ||
try { | ||
processor.deleteCompletedFiles(); | ||
} catch (Exception e) { | ||
LOG.error("deleteCompletedFiles: Delete file error", e); | ||
// Continue on any errors. We will retry on the next iteration. | ||
} | ||
LOG.trace("deleteCompletedFiles: END"); | ||
LOG.debug("deleteCompletedFiles: END"); | ||
} | ||
|
||
@Override | ||
|
@@ -199,17 +199,19 @@ protected void doStart() { | |
deleteFileTask = executor.scheduleAtFixedRate( | ||
this::deleteCompletedFiles, | ||
1, | ||
getDeleteCompletedFilesIntervalInMinutes(), | ||
TimeUnit.MINUTES); | ||
getDeleteCompletedFilesIntervalInSeconds(), | ||
TimeUnit.SECONDS); | ||
|
||
notifyStarted(); | ||
} | ||
|
||
@Override | ||
protected void doStop() { | ||
LOG.info("doStop: Cancelling ingestion task and process file task"); | ||
LOG.info("doStop: Cancelling ingestion, process and delete file task"); | ||
watchFileTask.cancel(false); | ||
processFileTask.cancel(false); | ||
deleteFileTask.cancel(false); | ||
LOG.info("doStop: Cancelled ingestion, process and delete file task"); | ||
notifyStopped(); | ||
} | ||
} |
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
209 changes: 209 additions & 0 deletions
209
...tor/src/test/java/io/pravega/sensor/collector/PravegaSensorCollectorIntegrationTests.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,209 @@ | ||
package io.pravega.sensor.collector; | ||
|
||
import com.google.common.util.concurrent.Service; | ||
import io.pravega.client.ClientConfig; | ||
import io.pravega.client.EventStreamClientFactory; | ||
import io.pravega.client.admin.ReaderGroupManager; | ||
import io.pravega.client.admin.StreamManager; | ||
import io.pravega.client.stream.*; | ||
import io.pravega.client.stream.impl.UTF8StringSerializer; | ||
import io.pravega.sensor.collector.util.FileNameWithOffset; | ||
import io.pravega.sensor.collector.util.SQliteDBUtility; | ||
import io.pravega.sensor.collector.util.TransactionStateDB; | ||
import io.pravega.sensor.collector.util.TransactionStateSQLiteImpl; | ||
import io.pravega.test.integration.utils.SetupUtils; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.nio.file.StandardCopyOption; | ||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
import java.time.Duration; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
import org.junit.jupiter.api.*; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class PravegaSensorCollectorIntegrationTests { | ||
private static final Logger log = LoggerFactory.getLogger(PravegaSensorCollectorIntegrationTests.class); | ||
private final SetupUtils setupUtils = new SetupUtils(); | ||
static String fileName = "./src/test/resources/RawFileIngest-integration-test.properties"; | ||
Map<String, String> properties = null; | ||
@BeforeEach | ||
public void setup() { | ||
log.info("Setup"); | ||
properties = Parameters.getProperties(fileName); | ||
try { | ||
setupUtils.startAllServices(); | ||
|
||
Files.deleteIfExists(Paths.get(properties.get("PRAVEGA_SENSOR_COLLECTOR_RAW1_DATABASE_FILE"))); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
properties.put("PRAVEGA_SENSOR_COLLECTOR_RAW1_PRAVEGA_CONTROLLER_URI", setupUtils.getControllerUri().toString()); | ||
log.debug("Properties: {}", properties); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() { | ||
log.info("TearDown"); | ||
try { | ||
setupUtils.stopAllServices(); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
try { | ||
Files.deleteIfExists(Paths.get(properties.get("PRAVEGA_SENSOR_COLLECTOR_RAW1_DATABASE_FILE"))); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
properties = null; | ||
} | ||
|
||
@Test | ||
@Timeout(value = 1, unit = TimeUnit.MINUTES) | ||
public void testPSCDataIntegration() { | ||
try { | ||
copyHelloWorldFile(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
URI controllerURI = setupUtils.getControllerUri(); | ||
String scope = "test-psc-data-integration"; | ||
String streamName ="test-psc-data-integration-stream"; | ||
|
||
properties.put("PRAVEGA_SENSOR_COLLECTOR_RAW1_SCOPE",scope); | ||
properties.put("PRAVEGA_SENSOR_COLLECTOR_RAW1_STREAM",streamName); | ||
|
||
final DeviceDriverManager deviceDriverManager = new DeviceDriverManager(properties); | ||
Service startService = deviceDriverManager.startAsync(); | ||
try { | ||
startService.awaitRunning(Duration.ofSeconds(30)); | ||
Thread.sleep(12000); | ||
} catch (InterruptedException | TimeoutException e) { | ||
throw new RuntimeException(e); | ||
} | ||
final Connection connection = SQliteDBUtility.createDatabase(properties.get("PRAVEGA_SENSOR_COLLECTOR_RAW1_DATABASE_FILE")); | ||
final TransactionStateDB state = new TransactionStateSQLiteImpl(connection, null); | ||
|
||
try { | ||
List<FileNameWithOffset> completedFiles = state.getCompletedFileRecords(); | ||
Assertions.assertEquals(1, completedFiles.size()); | ||
|
||
validateStreamData(controllerURI, scope, streamName, new String(Files.readAllBytes(Paths.get("../parquet-file-sample-data/test_file/hello-world.parquet")))); | ||
|
||
Thread.sleep(5000); | ||
|
||
Service stopService = deviceDriverManager.stopAsync(); | ||
stopService.awaitTerminated(Duration.ofSeconds(10)); | ||
|
||
// Till this time all the completed files should get deleted | ||
completedFiles = state.getCompletedFileRecords(); | ||
Assertions.assertEquals(0, completedFiles.size()); | ||
connection.close(); | ||
} catch (SQLException | InterruptedException | TimeoutException | IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
private static void validateStreamData(URI controllerURI, String scope, String streamName, String content) { | ||
StreamManager streamManager = StreamManager.create(controllerURI); | ||
|
||
final String readerGroup = UUID.randomUUID().toString().replace("-", ""); | ||
final ReaderGroupConfig readerGroupConfig = ReaderGroupConfig.builder() | ||
.stream(Stream.of(scope, streamName)) | ||
.build(); | ||
try (ReaderGroupManager readerGroupManager = ReaderGroupManager.withScope(scope, controllerURI)) { | ||
readerGroupManager.createReaderGroup(readerGroup, readerGroupConfig); | ||
} | ||
|
||
try (EventStreamClientFactory clientFactory = EventStreamClientFactory.withScope(scope, | ||
ClientConfig.builder().controllerURI(controllerURI).build()); | ||
EventStreamReader<String> reader = clientFactory.createReader("reader", | ||
readerGroup, | ||
new UTF8StringSerializer(), | ||
ReaderConfig.builder().build())) { | ||
System.out.format("Reading all the events from %s/%s%n", scope, streamName); | ||
EventRead<String> eventRead = null; | ||
try { | ||
while ((eventRead = reader.readNextEvent(2000)).getEvent() != null) { | ||
String event = eventRead.getEvent(); | ||
System.out.format("Read event: %s", event); | ||
Assertions.assertNotNull(event); | ||
Assertions.assertFalse(event.isEmpty()); | ||
Assertions.assertEquals(content, event); | ||
} | ||
} catch (ReinitializationRequiredException e) { | ||
//There are certain circumstances where the reader needs to be reinitialized | ||
e.printStackTrace(); | ||
} | ||
System.out.format("No more events from %s/%s%n", scope, streamName); | ||
} | ||
} | ||
|
||
public void copyHelloWorldFile() throws IOException { | ||
Path sourcePath = Paths.get("../parquet-file-sample-data/test_file/hello-world.parquet"); | ||
Path targetPath = Paths.get("../parquet-file-sample-data/integration-test/hello-world.parquet"); | ||
Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); | ||
} | ||
|
||
@Test | ||
@Timeout(value = 1, unit = TimeUnit.MINUTES) | ||
public void testRawFile() { | ||
try { | ||
copyFile(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
final DeviceDriverManager deviceDriverManager = new DeviceDriverManager(properties); | ||
Service startService = deviceDriverManager.startAsync(); | ||
try { | ||
startService.awaitRunning(Duration.ofSeconds(30)); | ||
Thread.sleep(15000); | ||
} catch (InterruptedException | TimeoutException e) { | ||
throw new RuntimeException(e); | ||
} | ||
final Connection connection = SQliteDBUtility.createDatabase(properties.get("PRAVEGA_SENSOR_COLLECTOR_RAW1_DATABASE_FILE")); | ||
final TransactionStateDB state = new TransactionStateSQLiteImpl(connection, null); | ||
|
||
try { | ||
List<FileNameWithOffset> completedFiles = state.getCompletedFileRecords(); | ||
Assertions.assertEquals(3, completedFiles.size()); | ||
|
||
Thread.sleep(5000); | ||
|
||
Service stopService = deviceDriverManager.stopAsync(); | ||
stopService.awaitTerminated(Duration.ofSeconds(10)); | ||
|
||
// Till this time all the completed files should get deleted | ||
completedFiles = state.getCompletedFileRecords(); | ||
Assertions.assertEquals(0, completedFiles.size()); | ||
connection.close(); | ||
} catch (SQLException | InterruptedException | TimeoutException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public void copyFile() throws IOException { | ||
Path sourcePath = Paths.get("../parquet-file-sample-data/test_file/sub1.parquet"); | ||
Path targetPath = Paths.get("../parquet-file-sample-data/integration-test/sub1.parquet"); | ||
Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); | ||
sourcePath = Paths.get("../parquet-file-sample-data/test_file/sub2.parquet"); | ||
targetPath = Paths.get("../parquet-file-sample-data/integration-test/sub2.parquet"); | ||
Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); | ||
sourcePath = Paths.get("../parquet-file-sample-data/test_file/sub3.parquet"); | ||
targetPath = Paths.get("../parquet-file-sample-data/integration-test/sub3.parquet"); | ||
Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); | ||
log.info("copyFile: Files copied successfully"); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we are going to lower version here @dada-dell-emc ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of higher version there is conflicting versions dependency on glassfish library.