Skip to content

Commit

Permalink
[case](udf) Only one backend, skip scp udf file (apache#36810)
Browse files Browse the repository at this point in the history
## Proposed changes
[case](udf) Only one backend, skip scp udf file (apache#36810)
Co-authored-by: stephen <[email protected]>
  • Loading branch information
hello-stephen authored Jun 26, 2024
1 parent 91439bf commit 2021aed
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -867,16 +867,18 @@ class Suite implements GroovyInterceptable {
Assert.assertEquals(0, code)
}

void sshExec(String username, String host, String cmd) {
void sshExec(String username, String host, String cmd, boolean alert=true) {
String command = "ssh ${username}@${host} '${cmd}'"
def cmds = ["/bin/bash", "-c", command]
logger.info("Execute: ${cmds}".toString())
Process p = cmds.execute()
def errMsg = new StringBuilder()
def msg = new StringBuilder()
p.waitForProcessOutput(msg, errMsg)
assert errMsg.length() == 0: "error occurred!" + errMsg
assert p.exitValue() == 0
if (alert) {
assert errMsg.length() == 0: "error occurred!\n" + errMsg
assert p.exitValue() == 0
}
}

List<String> getFrontendIpHttpPort() {
Expand Down Expand Up @@ -1789,10 +1791,15 @@ class Suite implements GroovyInterceptable {
def backendId_to_backendIP = [:]
def backendId_to_backendHttpPort = [:]
getBackendIpHttpPort(backendId_to_backendIP, backendId_to_backendHttpPort)
if(backendId_to_backendIP.size() == 1) {
logger.info("Only one backend, skip scp udf file")
return
}

def udf_file_dir = new File(udf_file_path).parent
backendId_to_backendIP.values().each { be_ip ->
sshExec ("root", be_ip, "ssh -o StrictHostKeyChecking=no root@${be_ip} \"mkdir -p ${udf_file_dir}\"")
sshExec("root", be_ip, "ssh-keygen -f '/root/.ssh/known_hosts' -R \"${be_ip}\"", false)
sshExec("root", be_ip, "ssh -o StrictHostKeyChecking=no root@${be_ip} \"mkdir -p ${udf_file_dir}\"", false)
scpFiles("root", be_ip, udf_file_path, udf_file_path, false)
}
}
Expand Down

0 comments on commit 2021aed

Please sign in to comment.