diff --git a/test/e2e_node/jenkins/e2e-node-jenkins.sh b/test/e2e_node/jenkins/e2e-node-jenkins.sh index 59db2c3b43a..fd2dbef2ffe 100755 --- a/test/e2e_node/jenkins/e2e-node-jenkins.sh +++ b/test/e2e_node/jenkins/e2e-node-jenkins.sh @@ -41,9 +41,9 @@ TIMEOUT=${TIMEOUT:-"45m"} mkdir -p ${ARTIFACTS} -go run test/e2e_node/runner/remote/run_remote.go --logtostderr --vmodule=*=4 --ssh-env="gce" \ - --zone="$GCE_ZONE" --project="$GCE_PROJECT" --hosts="$GCE_HOSTS" \ - --images="$GCE_IMAGES" --image-project="$GCE_IMAGE_PROJECT" \ +go run test/e2e_node/runner/remote/run_remote.go --logtostderr --vmodule=*=4 \ + --ssh-env="gce" --ssh-user="$GCE_USER" --zone="$GCE_ZONE" --project="$GCE_PROJECT" \ + --hosts="$GCE_HOSTS" --images="$GCE_IMAGES" --image-project="$GCE_IMAGE_PROJECT" \ --image-config-file="$GCE_IMAGE_CONFIG_PATH" --cleanup="$CLEANUP" \ --results-dir="$ARTIFACTS" --ginkgo-flags="--nodes=$PARALLELISM $GINKGO_FLAGS" \ --test-timeout="$TIMEOUT" --test_args="$TEST_ARGS --kubelet-flags=\"$KUBELET_ARGS\"" \ diff --git a/test/e2e_node/jenkins/template.properties b/test/e2e_node/jenkins/template.properties index 9e43c8e78f0..b23e5984055 100644 --- a/test/e2e_node/jenkins/template.properties +++ b/test/e2e_node/jenkins/template.properties @@ -1,4 +1,6 @@ # Copy this file to your home directory and modify +# User used on the gce instances to run the test. +GCE_USER= # Path to a yaml or json file describing images to run or empty GCE_IMAGE_CONFIG_PATH= # Names of gce hosts to test against (must be resolvable) or empty diff --git a/test/e2e_node/remote/ssh.go b/test/e2e_node/remote/ssh.go index 9a9617cd9e4..22e550ba0c5 100644 --- a/test/e2e_node/remote/ssh.go +++ b/test/e2e_node/remote/ssh.go @@ -29,6 +29,7 @@ import ( var sshOptions = flag.String("ssh-options", "", "Commandline options passed to ssh.") var sshEnv = flag.String("ssh-env", "", "Use predefined ssh options for environment. Options: gce") +var sshUser = flag.String("ssh-user", "", "Use predefined user for ssh.") var sshOptionsMap map[string]string @@ -53,13 +54,18 @@ func AddHostnameIp(hostname, ip string) { hostnameIpOverrides.m[hostname] = ip } +// GetHostnameOrIp converts hostname into ip and apply user if necessary. func GetHostnameOrIp(hostname string) string { hostnameIpOverrides.RLock() defer hostnameIpOverrides.RUnlock() + host := hostname if ip, found := hostnameIpOverrides.m[hostname]; found { - return ip + host = ip } - return hostname + if *sshUser != "" { + host = fmt.Sprintf("%s@%s", *sshUser, host) + } + return host } // getSSHCommand handles proper quoting so that multiple commands are executed in the same shell over ssh