Skip to content

Commit

Permalink
Backport to branch(3) : Add table importing feature (#967)
Browse files Browse the repository at this point in the history
Co-authored-by: Jun Nemoto <[email protected]>
  • Loading branch information
brfrn169 and jnmt authored Jul 20, 2023
1 parent 8cd260c commit cf55d4a
Show file tree
Hide file tree
Showing 51 changed files with 3,317 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ jobs:
- name: Setup and execute Gradle 'integrationTestJdbc' task
uses: gradle/gradle-build-action@v2
with:
arguments: integrationTestJdbc
arguments: integrationTestJdbc -Dscalardb.jdbc.mariadb=true

- name: Upload Gradle test reports
if: always()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.scalar.db.storage.jdbc;

import com.scalar.db.api.TableMetadata;
import com.scalar.db.transaction.consensuscommit.ConsensusCommitAdminImportTableIntegrationTestBase;
import java.sql.SQLException;
import java.util.Map;
import java.util.Properties;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.junit.jupiter.api.condition.EnabledIf;

public class ConsensusCommitAdminImportTableIntegrationTestWithJdbcDatabase
extends ConsensusCommitAdminImportTableIntegrationTestBase {

private JdbcAdminImportTestUtils testUtils;

@Override
protected Properties getProps(String testName) {
Properties properties = JdbcEnv.getProperties(testName);
testUtils = new JdbcAdminImportTestUtils(properties);
return JdbcEnv.getProperties(testName);
}

@Override
protected Map<String, TableMetadata> createExistingDatabaseWithAllDataTypes()
throws SQLException {
return testUtils.createExistingDatabaseWithAllDataTypes(getNamespace());
}

@Override
protected void dropNonImportableTable(String table) throws SQLException {
testUtils.dropTable(getNamespace(), table);
}

@SuppressWarnings("unused")
private boolean isSqlite() {
return JdbcEnv.isSqlite();
}

@Test
@Override
@DisabledIf("isSqlite")
public void importTable_ShouldWorkProperly() throws Exception {
super.importTable_ShouldWorkProperly();
}

@Test
@Override
@EnabledIf("isSqlite")
public void importTable_ForUnsupportedDatabase_ShouldThrowUnsupportedOperationException() {
super.importTable_ForUnsupportedDatabase_ShouldThrowUnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.scalar.db.storage.jdbc;

import com.scalar.db.api.DistributedStorageAdminImportTableIntegrationTestBase;
import com.scalar.db.api.TableMetadata;
import java.sql.SQLException;
import java.util.Map;
import java.util.Properties;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.junit.jupiter.api.condition.EnabledIf;

public class JdbcAdminImportTableIntegrationTest
extends DistributedStorageAdminImportTableIntegrationTestBase {

private JdbcAdminImportTestUtils testUtils;

@Override
protected Properties getProperties(String testName) {
Properties properties = JdbcEnv.getProperties(testName);
testUtils = new JdbcAdminImportTestUtils(properties);
return JdbcEnv.getProperties(testName);
}

@Override
protected Map<String, TableMetadata> createExistingDatabaseWithAllDataTypes()
throws SQLException {
return testUtils.createExistingDatabaseWithAllDataTypes(getNamespace());
}

@Override
protected void dropNonImportableTable(String table) throws SQLException {
testUtils.dropTable(getNamespace(), table);
}

@SuppressWarnings("unused")
private boolean isSqlite() {
return JdbcEnv.isSqlite();
}

@Test
@Override
@DisabledIf("isSqlite")
public void importTable_ShouldWorkProperly() throws Exception {
super.importTable_ShouldWorkProperly();
}

@Test
@Override
@EnabledIf("isSqlite")
public void importTable_ForUnsupportedDatabase_ShouldThrowUnsupportedOperationException() {
super.importTable_ForUnsupportedDatabase_ShouldThrowUnsupportedOperationException();
}
}
Loading

0 comments on commit cf55d4a

Please sign in to comment.