Drive a MikroTik router as a Lager net. This is the bench’s network fault-injection
tool: it lets a test assert what firmware does when the network degrades — loses
the internet, loses DNS, gets slow — rather than simply disappearing.
Handle
Methods
Types
RouterSystemInfo
Method Reference
connect() -> Result<serde_json::Value>
Verify connectivity by fetching the router’s identity.
system_info() -> Result<RouterSystemInfo>
Structured resource information.
block_internet() -> Result<()>
Drop all forwarded traffic, simulating an internet outage while leaving the local
network — and the DUT’s association to it — intact.
remove_firewall_rules() -> Result<()>
Remove every firewall rule Lager added. This is the undo for block_internet and
anything added through command().
Rules persist on the router until removed. A test that blocks the internet and then
fails without cleaning up leaves the next test running on a broken network. Put
remove_firewall_rules() in a teardown path that runs even on failure.
enable_interface(interface: &str) and disable_interface(interface: &str)
Enable or disable an interface by name — use these when you want the access point to
vanish entirely, rather than to lose routing.
set_wireless_ssid(interface: &str, ssid: &str) -> Result<serde_json::Value>
Change the broadcast SSID.
command(action: &str, params: serde_json::Value) -> Result<serde_json::Value>
The generic escape hatch: invoke any other router action by name with raw JSON
parameters. This is how you reach DNS blocking, port blocking, bandwidth limits,
DHCP control, security profiles and access lists, none of which have a typed wrapper
in this crate yet.
Examples
Assert firmware retries instead of rebooting when the internet goes away
Squeeze the bandwidth and check an OTA still completes
Supported Hardware
Notes
- This net sends no role hint. A router net may be saved with role
router or
the legacy mikrotik, and the box verifies a supplied hint exactly, so sending one
would fail against the other spelling. A consequence you will see: a missing router
net reports Net 'router1' not found without naming a role, where other net types
report Net 'x (role adc)' not found.
- Every router action gets a flat 60-second budget, because reboots and reset actions
are slow and a busy router lags.
reboot() returns as soon as the router accepts the command, not when it is back.
- Blocking the internet does not disconnect the DUT from WiFi. That distinction is
the entire point of this net type.