This is an automated email from the ASF dual-hosted git repository.
w41ter pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new e0b65d0ff42 [fix](regression) Fix creating db for downstream url
#39601 (#39818)
e0b65d0ff42 is described below
commit e0b65d0ff42b4b5a322869d5f0be47b983c19c31
Author: walter <[email protected]>
AuthorDate: Fri Aug 23 16:15:19 2024 +0800
[fix](regression) Fix creating db for downstream url #39601 (#39818)
cherry pick from #39601
---
.../org/apache/doris/regression/Config.groovy | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git
a/regression-test/framework/src/main/groovy/org/apache/doris/regression/Config.groovy
b/regression-test/framework/src/main/groovy/org/apache/doris/regression/Config.groovy
index c624fccf830..007d0d48f3b 100644
---
a/regression-test/framework/src/main/groovy/org/apache/doris/regression/Config.groovy
+++
b/regression-test/framework/src/main/groovy/org/apache/doris/regression/Config.groovy
@@ -642,6 +642,21 @@ class Config {
}
}
+ void tryCreateDownstreamDbIfNotExist(String dbName = defaultDb) {
+ // connect without specify default db
+ try {
+ String sql = "CREATE DATABASE IF NOT EXISTS ${dbName}"
+ log.info("Try to create db, sql: ${sql}".toString())
+ if (!dryRun) {
+ getDownstreamConnection().withCloseable { conn ->
+ JdbcUtils.executeToList(conn, sql)
+ }
+ }
+ } catch (Throwable t) {
+ throw new IllegalStateException("Create database failed,
ccrDownstreamUrl: ${ccrDownstreamUrl}", t)
+ }
+ }
+
boolean fetchRunMode() {
if (isCloudMode == RunMode.UNKNOWN) {
try {
@@ -685,9 +700,13 @@ class Config {
return DriverManager.getConnection(dbUrl, arrowFlightSqlJdbcUser,
arrowFlightSqlJdbcPassword)
}
+ Connection getDownstreamConnection() {
+ return DriverManager.getConnection(ccrDownstreamUrl,
ccrDownstreamUser, ccrDownstreamPassword)
+ }
+
Connection getDownstreamConnectionByDbName(String dbName) {
String dbUrl = buildUrlWithDb(ccrDownstreamUrl, dbName)
- tryCreateDbIfNotExist(dbName)
+ tryCreateDownstreamDbIfNotExist(dbName)
log.info("connect to ${dbUrl}".toString())
return DriverManager.getConnection(dbUrl, ccrDownstreamUser,
ccrDownstreamPassword)
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]