You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by xx...@apache.org on 2023/04/23 06:00:57 UTC

[kylin] 16/22: KYLIN-5454 add UT for Async Query Result

This is an automated email from the ASF dual-hosted git repository.

xxyu pushed a commit to branch kylin5
in repository https://gitbox.apache.org/repos/asf/kylin.git

commit 141eb4a7c306712ee5525789fdcb8cd8dbc68cc1
Author: Ruixuan Zhang <ru...@kyligence.io>
AuthorDate: Wed Feb 1 15:25:05 2023 +0800

    KYLIN-5454 add UT for Async Query Result
---
 .../kylin/rest/service/AysncQueryServiceTest.java     | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/query-service/src/test/java/org/apache/kylin/rest/service/AysncQueryServiceTest.java b/src/query-service/src/test/java/org/apache/kylin/rest/service/AysncQueryServiceTest.java
index 241ffd3d10..d5303e8345 100644
--- a/src/query-service/src/test/java/org/apache/kylin/rest/service/AysncQueryServiceTest.java
+++ b/src/query-service/src/test/java/org/apache/kylin/rest/service/AysncQueryServiceTest.java
@@ -59,6 +59,7 @@ import org.apache.hadoop.fs.Path;
 import org.apache.kylin.common.KapConfig;
 import org.apache.kylin.common.QueryContext;
 import org.apache.kylin.common.exception.KylinException;
+import org.apache.kylin.common.util.HadoopUtil;
 import org.apache.kylin.common.util.RandomUtil;
 import org.apache.kylin.metadata.query.QueryMetricsContext;
 import org.apache.kylin.metadata.querymeta.SelectedColumnMeta;
@@ -220,6 +221,12 @@ public class AysncQueryServiceTest extends ServiceTestBase {
         new QueryExec(PROJECT, getTestConfig()).executeQuery(sql);
 
         assertSame(AsyncQueryService.QueryStatus.SUCCESS, asyncQueryService.queryStatus(PROJECT, queryId));
+        String workingDir = getTestConfig().getHdfsWorkingDirectory(PROJECT);
+        FileSystem fs = HadoopUtil.getWorkingFileSystem();
+        Path path = new Path(workingDir + "/async_query_result" + "/" + queryId);
+        Assert.assertTrue(fs.exists(path));
+        Path file = new Path(path + "/" + queryId + "." + "csv");
+        Assert.assertTrue(fs.exists(file));
 
         List<org.apache.spark.sql.Row> rowList = ss.read()
                 .csv(asyncQueryService.getAsyncQueryResultDir(PROJECT, queryId).toString()).collectAsList();
@@ -466,6 +473,12 @@ public class AysncQueryServiceTest extends ServiceTestBase {
         queryContext.setProject(PROJECT);
         SparkSqlClient.executeSql(ss, sql, UUID.fromString(queryId), PROJECT);
         assertSame(AsyncQueryService.QueryStatus.SUCCESS, asyncQueryService.queryStatus(PROJECT, queryId));
+        String workingDir = getTestConfig().getHdfsWorkingDirectory(PROJECT);
+        FileSystem fs = HadoopUtil.getWorkingFileSystem();
+        Path path = new Path(workingDir + "/async_query_result" + "/" + queryId);
+        Assert.assertTrue(fs.exists(path));
+        Path resultFile = new Path(path + "/" + queryId + "." + "xlsx");
+        Assert.assertTrue(fs.exists(resultFile));
         HttpServletResponse response = mock(HttpServletResponse.class);
         ByteArrayOutputStream outputStream = mockOutputStream(response);
         asyncQueryService.retrieveSavedQueryResult(PROJECT, queryId, response, "xlsx", encodeDefault);
@@ -938,6 +951,12 @@ public class AysncQueryServiceTest extends ServiceTestBase {
         new QueryExec(PROJECT, getTestConfig()).executeQuery(sql);
 
         assertSame(AsyncQueryService.QueryStatus.SUCCESS, asyncQueryService.queryStatus(PROJECT, queryId));
+        String workingDir = getTestConfig().getHdfsWorkingDirectory(PROJECT);
+        FileSystem fs = HadoopUtil.getWorkingFileSystem();
+        Path path = new Path(workingDir + "/async_query_result" + "/" + queryId);
+        Assert.assertTrue(fs.exists(path));
+        Path file = new Path(path + "/" + queryId + "." + "csv");
+        Assert.assertTrue(fs.exists(file));
 
         QueryMetricsContext.start(queryId, "");
         Assert.assertTrue(QueryMetricsContext.isStarted());