mirror of
https://github.com/espressif/openthread.git
synced 2026-09-02 15:20:07 +00:00
[scripts] fix test_router_reattach (#5517)
Fix test_router_attach.py failing by a small chance. Root cause: routerdowngradethreshold restored back to default (23) after node reset, so the test had 5/120 chance to downgrade. We should set it back to 32 before starting it. This commit also enhances the test for a little bit: - Make sure the node reattached as Router within 1 second - Make sure the node does not downgrade after Router Selection Jitter (3s)
This commit is contained in:
@@ -771,6 +771,10 @@ class Node:
|
||||
self.send_command(cmd)
|
||||
self._expect('Done')
|
||||
|
||||
def get_router_downgrade_threshold(self) -> int:
|
||||
self.send_command('routerdowngradethreshold')
|
||||
return int(self._expect_result(r'\d+'))
|
||||
|
||||
def prefer_router_id(self, router_id):
|
||||
cmd = 'preferrouterid %d' % router_id
|
||||
self.send_command(cmd)
|
||||
|
||||
@@ -272,7 +272,16 @@ class test_router_reattach(thread_cert.TestCase):
|
||||
self.assertEqual(self.nodes[i].get_state(), 'router')
|
||||
|
||||
self.nodes[2].reset()
|
||||
self.nodes[2].set_router_selection_jitter(3)
|
||||
self.nodes[2].set_router_upgrade_threshold(32)
|
||||
self.nodes[2].set_router_downgrade_threshold(32)
|
||||
|
||||
self.nodes[2].start()
|
||||
self.assertEqual(self.nodes[2].get_router_downgrade_threshold(), 32)
|
||||
# Verify that the node restored as Router.
|
||||
self.simulator.go(1)
|
||||
self.assertEqual(self.nodes[2].get_state(), 'router')
|
||||
# Verify that the node does not downgrade after Router Selection Jitter.
|
||||
self.simulator.go(5)
|
||||
self.assertEqual(self.nodes[2].get_state(), 'router')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user