Unverified Commit 652f4c07 authored by Serge Panev's avatar Serge Panev Committed by GitHub
Browse files

[Dist] Add env var for non-default SSH configs in tests (#4098)


Signed-off-by: default avatarSerge Panev <spanev@nvidia.com>
Co-authored-by: default avatarRhett Ying <85214957+Rhett-Ying@users.noreply.github.com>
parent 473bf15f
import subprocess import subprocess
import multiprocessing as mp import multiprocessing as mp
from typing import Optional from typing import Optional
import os
def run(ssh_cmd): def run(ssh_cmd):
subprocess.check_call(ssh_cmd, shell=True) subprocess.check_call(ssh_cmd, shell=True)
...@@ -29,8 +29,22 @@ def execute_remote( ...@@ -29,8 +29,22 @@ def execute_remote(
ip_prefix = "" ip_prefix = ""
if username: if username:
ip_prefix += "{username}@".format(username=username) ip_prefix += "{username}@".format(username=username)
custom_port = os.getenv('DIST_DGL_TEST_SSH_PORT', '')
if custom_port:
port = custom_port
custom_ssh_key = os.getenv('DIST_DGL_TEST_SSH_KEY', '')
if custom_ssh_key:
custom_ssh_key = os.path.expanduser(custom_ssh_key)
custom_ssh_key = "-i " + custom_ssh_key
ssh_setup = os.getenv('DIST_DGL_TEST_SSH_SETUP', '')
if ssh_setup:
cmd = ssh_setup + ';' + cmd
# Construct ssh command that executes `cmd` on the remote host # Construct ssh command that executes `cmd` on the remote host
ssh_cmd = "ssh -o StrictHostKeyChecking=no -p {port} {ip_prefix}{ip} '{cmd}'".format( ssh_cmd = "ssh -o StrictHostKeyChecking=no {ssh_key} -p {port} {ip_prefix}{ip} '{cmd}'".format(
ssh_key=custom_ssh_key,
port=str(port), port=str(port),
ip_prefix=ip_prefix, ip_prefix=ip_prefix,
ip=ip, ip=ip,
......
...@@ -13,11 +13,24 @@ export DIST_DGL_TEST_CPP_BIN_DIR=${PWD}/build ...@@ -13,11 +13,24 @@ export DIST_DGL_TEST_CPP_BIN_DIR=${PWD}/build
export DIST_DGL_TEST_IP_CONFIG=/home/ubuntu/workspace/ip_config.txt export DIST_DGL_TEST_IP_CONFIG=/home/ubuntu/workspace/ip_config.txt
export DIST_DGL_TEST_PY_BIN_DIR=${PWD}/tests/dist/python export DIST_DGL_TEST_PY_BIN_DIR=${PWD}/tests/dist/python
if [[ -v DIST_DGL_TEST_SSH_PORT ]]; then
SSH_PORT_LINE="-p $DIST_DGL_TEST_SSH_PORT";
fi
if [[ -v DIST_DGL_TEST_SSH_KEY ]]; then
SSH_KEY_LINE="-i $DIST_DGL_TEST_SSH_KEY";
fi
if [[ -v DIST_DGL_TEST_SSH_SETUP ]]; then
SSH_SETUP_LINE="$DIST_DGL_TEST_SSH_SETUP;";
fi
while IFS= read line while IFS= read line
do do
for pkg in 'pytest' 'psutil' 'torch' for pkg in 'pytest' 'psutil' 'torch'
do do
ret_pkg=$(ssh ${line} "python3 -m pip list | grep -i ${pkg} ") || fail "${pkg} not installed in ${line}" ret_pkg=$(ssh -o StrictHostKeyChecking=no ${line} ${SSH_PORT_LINE} ${SSH_KEY_LINE} "${SSH_SETUP_LINE}python3 -m pip list | grep -i ${pkg} ") || fail "${pkg} not installed in ${line}"
done done
done < ${DIST_DGL_TEST_IP_CONFIG} done < ${DIST_DGL_TEST_IP_CONFIG}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment