joshelser commented on a change in pull request #25: RATIS-588 LogStream
StateMachine export
URL: https://github.com/apache/incubator-ratis/pull/25#discussion_r299662092
##########
File path:
ratis-logservice/src/test/java/org/apache/ratis/logservice/server/TestMetaServer.java
##########
@@ -123,6 +129,41 @@ public void testReadWritetoLog() throws IOException,
InterruptedException {
assert(res.array().length > 0);
}
+ @Test
+ public void testLogArchival() throws IOException, InterruptedException {
+ LogName logName = LogName.of("testArchivalLog");
+ LogStream logStream = client.createLog(logName);
+ LogWriter writer = logStream.createWriter();
+ List<LogInfo> listLogs = client.listLogs();
+ assert (listLogs.stream()
+ .filter(log ->
log.getLogName().getName().startsWith(logName.getName())).count() == 1);
+ List<LogServer> workers = cluster.getWorkers();
+ List<ByteBuffer> records = TestUtils.getRandomData(100, 10);
+ writer.write(records);
+ client.closeLog(logName);
+ assertEquals(logStream.getState(), State.CLOSED);
+ client.archiveLog(logName);
+ int retry = 0;
+ while (logStream.getState() != State.ARCHIVED && retry <= 40) {
+ Thread.sleep(1000);
+ retry++;
+ }
+ assertEquals(logStream.getState(), State.ARCHIVED);
+ LogReader reader = logStream.createReader();
+ List<ByteBuffer> data = reader.readBulk(records.size());
+ assertEquals(records.size(), data.size());
+ reader.seek(1);
+ data = reader.readBulk(records.size());
+ assertEquals(records.size() - 1, data.size());
+
+ //Test ArchiveLogStream
+ LogServiceConfiguration config = LogServiceConfiguration.create();
+ LogStream archiveLogStream = new ArchiveLogStreamImpl(logName, config);
Review comment:
We should have some API wrapper around this and not have users hit this Impl
classes (unless this is specifically just testing the archive reader/write
code). It wouldn't be a bad idea to have some code around these classes, just
validating that they work (in isolation of the LogService Ratis daemons).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services