[netdata] add otNetDataReplacePublishedExternalRoute() API (#9013)

This commit adds a public OT API to replace a previously published
external route entry in the Thread Network Data. It also adds a
related CLI command, and updates `test_netdata_publisher` to
validate the new behavior.
This commit is contained in:
Abtin Keshavarzian
2023-05-08 20:05:21 -07:00
committed by GitHub
parent 874b6beca8
commit 92b954ae1d
8 changed files with 110 additions and 5 deletions
+4
View File
@@ -2380,6 +2380,10 @@ class NodeImpl:
self.send_command(f'netdata publish route {prefix} {flags} {prf}')
self._expect_done()
def netdata_publish_replace(self, old_prefix, prefix, flags='s', prf='med'):
self.send_command(f'netdata publish replace {old_prefix} {prefix} {flags} {prf}')
self._expect_done()
def netdata_unpublish_prefix(self, prefix):
self.send_command(f'netdata unpublish {prefix}')
self._expect_done()
@@ -461,6 +461,19 @@ class NetDataPublisher(thread_cert.TestCase):
routes = leader.get_routes()
self.check_num_of_routes(routes, num - 1, 0, 1)
# Replace the published route on leader with '::/0'.
leader.netdata_publish_replace(EXTERNAL_ROUTE, '::/0', EXTERNAL_FLAGS, 'med')
self.simulator.go(0.2)
routes = leader.get_routes()
self.assertEqual([route.split(' ')[0] == '::/0' for route in routes].count(True), 1)
self.check_num_of_routes(routes, num - 1, 1, 0)
# Replace it back to the original route.
leader.netdata_publish_replace('::/0', EXTERNAL_ROUTE, EXTERNAL_FLAGS, 'high')
self.simulator.go(WAIT_TIME)
routes = leader.get_routes()
self.check_num_of_routes(routes, num - 1, 0, 1)
# Publish the same prefix on leader as an on-mesh prefix. Make
# sure it is removed from external routes and now seen in the
# prefix list.