|
|
|
@ -20,7 +20,6 @@ package org.apache.dolphinscheduler.plugin.storage.hdfs;
|
|
|
|
|
import static com.google.common.truth.Truth.assertThat; |
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertThrows; |
|
|
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.constants.Constants; |
|
|
|
|
import org.apache.dolphinscheduler.common.utils.FileUtils; |
|
|
|
|
import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata; |
|
|
|
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity; |
|
|
|
@ -47,7 +46,7 @@ class LocalStorageOperatorTest {
|
|
|
|
|
Paths.get(LocalStorageOperatorTest.class.getResource("/").getFile(), "localStorage").toString(); |
|
|
|
|
private static final String tenantCode = "default"; |
|
|
|
|
private static final String baseDir = |
|
|
|
|
Paths.get(resourceBaseDir, tenantCode, StorageConstants.RESOURCE_TYPE_FILE).toString(); |
|
|
|
|
Paths.get(resourceBaseDir, tenantCode, StorageOperator.FILE_FOLDER_NAME).toString(); |
|
|
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
|
@BeforeEach |
|
|
|
@ -116,7 +115,7 @@ class LocalStorageOperatorTest {
|
|
|
|
|
public void testGetStorageBaseDirectory_withTenant_withResourceTypeFile() { |
|
|
|
|
String storageBaseDirectory = storageOperator.getStorageBaseDirectory("default", ResourceType.FILE); |
|
|
|
|
assertThat(storageBaseDirectory) |
|
|
|
|
.isEqualTo("file:" + Paths.get(resourceBaseDir, tenantCode, Constants.RESOURCE_TYPE_FILE)); |
|
|
|
|
.isEqualTo("file:" + Paths.get(resourceBaseDir, tenantCode, StorageOperator.FILE_FOLDER_NAME)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -143,21 +142,21 @@ class LocalStorageOperatorTest {
|
|
|
|
|
public void testGetStorageFileAbsolutePath() { |
|
|
|
|
String fileAbsolutePath = storageOperator.getStorageFileAbsolutePath("default", "test.sh"); |
|
|
|
|
assertThat(fileAbsolutePath).isEqualTo( |
|
|
|
|
"file:" + Paths.get(resourceBaseDir, tenantCode, Constants.RESOURCE_TYPE_FILE, "test.sh")); |
|
|
|
|
"file:" + Paths.get(resourceBaseDir, tenantCode, StorageOperator.FILE_FOLDER_NAME, "test.sh")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
|
@Test |
|
|
|
|
public void testCreateStorageDir_notExists() { |
|
|
|
|
String testDirFileAbsolutePath = |
|
|
|
|
"file:" + Paths.get(resourceBaseDir, "root", Constants.RESOURCE_TYPE_FILE, "testDir"); |
|
|
|
|
"file:" + Paths.get(resourceBaseDir, "root", StorageOperator.FILE_FOLDER_NAME, "testDir"); |
|
|
|
|
try { |
|
|
|
|
storageOperator.createStorageDir(testDirFileAbsolutePath); |
|
|
|
|
StorageEntity storageEntity = storageOperator.getStorageEntity(testDirFileAbsolutePath); |
|
|
|
|
assertThat(storageEntity.getFullName()).isEqualTo(testDirFileAbsolutePath); |
|
|
|
|
assertThat(storageEntity.getFileName()).isEqualTo("testDir"); |
|
|
|
|
assertThat(storageEntity.getPfullName()) |
|
|
|
|
.isEqualTo("file:" + Paths.get(resourceBaseDir, "root", Constants.RESOURCE_TYPE_FILE)); |
|
|
|
|
.isEqualTo("file:" + Paths.get(resourceBaseDir, "root", StorageOperator.FILE_FOLDER_NAME)); |
|
|
|
|
assertThat(storageEntity.isDirectory()).isTrue(); |
|
|
|
|
assertThat(storageEntity.getType()).isEqualTo(ResourceType.FILE); |
|
|
|
|
} finally { |
|
|
|
@ -169,7 +168,7 @@ class LocalStorageOperatorTest {
|
|
|
|
|
@Test |
|
|
|
|
public void testCreateStorageDir_exists() { |
|
|
|
|
String testDirFileAbsolutePath = |
|
|
|
|
"file:" + Paths.get(resourceBaseDir, "default", Constants.RESOURCE_TYPE_FILE, "sqlDirectory"); |
|
|
|
|
"file:" + Paths.get(resourceBaseDir, "default", StorageOperator.FILE_FOLDER_NAME, "sqlDirectory"); |
|
|
|
|
assertThrows(FileAlreadyExistsException.class, () -> storageOperator.createStorageDir(testDirFileAbsolutePath)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|