blob: 31268cb547e2dbaf92f598cd061040ea0bc86d99 [file] [log] [blame]
/*
* Copyright 2009-2013 by The Regents of the University of California
* Licensed 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 from
*
* 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 edu.uci.ics.hivesterix.test.optimizer;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
import junit.framework.Test;
import org.apache.commons.io.FileUtils;
import edu.uci.ics.hivesterix.test.base.AbstractTestSuiteClass;
public class OptimizerTestSuite extends AbstractTestSuiteClass {
private static final String PATH_TO_QUERIES = "src/test/resources/optimizerts/queries/";
private static final String PATH_TO_RESULTS = "src/test/resources/optimizerts/results/";
private static final String PATH_TO_IGNORES = "src/test/resources/optimizerts/ignore.txt";
private static final String FILE_EXTENSION_OF_RESULTS = "plan";
public static Test suite() throws UnsupportedEncodingException, FileNotFoundException, IOException {
List<String> ignores = getIgnoreList(PATH_TO_IGNORES);
File testData = new File(PATH_TO_QUERIES);
File[] queries = testData.listFiles();
OptimizerTestSuite testSuite = new OptimizerTestSuite();
// set hdfs and hyracks cluster, and load test data to hdfs
try {
testSuite.setup();
testSuite.loadData();
FileUtils.forceMkdir(new File("optest"));
} catch (Exception e) {
e.printStackTrace();
throw new IllegalStateException(e.getMessage());
}
for (File qFile : queries) {
if (isIgnored(qFile.getName(), ignores))
continue;
if (qFile.isFile()) {
String resultFileName = hiveExtToResExt(qFile.getName());
File rFile = new File(PATH_TO_RESULTS + resultFileName);
testSuite.addTest(new OptimizerTestCase(qFile, rFile));
}
}
return testSuite;
}
private static String hiveExtToResExt(String fname) {
int dot = fname.lastIndexOf('.');
return fname.substring(0, dot + 1) + FILE_EXTENSION_OF_RESULTS;
}
}