You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sh...@apache.org on 2020/06/13 08:21:58 UTC

[incubator-ratis] branch master updated: RATIS-904. Fix Failed UT: testFileStoreAsync (#123)

This is an automated email from the ASF dual-hosted git repository.

shashikant pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git


The following commit(s) were added to refs/heads/master by this push:
     new 201e1ef  RATIS-904. Fix Failed UT: testFileStoreAsync (#123)
201e1ef is described below

commit 201e1ef88fcd99bc6c449799ea8d1807df6265b4
Author: runzhiwang <51...@users.noreply.github.com>
AuthorDate: Sat Jun 13 16:21:47 2020 +0800

    RATIS-904. Fix Failed UT: testFileStoreAsync (#123)
---
 .../main/java/org/apache/ratis/examples/filestore/FileInfo.java    | 7 +++++++
 .../apache/ratis/examples/filestore/FileStoreAsyncBaseTest.java    | 4 ++--
 .../org/apache/ratis/examples/filestore/FileStoreBaseTest.java     | 4 ++--
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileInfo.java b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileInfo.java
index 9bad915..5892036 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileInfo.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileInfo.java
@@ -224,6 +224,13 @@ abstract class FileInfo {
     }
 
     private int write(long offset, ByteString data, boolean close) throws IOException {
+      // If leader finish write data with offset = 4096 and writeSize become 8192,
+      // and 2 follower has not written the data with offset = 4096,
+      // then start a leader election. So client will retry send the data with offset = 4096,
+      // then offset < writeSize in leader.
+      if (offset < writeSize) {
+        return data.size();
+      }
       if (offset != writeSize) {
         throw new IOException("Offset/size mismatched: offset = " + offset
             + " != writeSize = " + writeSize + ", path=" + getRelativePath());
diff --git a/ratis-examples/src/test/java/org/apache/ratis/examples/filestore/FileStoreAsyncBaseTest.java b/ratis-examples/src/test/java/org/apache/ratis/examples/filestore/FileStoreAsyncBaseTest.java
index 7cf8e3a..80e4f7b 100644
--- a/ratis-examples/src/test/java/org/apache/ratis/examples/filestore/FileStoreAsyncBaseTest.java
+++ b/ratis-examples/src/test/java/org/apache/ratis/examples/filestore/FileStoreAsyncBaseTest.java
@@ -59,8 +59,8 @@ public abstract class FileStoreAsyncBaseTest<CLUSTER extends MiniRaftCluster>
     final FileStoreClient client = new FileStoreClient(cluster.getGroup(), getProperties());
     final ExecutorService executor = Executors.newFixedThreadPool(20);
 
-    testSingleFile("foo", SizeInBytes.valueOf("10M"), executor, client);
-    testMultipleFiles("file", 100, SizeInBytes.valueOf("1M"), executor, client);
+    testSingleFile("foo", SizeInBytes.valueOf("2M"), executor, client);
+    testMultipleFiles("file", 20, SizeInBytes.valueOf("1M"), executor, client);
 
     executor.shutdown();
     client.close();
diff --git a/ratis-examples/src/test/java/org/apache/ratis/examples/filestore/FileStoreBaseTest.java b/ratis-examples/src/test/java/org/apache/ratis/examples/filestore/FileStoreBaseTest.java
index 92c81f6..eac5fba 100644
--- a/ratis-examples/src/test/java/org/apache/ratis/examples/filestore/FileStoreBaseTest.java
+++ b/ratis-examples/src/test/java/org/apache/ratis/examples/filestore/FileStoreBaseTest.java
@@ -75,8 +75,8 @@ public abstract class FileStoreBaseTest<CLUSTER extends MiniRaftCluster>
     final CheckedSupplier<FileStoreClient, IOException> newClient =
         () -> new FileStoreClient(cluster.getGroup(), getProperties());
 
-    testSingleFile("foo", SizeInBytes.valueOf("10M"), newClient);
-    testMultipleFiles("file", 100, SizeInBytes.valueOf("1M"), newClient);
+    testSingleFile("foo", SizeInBytes.valueOf("2M"), newClient);
+    testMultipleFiles("file", 20, SizeInBytes.valueOf("1M"), newClient);
 
     cluster.shutdown();
   }