Skip to content

Commit

Permalink
Merge pull request #684 from kernelkit/fix-test-texts
Browse files Browse the repository at this point in the history
Update last tests for first version of test specification
  • Loading branch information
mattiaswal authored Oct 4, 2024
2 parents 571f4a6 + 65e5ab8 commit a66d1d3
Show file tree
Hide file tree
Showing 30 changed files with 157 additions and 83 deletions.
1 change: 1 addition & 0 deletions test/case/ietf_interfaces/Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ include::static_multicast_filters/Readme.adoc[]

include::vlan_qos/Readme.adoc[]

include::verify_all_interface_types/Readme.adoc[]
20 changes: 10 additions & 10 deletions test/case/ietf_interfaces/verify_all_interface_types/test.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/usr/bin/env python3
#
# lo br-0 br-Q.40 br-D br-X
# | | | | |
# o o eth-Q.10 br-Q veth0a.20 eth-X.30
# \ / \ | |
# eth-Q veth0b veth0a eth-X
# `---------'

"""
r"""
Verify that all interface types can be created
This test verify that all interface types can be created
and also, tesing setting the configuration in sequal (this
takes a little longer time than send it once)
....
lo br-0 br-Q.40 br-D br-X
| | | | |
o o ethQ.10 br-Q veth0a.20 ethX.30
\ / \ | |
ethQ veth0b veth0a ethX
`---------'
....
"""

import infamy
Expand Down
Binary file modified test/case/ietf_system/add_delete_user/topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/case/ietf_system/hostname/topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/case/ietf_system/timezone/topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/case/ietf_system/timezone_utc_offset/topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/case/ietf_system/user_admin/topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions test/case/infix_containers/container_basic/Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Set up topology and attach to target DUT
. Set hostname to 'container-host'
. Create container 'web' from bundled OCI image
. Verify container 'web' has started
. Verify container 'web' is reachable on http://container-host.local:91
. Stop container 'web'
. Verify container 'web' is stopped
. Restart container 'web'
. Verify container 'web' is reachable on http://container-host.local:91


<<<
Expand Down
23 changes: 17 additions & 6 deletions test/case/infix_containers/container_basic/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


def _verify(server):
# Should really use mDNS here....
url = infamy.Furl(f"http://[{server}]:91/index.html")
return url.check("It works")

Expand All @@ -35,7 +36,14 @@ def _verify(server):
if not target.has_model("infix-containers"):
test.skip()

with test.step(f"Create {NAME} container from bundled OCI image"):
with test.step("Set hostname to 'container-host'"):
target.put_config_dict("ietf-system", {
"system": {
"hostname": "container-host"
}
})

with test.step("Create container 'web' from bundled OCI image"):
target.put_config_dict("infix-containers", {
"containers": {
"container": [
Expand All @@ -51,21 +59,24 @@ def _verify(server):
}
})

with test.step(f"Verify {NAME} container has started"):
with test.step("Verify container 'web' has started"):
c = infamy.Container(target)
until(lambda: c.running(NAME), attempts=10)

with test.step(f"Verify {NAME} container responds"):
with test.step("Verify container 'web' is reachable on http://container-host.local:91"):
until(lambda: _verify(addr), attempts=10)

with test.step(f"Verify {NAME} container can be stopped and restarted"):
with test.step("Stop container 'web'"):
c = infamy.Container(target)
c.action(NAME, "stop")

with test.step("Verify container 'web' is stopped"):
until(lambda: not c.running(NAME), attempts=10)

with test.step("Restart container 'web'"):
c.action(NAME, "restart")

with test.step(f"Verify {NAME} container still responds"):
with test.step("Verify container 'web' is reachable on http://container-host.local:91"):
# Wait for it to restart and respond, or fail
until(lambda: _verify(addr), attempts=10)

test.succeed()
9 changes: 8 additions & 1 deletion test/case/infix_containers/container_bridge/Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Verify connectivity with a simple web server container from behind a
docker0 bridge. As an added twist, this test also verifies content
mounts, i.e., custom index.html from running-config.

This also verifies port forwarding from container internal port to a
port accessed from the host.

==== Topology
ifdef::topdoc[]
image::../../test/case/infix_containers/container_bridge/topology.png[Container with bridge network topology]
Expand All @@ -17,7 +20,11 @@ image::topology.png[Container with bridge network topology]
endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Initialize
. Set up topology and attach to target DUT
. Create container 'web-docker0' from bundled OCI image
. Verify container 'web-docker0' has started
. Verify basic DUT connectivity, host:data can ping DUT 10.0.0.2
. Verify container 'web-docker0' is reachable on http://10.0.0.2:8080


<<<
Expand Down
21 changes: 12 additions & 9 deletions test/case/infix_containers/container_bridge/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
Verify connectivity with a simple web server container from behind a
docker0 bridge. As an added twist, this test also verifies content
mounts, i.e., custom index.html from running-config.
This also verifies port forwarding from container internal port to a
port accessed from the host.
"""
import base64
import infamy
Expand All @@ -23,14 +26,14 @@
BODY = "<html><body><p>Kilroy was here</p></body></html>"
URL = f"http://{DUTIP}:8080/index.html"

with test.step("Initialize"):
with test.step("Set up topology and attach to target DUT"):
env = infamy.Env()
target = env.attach("target", "mgmt")

if not target.has_model("infix-containers"):
test.skip()

with test.step(f"Create {NAME} container from bundled OCI image"):
with test.step("Create container 'web-docker0' from bundled OCI image"):
_, ifname = env.ltop.xlate("target", "data")
enc = base64.b64encode(BODY.encode('utf-8'))
target.put_config_dict("ietf-interfaces", {
Expand Down Expand Up @@ -84,18 +87,18 @@
}
})

with test.step(f"Verify {NAME} container has started"):
with test.step("Verify container 'web-docker0' has started"):
c = infamy.Container(target)
until(lambda: c.running(NAME), attempts=10)

with test.step(f"Verify {NAME} container responds"):
_, hport = env.ltop.xlate("host", "data")
url = infamy.Furl(URL)
_, hport = env.ltop.xlate("host", "data")
url = infamy.Furl(URL)

with infamy.IsolatedMacVlan(hport) as ns:
ns.addip(OURIP)
with infamy.IsolatedMacVlan(hport) as ns:
ns.addip(OURIP)
with test.step("Verify basic DUT connectivity, host:data can ping DUT 10.0.0.2"):
ns.must_reach(DUTIP)

with test.step("Verify container 'web-docker0' is reachable on http://10.0.0.2:8080"):
until(lambda: url.nscheck(ns, "Kilroy was here"), attempts=10)

test.succeed()
Binary file modified test/case/infix_containers/container_bridge/topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion test/case/infix_containers/container_phys/Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ image::topology.png[Container with physical interface topology]
endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Initialize
. Set up topology and attach to target DUT
. Create container 'web-phys' from bundled OCI image
. Verify container 'web-phys' has started
. Verify host:data can ping 10.0.0.2
. Verify container 'web-phys' is reachable on http://10.0.0.2:91


<<<
Expand Down
17 changes: 9 additions & 8 deletions test/case/infix_containers/container_phys/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
OURIP = "10.0.0.1"
URL = f"http://{DUTIP}:91/index.html"

with test.step("Initialize"):
with test.step("Set up topology and attach to target DUT"):
env = infamy.Env()
target = env.attach("target", "mgmt")

if not target.has_model("infix-containers"):
test.skip()

with test.step(f"Create {NAME} container from bundled OCI image"):
with test.step("Create container 'web-phys' from bundled OCI image"):
_, ifname = env.ltop.xlate("target", "data")

target.put_config_dict("ietf-interfaces", {
Expand Down Expand Up @@ -63,18 +63,19 @@
}
})

with test.step(f"Verify {NAME} container has started"):
with test.step("Verify container 'web-phys' has started"):
c = infamy.Container(target)
until(lambda: c.running(NAME), attempts=10)

with test.step(f"Verify {NAME} container responds"):
_, hport = env.ltop.xlate("host", "data")
url = infamy.Furl(URL)
_, hport = env.ltop.xlate("host", "data")
url = infamy.Furl(URL)

with infamy.IsolatedMacVlan(hport) as ns:
ns.addip(OURIP)
with infamy.IsolatedMacVlan(hport) as ns:
ns.addip(OURIP)
with test.step("Verify host:data can ping 10.0.0.2"):
ns.must_reach(DUTIP)

with test.step("Verify container 'web-phys' is reachable on http://10.0.0.2:91"):
until(lambda: url.nscheck(ns, "It works"), attempts=10)

test.succeed()
Binary file modified test/case/infix_containers/container_phys/topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion test/case/infix_containers/container_veth/Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
Verify connectivity with a simple web server container from behind a
regular bridge, a VETH pair connects the container to the bridge.

....
.-------------. .---------------. .--------.
| | tgt |---------| mgmt | | | web- |
| host | data |---------| data | target | | server |
'-------------' '---------------' '--------'
| /
br0 /
`----- veth0 -----'
....

