Skip to content

Commit 6d051e2

Browse files
committed
Add integration tests for ConsensusCommitAdmin
1 parent ea08896 commit 6d051e2

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.scalar.db.api.DistributedStorageAdminImportTableIntegrationTestBase.TestData;
44
import com.scalar.db.exception.storage.ExecutionException;
55
import com.scalar.db.transaction.consensuscommit.ConsensusCommitAdminImportTableIntegrationTestBase;
6+
import com.scalar.db.util.AdminTestUtils;
67
import java.sql.SQLException;
78
import java.util.List;
89
import java.util.Properties;
@@ -53,6 +54,11 @@ protected void dropNonImportableTable(String table) throws SQLException {
5354
testUtils.dropTable(getNamespace(), table);
5455
}
5556

57+
@Override
58+
protected AdminTestUtils getAdminTestUtils(String testName) {
59+
return new JdbcAdminTestUtils(getProperties(testName));
60+
}
61+
5662
@SuppressWarnings("unused")
5763
private boolean isSqlite() {
5864
return JdbcEnv.isSqlite();
@@ -72,4 +78,9 @@ public void importTable_ForUnsupportedDatabase_ShouldThrowUnsupportedOperationEx
7278
throws ExecutionException {
7379
super.importTable_ForUnsupportedDatabase_ShouldThrowUnsupportedOperationException();
7480
}
81+
82+
@Test
83+
@Override
84+
@DisabledIf("isSqlite")
85+
public void dropNamespace_ShouldNotDropNonScalarDBTables() {}
7586
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ public void alterColumnType_Oracle_WideningConversion_ForImportedTable_ShouldAlt
271271
}
272272

273273
@Test
274+
@Override
274275
@DisabledIf("isSqlite")
275276
public void dropNamespace_ShouldNotDropNonScalarDBTables() {}
276277
}

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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.api.DistributedStorageAdminImportTableIntegrationTestBase.TestData;
@@ -9,6 +10,7 @@
910
import com.scalar.db.io.Column;
1011
import com.scalar.db.io.DataType;
1112
import com.scalar.db.service.TransactionFactory;
13+
import com.scalar.db.util.AdminTestUtils;
1214
import java.util.ArrayList;
1315
import java.util.Collections;
1416
import java.util.HashSet;
@@ -104,6 +106,8 @@ protected void afterAll() throws Exception {}
104106

105107
protected abstract void dropNonImportableTable(String table) throws Exception;
106108

109+
protected abstract AdminTestUtils getAdminTestUtils(String testName);
110+
107111
@Test
108112
public void importTable_ShouldWorkProperly() throws Exception {
109113
// Arrange
@@ -134,6 +138,43 @@ public void importTable_ForUnsupportedDatabase_ShouldThrowUnsupportedOperationEx
134138
.isInstanceOf(UnsupportedOperationException.class);
135139
}
136140

141+
@Test
142+
public void dropNamespace_ShouldNotDropNonScalarDBTables() throws Exception {
143+
AdminTestUtils adminTestUtils = getAdminTestUtils(TEST_NAME);
144+
try {
145+
// Arrange
146+
testDataList.addAll(createExistingDatabaseWithAllDataTypes());
147+
for (TestData testData : testDataList) {
148+
if (testData.isImportableTable()) {
149+
admin.importTable(
150+
getNamespace(),
151+
testData.getTableName(),
152+
Collections.emptyMap(),
153+
testData.getOverrideColumnsType());
154+
}
155+
}
156+
for (TestData testData : testDataList) {
157+
if (testData.isImportableTable()) {
158+
admin.dropTable(getNamespace(), testData.getTableName());
159+
}
160+
}
161+
162+
// Act
163+
assertThatCode(() -> admin.dropNamespace(getNamespace()))
164+
.isInstanceOf(IllegalStateException.class);
165+
166+
// Assert
167+
assertThat(admin.namespaceExists(getNamespace())).isTrue();
168+
for (TestData testData : testDataList) {
169+
if (!testData.isImportableTable()) {
170+
adminTestUtils.tableExists(getNamespace(), testData.getTableName());
171+
}
172+
}
173+
} finally {
174+
adminTestUtils.close();
175+
}
176+
}
177+
137178
private void importTable_ForImportableTable_ShouldImportProperly(
138179
String table, Map<String, DataType> overrideColumnsType, TableMetadata metadata)
139180
throws ExecutionException {

0 commit comments

Comments
 (0)