You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by vi...@apache.org on 2012/07/03 05:45:00 UTC
svn commit: r1356565 - in
/incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest: pom.xml
src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java
src/main/java/org/apache/vxquery/xtest/XTest.java
Author: vinayakb
Date: Tue Jul 3 03:44:59 2012
New Revision: 1356565
URL: http://svn.apache.org/viewvc?rev=1356565&view=rev
Log:
Fixed XTest to compile and run tests
Modified:
incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/pom.xml
incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java
incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTest.java
Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/pom.xml?rev=1356565&r1=1356564&r2=1356565&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/pom.xml (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/pom.xml Tue Jul 3 03:44:59 2012
@@ -94,6 +94,18 @@
<version>6.1.4</version>
<scope>compile</scope>
</dependency>
+
+ <dependency>
+ <groupId>edu.uci.ics.hyracks</groupId>
+ <artifactId>hyracks-control-cc</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>edu.uci.ics.hyracks</groupId>
+ <artifactId>hyracks-control-nc</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ </dependency>
</dependencies>
<reporting>
Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java?rev=1356565&r1=1356564&r2=1356565&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java Tue Jul 3 03:44:59 2012
@@ -14,27 +14,78 @@
*/
package org.apache.vxquery.xtest;
+import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.EnumSet;
import java.util.List;
+import org.apache.commons.io.FileUtils;
import org.apache.vxquery.compiler.CompilerControlBlock;
import org.apache.vxquery.context.RootStaticContextImpl;
import org.apache.vxquery.context.StaticContextImpl;
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.job.JobFlag;
+import edu.uci.ics.hyracks.api.job.JobId;
+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;
public class TestRunnerFactory {
private List<ResultReporter> reporters;
private XTestOptions opts;
+ private ClusterControllerService cc;
+ private NodeControllerService nc1;
+ private NodeControllerService nc2;
+ private IHyracksClientConnection hcc;
- public TestRunnerFactory(XTestOptions opts) {
+ public TestRunnerFactory(XTestOptions opts) throws Exception {
reporters = new ArrayList<ResultReporter>();
this.opts = opts;
+
+ CCConfig ccConfig = new CCConfig();
+ ccConfig.clientNetIpAddress = "127.0.0.1";
+ ccConfig.clientNetPort = 39000;
+ ccConfig.clusterNetIpAddress = "127.0.0.1";
+ ccConfig.clusterNetPort = 39001;
+ ccConfig.profileDumpPeriod = 10000;
+ File outDir = new File("target/ClusterController");
+ outDir.mkdirs();
+ File ccRoot = File.createTempFile(TestRunnerFactory.class.getName(), ".data", outDir);
+ ccRoot.delete();
+ ccRoot.mkdir();
+ ccConfig.ccRoot = ccRoot.getAbsolutePath();
+ cc = new ClusterControllerService(ccConfig);
+ cc.start();
+
+ NCConfig ncConfig1 = new NCConfig();
+ ncConfig1.ccHost = "localhost";
+ ncConfig1.ccPort = 39001;
+ ncConfig1.clusterNetIPAddress = "127.0.0.1";
+ ncConfig1.dataIPAddress = "127.0.0.1";
+ ncConfig1.nodeId = "nc1";
+ 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.nodeId = "nc2";
+ nc2 = new NodeControllerService(ncConfig2);
+ nc2.start();
+
+ hcc = new HyracksConnection(ccConfig.clientNetIpAddress, ccConfig.clientNetPort);
+ hcc.createApplication("test", null);
}
public void registerReporter(ResultReporter reporter) {
@@ -52,10 +103,18 @@ public class TestRunnerFactory {
long start = System.currentTimeMillis();
try {
XMLQueryCompiler compiler = new XMLQueryCompiler(null);
+ File tempFile = File.createTempFile(testCase.getXQueryFile().getName(), ".tmp");
+ tempFile.deleteOnExit();
Reader in = new InputStreamReader(new FileInputStream(testCase.getXQueryFile()), "UTF-8");
CompilerControlBlock ccb = new CompilerControlBlock(new StaticContextImpl(
- RootStaticContextImpl.INSTANCE), new FileSplit[] {});
+ RootStaticContextImpl.INSTANCE), new FileSplit[] { new FileSplit("nc1",
+ tempFile.getAbsolutePath()) });
compiler.compile(testCase.getXQueryDisplayName(), in, ccb, opts.optimizationLevel);
+ JobId jobId = hcc.createJob("test", compiler.getModule().getHyracksJobSpecification(),
+ EnumSet.of(JobFlag.PROFILE_RUNTIME));
+ hcc.start(jobId);
+ hcc.waitForCompletion(jobId);
+ res.result = FileUtils.readFileToString(tempFile, "UTF-8");
} catch (Throwable e) {
res.error = e;
} finally {
@@ -82,4 +141,10 @@ public class TestRunnerFactory {
public void registerReporters(Collection<ResultReporter> reporters) {
this.reporters.addAll(reporters);
}
+
+ public void close() throws Exception {
+ nc2.stop();
+ nc1.stop();
+ cc.stop();
+ }
}
\ No newline at end of file
Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTest.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTest.java?rev=1356565&r1=1356564&r2=1356565&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTest.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTest.java Tue Jul 3 03:44:59 2012
@@ -30,6 +30,7 @@ public class XTest {
private Server server;
private ExecutorService eSvc;
private List<ResultReporter> reporters;
+ private TestRunnerFactory trf;
private int count;
private int finishCount;
@@ -75,7 +76,7 @@ public class XTest {
}
}
});
- TestRunnerFactory trf = new TestRunnerFactory(opts);
+ trf = new TestRunnerFactory(opts);
trf.registerReporters(reporters);
TestCaseFactory tcf = new TestCaseFactory(opts.xqtsBase, trf, eSvc, opts);
count = tcf.process();
@@ -99,6 +100,7 @@ public class XTest {
if (server != null) {
server.stop();
}
+ trf.close();
} catch (Exception e) {
e.printStackTrace();
}