You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by pr...@apache.org on 2016/09/10 00:42:34 UTC

vxquery git commit: VXQUERY-25: Fixes the file issue with running JUNIT through maven

Repository: vxquery
Updated Branches:
  refs/heads/master eb76640fc -> f463f01d0


VXQUERY-25: Fixes the file issue with running JUNIT through maven

Maven will now be able to run the XQTS JUNIT test without opening
to many files. If XQTS is installed locally then the system will run
these tests during verify and/or integration-tests.

The fix involves only creating one cluster instance, one connection, and
one dataset. These instances are reused for each test.


Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/f463f01d
Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/f463f01d
Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/f463f01d

Branch: refs/heads/master
Commit: f463f01d034e3ce5972a403797a532ba5bffba5f
Parents: eb76640
Author: Preston Carman <pr...@apache.org>
Authored: Fri Sep 9 17:02:02 2016 -0700
Committer: Preston Carman <pr...@apache.org>
Committed: Fri Sep 9 17:02:02 2016 -0700

----------------------------------------------------------------------
 vxquery-xtest/pom.xml                           | 20 +++++--
 .../apache/vxquery/xtest/TestClusterUtil.java   | 43 ++++++++++-----
 .../org/apache/vxquery/xtest/TestRunner.java    |  9 +---
 .../java/org/apache/vxquery/xtest/XTest.java    |  2 +-
 .../vxquery/xtest/AbstractXQueryTest.java       |  2 +-
 .../vxquery/xtest/VXQueryCheckXQTSTest.java     | 56 --------------------
 .../org/apache/vxquery/xtest/VXQueryIT.java     | 56 ++++++++++++++++++++
 7 files changed, 106 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/f463f01d/vxquery-xtest/pom.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/pom.xml b/vxquery-xtest/pom.xml
index 44f157d..27c2bf8 100644
--- a/vxquery-xtest/pom.xml
+++ b/vxquery-xtest/pom.xml
@@ -14,7 +14,8 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
@@ -109,16 +110,29 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
-                     <!-- <argLine>-agentpath:"${yourkit.home}/bin/mac/libyjpagent.jnilib=sampling"</argLine> -->
+                    <!-- <argLine>-agentpath:"${yourkit.home}/bin/mac/libyjpagent.jnilib=sampling"</argLine> -->
                     <excludes>
                         <exclude>**/AbstractXQueryTest.java</exclude>
+                        <exclude>**/VXQueryCheckXQTSTest.java</exclude>
                         <exclude>**/VXQueryXMarkTest.java</exclude>
                         <exclude>**/XMarkTest.java</exclude>
                         <exclude>**/XQTSTest.java</exclude>
-                        <exclude>**/VXQueryCheckXQTSTest.java</exclude>
                     </excludes>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>integration-tests</id>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 

http://git-wip-us.apache.org/repos/asf/vxquery/blob/f463f01d/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestClusterUtil.java
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestClusterUtil.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestClusterUtil.java
index d7db8a8..0e5b481 100644
--- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestClusterUtil.java
+++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestClusterUtil.java
@@ -17,6 +17,8 @@
 
 package org.apache.vxquery.xtest;
 
+import org.apache.hyracks.api.client.HyracksConnection;
+import org.apache.hyracks.client.dataset.HyracksDataset;
 import org.apache.hyracks.control.cc.ClusterControllerService;
 import org.apache.hyracks.control.common.controllers.CCConfig;
 import org.apache.hyracks.control.common.controllers.NCConfig;
