Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
222 changes: 222 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,228 @@ jobs:
name: alloydb_16_integration_test_reports_${{ matrix.mode.label }}
path: core/build/reports/tests/integrationTestJdbc

integration-test-for-tidb-6-5:
name: TiDB 6.5 integration test (${{ matrix.mode.label }})
runs-on: ubuntu-latest

strategy:
matrix:
mode:
- label: default
group_commit_enabled: false
- label: with_group_commit
group_commit_enabled: true

steps:
- name: Install TiUP
run: |
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
echo "$HOME/.tiup/bin" >> $GITHUB_PATH

- name: Start TiDB with TiUP Playground
timeout-minutes: 3
run: |
tiup playground v6.5 --db 1 --pd 1 --kv 1 --tiflash 0 --without-monitor > tiup.log 2>&1 &
# Check if TiDB is running
while true; do
if mysql -h 127.0.0.1 -P 4000 -u root -e "SELECT 1" > /dev/null 2>&1; then
echo "TiDB is ready"
break
fi
echo "Waiting for TiDB to be ready..."
sleep 5
done

- uses: actions/checkout@v5

- name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }})
uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_VENDOR }}

- name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test
uses: actions/setup-java@v5
if: ${{ env.SET_UP_INT_TEST_RUNTIME_NON_ORACLE_JDK == 'true'}}
with:
java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }}
distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}

- name: Login to Oracle container registry
uses: docker/login-action@v3
if: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR == 'oracle' }}
with:
registry: container-registry.oracle.com
username: ${{ secrets.OCR_USERNAME }}
password: ${{ secrets.OCR_TOKEN }}

- name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (oracle) to run the integration test
if: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR == 'oracle' }}
run: |
container_id=$(docker create "container-registry.oracle.com/java/jdk:${{ env.INT_TEST_JAVA_RUNTIME_VERSION }}")
docker cp -L "$container_id:/usr/java/default" /usr/lib/jvm/oracle-jdk && docker rm "$container_id"

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5

- name: Execute Gradle 'integrationTestJdbc' task
run: ./gradlew integrationTestJdbc -Dscalardb.jdbc.url=jdbc:mysql://localhost:4000 -Dscalardb.jdbc.username=root -Dscalardb.jdbc.password= -Dscalardb.jdbc.isolation_level=REPEATABLE_READ ${{ matrix.mode.group_commit_enabled && env.INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT || '' }}

- name: Upload Gradle test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: tidb_6_5_integration_test_reports_${{ matrix.mode.label }}
path: core/build/reports/tests/integrationTestJdbc

integration-test-for-tidb-v7-5:
name: TiDB 7.5 integration test (${{ matrix.mode.label }})
runs-on: ubuntu-latest

strategy:
matrix:
mode:
- label: default
group_commit_enabled: false
- label: with_group_commit
group_commit_enabled: true

steps:
- name: Install TiUP
run: |
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
echo "$HOME/.tiup/bin" >> $GITHUB_PATH

- name: Start TiDB with TiUP Playground
timeout-minutes: 3
run: |
tiup playground v7.5 --db 1 --pd 1 --kv 1 --tiflash 0 --without-monitor > tiup.log 2>&1 &
# Check if TiDB is running
while true; do
if mysql -h 127.0.0.1 -P 4000 -u root -e "SELECT 1" > /dev/null 2>&1; then
echo "TiDB is ready"
break
fi
echo "Waiting for TiDB to be ready..."
sleep 5
done

- uses: actions/checkout@v5

- name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }})
uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_VENDOR }}

- name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test
uses: actions/setup-java@v5
if: ${{ env.SET_UP_INT_TEST_RUNTIME_NON_ORACLE_JDK == 'true'}}
with:
java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }}
distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}

- name: Login to Oracle container registry
uses: docker/login-action@v3
if: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR == 'oracle' }}
with:
registry: container-registry.oracle.com
username: ${{ secrets.OCR_USERNAME }}
password: ${{ secrets.OCR_TOKEN }}

- name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (oracle) to run the integration test
if: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR == 'oracle' }}
run: |
container_id=$(docker create "container-registry.oracle.com/java/jdk:${{ env.INT_TEST_JAVA_RUNTIME_VERSION }}")
docker cp -L "$container_id:/usr/java/default" /usr/lib/jvm/oracle-jdk && docker rm "$container_id"

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5

- name: Execute Gradle 'integrationTestJdbc' task
run: ./gradlew integrationTestJdbc -Dscalardb.jdbc.url=jdbc:mysql://localhost:4000 -Dscalardb.jdbc.username=root -Dscalardb.jdbc.password= -Dscalardb.jdbc.isolation_level=REPEATABLE_READ ${{ matrix.mode.group_commit_enabled && env.INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT || '' }}

- name: Upload Gradle test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: tidb_7_5_integration_test_reports_${{ matrix.mode.label }}
path: core/build/reports/tests/integrationTestJdbc

integration-test-for-tidb-v8-5:
name: TiDB 8.5 integration test (${{ matrix.mode.label }})
runs-on: ubuntu-latest

strategy:
matrix:
mode:
- label: default
group_commit_enabled: false
- label: with_group_commit
group_commit_enabled: true

steps:
- name: Install TiUP
run: |
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
echo "$HOME/.tiup/bin" >> $GITHUB_PATH

