Skip to content

Commit 2eb60eb

Browse files
committed
Add integration tests
1 parent 1302ce6 commit 2eb60eb

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcAdminImportTableIntegrationTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.scalar.db.api.TableMetadata;
77
import com.scalar.db.exception.storage.ExecutionException;
88
import com.scalar.db.io.DataType;
9+
import com.scalar.db.util.AdminTestUtils;
910
import java.sql.SQLException;
1011
import java.util.Collections;
1112
import java.util.List;
@@ -68,6 +69,11 @@ protected void dropNonImportableTable(String table) throws SQLException {
6869
testUtils.dropTable(getNamespace(), table);
6970
}
7071

72+
@Override
73+
protected AdminTestUtils getAdminTestUtils(String testName) {
74+
return new JdbcAdminTestUtils(getProperties(testName));
75+
}
76+
7177
@SuppressWarnings("unused")
7278
private boolean isOracle() {
7379
return JdbcEnv.isOracle();

integration-test/src/main/java/com/scalar/db/api/DistributedStorageAdminImportTableIntegrationTestBase.java

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package com.scalar.db.api;
22

33
import static org.assertj.core.api.Assertions.assertThat;
4+
import static org.assertj.core.api.Assertions.assertThatCode;
45
import static org.assertj.core.api.Assertions.assertThatThrownBy;
56

67
import com.scalar.db.exception.storage.ExecutionException;
78
import com.scalar.db.io.Column;
89
import com.scalar.db.io.DataType;
910
import com.scalar.db.service.StorageFactory;
11+
import com.scalar.db.util.AdminTestUtils;
1012
import java.sql.SQLException;
1113
import java.util.ArrayList;
1214
import java.util.Collections;
@@ -59,7 +61,7 @@ private void dropTable() throws Exception {
5961
if (!testData.isImportableTable()) {
6062
dropNonImportableTable(testData.getTableName());
6163
} else {
62-
admin.dropTable(getNamespace(), testData.getTableName());
64+
admin.dropTable(getNamespace(), testData.getTableName(), true);
6365
}
6466
}
6567
if (!admin.namespaceExists(getNamespace())) {
@@ -108,6 +110,8 @@ protected abstract List<String> getFloatCompatibleColumnNamesOnExistingDatabase(
108110

109111
protected abstract void dropNonImportableTable(String table) throws Exception;
110112

113+
protected abstract AdminTestUtils getAdminTestUtils(String testName);
114+
111115
@Test
112116
public void importTable_ShouldWorkProperly() throws Exception {
113117
// Arrange
@@ -222,6 +226,43 @@ public void alterColumnType_WideningConversion_ForImportedTable_ShouldAlterPrope
222226
}
223227
}
224228

229+
@Test
230+
public void dropNamespace_ShouldNotDropNonScalarDBTables() throws Exception {
231+
AdminTestUtils adminTestUtils = getAdminTestUtils(TEST_NAME);
232+
try {
233+
// Arrange
234+
testDataList.addAll(createExistingDatabaseWithAllDataTypes());
235+
for (TestData testData : testDataList) {
236+
if (testData.isImportableTable()) {
237+
admin.importTable(
238+
getNamespace(),
239+
testData.getTableName(),
240+
Collections.emptyMap(),
241+
testData.getOverrideColumnsType());
242+
}
243+
}
244+
for (TestData testData : testDataList) {
245+
if (testData.isImportableTable()) {
246+
admin.dropTable(getNamespace(), testData.getTableName());
247+
}
248+
}
249+
250+
// Act
251+
assertThatCode(() -> admin.dropNamespace(getNamespace()))
252+
.isInstanceOf(ExecutionException.class);
253+
254+
// Assert
255+
assertThat(admin.namespaceExists(getNamespace())).isTrue();
256+
for (TestData testData : testDataList) {
257+
if (!testData.isImportableTable()) {
258+
adminTestUtils.tableExists(getNamespace(), testData.getTableName());
259+
}
260+
}
261+
} finally {
262+
adminTestUtils.close();
263+
}
264+
}
265+
225266
private void importTable_ForImportableTable_ShouldImportProperly(
226267
String table, Map<String, DataType> overrideColumnsType, TableMetadata metadata)
227268
throws ExecutionException {

0 commit comments

Comments
 (0)