Merge asterix_stabilization_api_cleanup r1498:r1504.
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_lsm_stabilization@1507 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
index c4d32e1..12fa51a 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
@@ -6,6 +6,7 @@
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.List;
+import java.util.logging.Level;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServlet;
@@ -17,7 +18,9 @@
import edu.uci.ics.asterix.aql.base.Statement;
import edu.uci.ics.asterix.aql.parser.AQLParser;
import edu.uci.ics.asterix.aql.parser.ParseException;
+import edu.uci.ics.asterix.aql.parser.TokenMgrError;
import edu.uci.ics.asterix.aql.translator.AqlTranslator;
+import edu.uci.ics.asterix.common.config.GlobalConfig;
import edu.uci.ics.asterix.metadata.MetadataManager;
import edu.uci.ics.asterix.result.ResultReader;
import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
@@ -76,7 +79,8 @@
long endTime = System.currentTimeMillis();
duration = (endTime - startTime) / 1000.00;
out.println("<PRE>Duration of all jobs: " + duration + "</PRE>");
- } catch (ParseException pe) {
+ } catch (ParseException | TokenMgrError | edu.uci.ics.asterix.aqlplus.parser.TokenMgrError pe) {
+ out.println("<pre class=\"error\">");
String message = pe.getMessage();
message = message.replace("<", "<");
message = message.replace(">", ">");
@@ -85,12 +89,20 @@
if (pos > 0) {
int columnPos = message.indexOf(",", pos + 1 + "line".length());
int lineNo = Integer.parseInt(message.substring(pos + "line".length() + 1, columnPos));
- String line = query.split("\n")[lineNo - 1];
- out.println("==> " + line);
+ String[] lines = query.split("\n");
+ if (lineNo >= lines.length) {
+ out.println("===> <BLANK LINE>");
+ } else {
+ String line = lines[lineNo - 1];
+ out.println("==> " + line);
+ }
}
+ out.println("</pre>");
} catch (Exception e) {
- e.printStackTrace();
+ GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, e.getMessage(), e);
+ out.println("<pre class=\"error\">");
out.println(e.getMessage());
+ out.println("</pre>");
}
}
diff --git a/asterix-app/src/main/resources/webui/static/css/style.css b/asterix-app/src/main/resources/webui/static/css/style.css
index 10f28dd..b8688db 100644
--- a/asterix-app/src/main/resources/webui/static/css/style.css
+++ b/asterix-app/src/main/resources/webui/static/css/style.css
@@ -84,15 +84,7 @@
resize: none;
}
-div.error label.heading {
- color: #ff2020;
- font-size: 24px;
- margin-top: 2px;
- padding-bottom: 10px;
- font-weight: bold;
-}
-
-div.error .message {
+div.output .message pre.error {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
index 1555549..04f1aae 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
@@ -3,15 +3,21 @@
import static org.junit.Assert.fail;
import java.io.BufferedReader;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
import org.json.JSONArray;
import org.json.JSONException;
+import org.json.JSONObject;
-import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.NotImplementedException;
public class TestsUtils {
@@ -31,57 +37,44 @@
return path.delete();
}
- public static String getNextResult(JSONArray jArray) throws JSONException {
- String result = null;
- for (int i = 0; i < jArray.length(); i++) {
- JSONArray resultArray = jArray.getJSONArray(i);
- for (int j = 0; j < resultArray.length(); j++) {
- return resultArray.getString(j);
- }
- }
- return result;
- }
-
- public static void runScriptAndCompareWithResult(IHyracksClientConnection hcc, File scriptFile, PrintWriter print,
- File expectedFile, JSONArray jArray) throws Exception {
+ public static void runScriptAndCompareWithResult(File scriptFile, PrintWriter print, File expectedFile,
+ File actualFile) throws Exception {
BufferedReader readerExpected = new BufferedReader(new InputStreamReader(new FileInputStream(expectedFile),
"UTF-8"));
-
+ BufferedReader readerActual = new BufferedReader(
+ new InputStreamReader(new FileInputStream(actualFile), "UTF-8"));
String lineExpected, lineActual;
- int num = 0;
- int chunkCounter = 0;
- int recordCounter = 0;
-
+ int num = 1;
try {
while ((lineExpected = readerExpected.readLine()) != null) {
- // Skip the blank line in the expected file.
- if (lineExpected.isEmpty()) {
- continue;
+ lineActual = readerActual.readLine();
+ // Assert.assertEquals(lineExpected, lineActual);
+ if (lineActual == null) {
+ if (lineExpected.isEmpty()) {
+ continue;
+ }
+ throw new Exception("Result for " + scriptFile + " changed at line " + num + ":\n< " + lineExpected
+ + "\n> ");
}
- if (jArray.length() <= chunkCounter) {
- throw new Exception("No more results available.");
- }
- JSONArray resultArray = jArray.getJSONArray(chunkCounter);
- if ((lineActual = resultArray.getString(recordCounter)) == null) {
- throw new Exception("Result for " + scriptFile + " changed at line " + num + ":\n<" + lineExpected
- + "\n>");
-
- }
if (!equalStrings(lineExpected.split("Timestamp")[0], lineActual.split("Timestamp")[0])) {
fail("Result for " + scriptFile + " changed at line " + num + ":\n< " + lineExpected + "\n> "
+ lineActual);
}
- recordCounter++;
- if (recordCounter >= resultArray.length()) {
- chunkCounter++;
- recordCounter = 0;
- }
+ ++num;
}
+ lineActual = readerActual.readLine();
+ // Assert.assertEquals(null, lineActual);
+ if (lineActual != null) {
+ throw new Exception("Result for " + scriptFile + " changed at line " + num + ":\n< \n> " + lineActual);
+ }
+ // actualFile.delete();
} finally {
readerExpected.close();
+ readerActual.close();
}
+
}
private static boolean equalStrings(String s1, String s2) {
@@ -127,4 +120,79 @@
return fname.substring(0, dot + 1) + EXTENSION_AQL_RESULT;
}
+ public static void writeResultsToFile(File actualFile, JSONObject result) throws IOException, JSONException {
+ BufferedWriter writer = new BufferedWriter(new FileWriter(actualFile));
+ Results res = new Results(result);
+ for (String line : res) {
+ writer.write(line);
+ writer.newLine();
+ }
+ writer.close();
+ }
+
+ public static class Results implements Iterable<String> {
+ private final JSONArray chunks;
+
+ public Results(JSONObject result) throws JSONException {
+ chunks = result.getJSONArray("results");
+ }
+
+ public Iterator<String> iterator() {
+ return new ResultIterator(chunks);
+ }
+ }
+
+ public static class ResultIterator implements Iterator<String> {
+ private final JSONArray chunks;
+
+ private int chunkCounter = 0;
+ private int recordCounter = 0;
+
+ public ResultIterator(JSONArray chunks) {
+ this.chunks = chunks;
+ }
+
+ @Override
+ public boolean hasNext() {
+ JSONArray resultArray;
+ try {
+ resultArray = chunks.getJSONArray(chunkCounter);
+ if (resultArray.getString(recordCounter) != null) {
+ return true;
+ }
+ } catch (JSONException e) {
+ return false;
+ }
+ return false;
+ }
+
+ @Override
+ public String next() throws NoSuchElementException {
+ JSONArray resultArray;
+ String item = "";
+
+ try {
+ resultArray = chunks.getJSONArray(chunkCounter);
+ item = resultArray.getString(recordCounter);
+ if (item == null) {
+ throw new NoSuchElementException();
+ }
+ item = item.trim();
+
+ recordCounter++;
+ if (recordCounter >= resultArray.length()) {
+ chunkCounter++;
+ recordCounter = 0;
+ }
+ } catch (JSONException e) {
+ throw new NoSuchElementException(e.getMessage());
+ }
+ return item;
+ }
+
+ @Override
+ public void remove() {
+ throw new NotImplementedException();
+ }
+ }
}
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java
index 2519544..56259fa 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java
@@ -260,11 +260,18 @@
}
} else {
expectedResultFile = expectedResultFileCtxs.get(queryCount).getFile();
- TestsUtils
- .runScriptAndCompareWithResult(
- AsterixHyracksIntegrationUtil.getHyracksClientConnection(), testFile,
- new PrintWriter(System.err), expectedResultFile,
- result.getJSONArray("results"));
+
+ File actualFile = new File(PATH_ACTUAL + File.separator
+ + tcCtx.getTestCase().getFilePath().replace(File.separator, "_") + "_"
+ + cUnit.getName() + ".adm");
+
+ File actualResultFile = tcCtx.getActualResultFile(cUnit, new File(PATH_ACTUAL));
+ actualResultFile.getParentFile().mkdirs();
+
+ TestsUtils.writeResultsToFile(actualFile, result);
+
+ TestsUtils.runScriptAndCompareWithResult(testFile, new PrintWriter(System.err),
+ expectedResultFile, actualFile);
}
queryCount++;
break;
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
index aacec61..0dbf6d4 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
@@ -233,13 +233,6 @@
for (CompilationUnit cUnit : cUnits) {
LOGGER.info("[TEST]: " + tcCtx.getTestCase().getFilePath() + "/" + cUnit.getName());
-// if (!(tcCtx.getTestCase().getFilePath().contains("dml") && cUnit.getName().equals(
-// "delete-from-loaded-dataset-with-index"))) {
-// continue;
-// }
-//
-// System.out.println("/Test/: " + tcCtx.getTestCase().getFilePath() + "/" + cUnit.getName());
-
testFileCtxs = tcCtx.getTestFiles(cUnit);
expectedResultFileCtxs = tcCtx.getExpectedResultFiles(cUnit);
@@ -262,11 +255,18 @@
}
} else {
expectedResultFile = expectedResultFileCtxs.get(queryCount).getFile();
- TestsUtils
- .runScriptAndCompareWithResult(
- AsterixHyracksIntegrationUtil.getHyracksClientConnection(), testFile,
- new PrintWriter(System.err), expectedResultFile,
- result.getJSONArray("results"));
+
+ File actualFile = new File(PATH_ACTUAL + File.separator
+ + tcCtx.getTestCase().getFilePath().replace(File.separator, "_") + "_"
+ + cUnit.getName() + ".adm");
+
+ File actualResultFile = tcCtx.getActualResultFile(cUnit, new File(PATH_ACTUAL));
+ actualResultFile.getParentFile().mkdirs();
+
+ TestsUtils.writeResultsToFile(actualFile, result);
+
+ TestsUtils.runScriptAndCompareWithResult(testFile, new PrintWriter(System.err),
+ expectedResultFile, actualFile);
}
queryCount++;
break;
diff --git a/asterix-app/src/test/resources/metadata/results/basic/meta18/meta18.1.adm b/asterix-app/src/test/resources/metadata/results/basic/meta18/meta18.1.adm
index f6d8a37..61abc91 100644
--- a/asterix-app/src/test/resources/metadata/results/basic/meta18/meta18.1.adm
+++ b/asterix-app/src/test/resources/metadata/results/basic/meta18/meta18.1.adm
@@ -1 +1,3 @@
-{ "DataverseName": "Metadata", "DataFormat": "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat", "Timestamp": "Thu Sep 13 13:03:11 PDT 2012" }
+{ "DataverseName": "Metadata", "DataFormat": "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat", "Timestamp": "Thu Apr 04 21:10:48 PDT 2013", "PendingOp": 0 }
+{ "DataverseName": "test", "DataFormat": "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat", "Timestamp": "Thu Apr 04 21:10:55 PDT 2013", "PendingOp": 0 }
+{ "DataverseName": "testdv", "DataFormat": "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat", "Timestamp": "Thu Apr 04 21:10:52 PDT 2013", "PendingOp": 0 }
diff --git a/asterix-app/src/test/resources/metadata/results/basic/metadata_dataverse/metadata_dataverse.1.adm b/asterix-app/src/test/resources/metadata/results/basic/metadata_dataverse/metadata_dataverse.1.adm
index f6d8a37..61abc91 100644
--- a/asterix-app/src/test/resources/metadata/results/basic/metadata_dataverse/metadata_dataverse.1.adm
+++ b/asterix-app/src/test/resources/metadata/results/basic/metadata_dataverse/metadata_dataverse.1.adm
@@ -1 +1,3 @@
-{ "DataverseName": "Metadata", "DataFormat": "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat", "Timestamp": "Thu Sep 13 13:03:11 PDT 2012" }
+{ "DataverseName": "Metadata", "DataFormat": "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat", "Timestamp": "Thu Apr 04 21:10:48 PDT 2013", "PendingOp": 0 }
+{ "DataverseName": "test", "DataFormat": "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat", "Timestamp": "Thu Apr 04 21:10:55 PDT 2013", "PendingOp": 0 }
+{ "DataverseName": "testdv", "DataFormat": "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat", "Timestamp": "Thu Apr 04 21:10:52 PDT 2013", "PendingOp": 0 }
diff --git a/asterix-app/src/test/resources/runtimets/results/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.adm b/asterix-app/src/test/resources/runtimets/results/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.adm
index 4bd8c19..0dd81cd 100644
--- a/asterix-app/src/test/resources/runtimets/results/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.adm
@@ -1,2 +1,3 @@
{ "id": 10 }
{ "id": 12 }
+{ "id": 20 }
diff --git a/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.adm b/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.adm
index 2ffad7c..d22217a 100644
--- a/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.adm
@@ -1 +1,2 @@
-{ "id": 12 }
\ No newline at end of file
+{ "id": 12 }
+{ "id": 20 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index/rtree-secondary-index.1.adm b/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index/rtree-secondary-index.1.adm
index 2ffad7c..d22217a 100644
--- a/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index/rtree-secondary-index.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index/rtree-secondary-index.1.adm
@@ -1 +1,2 @@
-{ "id": 12 }
\ No newline at end of file
+{ "id": 12 }
+{ "id": 20 }
\ No newline at end of file
diff --git a/asterix-test-framework/src/main/java/edu/uci/ics/asterix/testframework/context/TestCaseContext.java b/asterix-test-framework/src/main/java/edu/uci/ics/asterix/testframework/context/TestCaseContext.java
index d1818ff..bb89a76 100644
--- a/asterix-test-framework/src/main/java/edu/uci/ics/asterix/testframework/context/TestCaseContext.java
+++ b/asterix-test-framework/src/main/java/edu/uci/ics/asterix/testframework/context/TestCaseContext.java
@@ -107,6 +107,13 @@
return resultFileCtxs;
}
+ public File getActualResultFile(CompilationUnit cUnit, File actualResultsBase) {
+ File path = actualResultsBase;
+ path = new File(path, testSuite.getResultOffsetPath());
+ path = new File(path, testCase.getFilePath());
+ return new File(path, cUnit.getOutputDir().getValue() + ".adm");
+ }
+
public static class Builder {
public Builder() {
}