mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 20:43:02 +02:00
Adapt tests to be able to run them with NETCONF and RESTCONF
This commit is contained in:
@@ -7,12 +7,6 @@ import time
|
||||
import infamy.netconf as netconf
|
||||
from infamy.util import until,wait_boot
|
||||
|
||||
def remove_config(target):
|
||||
running = target.get_config_dict("/ietf-hardware:hardware")
|
||||
new = copy.deepcopy(running)
|
||||
new["hardware"].clear()
|
||||
target.put_diff_dicts("ietf-hardware",running,new)
|
||||
|
||||
with infamy.Test() as test:
|
||||
with test.step("Initialize"):
|
||||
env = infamy.Env(infamy.std_topology("1x1"))
|
||||
@@ -88,7 +82,7 @@ with infamy.Test() as test:
|
||||
until(lambda: usb.get_usb_state(target, available[0]) == "unlocked")
|
||||
|
||||
with test.step("Remove all hardware configuration"):
|
||||
remove_config(target)
|
||||
target.delete_xpath("/ietf-hardware:hardware/component")
|
||||
|
||||
with test.step("Verify USB ports locked"):
|
||||
for port in available:
|
||||
@@ -118,7 +112,7 @@ with infamy.Test() as test:
|
||||
until(lambda: usb.get_usb_state(target, port) == "unlocked")
|
||||
|
||||
with test.step("Remove USB configuration, and reboot"):
|
||||
remove_config(target)
|
||||
target.delete_xpath("/ietf-hardware:hardware/component")
|
||||
target.copy("running", "startup")
|
||||
target.reboot()
|
||||
if wait_boot(target) == False:
|
||||
|
||||
@@ -30,13 +30,9 @@ with infamy.Test() as test:
|
||||
assert mac == cmac
|
||||
|
||||
with test.step(f"Remove custom MAC address"):
|
||||
running = target.get_config_dict("/ietf-interfaces:interfaces")
|
||||
new = copy.deepcopy(running)
|
||||
for i in new["interfaces"]["interface"]:
|
||||
if i["name"] == tport:
|
||||
del i["phys-address"]
|
||||
break
|
||||
target.put_diff_dicts("ietf-interfaces", running, new)
|
||||
xpath=target.get_iface_xpath(tport, "phys-address")
|
||||
target.delete_xpath(xpath)
|
||||
|
||||
until(lambda: iface.get_phys_address(target, tport) == pmac)
|
||||
|
||||
test.succeed()
|
||||
|
||||
@@ -40,17 +40,8 @@ with infamy.Test() as test:
|
||||
until(lambda: iface.address_exist(target, interface_name, new_ip_address, proto='static'))
|
||||
|
||||
with test.step(f"Remove IPv4 addresses from {interface_name}"):
|
||||
# Get current interface configuration
|
||||
running = target.get_config_dict("/ietf-interfaces:interfaces")
|
||||
|
||||
new = copy.deepcopy(running)
|
||||
for i in new["interfaces"]["interface"]:
|
||||
if i["name"] == interface_name and "ipv4" in i:
|
||||
del i["ipv4"]
|
||||
break
|
||||
|
||||
target.put_diff_dicts("ietf-interfaces", running, new)
|
||||
|
||||
xpath=target.get_iface_xpath(interface_name, path="ietf-ip:ipv4")
|
||||
target.delete_xpath(xpath)
|
||||
with test.step("Get updated IP addresses"):
|
||||
until(lambda: iface.address_exist(target, interface_name, new_ip_address) == False)
|
||||
|
||||
|
||||
@@ -64,10 +64,8 @@ with infamy.Test() as test:
|
||||
test_ping(hport,True)
|
||||
|
||||
with test.step("Remove VLAN interface, and test again (should not be able to ping)"):
|
||||
running = target.get_config_dict("/ietf-interfaces:interfaces")
|
||||
new = copy.deepcopy(running)
|
||||
new["interfaces"]["interface"] = [d for d in new["interfaces"]["interface"] if not (d["name"] == f"{tport}.10")]
|
||||
target.put_diff_dicts("ietf-interfaces",running,new)
|
||||
xpath=target.get_xpath("/ietf-interfaces:interfaces/interface", "name", f"{tport}.10")
|
||||
target.delete_xpath(xpath)
|
||||
_, hport = env.ltop.xlate("host", "data")
|
||||
test_ping(hport,False)
|
||||
|
||||
|
||||
@@ -183,12 +183,6 @@ def config_target2(target, link):
|
||||
}
|
||||
})
|
||||
|
||||
def config_remove_routes(target):
|
||||
running = target.get_config_dict("/ietf-routing:routing")
|
||||
new = copy.deepcopy(running)
|
||||
new["routing"]["control-plane-protocols"].clear()
|
||||
target.put_diff_dicts("ietf-routing",running,new)
|
||||
|
||||
with infamy.Test() as test:
|
||||
with test.step("Initialize"):
|
||||
env = infamy.Env(infamy.std_topology("2x2"))
|
||||
@@ -224,7 +218,7 @@ with infamy.Test() as test:
|
||||
ns0.must_reach("2001:db8:3c4d:200::1")
|
||||
|
||||
with test.step("Remove static routes on dut1"):
|
||||
config_remove_routes(target1);
|
||||
target1.delete_xpath("/ietf-routing:routing/control-plane-protocols")
|
||||
parallel(until(lambda: route.ipv4_route_exist(target1, "192.168.200.1/32") == False),
|
||||
until(lambda: route.ipv6_route_exist(target1, "2001:db8:3c4d:200::1/128") == False))
|
||||
|
||||
|
||||
@@ -55,13 +55,8 @@ with infamy.Test() as test:
|
||||
assert user_found, f"User {username} not found"
|
||||
|
||||
with test.step(f"Delete user ({username} / {hashed_password})"):
|
||||
running = target.get_config_dict("/ietf-system:system")
|
||||
new = copy.deepcopy(running)
|
||||
for userx in new["system"]["authentication"]["user"]:
|
||||
if userx["name"] == username:
|
||||
del new["system"]["authentication"]["user"][username]
|
||||
break
|
||||
target.put_diff_dicts("ietf-system", running, new)
|
||||
xpath=target.get_xpath("/ietf-system:system/authentication/user", "name", username)
|
||||
target.delete_xpath(xpath)
|
||||
|
||||
with test.step(f"Verify erasure of user ({username} / {hashed_password})"):
|
||||
running = target.get_config_dict("/ietf-system:system")
|
||||
|
||||
@@ -23,11 +23,6 @@ with infamy.Test() as test:
|
||||
addr = target.address()
|
||||
|
||||
with test.step(f"Create {NAME} container from bundled OCI image"):
|
||||
target.put_config_dict("infix-services", {
|
||||
"web": {
|
||||
"enabled": False
|
||||
}
|
||||
})
|
||||
target.put_config_dict("infix-containers", {
|
||||
"containers": {
|
||||
"container": [
|
||||
|
||||
@@ -24,12 +24,6 @@ with infamy.Test() as test:
|
||||
with test.step(f"Create {NAME} container from bundled OCI image"):
|
||||
_, ifname = env.ltop.xlate("target", "data")
|
||||
enc = base64.b64encode(BODY.encode('utf-8'))
|
||||
|
||||
target.put_config_dict("infix-services", {
|
||||
"web": {
|
||||
"enabled": False
|
||||
}
|
||||
})
|
||||
target.put_config_dict("ietf-interfaces", {
|
||||
"interfaces": {
|
||||
"interface": [
|
||||
|
||||
@@ -22,11 +22,6 @@ with infamy.Test() as test:
|
||||
with test.step(f"Create {NAME} container from bundled OCI image"):
|
||||
_, ifname = env.ltop.xlate("target", "data")
|
||||
|
||||
target.put_config_dict("infix-services", {
|
||||
"web": {
|
||||
"enabled": False
|
||||
}
|
||||
})
|
||||
target.put_config_dict("ietf-interfaces", {
|
||||
"interfaces": {
|
||||
"interface": [
|
||||
|
||||
@@ -21,12 +21,6 @@ with infamy.Test() as test:
|
||||
|
||||
with test.step(f"Create {NAME} container from bundled OCI image"):
|
||||
_, ifname = env.ltop.xlate("target", "data")
|
||||
|
||||
target.put_config_dict("infix-services", {
|
||||
"web": {
|
||||
"enabled": False
|
||||
}
|
||||
})
|
||||
target.put_config_dict("ietf-interfaces", {
|
||||
"interfaces": {
|
||||
"interface": [
|
||||
|
||||
@@ -4,12 +4,6 @@ import infamy
|
||||
from infamy.util import wait_boot
|
||||
import copy
|
||||
|
||||
def remove_config(target):
|
||||
running = target.get_config_dict("/ietf-hardware:hardware")
|
||||
new = copy.deepcopy(running)
|
||||
new["hardware"].clear()
|
||||
target.put_diff_dicts("ietf-hardware",running,new)
|
||||
|
||||
with infamy.Test() as test:
|
||||
with test.step("Initialize"):
|
||||
env = infamy.Env(infamy.std_topology("1x1"))
|
||||
@@ -21,7 +15,7 @@ with infamy.Test() as test:
|
||||
"hostname": "test"
|
||||
}
|
||||
})
|
||||
remove_config(target)
|
||||
target.delete_xpath("/ietf-hardware:hardware/component")
|
||||
target.copy("running", "startup")
|
||||
with test.step("Reboot and wait for the unit to come back"):
|
||||
target.copy("running", "startup")
|
||||
@@ -32,7 +26,6 @@ with infamy.Test() as test:
|
||||
|
||||
with test.step("Verify hostname"):
|
||||
data = target.get_dict("/ietf-system:system/hostname")
|
||||
print(data)
|
||||
assert(data["system"]["hostname"] == "test")
|
||||
|
||||
test.succeed()
|
||||
|
||||
Reference in New Issue
Block a user