Skip to content
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

Merged
merged 2 commits into from
Mar 17, 2018

Conversation

eloycoto
Copy link
Member

@eloycoto eloycoto commented Mar 13, 2018

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 #2900)
@me to run some test in Google Cloud.

Example:

ginkgo --focus "RuntimeValidatedLB" -v -- --cilium.provision=false --cilium.SSHConfig="cat ssh-config"

Signed-off-by: Eloy Coto [email protected]

@eloycoto eloycoto added kind/enhancement This would improve or streamline existing functionality. area/CI Continuous Integration testing issue or flake labels Mar 13, 2018
@eloycoto eloycoto requested a review from a team as a code owner March 13, 2018 10:27
@eloycoto
Copy link
Member Author

test-me-please

}

// 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from golang 1.8

const (

//CiliumPath the path where cilium test code is located.
CiliumPath = "github.com/cilium/cilum/test/"
Copy link
Member

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)
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Contributor

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.

@@ -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")
Copy link
Contributor

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..."

Copy link
Member

@ianvernon ianvernon left a 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.

"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
Copy link
Member

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.

@@ -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
Copy link
Member

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...

@@ -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")
Copy link
Member

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.

@eloycoto
Copy link
Member Author

test-me-please


const (

//CiliumPath the path where cilium test code is located.
Copy link
Member

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)
Copy link
Member

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.

const (

//CiliumPath the path where cilium test code is located.
CiliumPath = "/src/github.com/cilium/cilum/test"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo ;) cilum -> cilium

@eloycoto
Copy link
Member Author

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.

@nebril The node is always used, and the BasePath will be updated, it has been used in initialize function before the test.

@eloycoto
Copy link
Member Author

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 <[email protected]>
Signed-off-by: Eloy Coto <[email protected]>
@eloycoto
Copy link
Member Author

test-me-please

Copy link
Member

@joestringer joestringer left a 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.

@tgraf tgraf merged commit d535577 into cilium:master Mar 17, 2018
@tgraf tgraf added the release-note/minor This PR changes functionality that users may find relevant to operating Cilium. label Mar 17, 2018
@tgraf tgraf changed the title RFC: Ginkgo: Add a option to run test in different vms Ginkgo: Add a option to run test in different vms Mar 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/CI Continuous Integration testing issue or flake kind/enhancement This would improve or streamline existing functionality. release-note/minor This PR changes functionality that users may find relevant to operating Cilium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants