Skip to content

Commit

Permalink
[DIRTY] fix check style and UT
Browse files Browse the repository at this point in the history
  • Loading branch information
jlfsdtc committed Feb 6, 2023
1 parent 21f7ce8 commit c5d6c61
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static Properties datasourceParametersForProd(StorageURL url) {
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -42,12 +42,12 @@ public void testIsColumnExists() throws SQLException {
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"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ public void testRegisterHdfsMetrics() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

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;
Expand All @@ -34,6 +33,7 @@
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;
Expand All @@ -54,7 +54,6 @@
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 {
Expand Down
28 changes: 16 additions & 12 deletions src/tool/src/test/java/org/apache/kylin/tool/MetadataToolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,31 +129,35 @@ public void testFetchTargetFile() throws IOException {
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
Expand Down

0 comments on commit c5d6c61

Please sign in to comment.