Skip to content

Commit 136ec08

Browse files
committed
traffic rules: TestVLAN: vifRule
Signed-off-by: Sebastien Marie <semarie@kapouay.eu.org>
1 parent 46c934a commit 136ec08

1 file changed

Lines changed: 41 additions & 2 deletions

File tree

tests/network/test_traffic_rules.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import pytest
44

5+
import logging
6+
57
from lib.common import safe_split
68
from lib.host import Host
79
from lib.network import Network
10+
from lib.vlan import VLAN
811
from lib.vm import VM
912
from lib.xo import xo_cli
1013

@@ -276,5 +279,41 @@ def test_networkRule(self, connected_hosts_with_xo: list[Host], hostA2: Host, lo
276279
'protocol': 'icmp',
277280
})
278281

279-
assert count_of(hostA1, hostBr) == 0, "1 OF after migrate (on hostA1)"
280-
assert count_of(hostA2, hostBr) == 0, "1 OF after migrate (on hostA2)"
282+
assert count_of(hostA1, hostBr) == 0, "no OF at end (on hostA1)"
283+
assert count_of(hostA2, hostBr) == 0, "no OF at end (on hostA2)"
284+
285+
@pytest.mark.complex_prerequisites
286+
@pytest.mark.small_vm
287+
@pytest.mark.parametrize("vlan_device", ["eth1"])
288+
@pytest.mark.parametrize("vlan_tag", [42])
289+
class TestVLAN:
290+
def test_vifRule(self, connected_hosts_with_xo: list[Host], imported_vm: VM, empty_network: Network, vlan: VLAN):
291+
host = connected_hosts_with_xo[0]
292+
network = empty_network
293+
vm = imported_vm.clone()
294+
295+
# get bridge of the network of the tagged PIF
296+
hostBr = Network(host, vlan.tagged_PIF().network_uuid()).bridge()
297+
logging.info(f"host bridge for vlan: {hostBr}")
298+
299+
try:
300+
vif = vm.create_vif(1, network_uuid=network.uuid)
301+
302+
vm.start()
303+
304+
xo_cli('sdnController.addRule', {
305+
'vifId': vif.uuid,
306+
'ipRange': '0.0.0.0/0',
307+
'direction': 'to',
308+
'protocol': 'tcp',
309+
'port': 'json:81',
310+
'allow': 'true',
311+
})
312+
313+
vm.wait_for_os_booted()
314+
315+
assert count_of(host, hostBr) == 1, "1 OF after started"
316+
finally:
317+
vm.destroy()
318+
319+
assert count_of(host, hostBr) == 0, "no OF at end"

0 commit comments

Comments
 (0)