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 2013/09/11 02:25:00 UTC

svn commit: r1521691 - /incubator/vxquery/trunk/vxquery/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java

Author: prestonc
Date: Wed Sep 11 00:24:59 2013
New Revision: 1521691

URL: http://svn.apache.org/r1521691
Log:
Updated the test suite to use the output changes made to the CLI. Removed the second node controller due to the partition changes requiring custom queries need for local node clustering.

Modified:
    incubator/vxquery/trunk/vxquery/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java

Modified: incubator/vxquery/trunk/vxquery/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java?rev=1521691&r1=1521690&r2=1521691&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java Wed Sep 11 00:24:59 2013
@@ -18,6 +18,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.EnumSet;
@@ -25,7 +26,6 @@ import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.vxquery.compiler.CompilerControlBlock;
 import org.apache.vxquery.compiler.algebricks.VXQueryGlobalDataFactory;
 import org.apache.vxquery.context.DynamicContext;
@@ -34,20 +34,25 @@ import org.apache.vxquery.context.RootSt
 import org.apache.vxquery.context.StaticContextImpl;
 import org.apache.vxquery.exceptions.ErrorCode;
 import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.result.ResultUtils;
 import org.apache.vxquery.xmlquery.query.XMLQueryCompiler;
 
 import edu.uci.ics.hyracks.api.client.HyracksConnection;
 import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
+import edu.uci.ics.hyracks.api.comm.IFrameTupleAccessor;
+import edu.uci.ics.hyracks.api.dataset.IHyracksDataset;
+import edu.uci.ics.hyracks.api.dataset.IHyracksDatasetReader;
 import edu.uci.ics.hyracks.api.dataset.ResultSetId;
 import edu.uci.ics.hyracks.api.exceptions.HyracksException;
 import edu.uci.ics.hyracks.api.job.JobFlag;
 import edu.uci.ics.hyracks.api.job.JobId;
 import edu.uci.ics.hyracks.api.job.JobSpecification;
+import edu.uci.ics.hyracks.client.dataset.HyracksDataset;
 import edu.uci.ics.hyracks.control.cc.ClusterControllerService;
 import edu.uci.ics.hyracks.control.common.controllers.CCConfig;
 import edu.uci.ics.hyracks.control.common.controllers.NCConfig;
 import edu.uci.ics.hyracks.control.nc.NodeControllerService;
-import edu.uci.ics.hyracks.dataflow.std.file.FileSplit;
+import edu.uci.ics.hyracks.dataflow.common.comm.io.ResultFrameTupleAccessor;
 
 public class TestRunnerFactory {
     private static final Pattern EMBEDDED_SYSERROR_PATTERN = Pattern
@@ -57,8 +62,8 @@ public class TestRunnerFactory {
     private XTestOptions opts;
     private ClusterControllerService cc;
     private NodeControllerService nc1;
-    private NodeControllerService nc2;
     private IHyracksClientConnection hcc;
+    private IHyracksDataset hds;
 
     public TestRunnerFactory(XTestOptions opts) throws Exception {
         reporters = new ArrayList<ResultReporter>();
@@ -89,16 +94,6 @@ public class TestRunnerFactory {
         nc1 = new NodeControllerService(ncConfig1);
         nc1.start();
 
-        NCConfig ncConfig2 = new NCConfig();
-        ncConfig2.ccHost = "localhost";
-        ncConfig2.ccPort = 39001;
-        ncConfig2.clusterNetIPAddress = "127.0.0.1";
-        ncConfig2.dataIPAddress = "127.0.0.1";
-        ncConfig2.datasetIPAddress = "127.0.0.1";
-        ncConfig2.nodeId = "nc2";
-        nc2 = new NodeControllerService(ncConfig2);
-        nc2.start();
-
         hcc = new HyracksConnection(ccConfig.clientNetIpAddress, ccConfig.clientNetPort);
     }
 
@@ -117,12 +112,11 @@ public class TestRunnerFactory {
                 long start = System.currentTimeMillis();
                 try {
                     try {
-                        XMLQueryCompiler compiler = new XMLQueryCompiler(null, new String[]{ "nc1" });
-                        File tempFile = File.createTempFile(testCase.getXQueryFile().getName(), ".tmp");
-                        tempFile.deleteOnExit();
+                        XMLQueryCompiler compiler = new XMLQueryCompiler(null, new String[] { "nc1" });
                         Reader in = new InputStreamReader(new FileInputStream(testCase.getXQueryFile()), "UTF-8");
                         CompilerControlBlock ccb = new CompilerControlBlock(new StaticContextImpl(
-                                RootStaticContextImpl.INSTANCE), new ResultSetId(System.nanoTime()));
+                                RootStaticContextImpl.INSTANCE), new ResultSetId(testCase.getXQueryDisplayName()
+                                .hashCode()));
                         compiler.compile(testCase.getXQueryDisplayName(), in, ccb, opts.optimizationLevel);
                         JobSpecification spec = compiler.getModule().getHyracksJobSpecification();
 
@@ -131,8 +125,21 @@ public class TestRunnerFactory {
 
                         spec.setMaxReattempts(0);
                         JobId jobId = hcc.startJob(spec, EnumSet.of(JobFlag.PROFILE_RUNTIME));
+
+                        if (hds == null) {
+                            hds = new HyracksDataset(hcc, spec.getFrameSize(), opts.threads);
+                        }
+                        ByteBuffer buffer = ByteBuffer.allocate(spec.getFrameSize());
+                        IHyracksDatasetReader reader = hds.createReader(jobId, ccb.getResultSetId());
+                        IFrameTupleAccessor frameTupleAccessor = new ResultFrameTupleAccessor(spec.getFrameSize());
+                        buffer.clear();
+                        res.result = "";
+                        while (reader.read(buffer) > 0) {
+                            buffer.clear();
+                            res.result += ResultUtils.getStringFromBuffer(buffer, frameTupleAccessor);
+                        }
+                        res.result.trim();
                         hcc.waitForCompletion(jobId);
-                        res.result = FileUtils.readFileToString(tempFile, "UTF-8").trim();
                     } catch (HyracksException e) {
                         Throwable t = e;
                         while (t.getCause() != null) {
@@ -175,7 +182,6 @@ public class TestRunnerFactory {
     }
 
     public void close() throws Exception {
-        nc2.stop();
         nc1.stop();
         cc.stop();
     }