-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ginkgo: Add a option to run test in different vms #3120
Conversation
test-me-please |
test/helpers/node.go
Outdated
} | ||
|
||
// setBasePath if the SSHConfig is defined we set the BasePath to the GOPATH, | ||
// from golang 1.9 GOPATH is by default $HOME/go so we also check that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from golang 1.8
test/helpers/cons.go
Outdated
const ( | ||
|
||
//CiliumPath the path where cilium test code is located. | ||
CiliumPath = "github.com/cilium/cilum/test/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove trailing /
return | ||
} | ||
|
||
BasePath = filepath.Join(home, "go", CiliumPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does BasePath
needs to be public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it's used by the PolicyGen in Nightly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like policygen.TestSpec
and policygen.Target
should be initialised with proper BasePath , and refer to it in their code. Also seems like other places using BasePath are already using SSHMeta, maybe it should also be stored in it? I think we need an issue to track this if this is too big to work on in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the above BasePath cleanup should be done in a separate PR this PR is useful even without the cleanup.
test/config/config.go
Outdated
@@ -32,4 +33,6 @@ func (c *CiliumTestConfigType) ParseFlags() { | |||
"Provision Vagrant boxes and Cilium before running test") | |||
flag.BoolVar(&c.HoldEnvironment, "cilium.holdEnvironment", false, | |||
"On failure, hold the environment in its current state") | |||
flag.StringVar(&c.SSHConfig, "cilium.SSHConfig", "", | |||
"Command to get a different a different SSH-config") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo? "Command to get a different a different" should probably be "Command to get a different..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, some minor typos.
test/helpers/vagrant.go
Outdated
"github.com/onsi/ginkgo" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
//Create a new vagrant server. Receives and scope that it's the target server that need to be created. | ||
// In case of any error on vagrant [provision|up|ssh-config] error will be returned. | ||
// CreateVM a new vagrant server. Receives and scope that it's the target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creates a new...
Receives a scope which indicates the target server that needs to be created.
test/helpers/vagrant.go
Outdated
@@ -37,7 +40,7 @@ func CreateVM(scope string) error { | |||
case "not_created": | |||
createCMD = "vagrant up %s --provision" | |||
default: | |||
//Sometimes server are stoped and not destroyed. DestroyVM just in case | |||
// Sometimes server are stoped and not destroyed. DestroyVM just in case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
servers are stopped... Destroy VM...
test/config/config.go
Outdated
@@ -32,4 +33,6 @@ func (c *CiliumTestConfigType) ParseFlags() { | |||
"Provision Vagrant boxes and Cilium before running test") | |||
flag.BoolVar(&c.HoldEnvironment, "cilium.holdEnvironment", false, | |||
"On failure, hold the environment in its current state") | |||
flag.StringVar(&c.SSHConfig, "cilium.SSHConfig", "", | |||
"Command to get a different a different SSHConfig") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we expand the description to state the expected format? ie,
"Specify a custom command to fetch SSH configuration (eg: 'vagrant ssh-config')"
Would be nice to add this to the contributing docs too.
test-me-please |
test/helpers/cons.go
Outdated
|
||
const ( | ||
|
||
//CiliumPath the path where cilium test code is located. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: s/CiliumPath the/CiliumPath is the
return | ||
} | ||
|
||
BasePath = filepath.Join(home, "go", CiliumPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like policygen.TestSpec
and policygen.Target
should be initialised with proper BasePath , and refer to it in their code. Also seems like other places using BasePath are already using SSHMeta, maybe it should also be stored in it? I think we need an issue to track this if this is too big to work on in this PR.
test/helpers/cons.go
Outdated
const ( | ||
|
||
//CiliumPath the path where cilium test code is located. | ||
CiliumPath = "/src/github.com/cilium/cilum/test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo ;) cilum -> cilium
@nebril The node is always used, and the BasePath will be updated, it has been used in |
test-me-please |
This commit added a new flag --cilium.SSHConfig that it's a subcommand that change `vagrant ssh-config ${VM}` to something that we want to have. For example, if we want to run ginkgo test in a different VM, we can use the following: `vagrant ssh-config ${ID} > ssh-config` And in that file, we should update the Host line to something that matchs, like: `Host runtime` --> For Runtime test `Host k8s1-1.9` --> For Kubernetes test `Host k8s2-1.9` --> For Kubernetes test In the case of Kubernetes the value is 1.9, but that should match with the value from ${K8S_VERSION}. (As described in the contributing guide) This commit also updates helpers.BasePath, if the flag is defined, the variable will change to ssh-host $GOPATH value or ${HOME}/go if the GOPATH is not enabled. This change fixes multiple approaches that ginkgo should cover: @aanm Can dump the output of `vagrant shh-config` from his VMs and use those servers to run the test. @nebril Can use the test in minukube, a custom ssh-config can be created file where host and ssh-key can be specified. @jrfastab can create a custom ssh-config to run the test in baremetal. `ssh -G $(whoami)@127.0.0.1` can be used and added `Host runtime` in the top @joestringer can create a custom ssh-config and use on their laptop and the system will pickup the `$GOPATH` environment variable and bazel cache.(Feedback from issue cilium#2900) Signed-off-by: Eloy Coto <eloy.coto@gmail.com>
Signed-off-by: Eloy Coto <eloy.coto@gmail.com>
test-me-please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, I think we should merge it if it's not breaking anything and follow up on any tidyups/usage improvements once it's in.
This commit added a new flag --cilium.SSHConfig that it's a subcommand
that change
vagrant ssh-config ${VM}
to something that we want to have.For example, if we want to run ginkgo test in a different VM, we can use
the following:
vagrant ssh-config ${ID} > ssh-config
And in that file, we should update the Host line to something that
matchs, like:
Host runtime
--> For Runtime testHost k8s1-1.9
--> For Kubernetes testHost k8s2-1.9
--> For Kubernetes testIn the case of Kubernetes the value is 1.9, but that should match with
the value from ${K8S_VERSION}. (As described in the contributing guide)
This commit also updates helpers.BasePath, if the flag is defined, the$GOPATH value or $ {HOME}/go if the
variable will change to ssh-host
GOPATH is not enabled.
This change fixes multiple approaches that ginkgo should cover:
@aanm Can dump the output of
vagrant shh-config
from his VMs and usethose servers to run the test.
@nebril Can use the test in minukube, a custom ssh-config can be created
file where host and ssh-key can be specified.
@jrfastab can create a custom ssh-config to run the test in baremetal.
ssh -G $(whoami)@127.0.0.1
can be used and addedHost runtime
in thetop
@joestringer can create a custom ssh-config and use on their laptop and
the system will pickup the
$GOPATH
environment variable and bazelcache.(Feedback from issue #2900)
@me to run some test in Google Cloud.
Example:
Signed-off-by: Eloy Coto eloy.coto@gmail.com