From ae308902851281c95e83834c6cbebc1325c4dd0f Mon Sep 17 00:00:00 2001 From: Jasmine-ge Date: Mon, 18 Nov 2024 10:15:57 +0000 Subject: [PATCH] change testcontainer (#63) * change testcontainer and revise code * add ci test --- .github/workflows/benchmark.yml | 74 ------------------- .github/workflows/build.yml | 30 -------- .github/workflows/gh-pages.yml | 22 ------ .github/workflows/integration-test-legacy.yml | 32 -------- .github/workflows/integration-test.yml | 38 ---------- .github/workflows/native_jdbc_ci.yml | 36 +++++++++ CONTRIBUTE.md | 8 +- examples/pom.xml | 13 +--- pom.xml | 31 +------- timeplus-native-jdbc/pom.xml | 13 +--- .../buffer/CompressedBuffedWriter.java | 4 +- .../com/timeplus/client/NativeClient.java | 2 +- .../data/type/complex/DataTypeArray.java | 2 +- .../data/type/complex/DataTypeDecimal.java | 1 - .../jdbc/BalancedTimeplusDataSource.java | 24 +++--- .../com/timeplus/jdbc/TimeplusConnection.java | 4 +- .../jdbc/TimeplusDatabaseMetadata.java | 2 +- .../com/timeplus/jdbc/TimeplusDriver.java | 4 +- .../timeplus/jdbc/TimeplusJdbcUrlParser.java | 6 +- ...useCityHash.java => TimeplusCityHash.java} | 9 +-- .../com/timeplus/settings/SettingKey.java | 4 +- .../com/timeplus/settings/TimeplusConfig.java | 2 +- .../java/com/timeplus/jdbc/AbstractITest.java | 19 +++-- .../jdbc/BalancedTimeplusDataSourceITest.java | 12 +-- .../timeplus/jdbc/ConnectionParamITest.java | 24 +++--- ...a => FailoverTimeplusConnectionITest.java} | 28 +++---- .../jdbc/TimeplusConnectionITest.java | 54 +++++++------- .../jdbc/TimeplusDatabaseMetadataITest.java | 2 +- ...st.java => TimeplusSQLExceptionITest.java} | 2 +- .../jdbc/benchmark/AbstractIBenchmark.java | 7 +- .../timeplus/settings/TimeplusConfigTest.java | 4 +- 31 files changed, 146 insertions(+), 367 deletions(-) delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/gh-pages.yml delete mode 100644 .github/workflows/integration-test-legacy.yml delete mode 100644 .github/workflows/integration-test.yml create mode 100644 .github/workflows/native_jdbc_ci.yml rename timeplus-native-jdbc/src/main/java/com/timeplus/misc/{ClickHouseCityHash.java => TimeplusCityHash.java} (96%) rename timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/{FailoverClickhouseConnectionITest.java => FailoverTimeplusConnectionITest.java} (85%) rename timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/{ClickHouseSQLExceptionITest.java => TimeplusSQLExceptionITest.java} (94%) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 613a6b33..00000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: benchmark - -on: - push: - branches: - - "master" - pull_request: - branches: - - "master" - -jobs: - build: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - name: Set up JDK - uses: actions/setup-java@v1 - with: - java-version: 8 - - run: sed -i 's/TRACE/INFO/g' clickhouse-native-jdbc/src/test/resources/simplelogger.properties - - run: sed -i 's/DEBUG/INFO/g' clickhouse-native-jdbc/src/test/resources/simplelogger.properties - - - name: Install libasyncProfiler (remove this once async-profiler available on maven-central) - run: | - wget -O /tmp/async-profiler-1.8.3-linux-x64.tar.gz \ - https://github.com/jvm-profiling-tools/async-profiler/releases/download/v1.8.3/async-profiler-1.8.3-linux-x64.tar.gz - tar -C /tmp -xzf /tmp/async-profiler-1.8.3-linux-x64.tar.gz - - - name: Run benchmarks - env: - NETTY_RESOURCE_LEAK_DETECT_LEVEL: DISABLED - run: | - mvn -B -Pbenchmark clean integration-test -DskipITs -pl :clickhouse-native-jdbc -am | tee output.log - echo "BENCHMARK_REPORT<> $GITHUB_ENV - echo "`cat output.log | grep -E '^Benchmark\s.*\sUnits$' -A 300 | grep -E '.*\s(Units|ms/op)$'`" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - - run: tar -czf benchmark-reports.tgz -C clickhouse-native-jdbc reports - - name: Upload reports - uses: actions/upload-artifact@v2 - with: - name: benchmark-reports - path: benchmark-reports.tgz - retention-days: 30 - - - name: Comment PR - if: github.event_name == 'pull_request' - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const issue_number = context.issue.number; - const owner = context.repo.owner; - const repo = context.repo.repo; - const contentWithLineNumbers = `${process.env.BENCHMARK_REPORT}` - .split('\n') - .map((line, idx) => `${idx + 1}. ${line}`) - .join('\n'); - - const body = ` -
- BENCHMARK_REPORT -
-                ${contentWithLineNumbers}
-              
-
- `; - - github.rest.issues.createComment({ - issue_number, - owner, - repo, - body - }); \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index dd80c881..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: build - -on: - push: - branches: - - "master" - - "2.4" - - "2.5" - - "2.6" - pull_request: - branches: - - "master" - - "2.4" - - "2.5" - - "2.6" - -jobs: - build: - runs-on: ubuntu-20.04 - strategy: - matrix: - java: [ 8, 11 ] - steps: - - uses: actions/checkout@v2 - - name: Set up JDK - uses: actions/setup-java@v1 - with: - java-version: ${{ matrix.java }} - - name: Build with Maven - run: mvn -B clean package -Pscala-2.12 -Pspark-3.1 diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml deleted file mode 100644 index e415f553..00000000 --- a/.github/workflows/gh-pages.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: gh-pages - -on: - push: - branches: - - "master" - paths: - - "docs/**" - -jobs: - build: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - run: 'npm install' - - run: 'npm run docs:build' - - run: 'dev/deploy_gh_pages.sh' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/integration-test-legacy.yml b/.github/workflows/integration-test-legacy.yml deleted file mode 100644 index 44ca4765..00000000 --- a/.github/workflows/integration-test-legacy.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: integration-test-legacy - -on: - push: - branches: - - "2.4" - - "2.5" - pull_request: - branches: - - "2.4" - - "2.5" - -jobs: - build: - runs-on: ubuntu-20.04 - strategy: - matrix: - java: [ 8, 11 ] - steps: - - uses: actions/checkout@v2 - - name: Set up JDK - uses: actions/setup-java@v1 - with: - java-version: ${{ matrix.java }} - - name: Start clickhouse-server - run: docker-compose up -d - - name: Run integration tests with Scala 2.11 & Spark 2.4.7 - run: mvn -B clean verify - - name: upload code coverage report - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - run: bash <(curl -s https://codecov.io/bash) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml deleted file mode 100644 index 9323596c..00000000 --- a/.github/workflows/integration-test.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: integration-test - -on: - push: - branches: - - "master" - pull_request: - branches: - - "master" - -jobs: - build: - runs-on: ubuntu-20.04 - strategy: - matrix: - java: [ '8', '11' ] - scala: [ '2.11', '2.12' ] - spark: [ '2.4', '3.0', '3.1' ] - exclude: - - java: '11' - spark: '2.4' - - scala: '2.11' - spark: '3.0' - - scala: '2.11' - spark: '3.1' - steps: - - uses: actions/checkout@v2 - - name: Set up JDK - uses: actions/setup-java@v1 - with: - java-version: ${{ matrix.java }} - - name: Run integration tests with Scala ${{ matrix.scala }} & Spark ${{ matrix.spark }} - run: mvn -B clean verify -Pscala-${{ matrix.scala }} -Pspark-${{ matrix.spark }} - - name: upload code coverage report - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - if: matrix.java == '8' && matrix.scala == '2.12' && matrix.spark == '3.1' - run: bash <(curl -s https://codecov.io/bash) diff --git a/.github/workflows/native_jdbc_ci.yml b/.github/workflows/native_jdbc_ci.yml new file mode 100644 index 00000000..3d5ecc7f --- /dev/null +++ b/.github/workflows/native_jdbc_ci.yml @@ -0,0 +1,36 @@ +name: CI Pipeline + +on: + pull_request: + types: + - synchronize + - reopened + - opened + - ready_for_review + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + java-version: [8, 11] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: ${{ matrix.java-version }} + + - name: Find Maven dependencies + run: mvn dependency:resolve + + - name: Build with Maven + run: mvn clean install diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md index c0fd9cc6..5b52d506 100644 --- a/CONTRIBUTE.md +++ b/CONTRIBUTE.md @@ -70,9 +70,7 @@ To build the source code locally, checkout and update the `master` branch: Then use Maven to compile everything, build all artifacts, and install all JAR, ZIP, and TAR files into your local Maven repository: - mvn clean install -DskipITs -DskipTests - -(Currently the unit tests and integration tests are not fixed, so we have to skip them) + mvn clean install ### Running and debugging tests (Not working at this point) @@ -92,7 +90,7 @@ To fix pull requests with code style violations, simply run the project's build To run the build, navigate to the project's root directory and run: - mvn clean verify -DskipITs -DskipTests + mvn clean verify -DskipITs It might be useful to simply run a _validate_ check against the code instead of automatically applying code style changes. If you want to simply run validation, navigate to the project's root directory and run: @@ -122,7 +120,7 @@ export GPG_TTY=$(tty) Then run the following commmands: ```bash -mvn clean javadoc:jar source:jar package gpg:sign install deploy -DskipITs -DskipTests -Drevision=2.0.2 -e +mvn clean javadoc:jar source:jar package gpg:sign install deploy -DskipITs Drevision=2.0.2 -e ``` This will geneate target/central-staging folder with required jar/asc/md5/sha1 files. diff --git a/examples/pom.xml b/examples/pom.xml index a65b9d03..33b3ca8b 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -44,12 +44,6 @@ test-jar test - - com.clickhouse - clickhouse-jdbc - all - test - com.zaxxer HikariCP @@ -76,15 +70,10 @@ test - org.testcontainers - clickhouse - test - - + diff --git a/pom.xml b/pom.xml index 5e880972..0da0eb32 100644 --- a/pom.xml +++ b/pom.xml @@ -127,7 +127,6 @@ 0.21 3.0.2 1.27 - 0.3.1-patch 3.6.28 16.0.1 2.10.3 @@ -139,7 +138,7 @@ 1.2.4 2.8.0 5.7.0 - 1.19.0 + 1.20.3 /tmp/async-profiler-1.8.3-linux-x64/build @@ -201,27 +200,6 @@ jmh-generator-annprocess ${jmh.version} - - com.clickhouse - clickhouse-jdbc - 0.4.6 - - all - - - com.fasterxml.jackson.core - * - - - com.google.guava - * - - - org.apache.httpcomponents - * - - - org.scala-lang scala-compiler @@ -293,15 +271,10 @@ ${testcontainers.version} - org.testcontainers - clickhouse - ${testcontainers.version} - - + com.fasterxml.jackson.core jackson-annotations diff --git a/timeplus-native-jdbc/pom.xml b/timeplus-native-jdbc/pom.xml index 4f33c13a..9b3847c8 100644 --- a/timeplus-native-jdbc/pom.xml +++ b/timeplus-native-jdbc/pom.xml @@ -62,12 +62,6 @@ jmh-generator-annprocess test - - com.clickhouse - clickhouse-jdbc - all - test - org.mockito mockito-core @@ -94,16 +88,11 @@ test - org.testcontainers - clickhouse - test - - + diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/buffer/CompressedBuffedWriter.java b/timeplus-native-jdbc/src/main/java/com/timeplus/buffer/CompressedBuffedWriter.java index ddd6f1e6..6b153ddb 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/buffer/CompressedBuffedWriter.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/buffer/CompressedBuffedWriter.java @@ -15,7 +15,7 @@ package com.timeplus.buffer; import com.timeplus.misc.BytesHelper; -import com.timeplus.misc.ClickHouseCityHash; +import com.timeplus.misc.TimeplusCityHash; import io.airlift.compress.Compressor; import io.airlift.compress.lz4.Lz4Compressor; import io.airlift.compress.zstd.ZstdCompressor; @@ -78,7 +78,7 @@ public void flushToTarget(boolean force) throws IOException { System.arraycopy(getBytesLE(compressedSize), 0, compressedBuffer, CHECKSUM_LENGTH + 1, Integer.BYTES); System.arraycopy(getBytesLE(position), 0, compressedBuffer, CHECKSUM_LENGTH + Integer.BYTES + 1, Integer.BYTES); - long[] checksum = ClickHouseCityHash.cityHash128(compressedBuffer, CHECKSUM_LENGTH, compressedSize); + long[] checksum = TimeplusCityHash.cityHash128(compressedBuffer, CHECKSUM_LENGTH, compressedSize); System.arraycopy(getBytesLE(checksum[0]), 0, compressedBuffer, 0, Long.BYTES); System.arraycopy(getBytesLE(checksum[1]), 0, compressedBuffer, Long.BYTES, Long.BYTES); diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/client/NativeClient.java b/timeplus-native-jdbc/src/main/java/com/timeplus/client/NativeClient.java index ddf04f44..1da6e581 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/client/NativeClient.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/client/NativeClient.java @@ -43,7 +43,7 @@ import java.util.Map; import java.util.UUID; -// TODO throw ClickHouseException instead of SQLException +// TODO throw TimeplusException instead of SQLException public class NativeClient { private static final Logger LOG = LoggerFactory.getLogger(NativeClient.class); diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeArray.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeArray.java index 22fe82e6..4d8322c0 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeArray.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeArray.java @@ -31,7 +31,7 @@ import java.util.Arrays; import java.util.List; -// TODO avoid using ClickHouseArray because it's a subclass of java.sql.Array +// TODO avoid using TimeplusArray because it's a subclass of java.sql.Array public class DataTypeArray implements IDataType { public static DataTypeCreator creator = (lexer, serverContext) -> { diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeDecimal.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeDecimal.java index 5bd8646a..43cc3f68 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeDecimal.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeDecimal.java @@ -47,7 +47,6 @@ public class DataTypeDecimal implements IDataType, Bytes private final BigDecimal scaleFactor; private final int nobits; - // see https://clickhouse.tech/docs/en/sql-reference/data-types/decimal/ public DataTypeDecimal(String name, int precision, int scale) { this.name = name; this.precision = precision; diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/BalancedTimeplusDataSource.java b/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/BalancedTimeplusDataSource.java index 58d0a34f..7b0f9eb4 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/BalancedTimeplusDataSource.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/BalancedTimeplusDataSource.java @@ -42,7 +42,7 @@ import javax.sql.DataSource; /** - *

Database for clickhouse jdbc connections. + *

Database for timeplus jdbc connections. *

It has list of database urls. * For every {@link #getConnection() getConnection} invocation, it returns connection to random host from the list. * Furthermore, this class has method { #scheduleActualization(int, TimeUnit) scheduleActualization} @@ -51,7 +51,7 @@ public final class BalancedTimeplusDataSource implements DataSource, SQLWrapper { private static final Logger LOG = LoggerFactory.getLogger(BalancedTimeplusDataSource.class); - private static final Pattern URL_TEMPLATE = Pattern.compile(TimeplusJdbcUrlParser.JDBC_CLICKHOUSE_PREFIX + + private static final Pattern URL_TEMPLATE = Pattern.compile(TimeplusJdbcUrlParser.JDBC_TIMEPLUS_PREFIX + "//([a-zA-Z0-9_:,.-]+)" + "((/[a-zA-Z0-9_]+)?" + "([?][a-zA-Z0-9_]+[=][a-zA-Z0-9_]+([&][a-zA-Z0-9_]+[=][a-zA-Z0-9_]*)*)?" + @@ -68,7 +68,7 @@ public final class BalancedTimeplusDataSource implements DataSource, SQLWrapper private final TimeplusDriver driver = new TimeplusDriver(); /** - * create Datasource for clickhouse JDBC connections + * create Datasource for timeplus JDBC connections * * @param url address for connection to the database, must have the next format * {@code jdbc:timeplus://:,:/?param1=value1¶m2=value2 } @@ -81,7 +81,7 @@ public BalancedTimeplusDataSource(String url) { } /** - * create Datasource for clickhouse JDBC connections + * create Datasource for timeplus JDBC connections * * @param url address for connection to the database * @param properties database properties @@ -92,10 +92,10 @@ public BalancedTimeplusDataSource(String url, Properties properties) { } /** - * create Datasource for clickhouse JDBC connections + * create Datasource for timeplus JDBC connections * * @param url address for connection to the database - * @param settings clickhouse settings + * @param settings timeplus settings * @see #BalancedTimeplusDataSource(String) */ public BalancedTimeplusDataSource(final String url, Map settings) { @@ -107,7 +107,7 @@ private BalancedTimeplusDataSource(final List urls, Properties propertie } private BalancedTimeplusDataSource(final List urls, Map settings) { - Validate.ensure(!urls.isEmpty(), "Incorrect ClickHouse jdbc url list. It must be not empty"); + Validate.ensure(!urls.isEmpty(), "Incorrect timeplus jdbc url list. It must be not empty"); this.cfg = TimeplusConfig.Builder.builder() .withJdbcUrl(urls.get(0)) @@ -141,7 +141,7 @@ static List splitUrl(final String url) { final String database = StrUtil.getOrDefault(m.group(2), ""); String[] hosts = m.group(1).split(","); return Arrays.stream(hosts) - .map(host -> TimeplusJdbcUrlParser.JDBC_CLICKHOUSE_PREFIX + "//" + host + database) + .map(host -> TimeplusJdbcUrlParser.JDBC_TIMEPLUS_PREFIX + "//" + host + database) .collect(Collectors.toList()); } @@ -154,9 +154,9 @@ private boolean ping(final String url) { } /** - * Checks if clickhouse on url is alive, if it isn't, disable url, else enable. + * Checks if timeplus on url is alive, if it isn't, disable url, else enable. * - * @return number of available clickhouse urls + * @return number of available timeplus urls */ synchronized int actualize() { List enabledUrls = new ArrayList<>(allUrls.size()); @@ -247,11 +247,11 @@ public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedE throw new SQLFeatureNotSupportedException(); } - public List getAllClickhouseUrls() { + public List getAllTimeplusUrls() { return allUrls; } - public List getEnabledClickHouseUrls() { + public List getEnabledTimeplusUrls() { return enabledUrls; } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusConnection.java b/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusConnection.java index adf81bd4..13462240 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusConnection.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusConnection.java @@ -213,7 +213,7 @@ public boolean isValid(int timeout) throws SQLException { return getNativeClient().ping(Duration.ofSeconds(timeout), nativeCtx.serverCtx()); } - // ClickHouse support only `database`, we treat it as JDBC `schema` + // Timeplus support only `database`, we treat it as JDBC `schema` @Override public void setSchema(String schema) throws SQLException { this.cfg.set(this.cfg().withDatabase(schema)); @@ -314,7 +314,7 @@ private NativeClient getNativeClient() { return nativeCtx.nativeClient(); } - public static TimeplusConnection createClickHouseConnection(TimeplusConfig configure) throws SQLException { + public static TimeplusConnection createTimeplusConnection(TimeplusConfig configure) throws SQLException { return new TimeplusConnection(configure, createNativeContext(configure)); } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusDatabaseMetadata.java b/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusDatabaseMetadata.java index c0fed9b1..0f5fa4c0 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusDatabaseMetadata.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusDatabaseMetadata.java @@ -87,7 +87,7 @@ public boolean nullsAreSortedAtEnd() throws SQLException { @Override public String getDatabaseProductName() throws SQLException { - return "ClickHouse"; + return "Timeplus"; } @Override diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusDriver.java b/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusDriver.java index 18b3b378..ec9fc0c3 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusDriver.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusDriver.java @@ -35,7 +35,7 @@ public class TimeplusDriver implements Driver { @Override public boolean acceptsURL(String url) throws SQLException { - return url.startsWith(TimeplusJdbcUrlParser.JDBC_CLICKHOUSE_PREFIX); + return url.startsWith(TimeplusJdbcUrlParser.JDBC_TIMEPLUS_PREFIX); } @Override @@ -55,7 +55,7 @@ TimeplusConnection connect(String url, TimeplusConfig cfg) throws SQLException { if (!this.acceptsURL(url)) { return null; } - return TimeplusConnection.createClickHouseConnection(cfg.withJdbcUrl(url)); + return TimeplusConnection.createTimeplusConnection(cfg.withJdbcUrl(url)); } @Override diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusJdbcUrlParser.java b/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusJdbcUrlParser.java index a1436b0e..c36aacbc 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusJdbcUrlParser.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/jdbc/TimeplusJdbcUrlParser.java @@ -32,7 +32,7 @@ public class TimeplusJdbcUrlParser { public static final String JDBC_PREFIX = "jdbc:"; public static final String TIMEPLUS_PREFIX = "timeplus:"; - public static final String JDBC_CLICKHOUSE_PREFIX = JDBC_PREFIX + TIMEPLUS_PREFIX; + public static final String JDBC_TIMEPLUS_PREFIX = JDBC_PREFIX + TIMEPLUS_PREFIX; public static final String HOST_DELIMITER = ","; public static final String PORT_DELIMITER = ":"; @@ -47,7 +47,7 @@ public class TimeplusJdbcUrlParser { private static final Logger LOG = LoggerFactory.getLogger(TimeplusJdbcUrlParser.class); public static Map parseJdbcUrl(String jdbcUrl) { - String uri = jdbcUrl.substring(JDBC_CLICKHOUSE_PREFIX.length()); + String uri = jdbcUrl.substring(JDBC_TIMEPLUS_PREFIX.length()); Matcher matcher = CONNECTION_PATTERN.matcher(uri); if (!matcher.matches()) { throw new InvalidValueException("Connection is not support"); @@ -99,7 +99,7 @@ public static Map extractQueryParameters(String queryP while (tokenizer.hasMoreTokens()) { String[] queryParameter = tokenizer.nextToken().split("=", 2); Validate.ensure(queryParameter.length == 2, - "ClickHouse JDBC URL Parameter '" + queryParameters + "' Error, Expected '='."); + "Timeplus JDBC URL Parameter '" + queryParameters + "' Error, Expected '='."); String name = queryParameter[0]; String value = queryParameter[1]; diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/misc/ClickHouseCityHash.java b/timeplus-native-jdbc/src/main/java/com/timeplus/misc/TimeplusCityHash.java similarity index 96% rename from timeplus-native-jdbc/src/main/java/com/timeplus/misc/ClickHouseCityHash.java rename to timeplus-native-jdbc/src/main/java/com/timeplus/misc/TimeplusCityHash.java index 59e520bd..46e2f852 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/misc/ClickHouseCityHash.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/misc/TimeplusCityHash.java @@ -17,14 +17,7 @@ package com.timeplus.misc; -/** - * @author tamtam180 - kirscheless at gmail.com - * @see - * @see - *

- * NOTE: The code is modified to be compatible with CityHash128 used in ClickHouse - */ -public class ClickHouseCityHash { +public class TimeplusCityHash { private static final long k0 = 0xc3a5c85c97cb3127L; private static final long k1 = 0xb492b66fbe98f273L; diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/settings/SettingKey.java b/timeplus-native-jdbc/src/main/java/com/timeplus/settings/SettingKey.java index 346b23f1..271a1edd 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/settings/SettingKey.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/settings/SettingKey.java @@ -488,13 +488,13 @@ public class SettingKey implements Serializable { public static SettingKey send_progress_in_http_headers = SettingKey.builder() .withName("send_progress_in_http_headers") .withType(SettingType.Bool) - .withDescription("Send progress notifications using X-ClickHouse-Progress headers. Some clients do not support high amount of HTTP headers (Python requests in particular), so it is disabled by default.") + .withDescription("Send progress notifications using X-Timeplus-Progress headers. Some clients do not support high amount of HTTP headers (Python requests in particular), so it is disabled by default.") .build(); public static SettingKey http_headers_progress_interval_ms = SettingKey.builder() .withName("http_headers_progress_interval_ms") .withType(SettingType.Int64) - .withDescription("Do not send HTTP headers X-ClickHouse-Progress more frequently than at each specified interval.") + .withDescription("Do not send HTTP headers X-Timeplus-Progress more frequently than at each specified interval.") .build(); public static SettingKey fsync_metadata = SettingKey.builder() diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/settings/TimeplusConfig.java b/timeplus-native-jdbc/src/main/java/com/timeplus/settings/TimeplusConfig.java index 4d5de2e0..ae3cb704 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/settings/TimeplusConfig.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/settings/TimeplusConfig.java @@ -118,7 +118,7 @@ public String clientName() { } public String jdbcUrl() { - StringBuilder builder = new StringBuilder(TimeplusJdbcUrlParser.JDBC_CLICKHOUSE_PREFIX) + StringBuilder builder = new StringBuilder(TimeplusJdbcUrlParser.JDBC_TIMEPLUS_PREFIX) .append("//").append(host); if (hosts.size() == 1) { diff --git a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/AbstractITest.java b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/AbstractITest.java index 86fb65b0..2c83987b 100644 --- a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/AbstractITest.java +++ b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/AbstractITest.java @@ -19,8 +19,7 @@ import org.junit.jupiter.api.BeforeAll; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.clickhouse.*; -// import org.testcontainers.timeplus.TimeplusContainer; +import org.testcontainers.timeplus.TimeplusContainer; import org.testcontainers.utility.MountableFile; import javax.sql.DataSource; @@ -37,11 +36,11 @@ public abstract class AbstractITest implements Serializable { protected static final String DRIVER_CLASS_NAME = "com.timeplus.jdbc.TimeplusDriver"; public static final String TIMEPLUS_IMAGE = System.getProperty("TIMEPLUS_IMAGE", "timeplus/timeplusd:2.3.3"); - // public static DockerImageName proton_image = DockerImageName.parse(CLICKHOUSE_IMAGE).asCompatibleSubstituteFor("clickhouse/clickhouse-server"); + // public static DockerImageName proton_image = DockerImageName.parse(TIMEPLUS_IMAGE).asCompatibleSubstituteFor("timeplus/timeplus-server"); - protected static final String TIMEPLUS_USER = SystemUtil.loadProp("CLICKHOUSE_USER", ""); - protected static final String TIMEPLUS_PASSWORD = SystemUtil.loadProp("CLICKHOUSE_PASSWORD", ""); - protected static final String TIMEPLUS_DB = SystemUtil.loadProp("CLICKHOUSE_DB", ""); + protected static final String TIMEPLUS_USER = SystemUtil.loadProp("TIMEPLUS_USER", ""); + protected static final String TIMEPLUS_PASSWORD = SystemUtil.loadProp("TIMEPLUS_PASSWORD", ""); + protected static final String TIMEPLUS_DB = SystemUtil.loadProp("TIMEPLUS_DB", ""); protected static final int TIMEPLUS_HTTP_PORT = 3218; protected static final int TIMEPLUS_HTTPS_PORT = 3218; @@ -49,10 +48,10 @@ public abstract class AbstractITest implements Serializable { protected static final int TIMEPLUS_NATIVE_SECURE_PORT = 8463; @Container - public static ClickHouseContainer container = new ClickHouseContainer(TIMEPLUS_IMAGE) - .withEnv("CLICKHOUSE_USER", TIMEPLUS_USER) - .withEnv("CLICKHOUSE_PASSWORD", TIMEPLUS_PASSWORD) - .withEnv("CLICKHOUSE_DB", TIMEPLUS_DB) + public static TimeplusContainer container = new TimeplusContainer(TIMEPLUS_IMAGE) + .withEnv("TIMEPLUS_USER", TIMEPLUS_USER) + .withEnv("TIMEPLUS_PASSWORD", TIMEPLUS_PASSWORD) + .withEnv("TIMEPLUS_DB", TIMEPLUS_DB) .withExposedPorts(TIMEPLUS_HTTP_PORT, TIMEPLUS_HTTPS_PORT, TIMEPLUS_NATIVE_PORT, diff --git a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/BalancedTimeplusDataSourceITest.java b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/BalancedTimeplusDataSourceITest.java index 2c6874a3..5646235a 100644 --- a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/BalancedTimeplusDataSourceITest.java +++ b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/BalancedTimeplusDataSourceITest.java @@ -188,11 +188,11 @@ public void testConstructWithProperties() { assertEquals(Duration.ofSeconds(6789), cfg.queryTimeout()); assertEquals("888888", cfg.password()); assertEquals("click", cfg.database()); - assertEquals(2, dataSource.getAllClickhouseUrls().size()); + assertEquals(2, dataSource.getAllTimeplusUrls().size()); assertEquals(String.format(Locale.ROOT, "jdbc:timeplus://%s:%s/click", TP_HOST, TP_PORT), - dataSource.getAllClickhouseUrls().get(0)); + dataSource.getAllTimeplusUrls().get(0)); assertEquals(String.format(Locale.ROOT, "jdbc:timeplus://%s:%s/click", TP_HOST, TP_PORT), - dataSource.getAllClickhouseUrls().get(1)); + dataSource.getAllTimeplusUrls().get(1)); // with connection parameters dataSource = new BalancedTimeplusDataSource( @@ -202,10 +202,10 @@ public void testConstructWithProperties() { assertEquals("readonly", cfg.user()); assertEquals("888888", cfg.password()); assertEquals("click", cfg.database()); - assertEquals(2, dataSource.getAllClickhouseUrls().size()); + assertEquals(2, dataSource.getAllTimeplusUrls().size()); assertEquals(String.format(Locale.ROOT, "jdbc:timeplus://%s:%s/click?query_timeout=12345&user=readonly", TP_HOST, TP_PORT), - dataSource.getAllClickhouseUrls().get(0)); + dataSource.getAllTimeplusUrls().get(0)); assertEquals(String.format(Locale.ROOT, "jdbc:timeplus://%s:%s/click?query_timeout=12345&user=readonly", TP_HOST, TP_PORT), - dataSource.getAllClickhouseUrls().get(1)); + dataSource.getAllTimeplusUrls().get(1)); } } diff --git a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/ConnectionParamITest.java b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/ConnectionParamITest.java index cb2d154c..8a53bb6a 100644 --- a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/ConnectionParamITest.java +++ b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/ConnectionParamITest.java @@ -68,7 +68,7 @@ public void connectionPatternTest() { for (String jdbc : jdbcTrue) { TimeplusConfig cfg = TimeplusConfig.Builder.builder() - .withJdbcUrl(TimeplusJdbcUrlParser.JDBC_CLICKHOUSE_PREFIX + jdbc) + .withJdbcUrl(TimeplusJdbcUrlParser.JDBC_TIMEPLUS_PREFIX + jdbc) .build(); if (jdbc.contains("?")) { @@ -93,7 +93,7 @@ public void connectionPatternTest() { }; for (String jdbc : fullJdbc) { - jdbc = TimeplusJdbcUrlParser.JDBC_CLICKHOUSE_PREFIX + jdbc; + jdbc = TimeplusJdbcUrlParser.JDBC_TIMEPLUS_PREFIX + jdbc; TimeplusConfig cfg = TimeplusConfig.Builder.builder() .withJdbcUrl(jdbc) .build(); @@ -150,9 +150,9 @@ public void successfullyUrlParser() { @Test public void successfullyHostNameOnly() { - String url = "jdbc:timeplus://my_clickhouse_sever_host_name/system?min_insert_block_size_rows=1000&connect_timeout=50"; + String url = "jdbc:timeplus://my_timeplus_sever_host_name/system?min_insert_block_size_rows=1000&connect_timeout=50"; TimeplusConfig config = TimeplusConfig.Builder.builder().withJdbcUrl(url).build(); - assertEquals("my_clickhouse_sever_host_name", config.host()); + assertEquals("my_timeplus_sever_host_name", config.host()); assertEquals(9000, config.port()); assertEquals("system", config.database()); assertEquals(1000L, config.settings().get(SettingKey.min_insert_block_size_rows)); @@ -161,9 +161,9 @@ public void successfullyHostNameOnly() { @Test public void successfullyHostNameWithDefaultPort() { - String url = "jdbc:timeplus://my_clickhouse_sever_host_name:9000/system?min_insert_block_size_rows=1000&connect_timeout=50"; + String url = "jdbc:timeplus://my_timeplus_sever_host_name:9000/system?min_insert_block_size_rows=1000&connect_timeout=50"; TimeplusConfig config = TimeplusConfig.Builder.builder().withJdbcUrl(url).build(); - assertEquals("my_clickhouse_sever_host_name", config.host()); + assertEquals("my_timeplus_sever_host_name", config.host()); assertEquals(9000, config.port()); assertEquals("system", config.database()); assertEquals(1000L, config.settings().get(SettingKey.min_insert_block_size_rows)); @@ -172,9 +172,9 @@ public void successfullyHostNameWithDefaultPort() { @Test public void successfullyHostNameWithCustomPort() { - String url = "jdbc:timeplus://my_clickhouse_sever_host_name:1940/system?min_insert_block_size_rows=1000&connect_timeout=50"; + String url = "jdbc:timeplus://my_timeplus_sever_host_name:1940/system?min_insert_block_size_rows=1000&connect_timeout=50"; TimeplusConfig config = TimeplusConfig.Builder.builder().withJdbcUrl(url).build(); - assertEquals("my_clickhouse_sever_host_name", config.host()); + assertEquals("my_timeplus_sever_host_name", config.host()); assertEquals(1940, config.port()); assertEquals("system", config.database()); assertEquals(1000L, config.settings().get(SettingKey.min_insert_block_size_rows)); @@ -183,9 +183,9 @@ public void successfullyHostNameWithCustomPort() { @Test public void successfullyFailoverHostNameWithCustomPort() { - String url = "jdbc:timeplus://my_clickhouse_sever_host_name1:1940,my_clickhouse_sever_host_name2:1941/system?min_insert_block_size_rows=1000&connect_timeout=50"; + String url = "jdbc:timeplus://my_timeplus_sever_host_name1:1940,my_timeplus_sever_host_name2:1941/system?min_insert_block_size_rows=1000&connect_timeout=50"; TimeplusConfig config = TimeplusConfig.Builder.builder().withJdbcUrl(url).build(); - assertEquals("my_clickhouse_sever_host_name1:1940,my_clickhouse_sever_host_name2:1941", config.host()); + assertEquals("my_timeplus_sever_host_name1:1940,my_timeplus_sever_host_name2:1941", config.host()); assertEquals(2, config.hosts().size()); assertEquals(9000, config.port()); assertEquals("system", config.database()); @@ -195,9 +195,9 @@ public void successfullyFailoverHostNameWithCustomPort() { @Test public void successfullyFailoverHostNameWithDefaultPort() { - String url = "jdbc:timeplus://my_clickhouse_sever_host_name1,my_clickhouse_sever_host_name2/system?min_insert_block_size_rows=1000&connect_timeout=50"; + String url = "jdbc:timeplus://my_timeplus_sever_host_name1,my_timeplus_sever_host_name2/system?min_insert_block_size_rows=1000&connect_timeout=50"; TimeplusConfig config = TimeplusConfig.Builder.builder().withJdbcUrl(url).build(); - assertEquals("my_clickhouse_sever_host_name1,my_clickhouse_sever_host_name2", config.host()); + assertEquals("my_timeplus_sever_host_name1,my_timeplus_sever_host_name2", config.host()); assertEquals(2, config.hosts().size()); assertEquals(9000, config.port()); assertEquals("system", config.database()); diff --git a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/FailoverClickhouseConnectionITest.java b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/FailoverTimeplusConnectionITest.java similarity index 85% rename from timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/FailoverClickhouseConnectionITest.java rename to timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/FailoverTimeplusConnectionITest.java index 9ed44c8a..594c5d20 100644 --- a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/FailoverClickhouseConnectionITest.java +++ b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/FailoverTimeplusConnectionITest.java @@ -16,10 +16,10 @@ import com.timeplus.log.Logger; import com.timeplus.log.LoggerFactory; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.testcontainers.clickhouse.*; -//import org.testcontainers.timeplus.TimeplusContainer; +import org.testcontainers.timeplus.TimeplusContainer; import org.testcontainers.junit.jupiter.Container; import java.sql.Connection; @@ -31,17 +31,17 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public class FailoverClickhouseConnectionITest extends AbstractITest { - private static final Logger LOG = LoggerFactory.getLogger(FailoverClickhouseConnectionITest.class); +public class FailoverTimeplusConnectionITest extends AbstractITest { + private static final Logger LOG = LoggerFactory.getLogger(FailoverTimeplusConnectionITest.class); private static final Integer NATIVE_PORT = 8463; protected static String HA_HOST; protected static int HA_PORT; @Container - public static ClickHouseContainer containerHA = new ClickHouseContainer(AbstractITest.TIMEPLUS_IMAGE) - .withEnv("CLICKHOUSE_USER", TIMEPLUS_USER) - .withEnv("CLICKHOUSE_PASSWORD", TIMEPLUS_PASSWORD) - .withEnv("CLICKHOUSE_DB", TIMEPLUS_DB); + public static TimeplusContainer containerHA = new TimeplusContainer(AbstractITest.TIMEPLUS_IMAGE) + .withEnv("TIMEPLUS_USER", TIMEPLUS_USER) + .withEnv("TIMEPLUS_PASSWORD", TIMEPLUS_PASSWORD) + .withEnv("TIMEPLUS_DB", TIMEPLUS_DB); @BeforeEach @@ -57,7 +57,7 @@ public void reset() throws SQLException { } @Test - public void testClickhouseDownBeforeConnect() throws Exception { + public void testTimeplusDownBeforeConnect() throws Exception { String haHost = String.format(Locale.ROOT, "%s:%s,%s:%s", TP_HOST, TP_PORT, HA_HOST, HA_PORT); container.stop(); @@ -75,7 +75,7 @@ public void testClickhouseDownBeforeConnect() throws Exception { } @Test - public void testClickhouseDownBeforeStatement() throws Exception { + public void testTimeplusDownBeforeStatement() throws Exception { String haHost = String.format(Locale.ROOT, "%s:%s,%s:%s", TP_HOST, TP_PORT, HA_HOST, HA_PORT); try (Connection connection = DriverManager @@ -93,7 +93,7 @@ public void testClickhouseDownBeforeStatement() throws Exception { } @Test - public void testClickhouseDownBeforePrepareStatement() throws Exception { + public void testTimeplusDownBeforePrepareStatement() throws Exception { String haHost = String.format(Locale.ROOT, "%s:%s,%s:%s", TP_HOST, TP_PORT, HA_HOST, HA_PORT); try (Connection connection = DriverManager @@ -111,7 +111,7 @@ public void testClickhouseDownBeforePrepareStatement() throws Exception { } @Test - public void testClickhouseDownBeforeExecute() throws Exception { + public void testTimeplusDownBeforeExecute() throws Exception { String haHost = String.format(Locale.ROOT, "%s:%s,%s:%s", TP_HOST, TP_PORT, HA_HOST, HA_PORT); try (Connection connection = DriverManager @@ -129,7 +129,7 @@ public void testClickhouseDownBeforeExecute() throws Exception { } @Test - public void testClickhouseDownBeforeAndAfterConnect() { + public void testTimeplusDownBeforeAndAfterConnect() { String haHost = String.format(Locale.ROOT, "%s:%s,%s:%s", TP_HOST, TP_PORT, HA_HOST, HA_PORT); Exception ex = null; @@ -153,7 +153,7 @@ public void testClickhouseDownBeforeAndAfterConnect() { } @Test - public void testClickhouseAllDownBeforeConnect() throws Exception { + public void testTimeplusAllDownBeforeConnect() throws Exception { String haHost = String.format(Locale.ROOT, "%s:%s,%s", TP_HOST, TP_PORT, HA_HOST); Exception ex = null; diff --git a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/TimeplusConnectionITest.java b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/TimeplusConnectionITest.java index bb9db962..b395fe9a 100644 --- a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/TimeplusConnectionITest.java +++ b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/TimeplusConnectionITest.java @@ -14,10 +14,9 @@ package com.timeplus.jdbc; -import com.timeplus.jdbc.tool.LocalKeyStoreConfig; -import com.timeplus.settings.KeyStoreConfig; +// import com.timeplus.jdbc.tool.LocalKeyStoreConfig; +// import com.timeplus.settings.KeyStoreConfig; import org.junit.jupiter.api.Test; - import java.sql.ResultSet; import static org.junit.jupiter.api.Assertions.*; @@ -34,32 +33,33 @@ void ping() throws Exception { }); } - @Test - void pingWithSecureConnection() throws Exception { - withNewConnection(connection -> { - withStatement(connection, stmt -> { - ResultSet resultSet = stmt.executeQuery("SELECT 1"); - assertTrue(resultSet.next()); - }); - }, "ssl", "true", - "ssl_mode", "disabled"); - } + // FIXME current container doesn't support secure connection + // @Test + // void pingWithSecureConnection() throws Exception { + // withNewConnection(connection -> { + // withStatement(connection, stmt -> { + // ResultSet resultSet = stmt.executeQuery("SELECT 1"); + // assertTrue(resultSet.next()); + // }); + // }, "ssl", "true", + // "ssl_mode", "disabled"); + // } - @Test - void pingWithSecureConnectionAndVerification() throws Exception { - KeyStoreConfig keyStoreConfig = new LocalKeyStoreConfig(); + // @Test + // void pingWithSecureConnectionAndVerification() throws Exception { + // KeyStoreConfig keyStoreConfig = new LocalKeyStoreConfig(); - withNewConnection(connection -> { - withStatement(connection, stmt -> { - ResultSet resultSet = stmt.executeQuery("SELECT 1"); - assertTrue(resultSet.next()); - }); - }, "ssl", "true", - "ssl_mode", "verify_ca", - "key_store_type", keyStoreConfig.getKeyStoreType(), - "key_store_path", keyStoreConfig.getKeyStorePath(), - "key_store_password", keyStoreConfig.getKeyStorePassword()); - } + // withNewConnection(connection -> { + // withStatement(connection, stmt -> { + // ResultSet resultSet = stmt.executeQuery("SELECT 1"); + // assertTrue(resultSet.next()); + // }); + // }, "ssl", "true", + // "ssl_mode", "verify_ca", + // "key_store_type", keyStoreConfig.getKeyStoreType(), + // "key_store_path", keyStoreConfig.getKeyStorePath(), + // "key_store_password", keyStoreConfig.getKeyStorePassword()); + // } @Test public void testCatalog() throws Exception { diff --git a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/TimeplusDatabaseMetadataITest.java b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/TimeplusDatabaseMetadataITest.java index 1f8700a4..5d13dcec 100644 --- a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/TimeplusDatabaseMetadataITest.java +++ b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/TimeplusDatabaseMetadataITest.java @@ -104,7 +104,7 @@ void nullsAreSortedAtEnd() throws Exception { void getDatabaseProductName() throws Exception { withNewConnection(connection -> { DatabaseMetaData dm = connection.getMetaData(); - assertEquals("ClickHouse", dm.getDatabaseProductName()); + assertEquals("Timeplus", dm.getDatabaseProductName()); }); } diff --git a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/ClickHouseSQLExceptionITest.java b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/TimeplusSQLExceptionITest.java similarity index 94% rename from timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/ClickHouseSQLExceptionITest.java rename to timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/TimeplusSQLExceptionITest.java index 31da50c0..6dd14a74 100644 --- a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/ClickHouseSQLExceptionITest.java +++ b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/TimeplusSQLExceptionITest.java @@ -21,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.*; -public class ClickHouseSQLExceptionITest extends AbstractITest { +public class TimeplusSQLExceptionITest extends AbstractITest { @Test public void errorCodeShouldBeAssigned() throws Exception { diff --git a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/benchmark/AbstractIBenchmark.java b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/benchmark/AbstractIBenchmark.java index 1631aa33..e2b2515c 100644 --- a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/benchmark/AbstractIBenchmark.java +++ b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/benchmark/AbstractIBenchmark.java @@ -21,8 +21,7 @@ import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; -import org.testcontainers.clickhouse.*; -//import org.testcontainers.timeplus.TimeplusContainer; +import org.testcontainers.timeplus.TimeplusContainer; import java.sql.*; import java.util.Enumeration; @@ -39,10 +38,10 @@ public class AbstractIBenchmark { protected static final int TIMEPLUS_HTTP_PORT = 3218; protected static final int TIMEPLUS_NATIVE_PORT = 8463; - public static final ClickHouseContainer container; + public static final TimeplusContainer container; static { - container = new ClickHouseContainer(AbstractITest.TIMEPLUS_IMAGE); + container = new TimeplusContainer(AbstractITest.TIMEPLUS_IMAGE); container.start(); } diff --git a/timeplus-native-jdbc/src/test/java/com/timeplus/settings/TimeplusConfigTest.java b/timeplus-native-jdbc/src/test/java/com/timeplus/settings/TimeplusConfigTest.java index 0eed5465..52e07a9f 100644 --- a/timeplus-native-jdbc/src/test/java/com/timeplus/settings/TimeplusConfigTest.java +++ b/timeplus-native-jdbc/src/test/java/com/timeplus/settings/TimeplusConfigTest.java @@ -27,7 +27,7 @@ class TimeplusConfigTest { @Test - public void testDefaultClickHouseConfig() { + public void testDefaultTimeplusConfig() { TimeplusConfig cfg = TimeplusConfig.Builder.builder().build(); assertEquals("127.0.0.1", cfg.host()); assertEquals(9000, cfg.port()); @@ -43,7 +43,7 @@ public void testDefaultClickHouseConfig() { } @Test - public void testClickHouseConfig() { + public void testTimeplusConfig() { TimeplusConfig cfg = TimeplusConfig.Builder.builder() .withJdbcUrl("jdbc:timeplus://1.2.3.4:8123/db2") .charset("GBK")