@@ -29,12 +31,15 @@ import java.net.UnknownHostException;
 
 public class TestClusterUtil {
 
-    private static int clientNetPort = 39000;
-    private static int clusterNetPort = 39001;
-    private static int profileDumpPeriod = 10000;
-    private static String ccHost = "localhost";
-    private static String nodeId = "nc1";
-    private static String ioDevices = "target/tmp/indexFolder";
+    private static final int CLIENT_NET_PORT = 39000;
+    private static final int CLUSTER_NET_PORT = 39001;
+    private static final int PROFILE_DUMP_PERIOD = 10000;
+    private static final String CC_HOST = "localhost";
+    private static final String NODE_ID = "nc1";
+    private static final String IO_DEVICES = "target/tmp/indexFolder";
+
+    private static HyracksConnection hcc;
+    private static HyracksDataset hds;
 
     private TestClusterUtil() {
     }
@@ -43,27 +48,27 @@ public class TestClusterUtil {
         String publicAddress = InetAddress.getLocalHost().getHostAddress();
         CCConfig ccConfig = new CCConfig();
         ccConfig.clientNetIpAddress = publicAddress;
-        ccConfig.clientNetPort = clientNetPort;
+        ccConfig.clientNetPort = CLIENT_NET_PORT;
         ccConfig.clusterNetIpAddress = publicAddress;
-        ccConfig.clusterNetPort = clusterNetPort;
-        ccConfig.profileDumpPeriod = profileDumpPeriod;
+        ccConfig.clusterNetPort = CLUSTER_NET_PORT;
+        ccConfig.profileDumpPeriod = PROFILE_DUMP_PERIOD;
         return ccConfig;
     }
 
     public static NCConfig createNCConfig() throws UnknownHostException {
         String publicAddress = InetAddress.getLocalHost().getHostAddress();
         NCConfig ncConfig1 = new NCConfig();
-        ncConfig1.ccHost = ccHost;
-        ncConfig1.ccPort = clusterNetPort;
+        ncConfig1.ccHost = CC_HOST;
+        ncConfig1.ccPort = CLUSTER_NET_PORT;
         ncConfig1.clusterNetIPAddress = publicAddress;
         ncConfig1.dataIPAddress = publicAddress;
         ncConfig1.resultIPAddress = publicAddress;
-        ncConfig1.nodeId = nodeId;
-        ncConfig1.ioDevices = ioDevices;
+        ncConfig1.nodeId = NODE_ID;
+        ncConfig1.ioDevices = IO_DEVICES;
         return ncConfig1;
     }
 
-    public static ClusterControllerService startCC() throws IOException {
+    public static ClusterControllerService startCC(XTestOptions opts) throws IOException {
         CCConfig ccConfig = createCCConfig();
         File outDir = new File("target/ClusterController");
         outDir.mkdirs();
@@ -74,6 +79,8 @@ public class TestClusterUtil {
         try {
             ClusterControllerService cc = new ClusterControllerService(ccConfig);
             cc.start();
+            hcc = new HyracksConnection(ccConfig.clientNetIpAddress, ccConfig.clientNetPort);
+            hds = new HyracksDataset(hcc, opts.frameSize, opts.threads);
             return cc;
         } catch (Exception e) {
             throw new IOException(e);
@@ -92,6 +99,14 @@ public class TestClusterUtil {
         }
     }
 
+    public static HyracksConnection getConnection() {
+        return hcc;
+    }
+
+    public static HyracksDataset getDataset() {
+        return hds;
+    }
+
     public static void stopCluster(ClusterControllerService cc, NodeControllerService nc) throws IOException {
         try {
             nc.stop();

http://git-wip-us.apache.org/repos/asf/vxquery/blob/f463f01d/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java
index 524562a..1cd2696 100644
--- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java
+++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java
@@ -24,7 +24,6 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.hyracks.api.client.HyracksConnection;
 import org.apache.hyracks.api.client.IHyracksClientConnection;
 import org.apache.hyracks.api.client.NodeControllerInfo;
 import org.apache.hyracks.api.comm.IFrame;
@@ -38,7 +37,6 @@ import org.apache.hyracks.api.job.JobFlag;
 import org.apache.hyracks.api.job.JobId;
 import org.apache.hyracks.api.job.JobSpecification;
 import org.apache.hyracks.client.dataset.HyracksDataset;
-import org.apache.hyracks.control.common.controllers.CCConfig;
 import org.apache.hyracks.control.nc.resources.memory.FrameManager;
 import org.apache.hyracks.dataflow.common.comm.io.ResultFrameTupleAccessor;
 import org.apache.vxquery.compiler.CompilerControlBlock;
@@ -66,8 +64,8 @@ public class TestRunner {
     }
 
     public void open() throws Exception {
-        CCConfig ccConfig = TestClusterUtil.createCCConfig();
-        hcc = new HyracksConnection(ccConfig.clientNetIpAddress, ccConfig.clientNetPort);
+        hcc = TestClusterUtil.getConnection();
+        hds = TestClusterUtil.getDataset();
     }
 
     public TestCaseResult run(final TestCase testCase) {
@@ -111,9 +109,6 @@ public class TestRunner {
                 spec.setMaxReattempts(0);
                 JobId jobId = hcc.startJob(spec, EnumSet.of(JobFlag.PROFILE_RUNTIME));
 
-                if (hds == null) {
-                    hds = new HyracksDataset(hcc, spec.getFrameSize(), opts.threads);
-                }
                 FrameManager resultDisplayFrameMgr = new FrameManager(spec.getFrameSize());
                 IFrame frame = new VSizeFrame(resultDisplayFrameMgr);
                 IHyracksDatasetReader reader = hds.createReader(jobId, ccb.getResultSetId());

http://git-wip-us.apache.org/repos/asf/vxquery/blob/f463f01d/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTest.java
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTest.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTest.java
index fa07d9b..5aae691 100644
--- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTest.java
+++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTest.java
@@ -81,7 +81,7 @@ public class XTest {
                 }
             }
         });
-        cc = TestClusterUtil.startCC();
+        cc = TestClusterUtil.startCC(opts);
         nc = TestClusterUtil.startNC();
         trf = new TestRunnerFactory(opts);
         trf.registerReporters(reporters);

http://git-wip-us.apache.org/repos/asf/vxquery/blob/f463f01d/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/AbstractXQueryTest.java
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/AbstractXQueryTest.java b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/AbstractXQueryTest.java
index 78ed8ff..96cc7cb 100644
--- a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/AbstractXQueryTest.java
+++ b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/AbstractXQueryTest.java
@@ -92,7 +92,7 @@ public abstract class AbstractXQueryTest {
 
     @BeforeClass
     public static void setup() throws IOException {
-        cc = TestClusterUtil.startCC();
+        cc = TestClusterUtil.startCC(getDefaultTestOptions());
         nc = TestClusterUtil.startNC();
         setupFS();
     }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/f463f01d/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryCheckXQTSTest.java
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryCheckXQTSTest.java b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryCheckXQTSTest.java
deleted file mode 100644
index 7c4e43c..0000000
--- a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryCheckXQTSTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-* 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.vxquery.xtest;
-
-import java.io.File;
-import java.util.Collection;
-
-import org.apache.commons.lang3.StringUtils;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class VXQueryCheckXQTSTest extends AbstractXQueryTest {
-
-    private static String XQTS_CATALOG = StringUtils.join(new String[] { "test-suites", "xqts", "XQTSCatalog.xml" },
-            File.separator);
-
-    public VXQueryCheckXQTSTest(TestCase tc) throws Exception {
-        super(tc);
-    }
-
-    @Parameters(name = "VXQueryCheckXQTSTest {index}: {0}")
-    public static Collection<Object[]> tests() throws Exception {
-        JUnitTestCaseFactory jtcf_vxquery = new JUnitTestCaseFactory(getOptions());
-        Collection<Object[]> tests = jtcf_vxquery.getList();
-        return tests;
-    }
-
-    public static XTestOptions getOptions() {
-        XTestOptions options = getDefaultTestOptions();
-        options.catalog = XQTS_CATALOG;
-        options.previousTestResults = StringUtils.join(new String[] { "results", "xqts.txt" }, File.separator);
-        return options;
-    }
-
-    @Override
-    protected XTestOptions getTestOptions() {
-        return getOptions();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/f463f01d/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryIT.java
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryIT.java b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryIT.java
new file mode 100644
index 0000000..c6f54f6
--- /dev/null
+++ b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryIT.java
@@ -0,0 +1,56 @@
+/*
+* 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.vxquery.xtest;
+
+import java.io.File;
+import java.util.Collection;
+
+import org.apache.commons.lang3.StringUtils;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class VXQueryIT extends AbstractXQueryTest {
+
+    private static String XQTS_CATALOG = StringUtils.join(new String[] { "test-suites", "xqts", "XQTSCatalog.xml" },
+            File.separator);
+
+    public VXQueryIT(TestCase tc) throws Exception {
+        super(tc);
+    }
+
+    @Parameters(name = "VXQueryIT {index}: {0}")
+    public static Collection<Object[]> tests() throws Exception {
+        JUnitTestCaseFactory jtcf_vxquery = new JUnitTestCaseFactory(getOptions());
+        Collection<Object[]> tests = jtcf_vxquery.getList();
+        return tests;
+    }
+
+    public static XTestOptions getOptions() {
+        XTestOptions options = getDefaultTestOptions();
+        options.catalog = XQTS_CATALOG;
+        options.previousTestResults = StringUtils.join(new String[] { "results", "xqts.txt" }, File.separator);
+        return options;
+    }
+
+    @Override
+    protected XTestOptions getTestOptions() {
+        return getOptions();
+    }
+
+}