Skip to content

Conversation

@liornoy
Copy link
Contributor

@liornoy liornoy commented Sep 12, 2022

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:

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

hostIPv6 = ip
}

if _, res := os.LookupEnv("USE_IBGP_SINGLE_HOP"); res {
Copy link
Member

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.

Copy link
Contributor Author

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.


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

@fedepaol fedepaol Sep 13, 2022

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

}

func multiHopTearDown(cs *clientset.Clientset) error {
if containersNetwork == "host" || !isMultiHop {
Copy link
Member

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

Copy link
Member

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

Copy link
Contributor Author

@liornoy liornoy Sep 21, 2022

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

Choose a reason for hiding this comment

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

just containerIsRunning ?

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

@liornoy liornoy Sep 21, 2022

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

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

Copy link
Contributor Author

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

Choose a reason for hiding this comment

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

same

Copy link
Contributor Author

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

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

Copy link
Member

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

Copy link
Contributor Author

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@fedepaol
Copy link
Member

Looks really nice! I left a few comments, but overall seems great!

@liornoy liornoy force-pushed the e2etestmodify branch 3 times, most recently from c0a755f to 628e01d Compare September 22, 2022 12:20
ASN: metalLBASN,
Password: "ibgp-test",
MultiHop: false,
frrContainers := []frrcontainer.Config{
Copy link
Member

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.

Copy link
Contributor Author

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

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

Choose a reason for hiding this comment

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

nit: externalContainers / existingContainers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}
}
} else if containersNetwork == "host" {
res, err = frrcontainer.Create(frrContainers[ibgpSingleHopContainerConfig])
Copy link
Member

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)

Copy link
Contributor Author

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

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

Copy link
Contributor Author

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

LGTM thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants