Пример #1
0
 static {
   testBase = TpchTestBase.getInstance();
   testingCluster = testBase.getTestingCluster();
   conf = testBase.getTestingCluster().getConfiguration();
   catalog = testBase.getTestingCluster().getMaster().getCatalog();
   URL datasetBaseURL = ClassLoader.getSystemResource("dataset");
   datasetBasePath = new Path(datasetBaseURL.toString());
   URL queryBaseURL = ClassLoader.getSystemResource("queries");
   queryBasePath = new Path(queryBaseURL.toString());
   URL resultBaseURL = ClassLoader.getSystemResource("results");
   resultBasePath = new Path(resultBaseURL.toString());
 }
Пример #2
0
 /**
  * Assert the equivalence between the expected result and an actual query result. If it isn't it
  * throws an AssertionError with the given message.
  *
  * @param message message The message to printed if the assertion is failed.
  * @param result Query result to be compared.
  */
 public final void assertResultSet(String message, ResultSet result, String resultFileName)
     throws IOException {
   FileSystem fs = currentQueryPath.getFileSystem(testBase.getTestingCluster().getConfiguration());
   Path resultFile = getResultFile(resultFileName);
   assertTrue(resultFile.toString() + " existence check", fs.exists(resultFile));
   try {
     verifyResult(message, result, resultFile);
   } catch (SQLException e) {
     throw new IOException(e);
   }
 }
Пример #3
0
  /**
   * Execute a query contained in the given named file. This methods tries to find the given file
   * within the directory src/test/resources/results/<i>ClassName</i>.
   *
   * @param queryFileName The file name to be used to execute a query.
   * @return ResultSet of query execution.
   */
  public ResultSet executeFile(String queryFileName) throws Exception {
    Path queryFilePath = getQueryFilePath(queryFileName);
    FileSystem fs = currentQueryPath.getFileSystem(testBase.getTestingCluster().getConfiguration());
    assertTrue(queryFilePath.toString() + " existence check", fs.exists(queryFilePath));

    List<ParsedResult> parsedResults =
        SimpleParser.parseScript(FileUtil.readTextFile(new File(queryFilePath.toUri())));
    if (parsedResults.size() > 1) {
      assertNotNull("This script \"" + queryFileName + "\" includes two or more queries");
    }
    ResultSet result = client.executeQueryAndGetResult(parsedResults.get(0).getStatement());
    assertNotNull("Query succeeded test", result);
    return result;
  }
Пример #4
0
 protected ResultSet executeString(String sql) throws Exception {
   return testBase.execute(sql);
 }
Пример #5
0
 @BeforeClass
 public static void setUpClass() throws IOException {
   conf = testBase.getTestingCluster().getConfiguration();
   client = new TajoClient(conf);
 }