Luo Chen has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/2437

Change subject: [ASTERIXDB-2304] Ensure Flush is Finished in FlushRecoveryTest
......................................................................

[ASTERIXDB-2304] Ensure Flush is Finished in FlushRecoveryTest

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Previous in LSMFlushRecoveryTest, it's possible during recovery
we check component ids before the flush is finished (since flush is
asynchronous), and thus causes intermittent failures. This patch fixes
this problem by waiting for active IOs before checking component ids.

Change-Id: I1704c6606c7c7bef226ae31961c347c6ebb76c2a
---
M 
asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/LSMFlushRecoveryTest.java
1 file changed, 24 insertions(+), 25 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/37/2437/1

diff --git 
a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/LSMFlushRecoveryTest.java
 
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/LSMFlushRecoveryTest.java
index b10e9b1..e9e84f36 100644
--- 
a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/LSMFlushRecoveryTest.java
+++ 
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/LSMFlushRecoveryTest.java
@@ -32,6 +32,7 @@
 import org.apache.asterix.common.api.IDatasetLifecycleManager;
 import org.apache.asterix.common.config.DatasetConfig.IndexType;
 import org.apache.asterix.common.config.StorageProperties.Option;
+import org.apache.asterix.common.context.DatasetInfo;
 import org.apache.asterix.common.dataflow.LSMInsertDeleteOperatorNodePushable;
 import org.apache.asterix.common.transactions.ITransactionContext;
 import org.apache.asterix.common.transactions.ITransactionManager;
@@ -64,7 +65,6 @@
 import org.junit.Test;
 
 public class LSMFlushRecoveryTest {
-
     private static TestNodeController nc;
     private static Dataset dataset;
     private static PrimaryIndexInfo primaryIndexInfo;
@@ -111,31 +111,30 @@
     }
 
     @After
-    public void testRecovery() {
-        try {
-            // right now we've inserted 1000 records to the index, and each 
record is at least 12 bytes.
-            // thus, the memory component size is at least 12KB.
-            List<Pair<IOption, Object>> opts = new ArrayList<>();
-            opts.add(Pair.of(Option.STORAGE_MEMORYCOMPONENT_GLOBALBUDGET, 
"128MB"));
-            opts.add(Pair.of(Option.STORAGE_MAX_ACTIVE_WRITABLE_DATASETS, 
"10000"));
-            nc.setOpts(opts);
-            nc.init(false);
-            initializeTestCtx();
-            readIndex();
-            checkComponentIds();
-            insertOp = StorageTestUtils.getInsertPipeline(nc, ctx, 
secondaryIndexEntity);
-            // insert more records
-            insertRecords(StorageTestUtils.TOTAL_NUM_OF_RECORDS, 
StorageTestUtils.RECORDS_PER_COMPONENT);
-            checkComponentIds();
+    public void testRecovery() throws Exception {
+        // right now we've inserted 1000 records to the index, and each record 
is at least 12 bytes.
+        // thus, the memory component size is at least 12KB.
+        List<Pair<IOption, Object>> opts = new ArrayList<>();
+        opts.add(Pair.of(Option.STORAGE_MEMORYCOMPONENT_GLOBALBUDGET, 
"128MB"));
+        opts.add(Pair.of(Option.STORAGE_MAX_ACTIVE_WRITABLE_DATASETS, 
"10000"));
+        nc.setOpts(opts);
+        initializeNc(false);
+        initializeTestCtx();
+        readIndex();
+        // wait for ongoing flushes triggered by recovery to finish
+        DatasetInfo dsInfo = 
dsLifecycleMgr.getDatasetInfo(dataset.getDatasetId());
+        dsInfo.waitForIO();
 
-            dropIndex();
-            // cleanup after each test case
-            nc.deInit(true);
-            nc.clearOpts();
-        } catch (Throwable e) {
-            e.printStackTrace();
-            Assert.fail(e.getMessage());
-        }
+        checkComponentIds();
+        // insert more records
+        insertOp = StorageTestUtils.getInsertPipeline(nc, ctx, 
secondaryIndexEntity);
+        insertRecords(StorageTestUtils.TOTAL_NUM_OF_RECORDS, 
StorageTestUtils.RECORDS_PER_COMPONENT);
+        checkComponentIds();
+
+        dropIndex();
+        // cleanup after each test case
+        nc.deInit(true);
+        nc.clearOpts();
     }
 
     private void initializeNc(boolean cleanUpOnStart) throws Exception {

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2437
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1704c6606c7c7bef226ae31961c347c6ebb76c2a
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Luo Chen <[email protected]>

Reply via email to