Merge branch 'master' into eugenia/black_cherry_stable
diff --git a/asterix-app/src/test/resources/runtimets/queries/types/type_promotion_1/type_promotion_1.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/types/type_promotion_1/type_promotion_1.1.ddl.aql
new file mode 100644
index 0000000..6aa28cc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/types/type_promotion_1/type_promotion_1.1.ddl.aql
@@ -0,0 +1,22 @@
+drop dataverse TestDataverse if exists;
+create dataverse TestDataverse;
+use dataverse TestDataverse;
+
+create type TestType as {
+ id: int64,
+ int8_u: {{ int8 }},
+ int8_o: [ int8 ],
+ int16_u: {{ int16 }},
+ int16_o: [ int16 ],
+ int32_u: {{ int32 }},
+ int32_o: [ int32 ],
+ int64_u: {{ int64 }},
+ int64_o: [ int64 ],
+ float_u: {{ float }},
+ float_o: [ float ],
+ double_u: {{ double }},
+ double_o: [ double ]
+}
+
+create dataset TestSet(TestType)
+primary key id;
diff --git a/asterix-app/src/test/resources/runtimets/queries/types/type_promotion_1/type_promotion_1.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/types/type_promotion_1/type_promotion_1.2.update.aql
new file mode 100644
index 0000000..05ffa1d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/types/type_promotion_1/type_promotion_1.2.update.aql
@@ -0,0 +1,23 @@
+use dataverse TestDataverse;
+
+insert into dataset TestSet (
+ let $i08 := int8("100")
+ let $i16 := int16("10000")
+ let $i32 := 1000000
+ let $i64 := int64("10000000000")
+ return {
+ "id": 1,
+ "int8_u": {{ $i08 }},
+ "int8_o": [ $i08 ],
+ "int16_u": {{ $i08, $i16 }},
+ "int16_o": [ $i08, $i16 ],
+ "int32_u": {{ $i08, $i16, $i32 }},
+ "int32_o": [ $i08, $i16, $i32 ],
+ "int64_u": {{ $i08, $i16, $i32, $i64 }},
+ "int64_o": [ $i08, $i16, $i32, $i64 ],
+ "float_u": {{ $i08, $i16, $i32 }},
+ "float_o": [ $i08, $i16, $i32 ],
+ "double_u": {{ $i08, $i16, $i32, $i64 }},
+ "double_o": [ $i08, $i16, $i32, $i64 ]
+ }
+)
diff --git a/asterix-app/src/test/resources/runtimets/queries/types/type_promotion_1/type_promotion_1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/types/type_promotion_1/type_promotion_1.3.query.aql
new file mode 100644
index 0000000..137b994
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/types/type_promotion_1/type_promotion_1.3.query.aql
@@ -0,0 +1,4 @@
+use dataverse TestDataverse;
+
+for $i in dataset TestSet
+return $i
diff --git a/asterix-app/src/test/resources/runtimets/results/types/type_promotion_1/type_promotion_1.1.adm b/asterix-app/src/test/resources/runtimets/results/types/type_promotion_1/type_promotion_1.1.adm
new file mode 100644
index 0000000..2fc6069
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/types/type_promotion_1/type_promotion_1.1.adm
@@ -0,0 +1 @@
+{ "id": 1i64, "int8_u": {{ 100i8 }}, "int8_o": [ 100i8 ], "int16_u": {{ 100i16, 10000i16 }}, "int16_o": [ 100i16, 10000i16 ], "int32_u": {{ 100, 10000, 1000000 }}, "int32_o": [ 100, 10000, 1000000 ], "int64_u": {{ 100i64, 10000i64, 1000000i64, 10000000000i64 }}, "int64_o": [ 100i64, 10000i64, 1000000i64, 10000000000i64 ], "float_u": {{ 100.0f, 10000.0f, 1000000.0f }}, "float_o": [ 100.0f, 10000.0f, 1000000.0f ], "double_u": {{ 100.0d, 10000.0d, 1000000.0d, 1.0E10d }}, "double_o": [ 100.0d, 10000.0d, 1000000.0d, 1.0E10d ] }
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 9cdc3df..faab5aa 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -4994,5 +4994,10 @@
<output-dir compare="Text">type_promotion_0</output-dir>
</compilation-unit>
</test-case>
+ <test-case FilePath="types">
+ <compilation-unit name="type_promotion_1">
+ <output-dir compare="Text">type_promotion_1</output-dir>
+ </compilation-unit>
+ </test-case>
</test-group>
</test-suite>
diff --git a/asterix-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java b/asterix-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
index 9643e1d..ee94c33 100644
--- a/asterix-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
+++ b/asterix-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
@@ -23,7 +23,6 @@
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
-import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
@@ -44,8 +43,6 @@
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.io.IOUtils;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.json.JSONException;
import org.json.JSONObject;
import com.fasterxml.jackson.core.JsonFactory;
@@ -77,7 +74,7 @@
return path.delete();
}
- public static void runScriptAndCompareWithResult(File scriptFile, PrintWriter print, File expectedFile,
+ private static void runScriptAndCompareWithResult(File scriptFile, PrintWriter print, File expectedFile,
File actualFile) throws Exception {
BufferedReader readerExpected = new BufferedReader(new InputStreamReader(new FileInputStream(expectedFile),
"UTF-8"));
@@ -160,7 +157,7 @@
return fname.substring(0, dot + 1) + EXTENSION_AQL_RESULT;
}
- public static void writeResultsToFile(File actualFile, InputStream resultStream) throws IOException, JSONException {
+ private static void writeResultsToFile(File actualFile, InputStream resultStream) throws Exception {
BufferedWriter writer = new BufferedWriter(new FileWriter(actualFile));
try {
JsonFactory jsonFactory = new JsonFactory();
@@ -175,12 +172,11 @@
String record = resultParser.getValueAsString();
writer.write(record);
}
- } else {
- String summary = resultParser.getValueAsString();
- if (key.equals("summary")) {
- writer.write(summary);
- throw new JsonMappingException("Could not find results key in the JSON Object");
- }
+ } else if (key.equals("summary")) {
+ String summary = resultParser.nextTextValue();
+ writer.write(summary);
+ throw new Exception("Could not find results key in the JSON Object, result file is at "
+ + actualFile);
}
}
}
@@ -293,7 +289,7 @@
// Method that reads a DDL/Update/Query File
// and returns the contents as a string
// This string is later passed to REST API for execution.
- public static String readTestFile(File testFile) throws Exception {
+ private static String readTestFile(File testFile) throws Exception {
BufferedReader reader = new BufferedReader(new FileReader(testFile));
String line = null;
StringBuilder stringBuilder = new StringBuilder();
@@ -377,86 +373,75 @@
for (TestFileContext ctx : testFileCtxs) {
testFile = ctx.getFile();
statement = TestsUtils.readTestFile(testFile);
+ InputStream resultStream;
try {
switch (ctx.getType()) {
case "ddl":
TestsUtils.executeDDL(statement);
break;
case "update":
-
//isDmlRecoveryTest: set IP address
if (isDmlRecoveryTest && statement.contains("nc1://")) {
statement = statement
.replaceAll("nc1://", "127.0.0.1://../../../../../../asterix-app/");
-
}
TestsUtils.executeUpdate(statement);
break;
case "query":
- try {
- // isDmlRecoveryTest: insert Crash and Recovery
- if (isDmlRecoveryTest) {
- executeScript(pb, pb.environment().get("SCRIPT_HOME") + File.separator
- + "dml_recovery" + File.separator + "kill_cc_and_nc.sh");
- executeScript(pb, pb.environment().get("SCRIPT_HOME") + File.separator
- + "dml_recovery" + File.separator + "stop_and_start.sh");
- }
-
- InputStream resultStream = executeQuery(statement);
- expectedResultFile = expectedResultFileCtxs.get(queryCount).getFile();
-
- File actualFile = new File(actualPath + File.separator
- + testCaseCtx.getTestCase().getFilePath().replace(File.separator, "_") + "_"
- + cUnit.getName() + ".adm");
- TestsUtils.writeResultsToFile(actualFile, resultStream);
-
- File actualResultFile = testCaseCtx.getActualResultFile(cUnit, new File(actualPath));
- actualResultFile.getParentFile().mkdirs();
-
- TestsUtils.runScriptAndCompareWithResult(testFile, new PrintWriter(System.err),
- expectedResultFile, actualFile);
- LOGGER.info("[TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/"
- + cUnit.getName() + " PASSED ");
- } catch (JsonMappingException e) {
- throw new Exception("Test \"" + testFile + "\" FAILED!\n");
+ // isDmlRecoveryTest: insert Crash and Recovery
+ if (isDmlRecoveryTest) {
+ executeScript(pb, pb.environment().get("SCRIPT_HOME") + File.separator + "dml_recovery"
+ + File.separator + "kill_cc_and_nc.sh");
+ executeScript(pb, pb.environment().get("SCRIPT_HOME") + File.separator + "dml_recovery"
+ + File.separator + "stop_and_start.sh");
}
+
+ resultStream = executeQuery(statement);
+ if (queryCount >= expectedResultFileCtxs.size()) {
+ throw new IllegalStateException("no result file for " + testFile.toString());
+ }
+ expectedResultFile = expectedResultFileCtxs.get(queryCount).getFile();
+
+ File actualFile = new File(actualPath + File.separator
+ + testCaseCtx.getTestCase().getFilePath().replace(File.separator, "_") + "_"
+ + cUnit.getName() + ".adm");
+ TestsUtils.writeResultsToFile(actualFile, resultStream);
+
+ File actualResultFile = testCaseCtx.getActualResultFile(cUnit, new File(actualPath));
+ actualResultFile.getParentFile().mkdirs();
+
+ TestsUtils.runScriptAndCompareWithResult(testFile, new PrintWriter(System.err),
+ expectedResultFile, actualFile);
+ LOGGER.info("[TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/" + cUnit.getName()
+ + " PASSED ");
+
queryCount++;
break;
case "mgx":
executeManagixCommand(statement);
break;
case "txnqbc": //qbc represents query before crash
- try {
- InputStream resultStream = executeQuery(statement);
- qbcFile = new File(actualPath + File.separator
- + testCaseCtx.getTestCase().getFilePath().replace(File.separator, "_") + "_"
- + cUnit.getName() + "_qbc.adm");
- qbcFile.getParentFile().mkdirs();
- TestsUtils.writeResultsToFile(qbcFile, resultStream);
- } catch (JsonMappingException e) {
- throw new Exception("Test \"" + testFile + "\" FAILED!\n");
- }
+ resultStream = executeQuery(statement);
+ qbcFile = new File(actualPath + File.separator
+ + testCaseCtx.getTestCase().getFilePath().replace(File.separator, "_") + "_"
+ + cUnit.getName() + "_qbc.adm");
+ qbcFile.getParentFile().mkdirs();
+ TestsUtils.writeResultsToFile(qbcFile, resultStream);
break;
case "txnqar": //qar represents query after recovery
- try {
+ resultStream = executeQuery(statement);
+ qarFile = new File(actualPath + File.separator
+ + testCaseCtx.getTestCase().getFilePath().replace(File.separator, "_") + "_"
+ + cUnit.getName() + "_qar.adm");
+ qarFile.getParentFile().mkdirs();
+ TestsUtils.writeResultsToFile(qarFile, resultStream);
- InputStream resultStream = executeQuery(statement);
+ TestsUtils.runScriptAndCompareWithResult(testFile, new PrintWriter(System.err),
+ qbcFile, qarFile);
- qarFile = new File(actualPath + File.separator
- + testCaseCtx.getTestCase().getFilePath().replace(File.separator, "_") + "_"
- + cUnit.getName() + "_qar.adm");
- qarFile.getParentFile().mkdirs();
- TestsUtils.writeResultsToFile(qarFile, resultStream);
-
- TestsUtils.runScriptAndCompareWithResult(testFile, new PrintWriter(System.err),
- qbcFile, qarFile);
-
- LOGGER.info("[TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/"
- + cUnit.getName() + " PASSED ");
- } catch (JsonMappingException e) {
- throw new Exception("Test \"" + testFile + "\" FAILED!\n");
- }
+ LOGGER.info("[TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/"
+ + cUnit.getName() + " PASSED ");
break;
case "txneu": //eu represents erroneous update
try {
@@ -494,13 +479,15 @@
}
} catch (Exception e) {
- e.printStackTrace();
if (cUnit.getExpectedError().isEmpty()) {
+ e.printStackTrace();
throw new Exception("Test \"" + testFile + "\" FAILED!", e);
+ } else {
+ LOGGER.info("[TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/" + cUnit.getName()
+ + " failed as expected: " + e.getMessage());
}
}
}
}
}
-
}
diff --git a/asterix-installer/pom.xml b/asterix-installer/pom.xml
index c24a2e4..ed87902 100644
--- a/asterix-installer/pom.xml
+++ b/asterix-installer/pom.xml
@@ -17,7 +17,7 @@
<artifactId>asterix-installer</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <test.excludes>**/DmlRecoveryIT.java</test.excludes>
+ <failsafe.test.excludes>**/DmlRecoveryIT.java</failsafe.test.excludes>
</properties>
<build>
@@ -108,7 +108,7 @@
<runOrder>alphabetical</runOrder>
<forkMode>pertest</forkMode>
<excludes>
- <exclude>${test.excludes}</exclude>
+ <exclude>${failsafe.test.excludes}</exclude>
</excludes>
</configuration>
<executions>
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/cast/AListCaster.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/cast/AListCaster.java
index d46c800..77ae09a 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/cast/AListCaster.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/cast/AListCaster.java
@@ -83,13 +83,10 @@
.getStartOffset()]);
if (reqItemType == null || reqItemType.getTypeTag().equals(ATypeTag.ANY)) {
itemVisitorArg.second = DefaultOpenFieldType.getDefaultOpenFieldType(typeTag);
- item.accept(visitor, itemVisitorArg);
} else {
- if (typeTag != reqItemType.getTypeTag())
- throw new AsterixException("mismatched item type");
itemVisitorArg.second = reqItemType;
- item.accept(visitor, itemVisitorArg);
}
+ item.accept(visitor, itemVisitorArg);
if (reqType.getTypeTag().equals(ATypeTag.ORDEREDLIST)) {
orderedListBuilder.addItem(itemVisitorArg.first);
}
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 ba7d02a..04c10a5 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
@@ -60,66 +60,47 @@
return testCase;
}
- public List<TestFileContext> getTestFiles(CompilationUnit cUnit) {
+ public List<TestFileContext> getFilesInDir(String basePath, String dirName, boolean withType) {
List<TestFileContext> testFileCtxs = new ArrayList<TestFileContext>();
File path = tsRoot;
- path = new File(path, testSuite.getQueryOffsetPath());
+ path = new File(path, basePath);
path = new File(path, testCase.getFilePath());
- path = new File(path, cUnit.getName());
+ path = new File(path, dirName);
- String fileNames[] = path.list();
- for (String fName : fileNames) {
- if (fName.startsWith(".")) {
- continue;
+ if (path.isDirectory()) {
+ String fileNames[] = path.list();
+ for (String fName : fileNames) {
+ if (fName.startsWith(".")) {
+ continue;
+ }
+
+ File testFile = new File(path, fName);
+ TestFileContext tfsc = new TestFileContext(testFile);
+ String[] nameSplits = fName.split("\\.");
+ if (nameSplits.length < 3) {
+ throw new IllegalArgumentException("Test file '" + dirName + File.separatorChar + fName
+ + "' does not have the proper test file name format.");
+ }
+ if (withType) {
+ tfsc.setSeqNum(nameSplits[nameSplits.length - 3]);
+ tfsc.setType(nameSplits[nameSplits.length - 2]);
+ } else {
+ tfsc.setSeqNum(nameSplits[nameSplits.length - 2]);
+ }
+ testFileCtxs.add(tfsc);
}
-
- File testFile = new File(path, fName);
- TestFileContext tfsc = new TestFileContext(testFile);
- String[] nameSplits = fName.split("\\.");
- if (nameSplits.length < 3) {
- throw new IllegalArgumentException("Test file '" + cUnit.getName() + File.separatorChar
- + fName + "' does not have the proper test file name format.");
- }
- tfsc.setSeqNum(nameSplits[nameSplits.length - 3]);
- tfsc.setType(nameSplits[nameSplits.length - 2]);
- testFileCtxs.add(tfsc);
}
Collections.sort(testFileCtxs);
return testFileCtxs;
}
+ public List<TestFileContext> getTestFiles(CompilationUnit cUnit) {
+ return getFilesInDir(testSuite.getQueryOffsetPath(), cUnit.getName(), true);
+ }
+
public List<TestFileContext> getExpectedResultFiles(CompilationUnit cUnit) {
- List<TestFileContext> resultFileCtxs = new ArrayList<TestFileContext>();
-
- File path = tsRoot;
- path = new File(path, testSuite.getResultOffsetPath());
- path = new File(path, testCase.getFilePath());
- path = new File(path, cUnit.getOutputDir().getValue());
-
- String fileNames[] = path.list();
-
- if (fileNames != null) {
- for (String fName : fileNames) {
- if (fName.startsWith(".")) {
- continue;
- }
-
- File testFile = new File(path, fName);
- TestFileContext tfsc = new TestFileContext(testFile);
- String[] nameSplits = fName.split("\\.");
-
- if (nameSplits.length < 3) {
- throw new IllegalArgumentException("Test file '" + cUnit.getName() + File.separatorChar
- + fName + "' does not have the proper test file name format.");
- }
-
- tfsc.setSeqNum(nameSplits[nameSplits.length - 2]);
- resultFileCtxs.add(tfsc);
- }
- Collections.sort(resultFileCtxs);
- }
- return resultFileCtxs;
+ return getFilesInDir(testSuite.getResultOffsetPath(), cUnit.getOutputDir().getValue(), false);
}
public File getActualResultFile(CompilationUnit cUnit, File actualResultsBase) {
@@ -130,7 +111,9 @@
}
public static class Builder {
+ private final boolean m_doSlow;
public Builder() {
+ m_doSlow = System.getProperty("runSlowAQLTests", "false").equals("true");
}
public List<TestCaseContext> build(File tsRoot) throws Exception {
@@ -157,10 +140,9 @@
}
private void addContexts(File tsRoot, TestSuite ts, List<TestGroup> tgPath, List<TestCaseContext> tccs) {
- boolean doSlow = System.getProperty("runSlowAQLTests") != null;
TestGroup tg = tgPath.get(tgPath.size() - 1);
for (TestCase tc : tg.getTestCase()) {
- if (doSlow || tc.getCategory() != CategoryEnum.SLOW) {
+ if (m_doSlow || tc.getCategory() != CategoryEnum.SLOW) {
tccs.add(new TestCaseContext(tsRoot, ts, tgPath.toArray(new TestGroup[tgPath.size()]), tc));
}
}
diff --git a/pom.xml b/pom.xml
index e966057..1f001b9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,15 +24,15 @@
<algebricks.version>0.2.11-SNAPSHOT</algebricks.version>
<hyracks.version>0.2.11-SNAPSHOT</hyracks.version>
<jvm.extraargs />
- <skipSlowTests>true</skipSlowTests>
+ <runSlowAQLTests>false</runSlowAQLTests>
<!-- Definition of tests in various categories which may be excluded -->
<optimizer.tests>**/optimizer/**/*Test.java</optimizer.tests>
<metadata.tests>**/metadata/*Test.java</metadata.tests>
<execution.tests>**/ExecutionTest.java</execution.tests>
<invalid.tests>**/DmlTest.java</invalid.tests>
- <test.includes>**/*TestSuite.java,**/*Test.java</test.includes>
- <test.excludes>${optimizer.tests},${metadata.tests},${execution.tests},${invalid.tests}</test.excludes>
+ <global.test.includes>**/*TestSuite.java,**/*Test.java,${execution.tests}</global.test.includes>
+ <global.test.excludes>${optimizer.tests},${metadata.tests},${invalid.tests}</global.test.excludes>
</properties>
<build>
@@ -59,13 +59,14 @@
<argLine>-enableassertions -Xmx${test.heap.size}m
-Dfile.encoding=UTF-8
-Djava.util.logging.config.file=${user.home}/logging.properties
+ -DrunSlowAQLTests=${runSlowAQLTests}
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n</argLine>
<includes>
- <include>${test.includes}</include>
+ <include>${global.test.includes},${test.includes}</include>
</includes>
<excludes>
- <exclude>${test.excludes}</exclude>
+ <exclude>${global.test.excludes},${test.excludes}</exclude>
</excludes>
</configuration>
</plugin>
@@ -90,6 +91,12 @@
<profiles>
<profile>
+ <id>slow-aql-tests</id>
+ <properties>
+ <runSlowAQLTests>true</runSlowAQLTests>
+ </properties>
+ </profile>
+ <profile>
<id>optimizer-tests</id>
<properties>
<optimizer.tests />
@@ -139,13 +146,6 @@
</properties>
</profile>
- <profile>
- <id>slow</id>
- <properties>
- <skipSlowTests>false</skipSlowTests>
- </properties>
- </profile>
-
</profiles>
<modules>