- name: Start TiDB with TiUP Playground
timeout-minutes: 3
run: |
tiup playground v8.5 --db 1 --pd 1 --kv 1 --tiflash 0 --without-monitor > tiup.log 2>&1 &
# Check if TiDB is running
while true; do
if mysql -h 127.0.0.1 -P 4000 -u root -e "SELECT 1" > /dev/null 2>&1; then
echo "TiDB is ready"
break
fi
echo "Waiting for TiDB to be ready..."
sleep 5
done

- uses: actions/checkout@v5

- name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }})
uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_VENDOR }}

- name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test
uses: actions/setup-java@v5
if: ${{ env.SET_UP_INT_TEST_RUNTIME_NON_ORACLE_JDK == 'true'}}
with:
java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }}
distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}

- name: Login to Oracle container registry
uses: docker/login-action@v3
if: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR == 'oracle' }}
with:
registry: container-registry.oracle.com
username: ${{ secrets.OCR_USERNAME }}
password: ${{ secrets.OCR_TOKEN }}

- name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (oracle) to run the integration test
if: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR == 'oracle' }}
run: |
container_id=$(docker create "container-registry.oracle.com/java/jdk:${{ env.INT_TEST_JAVA_RUNTIME_VERSION }}")
docker cp -L "$container_id:/usr/java/default" /usr/lib/jvm/oracle-jdk && docker rm "$container_id"

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5

- name: Execute Gradle 'integrationTestJdbc' task
run: ./gradlew integrationTestJdbc -Dscalardb.jdbc.url=jdbc:mysql://localhost:4000 -Dscalardb.jdbc.username=root -Dscalardb.jdbc.password= -Dscalardb.jdbc.isolation_level=REPEATABLE_READ ${{ matrix.mode.group_commit_enabled && env.INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT || '' }}

- name: Upload Gradle test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: tidb_8_5_integration_test_reports_${{ matrix.mode.label }}
path: core/build/reports/tests/integrationTestJdbc

integration-test-for-multi-storage:
name: Multi-storage integration test (${{ matrix.mode.label }})
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,13 @@ private List<TestData> createExistingMysqlDatabaseWithAllDataTypes(String namesp
UNSUPPORTED_DATA_TYPES_MYSQL.stream()
.filter(type -> !type.equalsIgnoreCase("JSON"))
.collect(Collectors.toList())));
} else if (isTiDB()) {
data.addAll(
prepareCreateNonImportableTableSql(
namespace,
UNSUPPORTED_DATA_TYPES_MYSQL.stream()
.filter(type -> !type.equalsIgnoreCase("GEOMETRY"))
.collect(Collectors.toList())));
} else {
data.addAll(prepareCreateNonImportableTableSql(namespace, UNSUPPORTED_DATA_TYPES_MYSQL));
}
Expand Down Expand Up @@ -759,7 +766,16 @@ private boolean isMariaDB() {
String version = connection.getMetaData().getDatabaseProductVersion();
return version.contains("MariaDB");
} catch (SQLException e) {
throw new RuntimeException("Get database product version failed");
throw new RuntimeException("Get database product version failed", e);
}
}

private boolean isTiDB() {
try (Connection connection = dataSource.getConnection()) {
String version = connection.getMetaData().getDatabaseProductVersion();
return version.contains("TiDB");
} catch (SQLException e) {
throw new RuntimeException("Get database product version failed", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import com.scalar.db.config.DatabaseConfig;
import java.util.Properties;
import org.assertj.core.util.Strings;

public final class JdbcEnv {
private static final String PROP_JDBC_URL = "scalardb.jdbc.url";
private static final String PROP_JDBC_USERNAME = "scalardb.jdbc.username";
private static final String PROP_JDBC_PASSWORD = "scalardb.jdbc.password";
private static final String PROP_JDBC_NORMAL_USERNAME = "scalardb.jdbc.normal_username";
private static final String PROP_JDBC_NORMAL_PASSWORD = "scalardb.jdbc.normal_password";
private static final String PROP_JDBC_ISOLATION_LEVEL = "scalardb.jdbc.isolation_level";

private static final String DEFAULT_JDBC_URL = "jdbc:postgresql://localhost:5432/";
private static final String DEFAULT_JDBC_USERNAME = "postgres";
Expand All @@ -22,6 +24,7 @@ public static Properties getProperties(String testName) {
String jdbcUrl = System.getProperty(PROP_JDBC_URL, DEFAULT_JDBC_URL);
String username = System.getProperty(PROP_JDBC_USERNAME, DEFAULT_JDBC_USERNAME);
String password = System.getProperty(PROP_JDBC_PASSWORD, DEFAULT_JDBC_PASSWORD);
String isolationLevel = System.getProperty(PROP_JDBC_ISOLATION_LEVEL);

Properties properties = new Properties();
properties.setProperty(DatabaseConfig.CONTACT_POINTS, jdbcUrl);
Expand All @@ -31,6 +34,9 @@ public static Properties getProperties(String testName) {
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN, "true");
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_FILTERING, "true");
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_ORDERING, "true");
if (!Strings.isNullOrEmpty(isolationLevel)) {
properties.setProperty(JdbcConfig.ISOLATION_LEVEL, isolationLevel);
}

// Add testName as a metadata schema suffix
properties.setProperty(
Expand Down