-
Notifications
You must be signed in to change notification settings - Fork 1k
e2e: allow using external containers #1604
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
Conversation
e2etest/bgptests/infra_setup.go
Outdated
| hostIPv6 = ip | ||
| } | ||
|
|
||
| if _, res := os.LookupEnv("USE_IBGP_SINGLE_HOP"); res { |
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.
Given the name of the containers must follow our convention, how about accepting a comma-separated list of external containers instead of a list of bools as environment variables? We could have a validation over that list (to make sure no wrong parameters were passed), have a func that returns the configs given that list, and use it to feed UseExisting
And in general, I'd prefer having a flag over an env variable.
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.
done. changed to flags. added the required changes to tasks.py as well.
e2etest/bgptests/infra_setup.go
Outdated
|
|
||
| // multiHopSetUp connects the ebgp-single-hop container to the multi-hop-net network, | ||
| // and creates the required static routes between the multi-hop containers and the speaker pods. | ||
| func multiHopSetUp(externalContainers []*frrcontainer.FRR, cs *clientset.Clientset) error { |
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.
externalContainers -> containers, as it can be called also on existing containers
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.
done.
e2etest/bgptests/infra_setup.go
Outdated
| } | ||
|
|
||
| func multiHopTearDown(cs *clientset.Clientset) error { | ||
| if containersNetwork == "host" || !isMultiHop { |
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'd keep these outside, as the purpouse of the function is to "tear down the multihop" and not to "tear it down when..."
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.
Also, can we make this more robust and just not do nothing if the network is not there? That will allow us to get rid of the global isMultiHop
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.
done.
| } | ||
|
|
||
| // validateContainerIsRunning validates that the given container is up and running. | ||
| func validateContainerIsRunning(containerName string) error { |
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.
just containerIsRunning ?
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.
done.
|
|
||
| // UseExisting validates that the existing frr containers that correspond to the | ||
| // given configurations are up and running, and returns the corresponding *FRRs. | ||
| func UseExisting(cs *clientset.Clientset, c ...Config) ([]*FRR, error) { |
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.
cs is not used here I think?
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.
you're right. removed. thanks!
| if !useEBGPSingleHop { | ||
| return nil, fmt.Errorf("Failed to setup test infra. Must use ebgp-single-hop container for multi-hop.") | ||
| } | ||
| err = multiHopSetUp(res, cs) |
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.
if this errs, just leave
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.
done.
| return nil, errors.Wrapf(err, "failed to connect %s to %s: %s", ebgpSingleHopContainerConfig.Name, multiHopNetwork, out) | ||
| } | ||
| isMultiHop = true | ||
| err = multiHopSetUp(res, cs) |
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.
same
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.
done.
|
|
||
| // UseExisting validates that the existing frr containers that correspond to the | ||
| // given configurations are up and running, and returns the corresponding *FRRs. | ||
| func UseExisting(cs *clientset.Clientset, c ...Config) ([]*FRR, error) { |
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 is a public API, let's put it on the top of the file
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.
Also, this is more ConfigureExisting
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.
done.
| return nil, fmt.Errorf("Failed to start container %s. %w", cfg.Name, err) | ||
| } | ||
|
|
||
| frr, err := configureContainer(cfg, configDir) |
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.
here I'd get rid of
configDir, err := ioutil.TempDir("", "frr-conf")
add it to startContainer and remove start() entirely.
It feels confusing to have both start and startContainer
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.
done.
|
Looks really nice! I left a few comments, but overall seems great! |
c0a755f to
628e01d
Compare
e2etest/bgptests/infra_setup.go
Outdated
| ASN: metalLBASN, | ||
| Password: "ibgp-test", | ||
| MultiHop: false, | ||
| frrContainers := []frrcontainer.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.
why the need to use a slice here? If it's only for convenience of using the slice in config.For, then create a local array.
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 reverted to the way it was before without a slice
e2etest/bgptests/infra_setup.go
Outdated
| // InfraSetup brings up the external container mimicking external routers, and set up the routing needed for | ||
| // testing. | ||
| func InfraSetup(ipv4Addresses, ipv6Addresses []string, cs *clientset.Clientset) ([]*frrcontainer.FRR, error) { | ||
| func InfraSetup(ipv4Addresses, ipv6Addresses []string, containers string, cs *clientset.Clientset) ([]*frrcontainer.FRR, error) { |
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.
nit: externalContainers / existingContainers
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.
done
e2etest/bgptests/infra_setup.go
Outdated
| } | ||
| } | ||
| } else if containersNetwork == "host" { | ||
| res, err = frrcontainer.Create(frrContainers[ibgpSingleHopContainerConfig]) |
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.
see the comment above about the slice. It's clearer if you refer the container by name (we could rename the index as something like ...Index, but I still think there's no value in converting the single instances to a slice)
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.
done.
tasks.py
Outdated
| "containers": "a comma separated list of containers names to use for the test. (valid parameters are: ibgp-single-hop / ibgp-multi-hop / ebgp-single-hop / ebgp-multi-hop)", | ||
| }) | ||
| def e2etest(ctx, name="kind", export=None, kubeconfig=None, system_namespaces="kube-system,metallb-system", service_pod_port=80, skip_docker=False, focus="", skip="", ipv4_service_range=None, ipv6_service_range=None, prometheus_namespace="", node_nics="kind", local_nics="kind"): | ||
| def e2etest(ctx, name="kind", export=None, kubeconfig=None, system_namespaces="kube-system,metallb-system", service_pod_port=80, skip_docker=False, focus="", skip="", ipv4_service_range=None, ipv6_service_range=None, prometheus_namespace="", node_nics="kind", local_nics="kind", containers=""): |
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.
same: external_containers / external_peers
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.
done. changed to external_containers
This commit adds the option to run e2etests with existing containers, i.e. the tests don't create the external FRR containers, but use existing. see e2etest/README.md for more information. Extra general code gardening: * On e2etest_suite_test.go - Deleted redundant assertion. * On container.go - Renamed function "Stop" to "Delete" to reflect better what it does. * On container.go - Deleted redundant "todo" comment.
628e01d to
2f213df
Compare
|
LGTM thanks! |
This commit adds the option to run e2etests with existing containers, i.e. the tests don't create the external FRR containers, but use existing ones. see e2etest/README.md for more information.
Extra general code gardening: