You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mh...@apache.org on 2019/04/17 11:35:53 UTC

[asterixdb] branch master updated: [ASTERIXDB-2308][TEST] Add DDL Stress Test

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

mhubail pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 6facf73  [ASTERIXDB-2308][TEST] Add DDL Stress Test
6facf73 is described below

commit 6facf7337198870e95ce5ad96cf3e34fd2814d99
Author: Murtadha Hubail <mh...@apache.org>
AuthorDate: Tue Apr 16 16:34:43 2019 +0300

    [ASTERIXDB-2308][TEST] Add DDL Stress Test
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    - Add a test that repeatedly and concurrently performs the
      following operations:
      -- create dataset
      -- create primary index
      -- upsert data
      -- drop dataset
    
    Change-Id: Ia21ad70d5082ae93e1131c26191ce88dd8993b8d
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/3345
    Contrib: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Ali Alsuliman <al...@gmail.com>
---
 .../org/apache/asterix/common/TestDataUtil.java    |  4 ++
 .../apache/asterix/test/runtime/DdlStressTest.java | 80 ++++++++++++++++++++++
 2 files changed, 84 insertions(+)

diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/common/TestDataUtil.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/common/TestDataUtil.java
index 37f471e..d453824 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/common/TestDataUtil.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/common/TestDataUtil.java
@@ -69,6 +69,10 @@ public class TestDataUtil {
         TEST_EXECUTOR.executeSqlppUpdateOrDdl("CREATE DATASET " + dataset + "(KeyType) PRIMARY KEY id;", OUTPUT_FORMAT);
     }
 
+    public static void dropDataset(String dataset) throws Exception {
+        TEST_EXECUTOR.executeSqlppUpdateOrDdl("DROP DATASET " + dataset + ";", OUTPUT_FORMAT);
+    }
+
     /**
      * Creates a dataset with multiple fields
      * @param dataset The name of the dataset
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/DdlStressTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/DdlStressTest.java
new file mode 100644
index 0000000..1da7232
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/DdlStressTest.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.test.runtime;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.asterix.api.common.AsterixHyracksIntegrationUtil;
+import org.apache.asterix.common.TestDataUtil;
+import org.apache.asterix.common.config.GlobalConfig;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DdlStressTest {
+
+    protected static final String TEST_CONFIG_FILE_NAME = "src/main/resources/cc.conf";
+    private static final AsterixHyracksIntegrationUtil integrationUtil = new AsterixHyracksIntegrationUtil();
+
+    @Before
+    public void setUp() throws Exception {
+        System.setProperty(GlobalConfig.CONFIG_FILE_PROPERTY, TEST_CONFIG_FILE_NAME);
+        integrationUtil.init(true, TEST_CONFIG_FILE_NAME);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        integrationUtil.deinit(true);
+    }
+
+    @Test
+    public void concurrentDdlStressTest() throws Exception {
+        final String datasetNamePrefix = "ds";
+        AtomicBoolean failed = new AtomicBoolean(false);
+        Thread[] ddlThreads = new Thread[5];
+        for (int i = 0; i < ddlThreads.length; i++) {
+            String datasetName = datasetNamePrefix + i;
+            ddlThreads[i] = new Thread(() -> {
+                try {
+                    createUpsertDropDataset(datasetName, 50);
+                } catch (Exception e) {
+                    failed.set(true);
+                    e.printStackTrace();
+                }
+            });
+        }
+        for (Thread ddlThread : ddlThreads) {
+            ddlThread.start();
+        }
+        for (Thread ddlThread : ddlThreads) {
+            ddlThread.join();
+        }
+        Assert.assertFalse("unexpected ddl failure", failed.get());
+    }
+
+    private void createUpsertDropDataset(String datasetName, int count) throws Exception {
+        for (int i = 0; i < count; i++) {
+            TestDataUtil.createIdOnlyDataset(datasetName);
+            TestDataUtil.createPrimaryIndex(datasetName, "pIdx_" + datasetName);
+            TestDataUtil.upsertData(datasetName, 5);
+            TestDataUtil.dropDataset(datasetName);
+        }
+    }
+}