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/02/07 07:09:44 UTC
[kylin] 15/15: [DIRTY] fix check style and UT
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 63db1633ed013a58ddcf92f626334e31e95bc468
Author: longfei.jiang <lo...@kyligence.io>
AuthorDate: Fri Feb 3 16:09:48 2023 +0800
[DIRTY] fix check style and UT
---
.../common/persistence/metadata/jdbc/JdbcUtil.java | 2 +-
.../persistence/metadata/jdbc/JdbcUtilTest.java | 6 ++---
.../kylin/metrics/HdfsCapacityMetricsTest.java | 10 +++++++-
.../rest/service/StreamingTableServiceTest.java | 3 +--
.../org/apache/kylin/tool/MetadataToolTest.java | 28 ++++++++++++----------
5 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/src/core-common/src/main/java/org/apache/kylin/common/persistence/metadata/jdbc/JdbcUtil.java b/src/core-common/src/main/java/org/apache/kylin/common/persistence/metadata/jdbc/JdbcUtil.java
index caf500bc14..8d4d54873c 100644
--- a/src/core-common/src/main/java/org/apache/kylin/common/persistence/metadata/jdbc/JdbcUtil.java
+++ b/src/core-common/src/main/java/org/apache/kylin/common/persistence/metadata/jdbc/JdbcUtil.java
@@ -190,7 +190,7 @@ public class JdbcUtil {
public static Properties datasourceParametersForUT(StorageURL url) {
Properties props = new Properties();
props.put("driverClassName", "org.h2.Driver");
- props.put("url", "jdbc:h2:mem:db_default;DB_CLOSE_DELAY=-1;MODE=MySQL");
+ props.put("url", "jdbc:h2:mem:db_default;DB_CLOSE_DELAY=-1");
props.put("username", "sa");
props.put("password", "");
props.put("maxTotal", "50");
diff --git a/src/core-common/src/test/java/org/apache/kylin/common/persistence/metadata/jdbc/JdbcUtilTest.java b/src/core-common/src/test/java/org/apache/kylin/common/persistence/metadata/jdbc/JdbcUtilTest.java
index b038b18d7e..ab0f7926c9 100644
--- a/src/core-common/src/test/java/org/apache/kylin/common/persistence/metadata/jdbc/JdbcUtilTest.java
+++ b/src/core-common/src/test/java/org/apache/kylin/common/persistence/metadata/jdbc/JdbcUtilTest.java
@@ -31,7 +31,7 @@ public class JdbcUtilTest {
@Before
public void setup() throws SQLException {
- this.connection = DriverManager.getConnection("jdbc:h2:mem:jdbc_util_test;DB_CLOSE_DELAY=-1;MODE=MySQL", "sa",
+ this.connection = DriverManager.getConnection("jdbc:h2:mem:jdbc_util_test;DB_CLOSE_DELAY=-1", "sa",
null);
}
@@ -42,12 +42,12 @@ public class JdbcUtilTest {
Assert.assertTrue(JdbcUtil.isColumnExists(connection, table, "col1"));
// case insensitive
- this.connection = DriverManager.getConnection("jdbc:h2:mem:jdbc_util_test;DB_CLOSE_DELAY=-1;MODE=MySQL", "sa",
+ this.connection = DriverManager.getConnection("jdbc:h2:mem:jdbc_util_test;DB_CLOSE_DELAY=-1", "sa",
null);
Assert.assertTrue(JdbcUtil.isColumnExists(connection, table, "cOL1"));
// not exists
- this.connection = DriverManager.getConnection("jdbc:h2:mem:jdbc_util_test;DB_CLOSE_DELAY=-1;MODE=MySQL", "sa",
+ this.connection = DriverManager.getConnection("jdbc:h2:mem:jdbc_util_test;DB_CLOSE_DELAY=-1", "sa",
null);
Assert.assertFalse(JdbcUtil.isColumnExists(connection, table, "not_exists"));
}
diff --git a/src/core-job/src/test/java/org/apache/kylin/metrics/HdfsCapacityMetricsTest.java b/src/core-job/src/test/java/org/apache/kylin/metrics/HdfsCapacityMetricsTest.java
index 0c4332707a..20c233f71e 100644
--- a/src/core-job/src/test/java/org/apache/kylin/metrics/HdfsCapacityMetricsTest.java
+++ b/src/core-job/src/test/java/org/apache/kylin/metrics/HdfsCapacityMetricsTest.java
@@ -71,7 +71,15 @@ public class HdfsCapacityMetricsTest extends NLocalFileMetadataTestCase {
int activeThreadIdx = scheduledExecutor.indexOf(activeThreadStr);
String thread = scheduledExecutor.substring(activeThreadIdx + activeThreadStr.length(),
activeThreadIdx + activeThreadStr.length() + 1);
- Assert.assertEquals(1, Integer.parseInt(thread));
+ if (Integer.parseInt(thread) != 0) {
+ Assert.assertEquals(1, Integer.parseInt(thread));
+ } else {
+ String queuedThreadStr = "queued tasks = ";
+ int queuedThreadIdx = scheduledExecutor.indexOf(queuedThreadStr);
+ int queued = Integer.parseInt(scheduledExecutor.substring(queuedThreadIdx + queuedThreadStr.length(),
+ queuedThreadIdx + queuedThreadStr.length() + 1));
+ Assert.assertTrue(1 <= queued);
+ }
}
@Test
diff --git a/src/datasource-service/src/test/java/org/apache/kylin/rest/service/StreamingTableServiceTest.java b/src/datasource-service/src/test/java/org/apache/kylin/rest/service/StreamingTableServiceTest.java
index 42ed55b721..fba55979ec 100644
--- a/src/datasource-service/src/test/java/org/apache/kylin/rest/service/StreamingTableServiceTest.java
+++ b/src/datasource-service/src/test/java/org/apache/kylin/rest/service/StreamingTableServiceTest.java
@@ -22,7 +22,6 @@ import java.util.Locale;
import org.apache.commons.lang3.StringUtils;
import org.apache.kylin.common.KylinConfig;
-import org.apache.kylin.common.SystemPropertiesCache;
import org.apache.kylin.common.exception.KylinException;
import org.apache.kylin.common.msg.MsgPicker;
import org.apache.kylin.common.scheduler.EventBusFactory;
@@ -34,6 +33,7 @@ import org.apache.kylin.metadata.model.ColumnDesc;
import org.apache.kylin.metadata.model.NTableMetadataManager;
import org.apache.kylin.metadata.model.TableDesc;
import org.apache.kylin.metadata.project.NProjectManager;
+import org.apache.kylin.metadata.recommendation.candidate.JdbcRawRecStore;
import org.apache.kylin.metadata.streaming.KafkaConfig;
import org.apache.kylin.metadata.streaming.KafkaConfigManager;
import org.apache.kylin.rest.constant.Constant;
@@ -54,7 +54,6 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.test.util.ReflectionTestUtils;
-import org.apache.kylin.metadata.recommendation.candidate.JdbcRawRecStore;
import lombok.val;
public class StreamingTableServiceTest extends NLocalFileMetadataTestCase {
diff --git a/src/tool/src/test/java/org/apache/kylin/tool/MetadataToolTest.java b/src/tool/src/test/java/org/apache/kylin/tool/MetadataToolTest.java
index d8ddd329aa..2bf5331b5a 100644
--- a/src/tool/src/test/java/org/apache/kylin/tool/MetadataToolTest.java
+++ b/src/tool/src/test/java/org/apache/kylin/tool/MetadataToolTest.java
@@ -129,31 +129,35 @@ public class MetadataToolTest extends NLocalFileMetadataTestCase {
val junitFolder = temporaryFolder.getRoot();
val tool = new MetadataTool(getTestConfig());
// test case for fetching a specific file
- tool.execute(new String[] {
- "-fetch", "-target", "default/table/DEFAULT.STREAMING_TABLE.json", "-dir", junitFolder.getAbsolutePath(), "-folder", "target_fetch"
- });
+ tool.execute(new String[] { "-fetch", "-target", "default/table/DEFAULT.STREAMING_TABLE.json", "-dir",
+ junitFolder.getAbsolutePath(), "-folder", "target_fetch" });
//test case for fetching a folder
- tool.execute(new String[] {
- "-fetch", "-target", "_global", "-dir", junitFolder.getAbsolutePath(), "-folder", "target_fetch_global"
- });
+ tool.execute(new String[] { "-fetch", "-target", "_global", "-dir", junitFolder.getAbsolutePath(), "-folder",
+ "target_fetch_global" });
Assertions.assertThat(junitFolder.listFiles()).hasSize(2);
- val archiveFolder = junitFolder.listFiles()[1];
- val globleFolder = junitFolder.listFiles()[0];
+ File archiveFolder = null;
+ File globalFolder = null;
+ for (File folder : junitFolder.listFiles()) {
+ if (folder.getName().equals("target_fetch_global")) {
+ globalFolder = folder;
+ }
+ if (folder.getName().equals("target_fetch")) {
+ archiveFolder = folder;
+ }
+ }
Assertions.assertThat(archiveFolder).exists();
Assertions.assertThat(archiveFolder.list()).isNotEmpty().containsOnly("default", "UUID");
val projectFolder = findFile(archiveFolder.listFiles(), f -> f.getName().equals("default"));
- assertProjectFolder(projectFolder, globleFolder);
+ assertProjectFolder(projectFolder, globalFolder);
}
@Test
public void testListFile() {
val tool = new MetadataTool(getTestConfig());
- tool.execute(new String[] {
- "-list", "-target", "default"
- });
+ tool.execute(new String[] { "-list", "-target", "default" });
}
@Test