HomeFreeBSD

testing: add ability to specify multi-vnet topologies in the pytest framework.

Description

testing: add ability to specify multi-vnet topologies in the pytest framework.

Notable amount of tests related to the packet IO require two VNET jails
for proper testing and avoiding side effects for the host system.
Additionally, it is often required to run actions in the jails seme-sequentially

  • waiting for the listener initialisation can be an example of such dependency.

This change extends pytest vnet framework to allow defining multi-vnet
multi-epair topologies in declarative style, without any need to bother
about jail or repair names. All jail creation/teardown, interface
creation/teardown and address assignments are handled automatically.

Example:

TOPOLOGY = {

"vnet1": {"ifaces": ["if1", "if2", "if3"]},
"vnet2": {"ifaces": ["if1", "if2", "if3"]},
"if1": {"prefixes6": [("2001:db8:a::1/64", "2001:db8:a::2/64")]},
"if2": {"prefixes6": [("2001:db8:b::1/64", "2001:db8:b::2/64")]},
"if3": {"prefixes6": [("2001:db8:c::1/64", "2001:db8:c::2/64")]},

}
def vnet2_handler(self, vnet, obj_map, pipe):

ss = VerboseSocketServer("::", self.DEFAULT_PORT)
pipe.send("READY")

def test_output6_base(self):

self.wait_object(second_vnet.pipe)

The definitions above will create 2 vnets ("jail_test_output6_base",
"jail_test_output6_base_2"), 3 epairs, attached to both first and
second jails, set up the IP addresses for each epair, spawn another
process for vnet2_handler and pass control to vnet2_handler and
test_output6_base. Both processes can pass objects between each
other using pre-created pipes.

Differential Revision: https://reviews.freebsd.org/D35708

(cherry picked from commit cfc9cf9baf474618daad9f5d5f7c74e66acafbd3)