Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e731552

Browse files
Random-Liuixdy
authored andcommitted
Support set user with --ssh-user flag when running remote node e2e.
1 parent 712c729 commit e731552

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

test/e2e_node/e2e_remote.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434

3535
var sshOptions = flag.String("ssh-options", "", "Commandline options passed to ssh.")
3636
var sshEnv = flag.String("ssh-env", "", "Use predefined ssh options for environment. Options: gce")
37+
var sshUser = flag.String("ssh-user", "", "Use predefined user for ssh.")
3738
var testTimeoutSeconds = flag.Int("test-timeout", 45*60, "How long (in seconds) to wait for ginkgo tests to complete.")
3839
var resultsDir = flag.String("results-dir", "/tmp/", "Directory to scp test results to.")
3940
var ginkgoFlags = flag.String("ginkgo-flags", "", "Passed to ginkgo to specify additional flags such as --skip=.")
@@ -66,10 +67,14 @@ func AddHostnameIp(hostname, ip string) {
6667
func GetHostnameOrIp(hostname string) string {
6768
hostnameIpOverrides.RLock()
6869
defer hostnameIpOverrides.RUnlock()
70+
host := hostname
6971
if ip, found := hostnameIpOverrides.m[hostname]; found {
70-
return ip
72+
host = ip
7173
}
72-
return hostname
74+
if *sshUser != "" {
75+
host = fmt.Sprintf("%s@%s", *sshUser, host)
76+
}
77+
return host
7378
}
7479

7580
// CreateTestArchive builds the local source and creates a tar archive e2e_node_test.tar.gz containing

test/e2e_node/jenkins/e2e-node-jenkins.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ WORKSPACE=${WORKSPACE:-"/tmp/"}
3434
ARTIFACTS=${WORKSPACE}/_artifacts
3535

3636
mkdir -p ${ARTIFACTS}
37-
go run test/e2e_node/runner/run_e2e.go --logtostderr --vmodule=*=2 --ssh-env="gce" \
38-
--zone="$GCE_ZONE" --project="$GCE_PROJECT" --image-project="$GCE_IMAGE_PROJECT" \
39-
--hosts="$GCE_HOSTS" --images="$GCE_IMAGES" --cleanup="$CLEANUP" \
40-
--results-dir="$ARTIFACTS" --ginkgo-flags="$GINKGO_FLAGS" \
37+
go run test/e2e_node/runner/run_e2e.go --logtostderr --vmodule=*=2 \
38+
--ssh-env="gce" --ssh-user="$GCE_USER" --zone="$GCE_ZONE" --project="$GCE_PROJECT" \
39+
--image-project="$GCE_IMAGE_PROJECT" --hosts="$GCE_HOSTS" --images="$GCE_IMAGES" \
40+
--cleanup="$CLEANUP" --results-dir="$ARTIFACTS" --ginkgo-flags="$GINKGO_FLAGS" \
4141
--setup-node="$SETUP_NODE"

test/e2e_node/jenkins/template.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Copy this file to your home directory and modify
2+
# User used on the gce instances to run the test.
3+
GCE_USER=
24
# Names of gce hosts to test against (must be resolvable) or empty (one or more of GCE_IMAGES, GCE_HOSTS is required)
35
GCE_HOSTS=
46
# Names of gce images to test or empty (one or more of GCE_IMAGES, GCE_HOSTS is required)

0 commit comments

Comments
 (0)