This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 33db2776621d74477d17397dcd2ed595795faca7 Author: amory <wangqian...@selectdb.com> AuthorDate: Fri Aug 25 09:22:34 2023 +0800 [FIX](regresstest) fix regress test for export with scp files (#23417) * fix regress test for export with scp * fix outfile and outputfilepath --- .../suites/export/test_array_export.groovy | 27 +++++++++++++++------- .../suites/export/test_map_export.groovy | 22 +++++++++++++----- .../suites/export/test_struct_export.groovy | 23 +++++++++++++----- 3 files changed, 52 insertions(+), 20 deletions(-) diff --git a/regression-test/suites/export/test_array_export.groovy b/regression-test/suites/export/test_array_export.groovy index af17ab32fb..1ee097cefb 100644 --- a/regression-test/suites/export/test_array_export.groovy +++ b/regression-test/suites/export/test_array_export.groovy @@ -52,10 +52,15 @@ suite("test_array_export", "export") { // define the table and out file path def tableName = "array_outfile_test" def outFilePath = """${context.file.parent}/test_array_export""" - def outFile = "/tmp" + List<List<Object>> backends = sql """ show backends """ + assertTrue(backends.size() > 0) + def outFile = outFilePath + if (backends.size() > 1) { + outFile = "/tmp" + } def urlHost = "" def csvFiles = "" - logger.warn("test_array_export the outFilePath=" + outFilePath) + logger.warn("test_array_export the outFile=" + outFile) def create_test_table = {testTablex -> sql """ DROP TABLE IF EXISTS ${tableName} """ @@ -171,10 +176,14 @@ suite("test_array_export", "export") { """ url = result[0][3] urlHost = url.substring(8, url.indexOf("${outFile}")) - def filePrifix = url.split("${outFile}")[1] - csvFiles = "${outFile}${filePrifix}*.csv" - scpFiles ("root", urlHost, csvFiles, outFilePath); + if (backends.size() > 1) { + // custer will scp files + def filePrifix = url.split("${outFile}")[1] + csvFiles = "${outFile}${filePrifix}*.csv" + scpFiles ("root", urlHost, csvFiles, outFilePath) + } + // path is from outputfilepath File[] files = path.listFiles() assert files.length == 1 List<String> outLines = Files.readAllLines(Paths.get(files[0].getAbsolutePath()), StandardCharsets.UTF_8); @@ -193,8 +202,10 @@ suite("test_array_export", "export") { } path.delete(); } - cmd = "rm -rf ${csvFiles}" - sshExec ("root", urlHost, cmd) + if (csvFiles != "") { + cmd = "rm -rf ${csvFiles}" + sshExec("root", urlHost, cmd) + } } @@ -235,4 +246,4 @@ suite("test_array_export", "export") { try_sql("DROP TABLE IF EXISTS ${tableName}") } } -} \ No newline at end of file +} diff --git a/regression-test/suites/export/test_map_export.groovy b/regression-test/suites/export/test_map_export.groovy index c2bcb4661a..ba371fb3a1 100644 --- a/regression-test/suites/export/test_map_export.groovy +++ b/regression-test/suites/export/test_map_export.groovy @@ -78,7 +78,12 @@ suite("test_map_export", "export") { qt_select_count """SELECT COUNT(m) FROM ${testTable}""" def outFilePath = """${context.file.parent}/test_map_export""" - def outFile = "/tmp" + List<List<Object>> backends = sql """ show backends """ + assertTrue(backends.size() > 0) + def outFile = outFilePath + if (backends.size() > 1) { + outFile = "/tmp" + } def urlHost = "" def csvFiles = "" logger.info("test_map_export the outFilePath=" + outFilePath) @@ -95,9 +100,12 @@ suite("test_map_export", "export") { """ url = result[0][3] urlHost = url.substring(8, url.indexOf("${outFile}")) - def filePrifix = url.split("${outFile}")[1] - csvFiles = "${outFile}${filePrifix}*.csv" - scpFiles ("root", urlHost, csvFiles, outFilePath); + if (backends.size() > 1) { + // custer will scp files + def filePrifix = url.split("${outFile}")[1] + csvFiles = "${outFile}${filePrifix}*.csv" + scpFiles ("root", urlHost, csvFiles, outFilePath) + } File[] files = path.listFiles() assert files.length == 1 @@ -137,7 +145,9 @@ suite("test_map_export", "export") { } path.delete(); } - cmd = "rm -rf ${csvFiles}" - sshExec ("root", urlHost, cmd) + if (csvFiles != "") { + cmd = "rm -rf ${csvFiles}" + sshExec("root", urlHost, cmd) + } } } diff --git a/regression-test/suites/export/test_struct_export.groovy b/regression-test/suites/export/test_struct_export.groovy index e709bd7254..18ef26b834 100644 --- a/regression-test/suites/export/test_struct_export.groovy +++ b/regression-test/suites/export/test_struct_export.groovy @@ -80,7 +80,12 @@ suite("test_struct_export", "export") { qt_select_count """SELECT COUNT(k2), COUNT(k4) FROM ${testTable}""" def outFilePath = """${context.file.parent}/test_struct_export""" - def outFile = "/tmp" + List<List<Object>> backends = sql """ show backends """ + assertTrue(backends.size() > 0) + def outFile = outFilePath + if (backends.size() > 1) { + outFile = "/tmp" + } def urlHost = "" def csvFiles = "" logger.info("test_struct_export the outFilePath=" + outFilePath) @@ -97,9 +102,13 @@ suite("test_struct_export", "export") { """ url = result[0][3] urlHost = url.substring(8, url.indexOf("${outFile}")) - def filePrifix = url.split("${outFile}")[1] - csvFiles = "${outFile}${filePrifix}*.csv" - scpFiles ("root", urlHost, csvFiles, outFilePath); + if (backends.size() > 1) { + // custer will scp files + def filePrifix = url.split("${outFile}")[1] + csvFiles = "${outFile}${filePrifix}*.csv" + scpFiles ("root", urlHost, csvFiles, outFilePath) + } + File[] files = path.listFiles() assert files.length == 1 @@ -140,7 +149,9 @@ suite("test_struct_export", "export") { } path.delete(); } - cmd = "rm -rf ${csvFiles}" - sshExec ("root", urlHost, cmd) + if (csvFiles != "") { + cmd = "rm -rf ${csvFiles}" + sshExec("root", urlHost, cmd) + } } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org