mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-06 15:43:02 +02:00
test: minor, cleanup & pep-8 fixes
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -5,19 +5,19 @@ import copy
|
||||
import infamy.usb as usb
|
||||
import time
|
||||
import infamy.netconf as netconf
|
||||
from infamy.util import until,wait_boot
|
||||
from infamy.util import until, wait_boot
|
||||
|
||||
with infamy.Test() as test:
|
||||
with test.step("Initialize"):
|
||||
env = infamy.Env()
|
||||
target = env.attach("target", "mgmt")
|
||||
available=usb.get_usb_ports(target)
|
||||
available = usb.get_usb_ports(target)
|
||||
|
||||
if len(available) < 1:
|
||||
test.skip()
|
||||
|
||||
with test.step("Unlock USB ports"):
|
||||
components=[]
|
||||
components = []
|
||||
for port in available:
|
||||
component = {
|
||||
"name": port,
|
||||
@@ -40,7 +40,7 @@ with infamy.Test() as test:
|
||||
|
||||
if len(available) > 1:
|
||||
with test.step("Lock one port"):
|
||||
components=[]
|
||||
components = []
|
||||
component = {
|
||||
"name": available[1],
|
||||
"class": "infix-hardware:usb",
|
||||
@@ -60,7 +60,7 @@ with infamy.Test() as test:
|
||||
until(lambda: usb.get_usb_state(target, available[0]) == "unlocked")
|
||||
|
||||
with test.step("Lock USB ports"):
|
||||
components=[]
|
||||
components = []
|
||||
for port in available:
|
||||
component = {
|
||||
"class": "infix-hardware:usb",
|
||||
@@ -80,6 +80,7 @@ with infamy.Test() as test:
|
||||
with test.step("Verify USB ports locked"):
|
||||
for port in available:
|
||||
until(lambda: usb.get_usb_state(target, port) == "locked")
|
||||
|
||||
with test.step("Remove all hardware configuration"):
|
||||
for port in available:
|
||||
target.delete_xpath(f"/ietf-hardware:hardware/component[name='{port}']")
|
||||
@@ -88,9 +89,8 @@ with infamy.Test() as test:
|
||||
for port in available:
|
||||
until(lambda: usb.get_usb_state(target, port) == "locked")
|
||||
|
||||
|
||||
with test.step("Unlock USB ports"):
|
||||
components=[]
|
||||
components = []
|
||||
for port in available:
|
||||
component = {
|
||||
"name": port,
|
||||
@@ -107,7 +107,7 @@ with infamy.Test() as test:
|
||||
}
|
||||
})
|
||||
|
||||
with test.step("Verify USB ports unlocked"):
|
||||
with test.step("Verify USB ports are unlocked"):
|
||||
for port in available:
|
||||
until(lambda: usb.get_usb_state(target, port) == "unlocked")
|
||||
|
||||
@@ -115,11 +115,12 @@ with infamy.Test() as test:
|
||||
target.startup_override()
|
||||
target.copy("running", "startup")
|
||||
target.reboot()
|
||||
if wait_boot(target) == False:
|
||||
if not wait_boot(target, env):
|
||||
test.fail()
|
||||
target = env.attach("target", "mgmt", test_reset=False)
|
||||
|
||||
with test.step("Verify that all ports are unlocked"):
|
||||
with test.step("Verify USB port remain unlocked after reboot"):
|
||||
for port in available:
|
||||
until(lambda: usb.get_usb_state(target, port) == "unlocked")
|
||||
|
||||
test.succeed()
|
||||
|
||||
@@ -8,14 +8,16 @@
|
||||
#
|
||||
|
||||
import infamy
|
||||
from infamy.util import until
|
||||
from infamy.util import until
|
||||
|
||||
|
||||
def _verify(server):
|
||||
url = infamy.Furl(f"http://[{server}]:91/index.html")
|
||||
return url.check("It works")
|
||||
|
||||
|
||||
with infamy.Test() as test:
|
||||
NAME = "web"
|
||||
NAME = "web"
|
||||
|
||||
with test.step("Set up topology and attach to target DUT"):
|
||||
env = infamy.Env()
|
||||
|
||||
+3
-15
@@ -1,13 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import socket
|
||||
import time
|
||||
import requests
|
||||
import infamy, infamy.neigh
|
||||
import infamy
|
||||
import infamy.neigh
|
||||
import infamy.restconf as restconf
|
||||
import infamy.netconf as netconf
|
||||
import infamy.netconf as netconf
|
||||
|
||||
from requests.auth import HTTPBasicAuth
|
||||
|
||||
def ll6ping(node):
|
||||
neigh = None
|
||||
@@ -20,16 +18,6 @@ def ll6ping(node):
|
||||
|
||||
return None
|
||||
|
||||
def netconf_syn(neigh):
|
||||
try:
|
||||
ai = socket.getaddrinfo(neigh, 830, 0, 0, socket.SOL_TCP)
|
||||
sock = socket.socket(ai[0][0], ai[0][1], 0)
|
||||
sock.connect(ai[0][4])
|
||||
sock.close()
|
||||
print(f"{neigh} answers to TCP connections on port 830 (NETCONF)")
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
with infamy.Test() as test:
|
||||
with test.step("Initialize"):
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import infamy
|
||||
from infamy.util import wait_boot
|
||||
import copy
|
||||
|
||||
with infamy.Test() as test:
|
||||
with test.step("Initialize"):
|
||||
@@ -17,16 +16,17 @@ with infamy.Test() as test:
|
||||
})
|
||||
target.delete_xpath("/ietf-hardware:hardware/component")
|
||||
target.copy("running", "startup")
|
||||
|
||||
with test.step("Reboot and wait for the unit to come back"):
|
||||
target.startup_override()
|
||||
target.copy("running", "startup")
|
||||
target.reboot()
|
||||
if wait_boot(target) == False:
|
||||
if not wait_boot(target, env):
|
||||
test.fail()
|
||||
target = env.attach("target", "mgmt", test_default = False)
|
||||
target = env.attach("target", "mgmt", test_default=False)
|
||||
|
||||
with test.step("Verify hostname"):
|
||||
data = target.get_dict("/ietf-system:system/hostname")
|
||||
assert(data["system"]["hostname"] == "test")
|
||||
assert data["system"]["hostname"] == "test"
|
||||
|
||||
test.succeed()
|
||||
|
||||
Reference in New Issue
Block a user