Skip to content

Commit 5363a25

Browse files
committed
Support transaction metadata decoupling in Consensus Commit
1 parent 18121d2 commit 5363a25

File tree

39 files changed

+1724
-183
lines changed

39 files changed

+1724
-183
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public void afterAll() {
4545

4646
@Override
4747
protected List<TestData> createExistingDatabaseWithAllDataTypes() throws SQLException {
48-
return testUtils.createExistingDatabaseWithAllDataTypes(getNamespace());
48+
return testUtils.createExistingDatabaseWithAllDataTypes(namespace);
4949
}
5050

5151
@Override
5252
protected void dropNonImportableTable(String table) throws SQLException {
53-
testUtils.dropTable(getNamespace(), table);
53+
testUtils.dropTable(namespace, table);
5454
}
5555

5656
@SuppressWarnings("unused")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.scalar.db.storage.jdbc;
2+
3+
import com.scalar.db.api.DistributedStorageAdminImportTableIntegrationTestBase.TestData;
4+
import com.scalar.db.config.DatabaseConfig;
5+
import com.scalar.db.exception.storage.ExecutionException;
6+
import com.scalar.db.transaction.consensuscommit.ConsensusCommitAdminImportTableWithMetadataDecouplingIntegrationTestBase;
7+
import java.sql.SQLException;
8+
import java.util.List;
9+
import java.util.Properties;
10+
import org.junit.jupiter.api.Test;
11+
import org.junit.jupiter.api.condition.DisabledIf;
12+
import org.junit.jupiter.api.condition.EnabledIf;
13+
import org.slf4j.Logger;
14+
import org.slf4j.LoggerFactory;
15+
16+
public class ConsensusCommitAdminImportTableWithMetadataDecouplingIntegrationTestWithJdbcDatabase
17+
extends ConsensusCommitAdminImportTableWithMetadataDecouplingIntegrationTestBase {
18+
private static final Logger logger =
19+
LoggerFactory.getLogger(
20+
ConsensusCommitAdminImportTableWithMetadataDecouplingIntegrationTestWithJdbcDatabase
21+
.class);
22+
23+
private JdbcAdminImportTestUtils testUtils;
24+
25+
@Override
26+
protected Properties getProps(String testName) {
27+
Properties properties = JdbcEnv.getProperties(testName);
28+
29+
// Set the isolation level for consistency reads
30+
RdbEngineStrategy rdbEngine =
31+
RdbEngineFactory.create(new JdbcConfig(new DatabaseConfig(properties)));
32+
properties.setProperty(
33+
JdbcConfig.ISOLATION_LEVEL,
34+
JdbcTestUtils.getIsolationLevel(rdbEngine.getMinimumIsolationLevelForConsistencyRead())
35+
.name());
36+
37+
testUtils = new JdbcAdminImportTestUtils(properties);
38+
return properties;
39+
}
40+
41+
@Override
42+
public void afterAll() {
43+
try {
44+
super.afterAll();
45+
} catch (Exception e) {
46+
logger.warn("Failed to call super.afterAll", e);
47+
}
48+
49+
try {
50+
if (testUtils != null) {
51+
testUtils.close();
52+
}
53+
} catch (Exception e) {
54+
logger.warn("Failed to close test utils", e);
55+
}
56+
}
57+
58+
@Override
59+
protected List<TestData> createExistingDatabaseWithAllDataTypes() throws SQLException {
60+
return testUtils.createExistingDatabaseWithAllDataTypes(namespace);
61+
}
62+
63+
@Override
64+
protected void dropNonImportableTable(String table) throws SQLException {
65+
testUtils.dropTable(namespace, table);
66+
}
67+
68+
@SuppressWarnings("unused")
69+
private boolean isSqlite() {
70+
return JdbcEnv.isSqlite();
71+
}
72+
73+
@Test
74+
@Override
75+
@DisabledIf("isSqlite")
76+
public void importTable_ShouldWorkProperly() throws Exception {
77+
super.importTable_ShouldWorkProperly();
78+
}
79+
80+
@Test
81+
@Override
82+
@EnabledIf("isSqlite")
83+
public void importTable_ForUnsupportedDatabase_ShouldThrowUnsupportedOperationException()
84+
throws ExecutionException {
85+
super.importTable_ForUnsupportedDatabase_ShouldThrowUnsupportedOperationException();
86+
}
87+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.scalar.db.storage.jdbc;
2+
3+
import com.scalar.db.config.DatabaseConfig;
4+
import com.scalar.db.transaction.consensuscommit.ConsensusCommitSpecificWithMetadataDecouplingIntegrationTestBase;
5+
import java.util.Properties;
6+
7+
public class ConsensusCommitSpecificWithMetadataDecouplingIntegrationTestWithJdbcDatabase
8+
extends ConsensusCommitSpecificWithMetadataDecouplingIntegrationTestBase {
9+
10+
@Override
11+
protected Properties getProperties(String testName) {
12+
Properties properties = ConsensusCommitJdbcEnv.getProperties(testName);
13+
14+
// Set the isolation level for consistency reads
15+
RdbEngineStrategy rdbEngine =
16+
RdbEngineFactory.create(new JdbcConfig(new DatabaseConfig(properties)));
17+
properties.setProperty(
18+
JdbcConfig.ISOLATION_LEVEL,
19+
JdbcTestUtils.getIsolationLevel(rdbEngine.getMinimumIsolationLevelForConsistencyRead())
20+
.name());
21+
22+
return properties;
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.scalar.db.storage.jdbc;
2+
3+
import com.scalar.db.config.DatabaseConfig;
4+
import com.scalar.db.transaction.consensuscommit.ConsensusCommitWithMetadataDecouplingIntegrationTestBase;
5+
import java.util.Properties;
6+
7+
public class ConsensusCommitWithMetadataDecouplingIntegrationTestWithJdbcDatabase
8+
extends ConsensusCommitWithMetadataDecouplingIntegrationTestBase {
9+
10+
@Override
11+
protected Properties getProps(String testName) {
12+
Properties properties = ConsensusCommitJdbcEnv.getProperties(testName);
13+
14+
// Set the isolation level for consistency reads
15+
RdbEngineStrategy rdbEngine =
16+
RdbEngineFactory.create(new JdbcConfig(new DatabaseConfig(properties)));
17+
properties.setProperty(
18+
JdbcConfig.ISOLATION_LEVEL,
19+
JdbcTestUtils.getIsolationLevel(rdbEngine.getMinimumIsolationLevelForConsistencyRead())
20+
.name());
21+
22+
return properties;
23+
}
24+
}

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import java.util.Properties;
1212
import java.util.concurrent.TimeUnit;
1313
import org.junit.jupiter.api.AfterAll;
14-
import org.junit.jupiter.api.Test;
1514
import org.junit.jupiter.api.condition.DisabledIf;
1615
import org.slf4j.Logger;
1716
import org.slf4j.LoggerFactory;
@@ -179,19 +178,6 @@ protected void dropNonImportableTable(String namespace, String table) throws Exc
179178
testUtils.dropTable(namespace, table);
180179
}
181180

182-
@Test
183-
@Override
184-
public void importTables_ImportableTablesGiven_ShouldImportProperly() throws Exception {
185-
super.importTables_ImportableTablesGiven_ShouldImportProperly();
186-
}
187-
188-
@Test
189-
@Override
190-
public void importTables_ImportableTablesAndNonRelatedSameNameTableGiven_ShouldImportProperly()
191-
throws Exception {
192-
super.importTables_ImportableTablesAndNonRelatedSameNameTableGiven_ShouldImportProperly();
193-
}
194-
195181
@AfterAll
196182
@Override
197183
public void afterAll() {

0 commit comments

Comments
 (0)