Skip to content

Commit

Permalink
[fix](case) Enhance the robustness of set_config_temporary_action (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
deardeng authored Oct 24, 2024
1 parent 20c476b commit fffdca6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,14 @@ class Config {
return urlWithDb
}

public static String buildUrlWithDb(String host, int queryPort, String dbName) {
def url = String.format(
"jdbc:mysql://%s:%s/?useLocalSessionState=true&allowLoadLocalInfile=false",
host, queryPort)
url = buildUrlWithDb(url, dbName)
return url
}

private static String addSslUrl(String url) {
if (url.contains("TLS")) {
return url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import java.sql.Connection
import java.sql.DriverManager
import java.util.concurrent.ExecutorService
import java.util.function.Function
import org.apache.doris.regression.util.JdbcUtils

class ConnectionInfo {
Connection conn
Expand Down Expand Up @@ -315,6 +316,36 @@ class SuiteContext implements Closeable {
}
}

def reconnectToMasterFe = { ->
log.info("Reconnecting to a new master frontend...")
def result = JdbcUtils.executeToMapArray(getConnection(), "SHOW FRONTENDS")
def master = null
for (def row : result) {
if (row.IsMaster == "true") {
master = row
break
}
}
if (master) {
log.info("master found: ${master.Host}:${master.HttpPort}")
def url = Config.buildUrlWithDb(master.Host as String, master.QueryPort as Integer, dbName)
ConnectionInfo connInfo = threadLocalConn.get()
def userName = null
def userPass = null
if (connInfo) {
userName = connInfo.username
userPass = connInfo.password
} else {
userName = config.jdbcUser
userPass = config.jdbcPassword
}
connectTo(url, connInfo.username, connInfo.password)
log.info("Successfully reconnected to the master")
} else {
throw new Exception("No master found to reconnect")
}
}

public void reconnectFe() {
ConnectionInfo connInfo = threadLocalConn.get()
if (connInfo == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

suite('set_config_temporary_action', 'nonConcurrent') {
context.reconnectToMasterFe()
def key = 'schedule_slot_num_per_ssd_path'
setFeConfig(key, 8)
assertEquals(8, getFeConfig(key) as int)
Expand Down

0 comments on commit fffdca6

Please sign in to comment.