Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 75 additions & 75 deletions test/case/dhcp/server_host/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,84 +33,84 @@
lambda: env.attach("client2", "mgmt"))

with test.step("Configure DHCP client and server DUTs"):
parallel(
lambda: server.put_config_dicts({
"ietf-interfaces": {
"interfaces": {
"interface": [
{
"name": server["link1"],
"ipv4": {
"address": [{
"ip": "192.168.1.1",
"prefix-length": 24
}]
}
}, {
"name": server["link2"],
"ipv4": {
"address": [{
"ip": "192.168.2.1",
"prefix-length": 24
}]
}
},
]
}
},
"infix-dhcp-server": {
"dhcp-server": {
"option": [{
"id": "router", "address": "auto"
}],
"subnet": [
{
"subnet": "192.168.1.0/24",
"pool": {
"start-address": POOL1,
"end-address": POOL1
},
"host": [{
"address": ADDRESS1,
"match": {
"client-id": {"hex": HOSTCID1}
},
"option": [
{
"id": "hostname",
"name": HOSTNM11
}, {
"id": "classless-static-route",
"static-route": [{
"destination": "0.0.0.0/0",
"next-hop": GW1
}]
}
]
server.put_config_dicts({
"ietf-interfaces": {
"interfaces": {
"interface": [
{
"name": server["link1"],
"ipv4": {
"address": [{
"ip": "192.168.1.1",
"prefix-length": 24
}]
}, {
"subnet": "192.168.2.0/24",
"pool": {
"start-address": POOL2,
"end-address": POOL2
},
"host": [{
"address": ADDRESS2,
"match": {
"client-id": {"str": HOSTCID2}
},
"option": [
{
"id": "hostname",
"name": HOSTNM22
}
],
"lease-time": "infinite"
}
}, {
"name": server["link2"],
"ipv4": {
"address": [{
"ip": "192.168.2.1",
"prefix-length": 24
}]
}
},
]
}
},
"infix-dhcp-server": {
"dhcp-server": {
"option": [{
"id": "router", "address": "auto"
}],
"subnet": [
{
"subnet": "192.168.1.0/24",
"pool": {
"start-address": POOL1,
"end-address": POOL1
},
]
}
}}),
"host": [{
"address": ADDRESS1,
"match": {
"client-id": {"hex": HOSTCID1}
},
"option": [
{
"id": "hostname",
"name": HOSTNM11
}, {
"id": "classless-static-route",
"static-route": [{
"destination": "0.0.0.0/0",
"next-hop": GW1
}]
}
]
}]
}, {
"subnet": "192.168.2.0/24",
"pool": {
"start-address": POOL2,
"end-address": POOL2
},
"host": [{
"address": ADDRESS2,
"match": {
"client-id": {"str": HOSTCID2}
},
"option": [
{
"id": "hostname",
"name": HOSTNM22
}
],
"lease-time": "infinite"
}]
},
]
}
}})
parallel(
# We request hostname option just to ensure we don't get it.
lambda: client1.put_config_dicts({
"ietf-system": {
Expand Down
6 changes: 4 additions & 2 deletions test/case/system/etc_default/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
disabled, and that a file is removed when the entry is deleted.
"""
import base64
import subprocess

import infamy
from infamy.util import parallel
Expand All @@ -20,7 +21,8 @@ def content(text):


def cat(tgtssh, name):
return tgtssh.runsh(f"cat /etc/default/{name}").stdout
return tgtssh.run_retry(f"cat /etc/default/{name}", text=True,
stdout=subprocess.PIPE).stdout


with infamy.Test() as test:
Expand Down Expand Up @@ -80,6 +82,6 @@ def cat(tgtssh, name):
target.delete_xpath(f"/ietf-system:system/infix-system:advanced/defaults/default[name='{NEW}']")

with test.step("Verify /etc/default/infamy-test is removed"):
assert tgtssh.runsh(f"test -e /etc/default/{NEW}").returncode != 0
assert tgtssh.run_retry(f"test -e /etc/default/{NEW}").returncode == 1

test.succeed()
9 changes: 6 additions & 3 deletions test/case/system/rc_d/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
and rebooting, the file must list the two names in configured order.
"""
import base64
import subprocess

import infamy
from infamy.util import parallel, wait_boot
Expand Down Expand Up @@ -63,7 +64,8 @@ def cleanup(env):

with test.step("Verify scripts are extracted to /etc/rc.d in order"):
tgtssh = env.attach("target", "mgmt", "ssh")
files = tgtssh.runsh("ls /etc/rc.d").stdout.split()
files = tgtssh.run_retry("ls /etc/rc.d", text=True,
stdout=subprocess.PIPE).stdout.split()
assert files == ["01-first", "02-second"], f"unexpected /etc/rc.d contents: {files}"

with test.step("Save to startup-config and reboot"):
Expand All @@ -77,10 +79,11 @@ def cleanup(env):
lambda: env.attach("target", "mgmt", "ssh"))

with test.step("Verify enabled scripts ran once, in order"):
out = tgtssh.runsh(f"cat {ORDER}").stdout.split()
out = tgtssh.run_retry(f"cat {ORDER}", text=True,
stdout=subprocess.PIPE).stdout.split()
assert out == ["first", "second"], f"unexpected run order: {out}"

with test.step("Verify disabled script did not run"):
assert tgtssh.runsh(f"test -e {NEVER}").returncode != 0, "disabled script was run"
assert tgtssh.run_retry(f"test -e {NEVER}").returncode == 1, "disabled script was run"

test.succeed()
Loading