==== Topology
ifdef::topdoc[]
image::../../test/case/infix_containers/container_veth/topology.png[Container with VETH pair topology]
Expand All @@ -16,7 +26,11 @@ image::topology.png[Container with VETH pair topology]
endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Initialize
. Set up topology and attach to target DUT
. Create 'web-br0-veth' container from bundled OCI image
. Verify container 'web-br0-veth' has started
. Verify basic DUT connectivity, host:data can ping DUT 10.0.0.2
. Verify container 'web-br0-veth' is reachable on http://10.0.0.2:91


<<<
Expand Down
31 changes: 21 additions & 10 deletions test/case/infix_containers/container_veth/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@
# Verify connectivity with a simple web server container from behind a
# regular bridge, a VETH pair connects the container to the bridge.
#
"""
r"""
Container with VETH pair
Verify connectivity with a simple web server container from behind a
regular bridge, a VETH pair connects the container to the bridge.
....
.-------------. .---------------. .--------.
| | tgt |---------| mgmt | | | web- |
| host | data |---------| data | target | | server |
'-------------' '---------------' '--------'
| /
br0 /
`----- veth0 -----'
....
"""
import base64
import infamy
Expand All @@ -20,14 +31,14 @@
OURIP = "10.0.0.1"
URL = f"http://{DUTIP}:91/index.html"

with test.step("Initialize"):
with test.step("Set up topology and attach to target DUT"):
env = infamy.Env()
target = env.attach("target", "mgmt")

if not target.has_model("infix-containers"):
test.skip()

with test.step(f"Create {NAME} container from bundled OCI image"):
with test.step("Create 'web-br0-veth' container from bundled OCI image"):
_, ifname = env.ltop.xlate("target", "data")
target.put_config_dict("ietf-interfaces", {
"interfaces": {
Expand Down Expand Up @@ -86,18 +97,18 @@
}
})

with test.step(f"Verify {NAME} container has started"):
with test.step("Verify container 'web-br0-veth' has started"):
c = infamy.Container(target)
until(lambda: c.running(NAME), attempts=10)

with test.step(f"Verify {NAME} container responds"):
_, hport = env.ltop.xlate("host", "data")
url = infamy.Furl(URL)
_, hport = env.ltop.xlate("host", "data")
url = infamy.Furl(URL)

with infamy.IsolatedMacVlan(hport) as ns:
ns.addip(OURIP)
with infamy.IsolatedMacVlan(hport) as ns:
ns.addip(OURIP)
with test.step("Verify basic DUT connectivity, host:data can ping DUT 10.0.0.2"):
ns.must_reach(DUTIP)

with test.step("Verify container 'web-br0-veth' is reachable on http://10.0.0.2:91"):
until(lambda: url.nscheck(ns, "It works"), attempts=10)

test.succeed()
Binary file modified test/case/infix_containers/container_veth/topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/case/infix_dhcp/dhcp_basic/Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Initialize
. Verify client get DHCP lease for 10.0.0.42 on client:data


<<<
Expand Down
2 changes: 1 addition & 1 deletion test/case/infix_dhcp/dhcp_basic/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
client.put_config_dict("infix-dhcp-client", config)

with test.step(f"Waiting for client to set DHCP lease {ADDRESS}"):
with test.step("Verify client get DHCP lease for 10.0.0.42 on client:data"):
until(lambda: iface.address_exist(client, port, ADDRESS))

test.succeed()
1 change: 1 addition & 0 deletions test/case/infix_dhcp/dhcp_router/Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Initialize
. Verify client to set up default route via 192.168.0.254


<<<
Expand Down
2 changes: 1 addition & 1 deletion test/case/infix_dhcp/dhcp_router/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
client.put_config_dict("infix-dhcp-client", config)

with test.step(f"Wait for client to set up default route via {ROUTER}"):
with test.step("Verify client to set up default route via 192.168.0.254"):
until(lambda: route.ipv4_route_exist(client, "0.0.0.0/0", ROUTER))

test.succeed()
6 changes: 3 additions & 3 deletions test/case/infix_dhcp/dhcp_routes/Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Setting up client
. Verify client use classless routes, option 121
. Verify client did *not* use option 3
. Verify client has canary route, 20.0.0.0/24
. Verify 'client' has a route to 10.0.0.0/24 via 192.168.0.254
. Verify 'client' has a default route via 192.168.0.254
. Verify 'client' has a route to 20.0.0.0/24 via 192.168.0.2


<<<
Expand Down
8 changes: 5 additions & 3 deletions test/case/infix_dhcp/dhcp_routes/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@
with infamy.IsolatedMacVlan(host) as netns:
netns.addip("192.168.0.1")
with infamy.dhcp.Server(netns, prefix=PREFIX, router=ROUTER):
with test.step("Verify client use classless routes, option 121"):
with test.step("Verify 'client' has a route to 10.0.0.0/24 via 192.168.0.254"):
print("Verify client use classless routes, option 121")
until(lambda: route.ipv4_route_exist(client, PREFIX, ROUTER))

with test.step("Verify client did *not* use option 3"):
with test.step("Verify 'client' has a default route via 192.168.0.254"):
print("Verify client did *not* use option 3")
if route.ipv4_route_exist(client, "0.0.0.0/0", ROUTER):
test.fail()

with test.step("Verify client has canary route, 20.0.0.0/24"):
with test.step("Verify 'client' has a route to 20.0.0.0/24 via 192.168.0.2"):
until(lambda: route.ipv4_route_exist(client, CANARY,
CANHOP, pref=250))

Expand Down
Loading

0 comments on commit a66d1d3

Please sign in to comment.